List of usage examples for org.apache.commons.collections CollectionUtils subtract
public static Collection subtract(final Collection a, final Collection b)
From source file:net.sourceforge.fenixedu.applicationTier.Servico.administrativeOffice.gradeSubmission.EditMarkSheet.java
private static void editNormalMarkSheet(MarkSheetManagementEditBean markSheetManagementEditBean) { Collection<MarkSheetEnrolmentEvaluationBean> filteredEnrolmentEvaluationBeansToEditList = getEnrolmentEvaluationsWithValidGrades( markSheetManagementEditBean.getEnrolmentEvaluationBeansToEdit()); Collection<MarkSheetEnrolmentEvaluationBean> enrolmentEvaluationBeansToAppendList = getEnrolmentEvaluationsWithValidGrades( markSheetManagementEditBean.getEnrolmentEvaluationBeansToAppend()); Collection<MarkSheetEnrolmentEvaluationBean> enrolmentEvaluationBeansToRemoveList = CollectionUtils .subtract(markSheetManagementEditBean.getEnrolmentEvaluationBeansToEdit(), filteredEnrolmentEvaluationBeansToEditList); markSheetManagementEditBean.getMarkSheet().editNormal(filteredEnrolmentEvaluationBeansToEditList, enrolmentEvaluationBeansToAppendList, enrolmentEvaluationBeansToRemoveList); }
From source file:io.seldon.resources.external.NewResourceNotifier.java
private GlobalConfigUpdateListener createAllClientListeners(final String nodePattern, final PerClientExternalLocationListener listener) { return new GlobalConfigUpdateListener() { @Override/*from w ww. j av a 2s.c o m*/ public void configUpdated(String configKey, String configValue) { if (configValue == null) return; String[] clients = configValue.split(","); Set<String> watchingClients = nodeWatches.get(nodePattern).keySet(); Set<String> clientsSet = new HashSet<>(Arrays.asList(clients)); Collection<String> toRemove = CollectionUtils.subtract(watchingClients, clientsSet); Collection<String> toAdd = CollectionUtils.subtract(clientsSet, watchingClients); for (String toRemoveString : toRemove) { logger.info("Remove subscription for client " + toRemoveString + " nodePattern " + nodePattern); nodeWatches.get(nodePattern).remove(toRemoveString); listener.clientLocationDeleted(toRemoveString, nodePattern); } for (final String client : toAdd) { nodeWatches.get(nodePattern).put(client, listener); if (StringUtils.isNotEmpty(client)) { try { logger.info("Add subscription for client " + client + " nodePattern " + nodePattern); for (Map.Entry<String, String> entry : clientConfigHandler.requestCacheDump(client) .entrySet()) { if (entry.getKey().equals(nodePattern)) NewResourceNotifier.this.configUpdated(client, entry.getKey(), entry.getValue()); } } catch (Exception e) { logger.error("Problem when notifying about new resource location ", e); } } } } }; }
From source file:edu.northwestern.bioinformatics.studycalendar.web.AssignSiteController.java
@Override protected Map<String, Object> referenceData(HttpServletRequest httpServletRequest) throws Exception { Map<String, Object> refdata = new HashMap<String, Object>(); Study study = studyDao.getById(ServletRequestUtils.getRequiredIntParameter(httpServletRequest, "id")); List<Site> assigned = studySiteService.refreshAssociatedSites(study); refdata.put("study", study); refdata.put("assignedSites", assigned); refdata.put("availableSites", CollectionUtils.subtract(siteService.getAll(), assigned)); refdata.put("action", "Assign"); return refdata; }
From source file:acromusashi.stream.component.rabbitmq.RabbitmqClusterContext.java
/** * RabbitMQ?RabbitMQ????????/*from w w w. j av a2s . co m*/ * * @param mqProcessList RabbitMQ * @param connectionProcessMap ?RabbitMQ? * @throws RabbitmqCommunicateException RabbitMQ?RabbitMQ??????? */ private void validateProcessReference(List<String> mqProcessList, Map<String, String> connectionProcessMap) throws RabbitmqCommunicateException { //RabbitMQ????? if (mqProcessList == null || mqProcessList.size() == 0) { String message = "ProcessList is not defined."; throw new RabbitmqCommunicateException(message); } // ?RabbitMQ????????? if (connectionProcessMap == null || connectionProcessMap.size() == 0) { return; } Set<String> processSet = new HashSet<String>(mqProcessList); Set<String> connectionProcessSet = new HashSet<String>(connectionProcessMap.values()); if (processSet.containsAll(connectionProcessSet) == false) { @SuppressWarnings("unchecked") Set<String> nonContainedProcessSet = new HashSet<String>( CollectionUtils.subtract(connectionProcessSet, processSet)); String messageFmt = "Connection process is illegal. NonContainedProcessSet={0}"; String message = MessageFormat.format(messageFmt, nonContainedProcessSet.toString()); throw new RabbitmqCommunicateException(message); } }
From source file:gov.nih.nci.caarray.web.action.project.AbstractProjectAssociatedAnnotationsListTabAction.java
/** * Gets the set of initialSavedAssociations. * @return the set of items.//w w w .j a v a2s.c o m */ @SuppressWarnings("unchecked") public Collection getInitialSavedAssociations() { return CollectionUtils.subtract(getCurrentAssociationsCollection(), getItemsToRemove()); }
From source file:com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper.java
/** {@inheritDoc} */ public Collection getAddedKeys() { Set preSelected = getPreSelected(); Collection result = CollectionUtils.subtract(set, preSelected); return result; }
From source file:info.magnolia.ui.api.app.registry.AppDescriptorRegistry.java
@SuppressWarnings("unchecked") @Override/*from ww w .jav a 2s. co m*/ public Set<DefinitionMetadata> unregisterAndRegister(Collection<DefinitionMetadata> metaDataToUnregister, Collection<DefinitionProvider<AppDescriptor>> providersToRegister) { Collection<DefinitionMetadata> metadataBefore = getRegistryMap().keySet(); Collection<DefinitionProvider<AppDescriptor>> providersBefore = getRegistryMap().values(); Set<DefinitionMetadata> registeredMetaData = super.unregisterAndRegister(metaDataToUnregister, providersToRegister); Collection<DefinitionMetadata> metadataAfter = getRegistryMap().keySet(); Collection<DefinitionMetadata> added = CollectionUtils.subtract(metadataAfter, metadataBefore); Collection<DefinitionMetadata> removed = CollectionUtils.subtract(metadataBefore, metadataAfter); Collection<DefinitionMetadata> kept = CollectionUtils.subtract(metadataBefore, removed); Collection<DefinitionMetadata> changed = getAppsThatHaveChanged(kept, providersBefore, providersToRegister); sendEvent(AppRegistryEventType.REGISTERED, added); sendEvent(AppRegistryEventType.UNREGISTERED, removed); sendEvent(AppRegistryEventType.REREGISTERED, changed); return registeredMetaData; }
From source file:isi.pasco2.poller.DifferenceHandler.java
public void endDocument() { if (!initialized) { // it is now initialized = true;//from w w w . j a v a 2 s. c o m } else { Collection<Record> deletedRecords = CollectionUtils.subtract(currentUrlRecords, newUrlRecords); Collection<Record> newRecords = CollectionUtils.subtract(newUrlRecords, currentUrlRecords); if (deletedRecords.size() > 0 || newRecords.size() > 0) { StringWriter outWriter = new StringWriter(); outWriter.write(name + "\r\n"); for (Record rec : newRecords) { Calendar c = Calendar.getInstance(); outWriter.write("New record: (" + xsdDateFormat.format(c.getTime()) + rec.toString() + "\r\n"); } for (Record rec : deletedRecords) { outWriter.write("Deleted record: " + rec.toString() + "\r\n"); } System.out.println(outWriter.toString()); } currentUrlRecords = newUrlRecords; newUrlRecords = new Vector<Record>(); } }
From source file:com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper.java
/** {@inheritDoc} */ public Collection getRemovedKeys() { Set preSelected = getPreSelected(); Collection result = CollectionUtils.subtract(preSelected, set); return result; }
From source file:com.redhat.rhn.frontend.taglibs.list.helper.ListRhnSetHelper.java
/** {@inheritDoc} */ public Collection getAddedKeys() { Set preSelectedValues = getPreSelected(); Set setValues = set.getElementValues(); Collection result = CollectionUtils.subtract(setValues, preSelectedValues); return result; }