List of usage examples for java.util Collection removeAll
boolean removeAll(Collection<?> c);
From source file:org.metaabm.act.provider.AActItemProvider.java
@SuppressWarnings("unchecked") protected Command createAddCommand(EditingDomain domain, EObject owner, EStructuralFeature feature, Collection<?> collection, int index) { if (feature == MetaABMActPackage.Literals.AACT__SOURCES) { CompoundCommand cmd = new CompoundCommand("Add Source"); SuggestLabelCommand suggestLabelCommand = new SuggestLabelCommand(this, domain, (IID) owner); cmd.append(super.createAddCommand(domain, owner, feature, collection, index)); cmd.append(suggestLabelCommand); return cmd; } else if (feature == MetaABMActPackage.Literals.AACT__TARGETS) { // Don't allow any circular references! AAct source = (AAct) owner;//from w w w . j av a2 s . co m if (Collections.disjoint(source.getAllSources(), collection) && !collection.contains(owner)) { CompoundCommand cmd = new CompoundCommand("Add Target"); SuggestLabelCommand suggestLabelCommand = new SuggestLabelCommand(domain, (Collection<IID>) collection); cmd.append(super.createAddCommand(domain, owner, feature, collection, index)); AGroup group = source.getGroup(); if (group != null) { // do not add existing members.. Collection<?> newMembers = new ArrayList<Object>(collection); newMembers.removeAll(group.getMembers()); if (newMembers.size() > 0) { cmd.append(AddCommand.create(domain, group, MetaABMActPackage.Literals.AGROUP__MEMBERS, newMembers)); } } for (Object act : collection) { reassignSelects(domain, cmd, source, (AAct) act); } cmd.append(suggestLabelCommand); return cmd; } else { return UnexecutableCommand.INSTANCE; } } else { return super.createAddCommand(domain, owner, feature, collection, index); } }
From source file:ubic.gemma.analysis.report.WhatsNewServiceImpl.java
/** * @param date//from w w w .ja v a 2 s . co m * @return representing the updated or new objects. */ @Override public WhatsNew getReport(Date date) { WhatsNew wn = new WhatsNew(date); Collection<Auditable> updatedObjects = auditEventService.getUpdatedSinceDate(date); wn.setUpdatedObjects(updatedObjects); log.info(wn.getUpdatedObjects().size() + " updated objects since " + date); Collection<Auditable> newObjects = auditEventService.getNewSinceDate(date); wn.setNewObjects(newObjects); log.info(wn.getNewObjects().size() + " new objects since " + date); Collection<ExpressionExperiment> updatedExpressionExperiments = getExpressionExperiments(updatedObjects); Collection<ExpressionExperiment> newExpressionExperiments = getExpressionExperiments(newObjects); Collection<ArrayDesign> updatedArrayDesigns = getArrayDesigns(updatedObjects); Collection<ArrayDesign> newArrayDesigns = getArrayDesigns(newObjects); // don't show things that are "new" as "updated" too (if they were updated after being loaded) updatedExpressionExperiments.removeAll(newExpressionExperiments); updatedArrayDesigns.removeAll(newArrayDesigns); // build total, new and updated counts by taxon to display in data summary widget on front page wn.setNewEEIdsPerTaxon(getExpressionExperimentIdsByTaxon(newExpressionExperiments)); wn.setUpdatedEEIdsPerTaxon(getExpressionExperimentIdsByTaxon(updatedExpressionExperiments)); wn.setNewAssayCount(getAssayCount(newExpressionExperiments)); return wn; }
From source file:br.unb.cic.bionimbuz.services.storage.StorageService.java
@Override public void verifyPlugins() { final Collection<PluginInfo> temp = this.getPeers().values(); temp.removeAll(this.cloudMap.values()); for (final PluginInfo plugin : temp) { if (this.cms.getZNodeExist(Path.STATUS.getFullPath(plugin.getId(), null, null), null)) { this.cms.getData(Path.STATUS.getFullPath(plugin.getId()), new UpdatePeerData(this.cms, this, null)); }/* w w w .j ava 2 s .co m*/ } }
From source file:pltag.corpus.PredictionStringTree.java
public boolean hasUsefulNodes(Collection<Integer> cn, HashMap<Integer, Integer> mapper) { Iterator<Integer> it = cn.iterator(); //remove all nodes that are not actually in tree ArrayList<Integer> removelist = new ArrayList<Integer>(); while (it.hasNext()) { Integer cnnode = it.next(); if (cnnode >= arraysize || getCategory(cnnode) == null) { // if (Integer.parseInt(cnnode) >= arraysize ||getCategory(cnnode) == null){ removelist.add(cnnode);/* www . jav a 2s. co m*/ } } cn.removeAll(removelist); // if no nodes in tree, then clearly no useful ones if (cn.isEmpty()) return false; // if one useful node in tree, check it's not the root or foot node of an aux tree if (cn.size() == 1) { Integer cnnode = (Integer) cn.iterator().next(); if (cnnode >= arraysize || getCategory(cnnode) == null) return false; // if (Integer.parseInt(cnnode) >= arraysize || getCategory(cnnode) == null) return false; if (auxtree && cnnode.equals(foot)) { if (mapper.containsKey(root) || mapper.containsKey(foot)) { //System.out.println("further mapping needed"); } mapper.put(root, foot); mapper.put(foot, root); return false; } // can also remove if root of an initial tree??? else if (cnnode.equals(root)) {//&& auxtree){ if (auxtree) { if (mapper.containsKey(root) || mapper.containsKey(foot)) { //System.out.println("further mapping needed"); } mapper.put(root, foot); mapper.put(foot, root); } return false; } else { return true; } } // if two useful nodes in tree, check they're not the foot and root node else if (cn.size() == 2) { if (auxtree && cn.contains(foot) && cn.contains(root)) { if (mapper.containsKey(root) || mapper.containsKey(foot)) { //System.out.println("further mapping needed"); } mapper.put(root, foot); mapper.put(foot, root); return false; } else { Iterator cnit = cn.iterator(); boolean hasUsefulNode = false; while (cnit.hasNext()) { Integer cnel = (Integer) cnit.next(); if (this.arraysize > cnel && getCategory(cnel) != null) { // if (this.arraysize>Integer.parseInt(cnel) &&getCategory(cnel) !=null){ hasUsefulNode = true; } } return hasUsefulNode; } } //else there must be at least one useful non-foot non-root node else return true; }
From source file:org.jboss.aerogear.android.impl.datamanager.MemoryStorage.java
private void filterData(Collection<T> data, JSONObject where) { String filterPropertyName;/*from w w w.j a va 2 s. c o m*/ Object filterValue; Iterator keys = where.keys(); while (keys.hasNext()) { ArrayList toRemove = new ArrayList(data.size()); // We will not remove more items than are in data filterPropertyName = keys.next().toString(); filterValue = where.opt(filterPropertyName); for (T objectInStorage : data) { Property objectProperty = new Property(objectInStorage.getClass(), filterPropertyName); Object propertyValue = objectProperty.getValue(objectInStorage); if (propertyValue != null && filterValue != null) { if (!propertyValue.equals(filterValue)) { toRemove.add(objectInStorage); } } } data.removeAll(toRemove); } }
From source file:gov.nih.nci.ncicb.cadsr.common.cdebrowser.DataElementSearchBean.java
public void getContextsList(Collection<Context> contexts) { String excludeList = this.getExcludeContextList(); if (!excludeList.equals("")) { Collection<Context> exContexts = new ArrayList<Context>(); for (Context context : contexts) { // if this context is not excluded by user preference if (excludeList.contains(context.getName())) exContexts.add(context); }//from ww w . j ava 2s.c om if (!exContexts.isEmpty()) contexts.removeAll(exContexts); } }
From source file:org.openmrs.module.reportingcompatibility.service.ReportingCompatibilityServiceImpl.java
/** * Returns a PatientSet of patient who had drug orders for a set of drugs active on a certain * date. Can also be used to find patient with no drug orders on that date. * //from w w w. jav a 2 s . c o m * @param patientIds Collection of patientIds you're interested in. NULL means all patients. * @param takingIds Collection of drugIds the patient is taking. (Or the empty set to mean * "any drug" or NULL to mean "no drugs") * @param onDate Which date to look at the patients' drug orders. (NULL defaults to now().) * @return Cohort of Patients matching criteria */ public Cohort getPatientsHavingDrugOrder(Collection<Integer> patientIds, Collection<Integer> takingIds, Date onDate) { Map<Integer, Collection<Integer>> activeDrugs = getDao().getActiveDrugIds(patientIds, onDate, onDate); Set<Integer> ret = new HashSet<Integer>(); boolean takingAny = takingIds != null && takingIds.size() == 0; boolean takingNone = takingIds == null; if (takingAny) { ret.addAll(activeDrugs.keySet()); } else if (takingNone) { if (patientIds == null) { patientIds = getAllPatients().getMemberIds(); } patientIds.removeAll(activeDrugs.keySet()); ret.addAll(patientIds); } else { // taking any of the drugs in takingIds for (Map.Entry<Integer, Collection<Integer>> e : activeDrugs.entrySet()) { for (Integer drugId : takingIds) { if (e.getValue().contains(drugId)) { ret.add(e.getKey()); break; } } } } return new Cohort("Cohort from drug orders", "", ret); }
From source file:ubc.pavlab.aspiredb.server.service.BurdenAnalysisServiceImpl.java
/** * Excludes those IDs that have both label1 and label2. * /*from ww w.j a v a2 s . c om*/ * @param labelSubjectId * @param name * @param name2 * @return */ private Map<String, Collection<Long>> getMutuallyExclusiveSubjectIds( Map<String, Collection<Long>> labelSubjectId, String label1, String label2) { if (!labelSubjectId.containsKey(label1) || !labelSubjectId.containsKey(label2)) { log.warn("Label not found"); return labelSubjectId; } Collection<Long> label1IdsOld = new ArrayList<>(labelSubjectId.get(label1)); Collection<Long> label2IdsOld = new ArrayList<>(labelSubjectId.get(label2)); Collection<Long> label1Ids = labelSubjectId.get(label1); Collection<Long> label2Ids = labelSubjectId.get(label2); boolean removed = label1Ids.removeAll(label2IdsOld); label2Ids.removeAll(label1IdsOld); // for logging if (removed) { label1IdsOld.removeAll(label1Ids); label2IdsOld.removeAll(label2Ids); label1IdsOld.addAll(label2IdsOld); log.info("Ignoring " + label1IdsOld.size() + " (" + StringUtils.join(label1IdsOld, ",") + ") subjects with labels " + label1 + " and " + label2 + ". After filtering, " + label1 + " has " + label1Ids.size() + " and " + label2 + " has " + label2Ids.size()); } return labelSubjectId; }
From source file:ubc.pavlab.aspiredb.server.service.BurdenAnalysisServiceImpl.java
/** * Excludes those IDs that have both label1 and label2. * /* w w w . ja v a2s . co m*/ * @param labelPatientId * @param name * @param name2 * @return */ private Map<String, Collection<String>> getMutuallyExclusivePatientIds( Map<String, Collection<String>> labelPatientId, String label1, String label2) { if (!labelPatientId.containsKey(label1) || !labelPatientId.containsKey(label2)) { log.warn("Label not found"); return labelPatientId; } Collection<String> label1IdsOld = new ArrayList<>(labelPatientId.get(label1)); Collection<String> label2IdsOld = new ArrayList<>(labelPatientId.get(label2)); Collection<String> label1Ids = labelPatientId.get(label1); Collection<String> label2Ids = labelPatientId.get(label2); boolean removed = label1Ids.removeAll(label2IdsOld); label2Ids.removeAll(label1IdsOld); // for logging if (removed) { label1IdsOld.removeAll(label1Ids); label2IdsOld.removeAll(label2Ids); label1IdsOld.addAll(label2IdsOld); String overlappedIds = StringUtils.join(label1IdsOld, ", "); log.info("Ignoring " + label1IdsOld.size() + " (" + overlappedIds.substring(0, Math.min(50, overlappedIds.length())) + "... ) subjects with labels " + label1 + " and " + label2 + ". After filtering, " + label1 + " has " + label1Ids.size() + " and " + label2 + " has " + label2Ids.size()); } return labelPatientId; }
From source file:org.openmrs.module.openconceptlab.updater.ImporterTest.java
/** * @see Importer#importConcept(OclConcept,ImportQueue) * @verifies void names from concept//from w w w. ja v a2 s . co m */ @Test public void importConcept_shouldVoidNamesFromConcept() throws Exception { OclConcept oclConcept = newOclConcept(); Name fourthName = newFourthName(); oclConcept.getNames().add(fourthName); importer.importConcept(new CacheService(conceptService), update, oclConcept); List<Name> voided = new ArrayList<OclConcept.Name>(); for (Iterator<Name> it = oclConcept.getNames().iterator(); it.hasNext();) { Name name = it.next(); if (!name.isLocalePreferred()) { it.remove(); voided.add(name); } } assertThat(voided, is(not(empty()))); importer.importConcept(new CacheService(conceptService), update, oclConcept); Concept concept = assertImported(oclConcept); Collection<ConceptName> nonVoidedNames = concept.getNames(false); Collection<ConceptName> voidedNames = new ArrayList<ConceptName>(concept.getNames(true)); voidedNames.removeAll(nonVoidedNames); assertThat(voidedNames, containsNamesInAnyOrder(voided)); }