List of usage examples for org.apache.commons.collections CollectionUtils filter
public static void filter(Collection collection, Predicate predicate)
From source file:org.jumpmind.db.platform.AbstractDdlBuilder.java
/** * Calls the given closure for all changes that are of one of the given * types, and then removes them from the changes collection. * * @param changes/* w w w . j a va 2 s . c o m*/ * The changes * @param changeTypes * The types to search for * @param closure * The closure to invoke */ protected void applyForSelectedChanges(Collection<IModelChange> changes, Class<?>[] changeTypes, final Closure closure) { final Predicate predicate = new MultiInstanceofPredicate(changeTypes); // basically we filter the changes for all objects where the above // predicate returns true, and for these filtered objects we invoke the // given closure CollectionUtils.filter(changes, new Predicate() { public boolean evaluate(Object obj) { if (predicate.evaluate(obj)) { closure.execute(obj); return false; } else { return true; } } }); }
From source file:org.kalypso.ogc.gml.outline.nodes.FeatureThemeNode.java
@Override protected Object[] getElementChildren() { final IKalypsoStyle[] styles = getElement().getStyles(); final Predicate noSelectionStyles = new Predicate() { @Override/* w ww . j av a 2 s . co m*/ public boolean evaluate(final Object object) { final IKalypsoStyle style = (IKalypsoStyle) object; return !style.isUsedForSelection(); } }; final List<IKalypsoStyle> filteredList = new ArrayList<>(Arrays.asList(styles)); CollectionUtils.filter(filteredList, noSelectionStyles); return filteredList.toArray(new IKalypsoStyle[filteredList.size()]); }
From source file:org.kuali.rice.core.web.parameter.ParameterLookupableHelperServiceImpl.java
@Override public List<? extends BusinessObject> getSearchResults(java.util.Map<String, String> fieldValues) { List<? extends BusinessObject> results; // get the DD detail types List<Component> ddDetailTypes = KRADServiceLocatorWeb.getRiceApplicationConfigurationMediationService() .getNonDatabaseComponents(); if (fieldValues.containsKey(COMPONENT_NAME) && !StringUtils.isBlank(fieldValues.get(COMPONENT_NAME))) { final Set<ComponentBo> matchingDetailTypes = new HashSet<ComponentBo>(); // perform a basic database lookup for detail types codes String namespaceCode = fieldValues.get(NAMESPACE_CODE); String parameterDetailTypeName = fieldValues.get(COMPONENT_NAME); List<ComponentBo> dbDetailTypes = (List<ComponentBo>) getBusinessObjectService() .findAll(ComponentBo.class); List<ComponentBo> allDetailTypes = new ArrayList<ComponentBo>( ddDetailTypes.size() + dbDetailTypes.size()); allDetailTypes.addAll(dbDetailTypes); for (Component fromDD : ddDetailTypes) { allDetailTypes.add(ComponentBo.from(fromDD)); }//from w w w . j av a2 s .c o m // add some error logging if there are duplicates reportDuplicateDetailTypes(allDetailTypes); // filter all detail types by their name Pattern nameRegex = getParameterDetailTypeNameRegex(parameterDetailTypeName); for (ComponentBo detailType : allDetailTypes) { if (StringUtils.isBlank(namespaceCode) || detailType.getNamespaceCode().equals(namespaceCode)) { if (nameRegex == null || (detailType.getCode() != null && nameRegex.matcher(detailType.getCode().toUpperCase()).matches())) { matchingDetailTypes.add(detailType); } } } // we're filtering in memory, so remove this criteria fieldValues.remove(COMPONENT_NAME); results = super.getSearchResultsUnbounded(fieldValues); // attach the DD detail types to your results before we filter (else filtering won't work correctly) attachDataDictionaryDetailTypes(results, ddDetailTypes); // filter down to just results with matching parameter component (ParameterDetailType) CollectionUtils.filter(results, new Predicate() { public boolean evaluate(Object object) { return matchingDetailTypes.contains(((ParameterBo) object).getComponentCode()); } }); } else { results = super.getSearchResultsUnbounded(fieldValues); attachDataDictionaryDetailTypes(results, ddDetailTypes); } return results; }
From source file:org.kuali.rice.kew.actionrequest.service.impl.NotificationSuppression.java
/** * This method filters any ActionItems whose related ActionRequestValueS have been flagged for notification * suppression./*from ww w .j a va2s .c om*/ * * @param actionItems the ActionItemS to filter * @param routeNodeInstance the RouteNodeInstance that the actionItems are associated with */ protected void filterNotificationSuppressedActionItems(List<ActionItem> actionItems, final RouteNodeInstance routeNodeInstance) { // remove all actionItems from the collection whose request has a suppress notification node state element CollectionUtils.filter(actionItems, new Predicate() { public boolean evaluate(Object object) { boolean result = true; ActionItem actionItem = (ActionItem) object; ActionRequestValue actionRequest = KEWServiceLocator.getActionRequestService() .findByActionRequestId(actionItem.getActionRequestId()); List<String> suppressNotificationKeys = getSuppressNotifyNodeStateKeys(actionRequest); if (suppressNotificationKeys != null && suppressNotificationKeys.size() > 0) { // if any of the keys are not present, we need to notify boolean containsAll = true; for (String key : suppressNotificationKeys) { if (routeNodeInstance.getNodeState(key) == null) { containsAll = false; break; } } // actionItem will be filtered if this Predicate returns false result = !containsAll; // only filters if all keys are present } return result; } }); }
From source file:org.kuali.rice.kim.lookup.RoleMemberLookupableHelperServiceImpl.java
@SuppressWarnings("unchecked") protected List<RoleBo> searchRoles(Map<String, String> roleSearchCriteria, boolean unbounded) { List<RoleBo> roles = (List<RoleBo>) getLookupService().findCollectionBySearchHelper(RoleBo.class, roleSearchCriteria, unbounded); String membersCrt = roleSearchCriteria.get("members.memberId"); List<RoleBo> roles2Remove = new ArrayList<RoleBo>(); if (StringUtils.isNotBlank(membersCrt)) { List<String> memberSearchIds = new ArrayList<String>(); List<String> memberIds = new ArrayList<String>(); if (membersCrt.contains(KimConstants.KimUIConstants.OR_OPERATOR)) { memberSearchIds = new ArrayList<String>(Arrays.asList(membersCrt.split("\\|"))); } else {/* ww w . j av a 2s. c om*/ memberSearchIds.add(membersCrt); } for (RoleBo roleBo : roles) { List<RoleMemberBo> roleMembers = roleBo.getMembers(); memberIds.clear(); CollectionUtils.filter(roleMembers, new Predicate() { public boolean evaluate(Object object) { RoleMemberBo member = (RoleMemberBo) object; // keep active member return member.isActive(new Timestamp(System.currentTimeMillis())); } }); if (roleMembers != null && !roleMembers.isEmpty()) { for (RoleMemberBo memberImpl : roleMembers) { memberIds.add(memberImpl.getMemberId()); } if (((List<String>) CollectionUtils.intersection(memberSearchIds, memberIds)).isEmpty()) { roles2Remove.add(roleBo); } } else { roles2Remove.add(roleBo); } } } if (!roles2Remove.isEmpty()) { roles.removeAll(roles2Remove); } return roles; }
From source file:org.kuali.student.cm.course.service.impl.CourseMaintainableImpl.java
/** * This method filters out all the fake elements added to the collection when building * * @param collection//w ww . j a va 2s . co m */ protected void filterFakeCollectionElements(List<? extends CourseCompareCollectionElement> collection) { CollectionUtils.filter(collection, new Predicate() { public boolean evaluate(Object input) { return !((CourseCompareCollectionElement) input).isFakeObjectForCompare(); } }); }
From source file:org.linagora.linshare.webservice.impl.PluginCompatibilityRestServiceImpl.java
@POST @Path("/share/multiplesharedocuments") @Override/* w ww. ja va 2 s .c o m*/ public void multiplesharedocuments(@FormParam("targetMail") String targetMail, @FormParam("file") List<String> uuid, @FormParam("securedShare") @DefaultValue("0") int securedShare, @FormParam("message") @DefaultValue("") String message, @FormParam("inReplyTo") @DefaultValue("") String inReplyTo, @FormParam("references") @DefaultValue("") String references) throws BusinessException { User actor; actor = webServiceShareFacade.checkAuthentication(); if ((actor instanceof Guest && !actor.getCanUpload())) throw giveRestException(HttpStatus.SC_FORBIDDEN, "You are not authorized to use this service"); CollectionUtils.filter(uuid, StringPredicates.isNotBlank()); if (uuid.isEmpty()) throw giveRestException(HttpStatus.SC_BAD_REQUEST, "Missing parameter file"); webServiceShareFacade.multiplesharedocuments(targetMail, uuid, securedShare, message, inReplyTo, references); }
From source file:org.linagora.linshare.webservice.legacy.impl.PluginCompatibilityRestServiceImpl.java
@POST @Path("/share/multiplesharedocuments") @Override//from w ww. j a v a2 s . c o m public void multiplesharedocuments(@FormParam("targetMail") String targetMail, @FormParam("file") List<String> uuid, @FormParam("securedShare") @DefaultValue("0") int securedShare, @FormParam("message") @DefaultValue("") String message, @FormParam("inReplyTo") @DefaultValue("") String inReplyTo, @FormParam("references") @DefaultValue("") String references) throws BusinessException { CollectionUtils.filter(uuid, StringPredicates.isNotBlank()); if (uuid.isEmpty()) throw giveRestException(HttpStatus.SC_BAD_REQUEST, "Missing parameter file"); webServiceShareFacade.multiplesharedocuments(targetMail, uuid, securedShare, message, inReplyTo, references); }
From source file:org.medici.bia.common.access.ApplicationAccessContainer.java
private List<String> getCommunityJoined(boolean isAnonymous) { Collection<AccessDetail> joinedAccessDetails = getAllJoined(isAnonymous); CollectionUtils.filter(joinedAccessDetails, new Predicate() { @Override/*ww w .j a va 2s.c o m*/ public boolean evaluate(Object object) { AccessDetail detail = (AccessDetail) object; return detail.isCommunityOnline(); } }); return getJoinedIds(joinedAccessDetails, isAnonymous); }
From source file:org.medici.bia.common.access.ApplicationAccessContainer.java
private List<String> getJoined(boolean isAnonymous) { Collection<AccessDetail> joinedAccessDetails = getAllJoined(isAnonymous); CollectionUtils.filter(joinedAccessDetails, new Predicate() { @Override/*from w ww . ja v a 2 s . com*/ public boolean evaluate(Object object) { AccessDetail detail = (AccessDetail) object; return detail.isOnline(); } }); return getJoinedIds(joinedAccessDetails, isAnonymous); }