List of usage examples for java.util Map containsValue
boolean containsValue(Object value);
From source file:com.baidu.cc.spring.ConfigCenterPropertyExtractorTest.java
/** * test property extractor//from w w w. j a v a 2 s .c om * @throws Exception */ @Test public void testPropertyExtractor() throws Exception { ExtConfigServerService service = new ExtConfigServerService() { /* (non-Javadoc) * @see com.baidu.cc.interfaces.ConfigServerService#getLastestConfigVersion(java.lang.String, java.lang.String, java.lang.Long) */ public Long getLastestConfigVersion(String user, String password, Long envId) { return null; } /* (non-Javadoc) * @see com.baidu.cc.interfaces.ConfigServerService#getLastestConfigItems(java.lang.String, java.lang.String, java.lang.Long) */ public Map<String, String> getLastestConfigItems(String user, String password, Long envId) { return null; } /* (non-Javadoc) * @see com.baidu.cc.interfaces.ConfigServerService#getConfigItems(java.lang.String, java.lang.String, java.lang.Long) */ public Map<String, String> getConfigItems(String user, String password, Long version) { Map<String, String> ret = new HashMap<String, String>(); ret.put("new", "value"); return ret; } /* (non-Javadoc) * @see com.baidu.cc.interfaces.ConfigServerService#getConfigItemValue(java.lang.String, java.lang.String, java.lang.Long, java.lang.String) */ public String getConfigItemValue(String user, String password, Long version, String key) { return null; } /* (non-Javadoc) * @see com.baidu.cc.interfaces.ConfigServerService#checkVersionTag(java.lang.String, java.lang.String, java.lang.Long, java.lang.String) */ public boolean checkVersionTag(String user, String password, Long version, String tag) { return false; } /* (non-Javadoc) * @see com.baidu.cc.interfaces.ExtConfigServerService#importConfigItems(java.lang.String, java.lang.String, java.lang.Long, java.util.Map) */ public void importConfigItems(String user, String password, Long version, Map<String, String> configItems) { Assert.assertEquals("xie", user); StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor(); encryptor.setPassword(ExtConfigServerService.class.getSimpleName()); Assert.assertEquals("matthew", encryptor.decrypt(password)); Assert.assertEquals(2, version.longValue()); Assert.assertTrue(configItems.containsKey("name")); Assert.assertTrue(configItems.containsKey("age")); Assert.assertTrue(configItems.containsValue("100")); Assert.assertEquals(3, configItems.size()); } /* (non-Javadoc) * @see com.baidu.cc.interfaces.ConfigServerService#getLastestConfigVersion(java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ public Long getLastestConfigVersion(String user, String password, String projectName, String envName) { return null; } /* (non-Javadoc) * @see com.baidu.cc.interfaces.ConfigServerService#getVersionId(java.lang.String, java.lang.String, java.lang.String) */ public Long getVersionId(String user, String password, String versionName) { return null; } }; ConfigCenterPropertyPlaceholderConfigurer extractor = new ConfigCenterPropertyPlaceholderConfigurer(); ClassPathResource cpr = new ClassPathResource("/com/baidu/cc/spring/test.properties"); extractor.setLocation(cpr); extractor.setConfigServerService(service); ConfigCenterPropertyPlaceholderConfigurer importer; importer = new ConfigCenterPropertyPlaceholderConfigurer(); importer.setCcUser("xie"); importer.setCcPassword("matthew"); importer.setCcVersion(1); extractor.setCcUser("xie"); extractor.setCcPassword("matthew"); extractor.setCcVersion(1); importer.setConfigServerService(service); //initial importer ConfigCenterPropertyPlaceholderConfigurerTest test = new ConfigCenterPropertyPlaceholderConfigurerTest(); importer.setApplicationContext(test.appContext); DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); importer.postProcessBeanFactory(beanFactory); extractor.setApplicationContext(test.appContext); extractor.postProcessBeanFactory(beanFactory); ConfigCenterPropertyExtractor ccpe = new ConfigCenterPropertyExtractor(); ccpe.setCcVersion(2); ccpe.setExtractor(extractor); ccpe.setImporter(importer); ccpe.afterPropertiesSet(); }
From source file:com.microsoft.exchange.impl.BaseExchangeCalendarDataDao.java
public FolderIdType getCalendarFolderId(String upn, String calendarName) { Map<String, String> calendarFolderMap = getCalendarFolderMap(upn); if (!CollectionUtils.isEmpty(calendarFolderMap) && calendarFolderMap.containsValue(calendarName)) { for (String c_id : calendarFolderMap.keySet()) { String c_name = calendarFolderMap.get(c_id); if (calendarName.equals(c_name)) { FolderIdType folderIdType = new FolderIdType(); folderIdType.setId(c_id); return folderIdType; }/* w ww.j a v a2 s. c om*/ } } throw new ExchangeRuntimeException("No calendar folder with name of '" + calendarName + "' for " + upn); }
From source file:org.medici.bia.controller.community.ShowForumController.java
/** * //from w w w .jav a 2 s . c o m * @param request * @param model * @return */ @SuppressWarnings("unchecked") @RequestMapping(method = RequestMethod.GET) public ModelAndView setupForm(@ModelAttribute("command") ShowForumCommand command, HttpSession httpSession) { Map<String, Object> model = new HashMap<String, Object>(0); Forum forum = new Forum(); try { User userInformation = (User) httpSession.getAttribute("user"); // RR (March 12th, 2014): we filter forum access in this controller so ShowForum.jsp is maintained pretty compact. // --> First we calculate the user authorities (none for anonymous user) and then we filter what to show or we // redirect to 'accessDenied' page. Set<Authority> userAuthorities = null; if (userInformation != null) { model.put("account", userInformation.getAccount()); userAuthorities = getUserAuthorities(userInformation); if (userInformation.getForumJoinedDate() == null) { userInformation = getCommunityService().joinUserOnForum(); httpSession.setAttribute("user", userInformation); } } if (command.getForumId() == null) { forum = getCommunityService().getFirstCategory(); } else { forum = getCommunityService().findForum(command.getForumId()); if (Boolean.TRUE.equals(forum.getLogicalDelete()) || (SubType.COURSE.equals(forum.getSubType()) && !Type.CATEGORY.equals(forum.getForumParent().getType()) && !getTeachingService().isForumInActiveCourse(command.getForumId()))) { // the forum to show was deleted or it is correspondent to a deactivated course return new ModelAndView("404", model); } // we can update forum access informations forum = getCommunityService().getForumForView(command.getForumId()); } if (forum.getType().equals(Type.CATEGORY)) { model.put("category", forum); if (forum.getOption().getCanHaveSubCategory()) { List<Forum> subCategories = getCommunityService() .getSubCategories(new Forum(forum.getForumId())); // We filter forums with special access credentials List<Forum> visibleSubcategories = filterForumsForCurrentUser(subCategories, userAuthorities); model.put("subCategories", visibleSubcategories); //SubForums are extracted only if category is enabled to subForum... List<Integer> subCategoriesIdsEnabledToSubForums = new ArrayList<Integer>(0); for (Forum category : visibleSubcategories) { if (category.getOption().getCanHaveSubForum()) { subCategoriesIdsEnabledToSubForums.add(category.getForumId()); } } Map<Integer, List<Forum>> forumsHashMap = getCommunityService() .getForumsGroupByCategory(subCategoriesIdsEnabledToSubForums); //MD: To show the number of subforums that have one or more topics for the document forum model.put("documentSubForumsWithTopics", getCommunityService().getSubForumsNumberWithTopics(5)); model.put("forumsBySubCategories", forumsHashMap); if (forum.getOption().getCanHaveSubForum()) { PaginationFilter paginationFilterForum = getPaginationFilter(command, forum.getOption().getPageLength() != null ? forum.getOption().getPageLength() : DEFAULT_ROWS_PER_PAGE, "dispositionOrder", true, true); Page page = getCommunityService().getSubForums(forum.getForumId(), paginationFilterForum); model.put("subForumsPage", page); } } } else if (forum.getType().equals(Type.FORUM)) { if (canAccessToForum(forum, userAuthorities)) { model.put("forum", forum); //MD: Prepare the Manuscript Viewer if (forum.getDocument() != null && !SubType.COURSE.equals(forum.getSubType())) { Document document = forum.getDocument(); if (getManuscriptViewerService().findDocumentImageThumbnail(document) != null) { DocumentExplorer documentExplorer = new DocumentExplorer(document.getEntryId(), document.getVolume().getVolNum(), document.getVolume().getVolLetExt()); documentExplorer.setImage(new Image()); documentExplorer.getImage().setInsertNum(document.getInsertNum()); documentExplorer.getImage().setInsertLet(document.getInsertLet()); documentExplorer.getImage().setImageProgTypeNum(document.getFolioNum()); documentExplorer.getImage().setMissedNumbering(document.getFolioMod()); documentExplorer.getImage() .setImageRectoVerso(document.getFolioRectoVerso() == null ? null : Image.ImageRectoVerso .convertFromString(document.getFolioRectoVerso().toString())); documentExplorer.getImage().setImageType(ImageType.C); documentExplorer.setTotal(null); try { documentExplorer = getManuscriptViewerService() .getDocumentExplorer(documentExplorer); model.put("documentExplorer", documentExplorer); } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); return new ModelAndView("error/ShowForum", model); } } else { model.put("documentExplorer", null); } } else if (forum.getVolume() != null) { Volume volume = forum.getVolume(); if (volume.getDigitized()) { VolumeExplorer volumeExplorer = new VolumeExplorer(volume.getSummaryId(), volume.getVolNum(), volume.getVolLetExt()); if (getManuscriptViewerService().findVolumeImageSpine(volume.getVolNum(), volume.getVolLetExt()) != null) { volumeExplorer.setImage(getManuscriptViewerService() .findVolumeImageSpine(volume.getVolNum(), volume.getVolLetExt())); } else { volumeExplorer.setImage(new Image()); volumeExplorer.getImage().setImageOrder(1); volumeExplorer.getImage().setImageType(ImageType.C); } volumeExplorer.setTotal(null); try { volumeExplorer = getManuscriptViewerService().getVolumeExplorer(volumeExplorer); model.put("volumeExplorer", volumeExplorer); } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); return new ModelAndView("error/ShowForum", model); } } else { model.put("volumeExplorer", null); } } if (forum.getOption().getCanHaveSubForum()) { // All forum have group by excepted document... if (forum.getOption().getGroupBySubForum()) { PaginationFilter paginationFilterForum = null; Page page = null; if (SubType.COURSE.equals(forum.getSubType())) { paginationFilterForum = getPaginationFilter(command, forum.getOption().getPageLength() != null ? forum.getOption().getPageLength() : DEFAULT_ROWS_PER_PAGE, "courseForum.lastPost", false, true); page = getTeachingService().getCoursesElements(forum.getForumId(), paginationFilterForum); } else { paginationFilterForum = getPaginationFilter(command, forum.getOption().getPageLength() != null ? forum.getOption().getPageLength() : DEFAULT_ROWS_PER_PAGE, "lastPost", false, true); page = getCommunityService().getSubForums(forum.getForumId(), paginationFilterForum); } model.put("subForumsPage", page); } else { // paginationFilter to manage topics results.. PaginationFilter paginationFilterTopic = getPaginationFilter(command, forum.getOption().getPageLength() != null ? forum.getOption().getPageLength() : DEFAULT_ROWS_PER_PAGE, "lastPost", false, false); Page topicPage = getCommunityService().getForumTopicsByParentForum(forum, paginationFilterTopic); model.put("subForumsTopicsPage", topicPage); } } } else { // TODO return new ModelAndView("403", model); } } if (forum.getOption().getCanHaveTopics()) { // paginationFilter to manage topics results.. PaginationFilter paginationFilterTopic = getPaginationFilter(command, forum.getOption().getPageLength() != null ? forum.getOption().getPageLength() : DEFAULT_ROWS_PER_PAGE, "lastUpdate", false, false); Page topicPage = getCommunityService().getForumTopics(forum, paginationFilterTopic); model.put("topicsPage", topicPage); if (SubType.COURSE.equals(forum.getSubType())) { Map<Integer, CourseTopicMode> topicsMap = getTeachingService() .getCourseTopicsMode((List<ForumTopic>) topicPage.getList()); model.put("topicsMap", topicsMap); if (topicsMap.containsValue(CourseTopicMode.I) || topicsMap.containsValue(CourseTopicMode.R) || topicsMap.containsValue(CourseTopicMode.C)) { // the topicsMap contains a course transcription (the help resources does not contain transcriptions) model.put("containsTranscriptionTopic", true); } } } Map<String, Object> statisticsHashMap = getCommunityService().getForumsStatistics(); model.put("statisticsHashMap", statisticsHashMap); Map<String, Object> whoIsOnlineHashMap = getCommunityService().getForumWhoIsOnline(); model.put("whoIsOnlineHashMap", whoIsOnlineHashMap); } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); return new ModelAndView("error/ShowForum", model); } if (ObjectUtils.toString(command.getCompleteDOM()).equals(Boolean.TRUE.toString())) { return new ModelAndView("community/ShowForumCompleteDOM", model); } else { return new ModelAndView("community/ShowForum", model); } }
From source file:com.haulmont.cuba.gui.app.core.categories.AttributeEditor.java
protected void fillSelectEntityScreens(Class entityClass) { String value = attribute.getScreen(); Map<String, Object> screensMap = screensHelper.getAvailableBrowserScreens(entityClass); screenField.setValue(null); // While #PL-4731 unfixed screenField.setOptionsMap(screensMap); screenField.setValue(screensMap.containsValue(value) ? value : null); }
From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java
@Test(dataProvider = "warmedMap") public void valueIterator(Map<Integer, Integer> map) { int iterations = 0; for (Iterator<Integer> i = map.values().iterator(); i.hasNext();) { assertThat(map.containsValue(i.next()), is(true)); iterations++;/* www .ja va 2 s. com*/ i.remove(); } assertThat(iterations, is(equalTo((int) capacity()))); assertThat(map, is(emptyMap())); }
From source file:org.openecomp.sdc.be.model.operations.impl.ResourceOperationTest.java
@Test public void getVersionListNotDeleted() { String resName = "myResource"; String userId = "jh0003"; String category = CATEGORY_NAME; deleteAndCreateCategory(category);/*w w w . j a v a 2s. c o m*/ Resource newResource = createResource(userId, category, resName, "0.1", null, false, true); String resourceId1 = newResource.getUniqueId(); User admin = new User("j", "h", userId, null, "ADMIN", System.currentTimeMillis()); Either<Resource, StorageOperationStatus> checkoutResource = (Either<Resource, StorageOperationStatus>) lifecycleOperation .checkoutComponent(NodeTypeEnum.Resource, newResource, admin, admin, false); assertTrue(checkoutResource.isLeft()); Resource newResource2 = checkoutResource.left().value(); String resourceId2 = newResource2.getUniqueId(); Resource newResource3 = createResource(userId, category, resName, "0.1", null, false, true); String resourceId3 = newResource3.getUniqueId(); Either<Map<String, String>, TitanOperationStatus> versionList = resourceOperation.getVersionList( NodeTypeEnum.Resource, "0.2", newResource2.getUUID(), newResource2.getSystemName(), ResourceMetadataData.class); assertTrue(versionList.isLeft()); Map<String, String> versionMap = versionList.left().value(); assertTrue(versionMap.size() == 2); assertTrue(versionMap.containsValue(resourceId1)); assertTrue(versionMap.containsValue(resourceId2)); assertFalse(versionMap.containsValue(resourceId3)); Either<Resource, StorageOperationStatus> deleteResource = resourceOperation.deleteResource(resourceId1); assertTrue(deleteResource.isLeft()); deleteResource = resourceOperation.deleteResource(resourceId2); assertTrue(deleteResource.isLeft()); deleteResource = resourceOperation.deleteResource(resourceId3); assertTrue(deleteResource.isLeft()); }
From source file:org.openecomp.sdc.be.model.operations.impl.ResourceOperationTest.java
@Test public void getVersionListWithDeleted() { String resName = "myResource"; String userId = "jh0003"; String category = CATEGORY_NAME; deleteAndCreateCategory(category);// w w w . j a v a2 s. c o m Resource newResource = createResource(userId, category, resName, "0.1", null, false, true); String resourceId1 = newResource.getUniqueId(); User admin = new User("j", "h", userId, null, "ADMIN", System.currentTimeMillis()); Either<Resource, StorageOperationStatus> checkoutResource = (Either<Resource, StorageOperationStatus>) lifecycleOperation .checkoutComponent(NodeTypeEnum.Resource, newResource, admin, admin, false); assertTrue(checkoutResource.isLeft()); Resource newResource2 = checkoutResource.left().value(); String resourceId2 = newResource2.getUniqueId(); Either<Resource, StorageOperationStatus> resource = resourceOperation.getResource(resourceId1, false); assertTrue(resource.isLeft()); Either<Component, StorageOperationStatus> markResourceToDelete = resourceOperation .markComponentToDelete(resource.left().value(), false); assertTrue(markResourceToDelete.isLeft()); Either<Map<String, String>, TitanOperationStatus> versionList = resourceOperation.getVersionList( NodeTypeEnum.Resource, "0.2", newResource2.getUUID(), newResource2.getSystemName(), ResourceMetadataData.class); assertTrue(versionList.isLeft()); Map<String, String> versionMap = versionList.left().value(); assertTrue(versionMap.size() == 1); assertFalse(versionMap.containsValue(resourceId1)); assertTrue(versionMap.containsValue(resourceId2)); Either<Resource, StorageOperationStatus> deleteResource = resourceOperation.deleteResource(resourceId1); assertTrue(deleteResource.isLeft()); deleteResource = resourceOperation.deleteResource(resourceId2); assertTrue(deleteResource.isLeft()); }
From source file:com.palantir.atlasdb.keyvalue.impl.AbstractAtlasDbKeyValueServiceTest.java
@Test public void testGetRowsWhenMultipleVersions() { putTestDataForMultipleTimestamps();/*from www. j a v a2 s .c o m*/ Map<Cell, Value> result = keyValueService.getRows(TEST_TABLE, ImmutableSet.of(row0), ColumnSelection.all(), TEST_TIMESTAMP + 1); assertEquals(1, result.size()); assertTrue(result.containsKey(Cell.create(row0, column0))); assertTrue(result.containsValue(Value.create(value0_t0, TEST_TIMESTAMP))); result = keyValueService.getRows(TEST_TABLE, ImmutableSet.of(row0), ColumnSelection.all(), TEST_TIMESTAMP + 2); assertEquals(1, result.size()); assertTrue(result.containsKey(Cell.create(row0, column0))); assertTrue(result.containsValue(Value.create(value0_t1, TEST_TIMESTAMP + 1))); }
From source file:com.vmware.vchs.base.DbaasInstance.java
public boolean isDatabaseExists(String dbName) { boolean result = false; List<Map<String, Object>> rows = mssqlConnection.getTemplate() .queryForList("SELECT [name] FROM sys.databases;"); if (rows != null) { for (Map<String, Object> row : rows) { if (row.containsValue(dbName)) { result = true;//from w ww. j ava 2s .c o m logger.info("Database " + dbName + " already exists."); } } } return result; }
From source file:com.palantir.atlasdb.keyvalue.impl.AbstractAtlasDbKeyValueServiceTest.java
@Test public void testGetRowsWhenMultipleVersionsAndColumnsSelected() { putTestDataForMultipleTimestamps();// w w w . j av a 2 s.c o m Map<Cell, Value> result = keyValueService.getRows(TEST_TABLE, ImmutableSet.of(row0), ColumnSelection.create(ImmutableSet.of(column0)), TEST_TIMESTAMP + 1); assertEquals(1, result.size()); assertTrue(result.containsKey(Cell.create(row0, column0))); assertTrue(result.containsValue(Value.create(value0_t0, TEST_TIMESTAMP))); result = keyValueService.getRows(TEST_TABLE, ImmutableSet.of(row0), ColumnSelection.create(ImmutableSet.of(column0)), TEST_TIMESTAMP + 2); assertEquals(1, result.size()); assertTrue(result.containsKey(Cell.create(row0, column0))); assertTrue(result.containsValue(Value.create(value0_t1, TEST_TIMESTAMP + 1))); }