List of usage examples for org.apache.commons.collections CollectionUtils intersection
public static Collection intersection(final Collection a, final Collection b)
From source file:com.univocity.app.DataUpdateTest.java
private void executeAndValidate(String entityName, boolean inserting, RowDataCollector dataCollector) { System.gc();/*from ww w .j a v a2s. c o m*/ loadProcess.execute(entityName); Set<String> persistedRows = dataCollector.getPersistedData(); Set<String> expectedRows = dataCollector.getExpected(); if (!expectedRows.containsAll(persistedRows)) { @SuppressWarnings("unchecked") Collection<String> intersection = CollectionUtils.intersection(persistedRows, expectedRows); persistedRows.removeAll(intersection); expectedRows.removeAll(intersection); if (!isExpectedDiscrepancy(entityName, dataCollector.getFieldNames(), inserting, persistedRows)) { fail("Unexpected rows persisted:\n" + persistedRows.size() + "\n\nRows expected but not persisted:\n" + expectedRows.size()); } } System.gc(); }
From source file:gov.nih.nci.caintegrator.application.study.GenomicDataSourceConfiguration.java
/** * @return the control samples/*from w w w .j a v a2 s . com*/ */ @SuppressWarnings("unchecked") public List<Sample> getControlSamples() { List<Sample> controlSamples = new ArrayList<Sample>(); if (CollectionUtils.isNotEmpty(getStudyConfiguration().getAllControlSamples())) { controlSamples.addAll( CollectionUtils.intersection(getSamples(), getStudyConfiguration().getAllControlSamples())); } return controlSamples; }
From source file:com.sonymobile.jenkins.plugins.lenientshutdown.PluginImpl.java
/** * Checks if any of the project names in argument list are marked as white listed upstream * projects for a specific slave.// ww w.j ava 2s . c o m * @param queueItemsIds the list of project names to check * @param nodeName the specific slave name to check for * @return true if at least one of the projects is white listed */ @Restricted(NoExternalUse.class) public boolean isAnyPermittedUpstreamQueueId(Set<Long> queueItemsIds, String nodeName) { boolean isPermitted = false; Set<Long> permittedQueueItemIds = getPermittedQueuedItemIds(nodeName); if (permittedQueueItemIds != null) { Collection<?> intersection = CollectionUtils.intersection(queueItemsIds, permittedQueueItemIds); isPermitted = !intersection.isEmpty(); } return isPermitted; }
From source file:expansionBlocks.ProcessCommunities.java
private static double calculateSimilarity(Set<String> tokens, Map<Entity, Double> set, Definitions.LANGUAGE language) throws Exception { //println("Tokens:"+tokens); //Set<String> tokensSet = new HashSet<String>(); double d = 0.0; Collection<String> intersection; ///List<Article> union = new ArrayList<Article>(); List<String> checkedToken = new ArrayList<String>(); //println("--------------------"); for (Map.Entry<Entity, Double> e : set.entrySet()) { if (e.getValue() > 0)// Si e.getValue == 0 l'article no forma part de la comunitat {/*w w w . j a v a 2 s. c o m*/ Entity entity = (e.getKey()); //println("Is entity \""+entity.getName()+"\" ambiguous?"+ entity.isAmbiguous()); Set<String> otherNames = entity.getEntityNames(); for (String otherName : otherNames) { intersection = CollectionUtils .intersection(Tokenizer.getTokenizedList(otherName, language, false), tokens); if (intersection.size() > 0 && intersection .size() == (Tokenizer.getTokenizedList(otherName, language, false)).size()) { d += intersection.size(); } } } } // println("Community weight: " + d + "\n--------------------"); return d; }
From source file:edu.scripps.fl.pubchem.promiscuity.PCPromiscuityFactory.java
public void addAllProteinCount(OverallListsAndMaps overall, Map<String, PromiscuityCount<?>> counts) { log.info("\t adding all protein and no protein counts"); PromiscuityCount<Long> allAssays = (PromiscuityCount<Long>) counts.get(allAssayName); Set<Protein> activeProteins = new HashSet<Protein>(); Set<Protein> allProteins = new HashSet<Protein>(); List<Long> allProteinAIDs = overall.getAllProteinAIDs(); List<Long> activeProteinAIDs = (List<Long>) CollectionUtils.intersection(allAssays.getActive(), allProteinAIDs);//from w w w . j a v a 2 s . c o m List<Long> totalProteinAIDs = (List<Long>) CollectionUtils.intersection(allAssays.getTotal(), allProteinAIDs); for (Long aid : totalProteinAIDs) { List<Protein> proteins = overall.getAidProteinMap().get(aid); if (proteins != null && proteins.size() > 0) { allProteins.addAll(proteins); if (activeProteinAIDs.contains(aid)) activeProteins.addAll(proteins); } } PromiscuityCount<Protein> allProteinsCount = new PromiscuityCount<Protein>(allProteinsName, new ArrayList<Protein>(activeProteins), new ArrayList<Protein>(allProteins)); counts.put(allProteinsCount.getName(), allProteinsCount); log.info("\t all protein counts complete"); }
From source file:com.qrmedia.pattern.compositeannotation.CompositeAnnotatedElements.java
@SuppressWarnings("unchecked") private Collection<Class<? extends Annotation>> getPresentProvidingCompositeTypes( AnnotatedElement annotatedElement, Class<? extends Annotation> annotationClass) { // check how many of the composite elements that deliver the required elements are present Collection<Class<? extends Annotation>> presentProvidingCompositeTypes = (Collection<Class<? extends Annotation>>) CollectionUtils .intersection(getCompositeAnnotationTypes(annotatedElement, true), leafAnnotationTypeProvidingCompositeTypes.get(annotationClass)); // at most one providing composite may be present if (presentProvidingCompositeTypes.size() > 1) { throw new IllegalArgumentException( annotatedElement + " is annotated with multiple composite annotations (" + presentProvidingCompositeTypes + ") that declare leaves of type " + annotationClass); }//from w w w . j a v a 2 s . c o m return presentProvidingCompositeTypes; }
From source file:com.ephesoft.dcma.batch.service.impl.ServerBatchPriorityServiceImpl.java
@Override public boolean validatePriorityRange(final Set<Integer> currentServerPrioritySet, final ServerRegistry serverRegistry, final boolean isSecure) { boolean isValid; List<Set<Integer>> prioritySetList = serverRegistryService .getPriorityLoadedActiveServers(serverRegistry.getId(), isSecure); if (CollectionUtils.isEmpty(currentServerPrioritySet)) { isValid = false;/*from w w w .j a v a 2 s .c o m*/ } else if (CollectionUtils.isEmpty(prioritySetList)) { isValid = true; } else { boolean isValidForAllServers = true; for (Set<Integer> anActiveServerPrioritySet : prioritySetList) { if (CollectionUtils.isEmpty(anActiveServerPrioritySet)) { isValidForAllServers &= true; } else { Collection<Integer> collection = (Collection<Integer>) CollectionUtils .intersection(anActiveServerPrioritySet, currentServerPrioritySet); if (CollectionUtils.isEmpty(collection) || collection.size() == currentServerPrioritySet.size()) { isValidForAllServers &= true; } else { isValidForAllServers &= false; break; } } } isValid = isValidForAllServers; } return isValid; }
From source file:edu.internet2.middleware.changelogconsumer.googleapps.GoogleAppsFullSync.java
/** * Runs a fullSync.//from w ww . ja v a 2 s . co m * @param dryRun indicates that this is dryRun */ public void process(boolean dryRun) { synchronized (fullSyncIsRunningLock) { fullSyncIsRunning.put(consumerName, Boolean.toString(true)); } connector = new GoogleGrouperConnector(); //Start with a clean cache GoogleCacheManager.googleGroups().clear(); GoogleCacheManager.googleGroups().clear(); properties = new GoogleAppsSyncProperties(consumerName); Pattern googleGroupFilter = Pattern.compile(properties.getGoogleGroupFilter()); try { connector.initialize(consumerName, properties); if (properties.getprefillGoogleCachesForFullSync()) { connector.populateGoogleCache(); } } catch (GeneralSecurityException e) { LOG.error("Google Apps Consume '{}' Full Sync - This consumer failed to initialize: {}", consumerName, e.getMessage()); } catch (IOException e) { LOG.error("Google Apps Consume '{}' Full Sync - This consumer failed to initialize: {}", consumerName, e.getMessage()); } GrouperSession grouperSession = null; try { grouperSession = GrouperSession.startRootSession(); connector.getGoogleSyncAttribute(); connector.cacheSyncedGroupsAndStems(true); // time context processing final StopWatch stopWatch = new StopWatch(); stopWatch.start(); //Populate a normalized list (google naming) of Grouper groups ArrayList<ComparableGroupItem> grouperGroups = new ArrayList<ComparableGroupItem>(); for (String groupKey : connector.getSyncedGroupsAndStems().keySet()) { if (connector.getSyncedGroupsAndStems().get(groupKey).equalsIgnoreCase("yes")) { edu.internet2.middleware.grouper.Group group = connector.fetchGrouperGroup(groupKey); if (group != null) { grouperGroups.add(new ComparableGroupItem( connector.getAddressFormatter().qualifyGroupAddress(group.getName()), group)); } } } //Populate a comparable list of Google groups ArrayList<ComparableGroupItem> googleGroups = new ArrayList<ComparableGroupItem>(); for (String groupName : GoogleCacheManager.googleGroups().getKeySet()) { if (googleGroupFilter.matcher(groupName.replace("@" + properties.getGoogleDomain(), "")).find()) { googleGroups.add(new ComparableGroupItem(groupName)); LOG.debug("Google Apps Consumer '{}' Full Sync - {} group matches group filter: included", consumerName, groupName); } else { LOG.debug("Google Apps Consumer '{}' Full Sync - {} group does not match group filter: ignored", consumerName, groupName); } } //Get our sets Collection<ComparableGroupItem> extraGroups = CollectionUtils.subtract(googleGroups, grouperGroups); processExtraGroups(dryRun, extraGroups); Collection<ComparableGroupItem> missingGroups = CollectionUtils.subtract(grouperGroups, googleGroups); processMissingGroups(dryRun, missingGroups); Collection<ComparableGroupItem> matchedGroups = CollectionUtils.intersection(grouperGroups, googleGroups); processMatchedGroups(dryRun, matchedGroups); // stop the timer and log stopWatch.stop(); LOG.debug("Google Apps Consumer '{}' Full Sync - Processed, Elapsed time {}", new Object[] { consumerName, stopWatch }); } finally { GrouperSession.stopQuietly(grouperSession); synchronized (fullSyncIsRunningLock) { fullSyncIsRunning.put(consumerName, Boolean.toString(true)); } } }
From source file:edu.scripps.fl.pubchem.promiscuity.PCPromiscuityFactory.java
public void addAllNoProteinAIDCount(Map<String, PromiscuityCount<?>> countMap, OverallListsAndMaps overall) { PromiscuityCount<Long> allAssayCount = (PromiscuityCount<Long>) countMap .get(PCPromiscuityFactory.allAssayName); List<Long> actives = allAssayCount.getActive(); List<Long> total = allAssayCount.getTotal(); List<Long> allNoProteinAIDs = overall.getAllNoProteinAIDs(); List<Long> activeNoProtein = (List<Long>) CollectionUtils.intersection(allNoProteinAIDs, actives); List<Long> totalNoProtein = (List<Long>) CollectionUtils.intersection(allNoProteinAIDs, total); PromiscuityCount<Long> noProteinCount = new PromiscuityCount<Long>(noProteinsName, activeNoProtein, totalNoProtein);// ww w.j ava 2 s .c o m countMap.put(noProteinsName, noProteinCount); }
From source file:com.sonymobile.jenkins.plugins.lenientshutdown.ShutdownManageLink.java
/** * Checks if any of the queue ids in argument list is in the list of permitted queue ids. * * @param queueIds the list of queue ids to check * @return true if at least one of the projects is white listed *///from ww w .j ava 2 s . c o m public boolean isAnyPermittedUpstreamProject(Set<Long> queueIds) { Collection<?> intersection = CollectionUtils.intersection(queueIds, permittedQueueIds); return !intersection.isEmpty(); }