List of usage examples for com.google.common.collect BiMap entrySet
Set<Map.Entry<K, V>> entrySet();
From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.AccessibilityHierarchy.java
/** * For every View in {@code originMap} that has a labelFor value, set labeledBy on the * ViewHierarchyElement that represents the View with the referenced View ID. *///from w ww . java 2 s. com @RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void resolveLabelForRelationshipsAmongViews(Context context, BiMap<Long, View> originMap) { for (Entry<Long, View> entry : originMap.entrySet()) { int labeledViewId = entry.getValue().getLabelFor(); if (labeledViewId != View.NO_ID) { ViewHierarchyElement labelElement = getViewById(entry.getKey()); ViewHierarchyElement labeledElement = findElementByViewId(labeledViewId, originMap); if (labeledElement == null) { LogUtils.w(this, "View not found for labelFor = %1$s", resourceName(context, labeledViewId)); } else { labeledElement.setLabeledBy(labelElement); } } } }
From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.AccessibilityHierarchy.java
/** * Find the element corresponding to the View in value of {@code originMap} whose ID is {@code * targetViewId}, or {@code null} if no view is found with that ID. *///from ww w .j a v a 2 s. c om private @Nullable ViewHierarchyElement findElementByViewId(int targetViewId, BiMap<Long, View> originMap) { for (Entry<Long, View> matchingEntry : originMap.entrySet()) { if (matchingEntry.getValue().getId() == targetViewId) { return getViewById(matchingEntry.getKey()); } } return null; }
From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.AccessibilityHierarchy.java
@RequiresApi(Build.VERSION_CODES.LOLLIPOP_MR1) private void resolveAccessibilityTraversalRelationshipsAmongViews(Context context, BiMap<Long, View> originMap) { for (Entry<Long, View> entry : originMap.entrySet()) { int beforeViewId = entry.getValue().getAccessibilityTraversalBefore(); int afterViewId = entry.getValue().getAccessibilityTraversalAfter(); ViewHierarchyElement viewElement = getViewById(entry.getKey()); if (beforeViewId != View.NO_ID) { ViewHierarchyElement matchingElement = findElementByViewId(beforeViewId, originMap); if (matchingElement == null) { LogUtils.w(this, "View not found for accessibilityTraversalBefore = %1$s", resourceName(context, beforeViewId)); } else { viewElement.setAccessibilityTraversalBefore(matchingElement); }/* w ww. ja v a 2 s. com*/ } if (afterViewId != View.NO_ID) { ViewHierarchyElement matchingElement = findElementByViewId(afterViewId, originMap); if (matchingElement == null) { LogUtils.w(this, "View not found for accessibilityTraversalAfter = %1$s", resourceName(context, afterViewId)); } else { viewElement.setAccessibilityTraversalAfter(matchingElement); } } } }
From source file:org.apache.usergrid.management.export.ExportServiceImpl.java
/** * Exports All Applications from an Organization *//*w w w .ja v a 2 s . c o m*/ private void exportApplicationsFromOrg(UUID organizationUUID, final Map<String, Object> config, final JobExecution jobExecution, S3Export s3Export) throws Exception { //retrieves export entity Export export = getExportEntity(jobExecution); String appFileName = null; BiMap<UUID, String> applications = managementService.getApplicationsForOrganization(organizationUUID); for (Map.Entry<UUID, String> application : applications.entrySet()) { if (application.getValue() .equals(managementService.getOrganizationByUuid(organizationUUID).getName() + "/exports")) { continue; } appFileName = prepareOutputFileName("application", application.getValue(), null); File ephemeral = collectionExportAndQuery(application.getKey(), config, export, jobExecution); fileTransfer(export, appFileName, ephemeral, config, s3Export); } }
From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.AccessibilityHierarchy.java
/** * Associates {@link ViewHierarchyElement}s based on labeling ({@code android:labelFor}) * relationships//from w w w . j a va 2 s .com * * @param originMap A map from condensed unique IDs to the originating {@link * AccessibilityNodeInfo} structures from which a {@link ViewHierarchyElement} was * constructed, as populated by {@link AccessibilityHierarchy} constructors. */ @RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void resolveLabelForRelationshipsAmongInfos(BiMap<Long, AccessibilityNodeInfo> originMap) { for (Entry<Long, AccessibilityNodeInfo> entry : originMap.entrySet()) { AccessibilityNodeInfo labeledNode = entry.getValue().getLabelFor(); if (labeledNode != null) { Long labeledElementId = originMap.inverse().get(labeledNode); if (labeledElementId != null) { ViewHierarchyElement labelElement = getViewById(entry.getKey()); ViewHierarchyElement labeledElement = getViewById(labeledElementId); labeledElement.setLabeledBy(labelElement); } } } }
From source file:com.google.android.apps.common.testing.accessibility.framework.uielement.AccessibilityHierarchy.java
@RequiresApi(Build.VERSION_CODES.LOLLIPOP_MR1) private void resolveAccessibilityTraversalRelationshipsAmongInfos( BiMap<Long, AccessibilityNodeInfo> originMap) { for (Entry<Long, AccessibilityNodeInfo> entry : originMap.entrySet()) { AccessibilityNodeInfo beforeNode = entry.getValue().getTraversalBefore(); AccessibilityNodeInfo afterNode = entry.getValue().getTraversalAfter(); if (beforeNode != null || afterNode != null) { ViewHierarchyElement currentElement = getViewById(entry.getKey()); if (beforeNode != null) { ViewHierarchyElement beforeElement = findElementByNodeInfo(beforeNode, originMap); if (beforeElement == null) { LogUtils.w(this, "Element not found for accessibilityTraversalBefore."); } else { currentElement.setAccessibilityTraversalBefore(beforeElement); }/*from w w w .j ava 2s. com*/ } if (afterNode != null) { ViewHierarchyElement afterElement = findElementByNodeInfo(afterNode, originMap); if (afterElement == null) { LogUtils.w(this, "Element not found for accessibilityTraversalAfter."); } else { currentElement.setAccessibilityTraversalAfter(afterElement); } } } } }
From source file:org.apache.usergrid.management.importer.ImportServiceIT.java
@Test @Ignore("Pending merge of export-feature branch. Import organization not supported") public void testImportOrganization() throws Exception { // creates 5 entities in usertests collection EntityManager em = setup.getEmf().getEntityManager(applicationId); //intialize user object to be posted Map<String, Object> userProperties = null; Entity entity[] = new Entity[5]; //creates entities for (int i = 0; i < 5; i++) { userProperties = new LinkedHashMap<String, Object>(); userProperties.put("name", "user" + i); userProperties.put("email", "user" + i + "@test.com"); entity[i] = em.create("usertests", userProperties); em.getCollections(entity[i]).contains("usertests"); }// w w w . j a v a 2 s.co m //creates test connections between first 2 entities in usertests collection ConnectedEntityRef ref = em.createConnection(entity[0], "related", entity[1]); em.createConnection(entity[1], "related", entity[0]); //create 2nd test application, add entities to it, create connections and set permissions createAndSetup2ndApplication(); //export all applications in an organization ExportService exportService = setup.getExportService(); S3Export s3Export = new S3ExportImpl(); HashMap<String, Object> payload = payloadBuilder(); payload.put("organizationId", organization.getUuid()); //schdeule the export job UUID exportUUID = exportService.schedule(payload); //create and initialize jobData returned in JobExecution. JobData jobData = jobExportDataCreator(payload, exportUUID, s3Export); JobExecution jobExecution = mock(JobExecution.class); when(jobExecution.getJobData()).thenReturn(jobData); //export organization data and wait for the export job to finish exportService.doExport(jobExecution); while (!exportService.getState(exportUUID).equals("FINISHED")) { ; } //TODO: can check if the temp files got created // import S3Import s3Import = new S3ImportImpl(); ImportService importService = setup.getImportService(); //schedule the import job final Import importEntity = importService.schedule(null, payload); final UUID importUUID = importEntity.getUuid(); //create and initialize jobData returned in JobExecution. jobData = jobImportDataCreator(payload, importUUID, s3Import); jobExecution = mock(JobExecution.class); when(jobExecution.getJobData()).thenReturn(jobData); //import the all application files for the organization and wait for the import to finish importService.doImport(jobExecution); while (!importService.getState(importUUID).equals(Import.State.FINISHED)) { ; } try { //checks if temp import files are created i.e. downloaded from S3 //assertThat(importService.getEphemeralFile().size(), is(not(0))); //get all applications for an organization BiMap<UUID, String> applications = setup.getMgmtSvc() .getApplicationsForOrganization(organization.getUuid()); for (BiMap.Entry<UUID, String> app : applications.entrySet()) { //check if all collections-entities are updated - created and modified should be different UUID appID = app.getKey(); em = setup.getEmf().getEntityManager(appID); Set<String> collections = em.getApplicationCollections(); Iterator<String> itr = collections.iterator(); while (itr.hasNext()) { String collectionName = itr.next(); Results collection = em.getCollection(appID, collectionName, null, Level.ALL_PROPERTIES); List<Entity> entities = collection.getEntities(); if (collectionName.equals("usertests")) { // check if connections are created for only the 1st 2 entities in user collection Results r; List<ConnectionRef> connections; for (int i = 0; i < 2; i++) { r = em.getTargetEntities(entities.get(i), "related", null, Level.IDS); connections = r.getConnections(); assertNotNull(connections); } //check if dictionary is created EntityRef er; Map<Object, Object> dictionaries1, dictionaries2; for (int i = 0; i < 3; i++) { er = entities.get(i); dictionaries1 = em.getDictionaryAsMap(er, "connected_types"); dictionaries2 = em.getDictionaryAsMap(er, "connecting_types"); if (i == 2) { //for entity 2, these should be empty assertThat(dictionaries1.size(), is(0)); assertThat(dictionaries2.size(), is(0)); } else { assertThat(dictionaries1.size(), is(not(0))); assertThat(dictionaries2.size(), is(not(0))); } } } } } } finally { //delete bucket deleteBucket(); } }
From source file:org.apache.usergrid.management.cassandra.ImportServiceIT.java
@Ignore //For this test please input your s3 credentials into settings.xml or Attach a -D with relevant fields. // test case to check if all applications file for an organization are imported correctly //@Test// w w w . j av a2 s .c o m public void testIntegrationImportOrganization() throws Exception { // //creates 5 entities in usertests collection EntityManager em = setup.getEmf().getEntityManager(applicationId); //intialize user object to be posted Map<String, Object> userProperties = null; Entity entity[] = new Entity[5]; //creates entities for (int i = 0; i < 5; i++) { userProperties = new LinkedHashMap<String, Object>(); userProperties.put("name", "user" + i); userProperties.put("email", "user" + i + "@test.com"); entity[i] = em.create("usertests", userProperties); em.getCollections(entity[i]).contains("usertests"); } //creates test connections between first 2 entities in usertests collection ConnectedEntityRef ref = em.createConnection(em.getRef(entity[0].getUuid()), "related", em.getRef(entity[1].getUuid())); em.createConnection(em.getRef(entity[1].getUuid()), "related", em.getRef(entity[0].getUuid())); //create 2nd test application, add entities to it, create connections and set permissions createAndSetup2ndApplication(); //export all applications in an organization ExportService exportService = setup.getExportService(); S3Export s3Export = new S3ExportImpl(); HashMap<String, Object> payload = payloadBuilder(); payload.put("organizationId", organization.getUuid()); //schdeule the export job UUID exportUUID = exportService.schedule(payload); //create and initialize jobData returned in JobExecution. JobData jobData = jobExportDataCreator(payload, exportUUID, s3Export); JobExecution jobExecution = mock(JobExecution.class); when(jobExecution.getJobData()).thenReturn(jobData); //export organization data and wait for the export job to finish exportService.doExport(jobExecution); while (!exportService.getState(exportUUID).equals("FINISHED")) { ; } //TODo: can check if the temp files got created // import S3Import s3Import = new S3ImportImpl(); ImportService importService = setup.getImportService(); //schedule the import job UUID importUUID = importService.schedule(payload); //create and initialize jobData returned in JobExecution. jobData = jobImportDataCreator(payload, importUUID, s3Import); jobExecution = mock(JobExecution.class); when(jobExecution.getJobData()).thenReturn(jobData); //import the all application files for the organization and wait for the import to finish importService.doImport(jobExecution); while (!importService.getState(importUUID).equals("FINISHED")) { ; } try { //checks if temp import files are created i.e. downloaded from S3 assertThat(importService.getEphemeralFile().size(), is(not(0))); //get all applications for an organization BiMap<UUID, String> applications = setup.getMgmtSvc() .getApplicationsForOrganization(organization.getUuid()); for (BiMap.Entry<UUID, String> app : applications.entrySet()) { //check if all collections-entities are updated - created and modified should be different UUID appID = app.getKey(); em = setup.getEmf().getEntityManager(appID); Set<String> collections = em.getApplicationCollections(); Iterator<String> itr = collections.iterator(); while (itr.hasNext()) { String collectionName = itr.next(); Results collection = em.getCollection(appID, collectionName, null, Results.Level.ALL_PROPERTIES); List<Entity> entities = collection.getEntities(); if (collectionName.equals("usertests")) { // check if connections are created for only the 1st 2 entities in user collection Results r; List<ConnectionRef> connections; for (int i = 0; i < 2; i++) { r = em.getConnectedEntities(entities.get(i).getUuid(), "related", null, Results.Level.IDS); connections = r.getConnections(); assertNotNull(connections); } //check if dictionary is created EntityRef er; Map<Object, Object> dictionaries1, dictionaries2; for (int i = 0; i < 3; i++) { er = em.getRef(entities.get(i).getUuid()); dictionaries1 = em.getDictionaryAsMap(er, "connected_types"); dictionaries2 = em.getDictionaryAsMap(er, "connecting_types"); if (i == 2) { //for entity 2, these should be empty assertThat(dictionaries1.size(), is(0)); assertThat(dictionaries2.size(), is(0)); } else { assertThat(dictionaries1.size(), is(not(0))); assertThat(dictionaries2.size(), is(not(0))); } } } } } } finally { //delete bucket deleteBucket(); } }
From source file:org.opencb.opencga.storage.mongodb.variant.converters.DocumentToSamplesConverter.java
/** * Lazy usage of loaded samplesIdMap.// w ww. j a v a2 s .c o m **/ private BiMap<String, Integer> getIndexedSamplesIdMap(int studyId) { BiMap<String, Integer> sampleIds; if (this.__studySamplesId.get(studyId) == null) { StudyConfiguration studyConfiguration = studyConfigurations.get(studyId); sampleIds = StudyConfiguration.getIndexedSamples(studyConfiguration); if (!returnedSamples.isEmpty()) { BiMap<String, Integer> returnedSampleIds = HashBiMap.create(); sampleIds.entrySet().stream() //ReturnedSamples could be sampleNames or sampleIds as a string .filter(e -> returnedSamples.contains(e.getKey()) || returnedSamples.contains(e.getValue().toString())) .forEach(stringIntegerEntry -> returnedSampleIds.put(stringIntegerEntry.getKey(), stringIntegerEntry.getValue())); sampleIds = returnedSampleIds; } this.__studySamplesId.put(studyId, sampleIds); } else { sampleIds = this.__studySamplesId.get(studyId); } return sampleIds; }
From source file:com.android.tools.idea.editors.navigation.NavigationView.java
private <K, V extends Component> void removeLeftovers(BiMap<K, V> assoc, Collection<K> a) { for (Map.Entry<K, V> e : new ArrayList<Map.Entry<K, V>>(assoc.entrySet())) { K k = e.getKey();//from w ww .j ava 2s . co m V v = e.getValue(); if (!a.contains(k)) { assoc.remove(k); remove(v); repaint(); } } }