List of usage examples for java.util Collection removeAll
boolean removeAll(Collection<?> c);
From source file:com.bt.download.android.gui.Librarian.java
private void scan(File file, Set<File> ignorableFiles) { //if we just have a single file, do it the old way if (file.isFile()) { if (ignorableFiles.contains(file)) { return; }/*from ww w.j a va 2 s . c o m*/ new UniversalScanner(context).scan(file.getAbsolutePath()); } else if (file.isDirectory() && file.canRead()) { Collection<File> flattenedFiles = DirectoryUtils.getAllFolderFiles(file, null); if (ignorableFiles != null && !ignorableFiles.isEmpty()) { flattenedFiles.removeAll(ignorableFiles); } if (flattenedFiles != null && !flattenedFiles.isEmpty()) { new UniversalScanner(context).scan(flattenedFiles); } } }
From source file:org.openmrs.api.impl.PatientSetServiceImpl.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. * * @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 *///from w ww . j a v a2 s . com public Cohort getPatientsHavingDrugOrder(Collection<Integer> patientIds, Collection<Integer> takingIds, Date onDate) { Map<Integer, Collection<Integer>> activeDrugs = getPatientSetDAO().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:msi.gaml.statements.SaveStatement.java
public void saveText(final String type, final File fileTxt, final boolean header, final IScope scope) throws GamaRuntimeException { try (FileWriter fw = new FileWriter(fileTxt, true)) { if (item == null) { return; }/*from w ww. j a v a 2s .co m*/ if (type.equals("text")) { fw.write(Cast.asString(scope, item.value(scope)) + Strings.LN); } else if (type.equals("csv")) { final IType itemType = item.getGamlType(); final SpeciesDescription sd; if (itemType.isAgentType()) { sd = itemType.getSpecies(); } else if (itemType.getContentType().isAgentType()) { sd = itemType.getContentType().getSpecies(); } else { sd = null; } final Object value = item.value(scope); final IList values = itemType.isContainer() ? Cast.asList(scope, value) : GamaListFactory.create(scope, itemType, value); if (values.isEmpty()) { return; } if (sd != null) { final Collection<String> attributeNames = sd.getAttributeNames(); attributeNames.removeAll(NON_SAVEABLE_ATTRIBUTE_NAMES); if (header) { // final IAgent ag0 = Cast.asAgent(scope, // values.get(0)); fw.write("cycle;name;location.x;location.y;location.z"); for (final String v : attributeNames) { fw.write(";" + v); } fw.write(Strings.LN); } for (final Object obj : values) { if (obj instanceof IAgent) { final IAgent ag = Cast.asAgent(scope, obj); fw.write(scope.getClock().getCycle() + ";" + ag.getName().replace(';', ',') + ";" + ag.getLocation().getX() + ";" + ag.getLocation().getY() + ";" + ag.getLocation().getZ()); for (final String v : attributeNames) { String val = Cast.toGaml(ag.getDirectVarValue(scope, v)).replace(';', ','); if (val.startsWith("'") && val.endsWith("'") || val.startsWith("\"") && val.endsWith("\"")) { val = val.substring(1, val.length() - 1); } fw.write(";" + val); } fw.write(Strings.LN); } } } else { if (header) { fw.write(item.serialize(true).replace("]", "").replace("[", "")); fw.write(Strings.LN); } if (itemType.id() == IType.MATRIX) { final String[] tmpValue = value.toString().replace("[", "").replace("]", "").split(","); for (int i = 0; i < tmpValue.length; i++) { if (i > 0) { fw.write(','); } fw.write(toCleanString(tmpValue[i])); } fw.write(Strings.LN); } else { final int size = values.size(); for (int i = 0; i < size; i++) { if (i > 0) { fw.write(','); } fw.write(toCleanString(values.get(i))); } fw.write(Strings.LN); } } } } catch (final GamaRuntimeException e) { throw e; } catch (final Throwable e) { throw GamaRuntimeException.create(e, scope); } }
From source file:com.atlassian.jira.user.util.UserUtilImpl.java
private Collection<Group> getGroupsWithUsePermissionAndNoAdminsitrativePermissions() { final Collection<Group> useGroups = new ArrayList<Group>( globalPermissionManager.getGroupsWithPermission(Permissions.USE)); useGroups.removeAll(globalPermissionManager.getGroupsWithPermission(Permissions.ADMINISTER)); useGroups.removeAll(globalPermissionManager.getGroupsWithPermission(Permissions.SYSTEM_ADMIN)); return Collections.unmodifiableCollection(useGroups); }
From source file:org.kuali.coeus.propdev.impl.attachment.ProposalNarrativeTypeValuesFinder.java
protected Collection<NarrativeType> filterCollection(Collection<NarrativeType> narrativeTypes, DevelopmentProposal developmentProposal, String narrativeTypeCode) { Collection<NarrativeType> forRemoval = new ArrayList<>(); for (NarrativeType narrativeType : narrativeTypes) { for (Narrative narrative : developmentProposal.getNarratives()) { if (narrative.getNarrativeType() != null && filterCondition(narrative.getNarrativeType(), narrativeType) && !narrative.getNarrativeTypeCode().equals(narrativeTypeCode)) { forRemoval.add(narrativeType); } else { LOG.debug("Not removing narrative type " + narrativeType.getDescription()); }/*from w ww . j ava2 s. c om*/ } } // Remove any instances for with these type codes already in the document narrativeTypes.removeAll(forRemoval); return narrativeTypes; }
From source file:org.openmrs.module.reportingcompatibility.service.ReportingCompatibilityServiceImpl.java
public Cohort getPatientsHavingDrugOrder(Collection<Integer> patientIds, Collection<Integer> drugIds, GroupMethod groupMethod, Date fromDate, Date toDate) { Map<Integer, Collection<Integer>> activeDrugs = getDao().getActiveDrugIds(patientIds, fromDate, toDate); Set<Integer> ret = new HashSet<Integer>(); if (drugIds == null) drugIds = new ArrayList<Integer>(); if (drugIds.size() == 0) { if (groupMethod == GroupMethod.NONE) { // Patients taking no drugs if (patientIds == null) { patientIds = getAllPatients().getMemberIds(); }/*from w ww .j a v a 2 s .c om*/ patientIds.removeAll(activeDrugs.keySet()); ret.addAll(patientIds); } else { // Patients taking any drugs ret.addAll(activeDrugs.keySet()); } } else { if (groupMethod == GroupMethod.NONE) { // Patients taking none of the specified drugs // first get all patients taking no drugs at all ret.addAll(patientIds); ret.removeAll(activeDrugs.keySet()); // next get all patients taking drugs, but not the specified ones for (Map.Entry<Integer, Collection<Integer>> e : activeDrugs.entrySet()) if (!OpenmrsUtil.containsAny(e.getValue(), drugIds)) ret.add(e.getKey()); } else if (groupMethod == GroupMethod.ALL) { // Patients taking all of the specified drugs for (Map.Entry<Integer, Collection<Integer>> e : activeDrugs.entrySet()) if (e.getValue().containsAll(drugIds)) ret.add(e.getKey()); } else { // groupMethod == GroupMethod.ANY // Patients taking any of the specified drugs for (Map.Entry<Integer, Collection<Integer>> e : activeDrugs.entrySet()) if (OpenmrsUtil.containsAny(e.getValue(), drugIds)) ret.add(e.getKey()); } } Cohort ps = new Cohort("Cohort from drug orders", "", ret); return ps; }
From source file:br.unb.cic.bionimbuz.services.sched.SchedService.java
@Override public void verifyPlugins() { final Collection<PluginInfo> temp = this.getPeers().values(); temp.removeAll(this.cloudMap.values()); for (final PluginInfo plugin : temp) { // try {//from w w w. j a va 2s.com if (this.cms.getZNodeExist(Path.STATUS.getFullPath(plugin.getId()), null)) { this.cms.getData(Path.STATUS.getFullPath(plugin.getId()), new UpdatePeerData(this.cms, this, null)); } // } catch (KeeperException ex) { // java.util.logging.Logger.getLogger(SchedService.class.getName()).log(Level.SEVERE, null, ex); // } catch (InterruptedException ex) { // java.util.logging.Logger.getLogger(SchedService.class.getName()).log(Level.SEVERE, null, ex); // } } }
From source file:org.apache.storm.scheduler.resource.strategies.scheduling.DefaultResourceAwareStrategy.java
public SchedulingResult schedule(TopologyDetails td) { if (_nodes.getNodes().size() <= 0) { LOG.warn("No available nodes to schedule tasks on!"); return SchedulingResult.failure(SchedulingStatus.FAIL_NOT_ENOUGH_RESOURCES, "No available nodes to schedule tasks on!"); }//from w w w .j a v a 2s .co m Collection<ExecutorDetails> unassignedExecutors = new HashSet<ExecutorDetails>( _cluster.getUnassignedExecutors(td)); Map<WorkerSlot, Collection<ExecutorDetails>> schedulerAssignmentMap = new HashMap<>(); LOG.debug("ExecutorsNeedScheduling: {}", unassignedExecutors); Collection<ExecutorDetails> scheduledTasks = new ArrayList<>(); List<Component> spouts = this.getSpouts(td); if (spouts.size() == 0) { LOG.error("Cannot find a Spout!"); return SchedulingResult.failure(SchedulingStatus.FAIL_INVALID_TOPOLOGY, "Cannot find a Spout!"); } //order executors to be scheduled List<ExecutorDetails> orderedExecutors = orderExecutors(td, unassignedExecutors); Collection<ExecutorDetails> executorsNotScheduled = new HashSet<>(unassignedExecutors); for (ExecutorDetails exec : orderedExecutors) { LOG.debug("\n\nAttempting to schedule: {} of component {}[ REQ {} ]", exec, td.getExecutorToComponent().get(exec), td.getTaskResourceReqList(exec)); scheduleExecutor(exec, td, schedulerAssignmentMap, scheduledTasks); } executorsNotScheduled.removeAll(scheduledTasks); LOG.debug("/* Scheduling left over task (most likely sys tasks) */"); // schedule left over system tasks for (ExecutorDetails exec : executorsNotScheduled) { scheduleExecutor(exec, td, schedulerAssignmentMap, scheduledTasks); } SchedulingResult result; executorsNotScheduled.removeAll(scheduledTasks); if (executorsNotScheduled.size() > 0) { LOG.error("Not all executors successfully scheduled: {}", executorsNotScheduled); schedulerAssignmentMap = null; result = SchedulingResult.failure(SchedulingStatus.FAIL_NOT_ENOUGH_RESOURCES, (td.getExecutors().size() - unassignedExecutors.size()) + "/" + td.getExecutors().size() + " executors scheduled"); } else { LOG.debug("All resources successfully scheduled!"); result = SchedulingResult.successWithMsg(schedulerAssignmentMap, "Fully Scheduled by DefaultResourceAwareStrategy"); } if (schedulerAssignmentMap == null) { LOG.error("Topology {} not successfully scheduled!", td.getId()); } return result; }
From source file:org.topazproject.otm.ClassMetadata.java
/** * Gets a field mapper by its predicate uri. * * @param sf the session factory for looking up associations * @param uri the predicate uri/*from w ww .ja va2 s .co m*/ * @param inverse if the mapping is reverse (ie. o,p,s instead of s,p,o)) * @param typeUris Collection of rdf:Type values * * @return the mapper or null */ public RdfMapper getMapperByUri(SessionFactory sf, String uri, boolean inverse, Collection<String> typeUris) { List<RdfMapper> rdfMappers = uriMap.get(uri); if (rdfMappers == null) return null; Collection<String> uris = typeUris; RdfMapper candidate = null; for (RdfMapper m : rdfMappers) { if (m.hasInverseUri() != inverse) continue; if (candidate == null) candidate = m; if ((uris == null) || uris.isEmpty()) break; ClassMetadata assoc = !m.isAssociation() ? null : sf.getClassMetadata(m.getAssociatedEntity()); if ((assoc == null) || assoc.getTypes().isEmpty()) continue; if (uris.containsAll(assoc.getTypes())) { if (uris == typeUris) uris = new HashSet<String>(typeUris); // lazy copy uris.removeAll(assoc.getAllTypes()); candidate = m; } } return candidate; }
From source file:org.openmrs.api.impl.PatientSetServiceImpl.java
public Cohort getPatientsHavingDrugOrder(Collection<Integer> patientIds, Collection<Integer> drugIds, GroupMethod groupMethod, Date fromDate, Date toDate) { Map<Integer, Collection<Integer>> activeDrugs = getPatientSetDAO().getActiveDrugIds(patientIds, fromDate, toDate);//from ww w .j ava 2 s . c o m Set<Integer> ret = new HashSet<Integer>(); if (drugIds == null) { drugIds = new ArrayList<Integer>(); } if (drugIds.size() == 0) { if (groupMethod == GroupMethod.NONE) { // Patients taking no drugs if (patientIds == null) { patientIds = getAllPatients().getMemberIds(); } patientIds.removeAll(activeDrugs.keySet()); ret.addAll(patientIds); } else { // Patients taking any drugs ret.addAll(activeDrugs.keySet()); } } else { if (groupMethod == GroupMethod.NONE) { // Patients taking none of the specified drugs // first get all patients taking no drugs at all ret.addAll(patientIds); ret.removeAll(activeDrugs.keySet()); // next get all patients taking drugs, but not the specified ones for (Map.Entry<Integer, Collection<Integer>> e : activeDrugs.entrySet()) { if (!OpenmrsUtil.containsAny(e.getValue(), drugIds)) { ret.add(e.getKey()); } } } else if (groupMethod == GroupMethod.ALL) { // Patients taking all of the specified drugs for (Map.Entry<Integer, Collection<Integer>> e : activeDrugs.entrySet()) { if (e.getValue().containsAll(drugIds)) { ret.add(e.getKey()); } } } else { // groupMethod == GroupMethod.ANY // Patients taking any of the specified drugs for (Map.Entry<Integer, Collection<Integer>> e : activeDrugs.entrySet()) { if (OpenmrsUtil.containsAny(e.getValue(), drugIds)) { ret.add(e.getKey()); } } } } Cohort ps = new Cohort("Cohort from drug orders", "", ret); return ps; }