List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:disAMS.AMRMClient.Impl.AMRMClientImpl.java
@Override public synchronized void updateBlacklist(List<String> blacklistAdditions, List<String> blacklistRemovals) { if (blacklistAdditions != null) { this.blacklistAdditions.addAll(blacklistAdditions); this.blacklistedNodes.addAll(blacklistAdditions); // if some resources are also in blacklistRemovals updated before, we // should remove them here. this.blacklistRemovals.removeAll(blacklistAdditions); }//w w w . j av a2 s . co m if (blacklistRemovals != null) { this.blacklistRemovals.addAll(blacklistRemovals); this.blacklistedNodes.removeAll(blacklistRemovals); // if some resources are in blacklistAdditions before, we should remove // them here. this.blacklistAdditions.removeAll(blacklistRemovals); } if (blacklistAdditions != null && blacklistRemovals != null && blacklistAdditions.removeAll(blacklistRemovals)) { // we allow resources to appear in addition list and removal list in the // same invocation of updateBlacklist(), but should get a warn here. LOG.warn("The same resources appear in both blacklistAdditions and " + "blacklistRemovals in updateBlacklist."); } }
From source file:io.fabric8.maven.core.service.ApplyService.java
/** * Removes all the tags with the given name * @return the number of tags removed//w w w.ja va 2 s .co m */ private int removeTagByName(List<TagReference> tags, String tagName) { List<TagReference> removeTags = new ArrayList<>(); for (TagReference tag : tags) { if (Objects.equals(tagName, tag.getName())) { removeTags.add(tag); } } tags.removeAll(removeTags); return removeTags.size(); }
From source file:fragment.web.ChannelControllerTest.java
@Test public void testEditChannelCurrencyPostNegative() { try {/*ww w . ja va 2 s . c om*/ Channel channel = channelDAO.find(4L); channelController.editChannelCurrency(channel.getId().toString(), map); List<CurrencyValue> availableCurrencies = (List<CurrencyValue>) map.get("availableCurrencies"); String activeCurrencyCode = availableCurrencies.get(0).getCurrencyCode(); List<CurrencyValue> activeCurrencyList = currencyService.listActiveCurrencies(); List<CurrencyValue> currencyList = currencyService.getCurrencyValues(); currencyList.removeAll(activeCurrencyList); String currencyCodeArray = "['" + currencyList.get(0).getCurrencyCode() + "','" + activeCurrencyCode + "']"; String status = channelController.editChannelCurrency(channel.getId().toString(), currencyCodeArray, map); Assert.assertEquals("success", status); Assert.assertFalse(channel.getCatalog().getSupportedCurrencyValuesByOrder() .contains(currencyValueService.locateBYCurrencyCode(currencyList.get(0).getCurrencyCode()))); Assert.assertTrue(channel.getCatalog().getSupportedCurrencyValuesByOrder() .contains(currencyValueService.locateBYCurrencyCode(activeCurrencyCode))); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
From source file:com.cloudbees.hudson.plugins.folder.AbstractFolder.java
/** * Removes any actions of the specified type. * Note: calls to {@link #getAllActions()} that happen before calls to this method may not see the update. * Note: this method does not affect transient actions contributed by a {@link TransientActionFactory} * * @param clazz the type of actions to remove * @return {@code true} if this actions changed as a result of the call * @since FIXME/*from w w w .j a va 2 s.c om*/ */ // TODO remove once baseline has JENKINS-39404 @SuppressWarnings({ "ConstantConditions", "deprecation" }) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public boolean removeActions(@Nonnull Class<? extends Action> clazz) { if (clazz == null) { throw new IllegalArgumentException("Action type must be non-null"); } // CopyOnWriteArrayList does not support Iterator.remove, so need to do it this way: List<Action> old = new ArrayList<Action>(); List<Action> current = super.getActions(); for (Action a : current) { if (clazz.isInstance(a)) { old.add(a); } } return current.removeAll(old); }
From source file:org.openmrs.module.auditlog.CollectionsAuditLogBehaviorTest.java
@Test @NotTransactional//w w w . ja v a 2 s . co m public void shouldCreateAnAuditLogForAParentWhenAnUnAuditedElementIsAddedToAChildCollection() throws Exception { assertFalse(auditLogService.isAudited(ConceptDescription.class)); Concept concept = conceptService.getConcept(5089); //something with ConceptMaps having blank uuids and now getting set, this should have been //fixed in later versions conceptService.saveConcept(concept); List<AuditLog> existingUpdateLogs = getAllLogs(concept.getId(), Concept.class, Collections.singletonList(UPDATED)); int originalCount = concept.getDescriptions().size(); assertTrue(originalCount == 1); Integer previousDescriptionId = concept.getDescription().getId(); ConceptDescription cd1 = new ConceptDescription("desc1", Locale.ENGLISH); cd1.setDateCreated(new Date()); cd1.setCreator(Context.getAuthenticatedUser()); concept.addDescription(cd1); conceptService.saveConcept(concept); List<AuditLog> conceptLogs = getAllLogs(concept.getId(), Concept.class, Collections.singletonList(UPDATED)); assertEquals(existingUpdateLogs.size() + 1, conceptLogs.size()); conceptLogs.removeAll(existingUpdateLogs); assertEquals(1, conceptLogs.size()); AuditLog al = conceptLogs.get(0); assertEquals(AuditLogUtil.getNewValueOfUpdatedItem("descriptions", al), "[\"" + previousDescriptionId + "\"" + AuditLogConstants.SEPARATOR + "\"" + cd1.getId() + "\"]"); assertEquals(AuditLogUtil.getPreviousValueOfUpdatedItem("descriptions", al), "[\"" + previousDescriptionId + "\"]"); List<AuditLog> descriptionLogs = getAllLogs(cd1.getId(), ConceptDescription.class, Collections.singletonList(CREATED)); assertEquals(1, descriptionLogs.size()); assertEquals(al, descriptionLogs.get(0).getParentAuditLog()); }
From source file:org.openmrs.module.auditlog.CollectionsAuditLogBehaviorTest.java
@Test @NotTransactional/*from w w w .j av a 2 s . c om*/ public void shouldCreateAnAuditLogForAParentWhenAnAuditedElementIsAddedToAChildCollection() throws Exception { Concept concept = conceptService.getConcept(5089); //something with ConceptMaps having blank uuids and now getting set, this should have been //fixed in later versions conceptService.saveConcept(concept); List<AuditLog> existingUpdateLogs = getAllLogs(concept.getId(), Concept.class, Collections.singletonList(UPDATED)); int originalCount = concept.getDescriptions().size(); assertTrue(originalCount == 1); Integer previousDescriptionId = concept.getDescription().getId(); startAuditing(ConceptDescription.class); assertTrue(auditLogService.isAudited(ConceptDescription.class)); ConceptDescription cd1 = new ConceptDescription("desc1", Locale.ENGLISH); cd1.setDateCreated(new Date()); cd1.setCreator(Context.getAuthenticatedUser()); concept.addDescription(cd1); conceptService.saveConcept(concept); List<AuditLog> conceptLogs = getAllLogs(concept.getId(), Concept.class, Collections.singletonList(UPDATED)); assertEquals(existingUpdateLogs.size() + 1, conceptLogs.size()); conceptLogs.removeAll(existingUpdateLogs); assertEquals(1, conceptLogs.size()); AuditLog al = conceptLogs.get(0); assertEquals(AuditLogUtil.getNewValueOfUpdatedItem("descriptions", al), "[\"" + previousDescriptionId + "\"" + AuditLogConstants.SEPARATOR + "\"" + cd1.getId() + "\"]"); assertEquals(AuditLogUtil.getPreviousValueOfUpdatedItem("descriptions", al), "[\"" + previousDescriptionId + "\"]"); List<AuditLog> descriptionLogs = getAllLogs(cd1.getId(), ConceptDescription.class, Collections.singletonList(CREATED)); assertEquals(1, descriptionLogs.size()); assertEquals(al, descriptionLogs.get(0).getParentAuditLog()); }
From source file:com.enonic.cms.web.portal.services.UserServicesProcessor.java
protected void handlerJoinGroup(HttpServletRequest request, HttpServletResponse response, ExtendedMap formItems) throws VerticalUserServicesException, RemoteException { UserEntity user = securityService.getLoggedInPortalUserAsEntity(); if (user == null) { String message = "User must be logged in."; VerticalUserServicesLogger.warn(message); redirectToErrorPage(request, response, formItems, ERR_USER_NOT_LOGGED_IN); return;/*www. j av a 2s . c o m*/ } String[] requiredParameters = new String[] { "key" }; List<String> missingParameters = findMissingRequiredParameters(requiredParameters, formItems, true); if (!missingParameters.isEmpty()) { String message = createMissingParametersMessage("Join group", missingParameters); VerticalUserServicesLogger.warn(message); redirectToErrorPage(request, response, formItems, ERR_PARAMETERS_MISSING); return; } List<GroupKey> groupKeysToAdd = getSubmittedGroupKeys(formItems, "key"); List<GroupKey> existingKeysForUser = getExistingDirectMembershipsForUser(user); groupKeysToAdd.removeAll(existingKeysForUser); if (groupKeysToAdd.size() >= 1) { GroupSpecification userGroupForLoggedInUser = new GroupSpecification(); userGroupForLoggedInUser.setKey(user.getUserGroupKey()); AddMembershipsCommand addMembershipCommand = new AddMembershipsCommand(userGroupForLoggedInUser, user.getKey()); addMembershipCommand.setUpdateOpenGroupsOnly(true); addMembershipCommand.setRespondWithException(true); for (GroupKey groupKeyToAdd : groupKeysToAdd) { addMembershipCommand.addGroupToAddTo(groupKeyToAdd); } try { userStoreService.addMembershipsToGroup(addMembershipCommand); updateUserInSession(ServletRequestAccessor.getSession()); } catch (UserStoreAccessException e) { String message = "Not allowed to add user to group: %t"; VerticalUserServicesLogger.warn(message, e); redirectToErrorPage(request, response, formItems, ERR_JOIN_GROUP_NOT_ALLOWED); return; } catch (RuntimeException e) { String message = "Failed to add user to group: %t"; VerticalUserServicesLogger.warn(message, e); redirectToErrorPage(request, response, formItems, ERR_JOIN_GROUP_FAILED); return; } } redirectToPage(request, response, formItems); }
From source file:com.ah.ui.actions.admin.UsersAction.java
public void initLocalUserGroups() throws Exception { List<CheckItem> availableList = getBoCheckItems("groupName", LocalUserGroup.class, new FilterParams("userType", LocalUserGroup.USERGROUP_USERTYPE_AUTOPSK)); Collection<CheckItem> removeList = new Vector<CheckItem>(); for (CheckItem obj : availableList) { for (LocalUserGroup userGroup : getDataSource().getLocalUserGroups()) { if (userGroup.getId().longValue() == obj.getId()) { removeList.add(obj);/*w ww .j ava 2 s. c o m*/ } } } availableList.removeAll(removeList); String leftTitle = isEasyMode() ? "admin.user.avaliable.ssidProfile" : "admin.user.avaliable.pskUserGroup"; String rightTitle = isEasyMode() ? "admin.user.selected.ssidProfile" : "admin.user.selected.pskUserGroup"; localUserGroupOptions = new OptionsTransfer(MgrUtil.getUserMessage(leftTitle), MgrUtil.getUserMessage(rightTitle), availableList, getDataSource().getLocalUserGroups(), "id", "value", "localUserGroups", 8, "200px", "8", true); }
From source file:fr.paris.lutece.plugins.directory.modules.pdfproducer.web.PDFProducerJspBean.java
/** * This method delete an id group entry if it have no child in config list * @param listIdEntry list of id entry//from w w w . ja v a 2s .c o m */ private void checkEntryGroup(List<Integer> listIdEntry) { List<Integer> listIdEntryToDelete = new ArrayList<Integer>(); boolean bNoChildEntryGroup = false; for (Integer idEntry : listIdEntry) { IEntry entry = EntryHome.findByPrimaryKey(idEntry.intValue(), getPlugin()); if (entry.getEntryType().getGroup() && (entry.getChildren() != null)) { for (IEntry child : entry.getChildren()) { if (listIdEntry.contains(child.getIdEntry())) { bNoChildEntryGroup = true; } } if (!bNoChildEntryGroup) { listIdEntryToDelete.add(idEntry); } } bNoChildEntryGroup = false; } if (!listIdEntryToDelete.isEmpty()) { listIdEntry.removeAll(listIdEntryToDelete); } }
From source file:com.inkubator.hrm.web.flow.JobJabatanFormController.java
public void doResetJobJabatanProfesiForm(RequestContext context) { JobJabatanModel jobJabatanModel = (JobJabatanModel) context.getFlowScope().get("jobJabatanModel"); try {// ww w . j a va 2 s . c o m if (jobJabatanModel.getId() == null) { List<OccupationType> listSourceOccupationType = occupationTypeService.getAllData(); dualListModelOccupationType.setSource(listSourceOccupationType); dualListModelOccupationType.setTarget(new ArrayList<OccupationType>()); } else { List<OccupationType> listSourceEducationLevel = occupationTypeService.getAllData(); List<JabatanProfesi> listTargetJabatanProfesi = jabatanProfesiService .getAllDataByJabatanId(jobJabatanModel.getId()); List<OccupationType> listTargetOccupationType = Lambda.extract(listTargetJabatanProfesi, Lambda.on(JabatanProfesi.class).getOccupationType()); listSourceEducationLevel.removeAll(listTargetOccupationType); dualListModelOccupationType = new DualListModel<OccupationType>(listSourceEducationLevel, listTargetOccupationType); } } catch (Exception e) { e.printStackTrace(); } jobJabatanModel.setListOccupationType(new ArrayList<OccupationType>()); context.getFlowScope().put("jobJabatanModel", jobJabatanModel); }