List of usage examples for org.apache.commons.collections CollectionUtils select
public static Collection select(Collection inputCollection, Predicate predicate)
From source file:org.apache.james.mailet.AbstractMailetdocsReport.java
private void writeDescriptions() { final List<MailetMatcherDescriptor> descriptors = buildSortedDescriptors(); @SuppressWarnings("unchecked") final List<MailetMatcherDescriptor> matchers = (List<MailetMatcherDescriptor>) CollectionUtils .select(descriptors, new TypePredicate(MailetMatcherDescriptor.Type.MATCHER)); @SuppressWarnings("unchecked") final List<MailetMatcherDescriptor> mailets = (List<MailetMatcherDescriptor>) CollectionUtils .select(descriptors, new TypePredicate(MailetMatcherDescriptor.Type.MAILET)); final boolean matchersExist = matchers.size() > 0; final boolean mailetsExist = mailets.size() > 0; if (matchersExist && mailetsExist) { getSink().table();/*from w w w .ja v a 2 s.c o m*/ getSink().tableRow(); getSink().tableCell(); } if (matchersExist) { outputDescriptorIndex(matchers, "Matchers"); } if (matchersExist && mailetsExist) { getSink().tableCell_(); getSink().tableCell(); } if (mailetsExist) { outputDescriptorIndex(mailets, "Mailets"); } if (matchersExist && mailetsExist) { getSink().tableCell_(); getSink().tableRow_(); getSink().table_(); } if (matchersExist) { outputDescriptorList(matchers, "Matchers"); } if (mailetsExist) { outputDescriptorList(mailets, "Mailets"); } }
From source file:org.beanfuse.security.restriction.service.RestrictionServiceImpl.java
/** * ????/*from w ww . ja va2 s .c o m*/ */ public List getRestrictions(final User user, final Resource resource) { List restrictions = new ArrayList(); final Set paramGroups = new HashSet(); for (Iterator iterator = resource.getPatterns().iterator(); iterator.hasNext();) { Pattern pattern = (Pattern) iterator.next(); paramGroups.add(pattern.getParamGroup()); } // ??? restrictions.addAll(getAuthorityRestrictions(user, resource)); // ? for (Iterator iterator = user.getGroups().iterator(); iterator.hasNext();) { RestrictionHolder group = (RestrictionHolder) iterator.next(); restrictions.addAll(group.getRestrictions()); } // ? RestrictionHolder userHolder = (RestrictionHolder) user; restrictions.addAll(userHolder.getRestrictions()); // ? return (List) CollectionUtils.select(restrictions, new Predicate() { public boolean evaluate(Object obj) { Restriction restriciton = (Restriction) obj; if (restriciton.isEnabled() && paramGroups.contains(restriciton.getParamGroup())) return true; else return false; } }); }
From source file:org.beangle.ems.security.restrict.service.RestrictionServiceImpl.java
/** * ????//from w ww . j a v a 2s.com */ @SuppressWarnings("unchecked") public List<Restriction> getRestrictions(final User user, final Resource resource) { List<Restriction> restrictions = CollectUtils.newArrayList(); final Set<RestrictEntity> entities = CollectUtils.newHashSet(resource.getEntities()); // ??? restrictions.addAll(getAuthorityRestrictions(user, resource)); List<Group> groups = userService.getGroups(user, GroupMember.Ship.MEMBER); // ? for (Group group : authorityService.filter(groups, resource)) { restrictions.addAll(group.getRestrictions()); } // ? RestrictionHolder<?> userHolder = user; restrictions.addAll(userHolder.getRestrictions()); // return (List<Restriction>) CollectionUtils.select(restrictions, new Predicate() { public boolean evaluate(Object obj) { Restriction restriciton = (Restriction) obj; if (restriciton.isEnabled() && entities.contains(restriciton.getPattern().getEntity())) return true; else return false; } }); }
From source file:org.beangle.ems.security.service.UserServiceImpl.java
public int updateState(final User manager, Long[] ids, final boolean enabled) { assert (null == ids || ids.length < 1); @SuppressWarnings("unchecked") List<User> users = (List<User>) CollectionUtils.select(getUsers(ids), new Predicate() { public boolean evaluate(Object object) { User one = (User) object;// ww w .j a v a 2s .c om return isManagedBy(manager, one) && !manager.equals(one) && (one.isEnabled() != enabled); } }); for (int i = 0; i < users.size(); i++) { User cur = users.get(i); cur.setEnabled(enabled); } if (!users.isEmpty()) { entityDao.saveOrUpdate(users); publish(new UserStatusEvent(users, enabled)); } return users.size(); }
From source file:org.beangle.emsapp.security.action.RestrictionAction.java
public String save() { Restriction restriction = getRestriction(); RestrictionHolder<Restriction> holder = new RestrictionHelper(entityDao).getHolder(); List<Restriction> myRestrictions = getMyRestrictions(restriction.getPattern(), holder); Set<RestrictField> ignoreFields = getIgnoreFields(myRestrictions); boolean isAdmin = isAdmin(); for (final RestrictField field : restriction.getPattern().getEntity().getFields()) { String[] values = (String[]) getAll(field.getName()); if ((ignoreFields.contains(field) || isAdmin) && getBool("ignoreField" + field.getId())) { restriction.setItem(field, "*"); } else {/*from www . ja va2 s. c o m*/ if (null == values || values.length == 0) { restriction.getItems().remove(field.getId()); } else { String storedValue = null; if (null != field.getKeyName()) { final Set<String> keys = CollectUtils.newHashSet(values); Collection<?> allValues = restrictionService.getFieldValues(field.getName()); allValues = CollectionUtils.select(allValues, new Predicate() { public boolean evaluate(Object arg0) { try { String keyValue = String .valueOf(PropertyUtils.getProperty(arg0, field.getKeyName())); return keys.contains(keyValue); } catch (Exception e) { e.printStackTrace(); } return false; } }); storedValue = idDataResolver.marshal(field, allValues); } else { storedValue = StrUtils.join(values); } restriction.setItem(field, storedValue); } } } if (restriction.getItems().isEmpty()) { holder.getRestrictions().remove(restriction); if (restriction.isPersisted()) entityDao.remove(restriction); entityDao.saveOrUpdate(holder); return redirect("info", "info.save.success"); } else { if (!restriction.isPersisted()) { holder.getRestrictions().add(restriction); entityDao.saveOrUpdate(holder); } else { entityDao.saveOrUpdate((String) RestrictionHelper.restrictionTypeMap.get(get("restrictionType")), restriction); } return redirect("info", "info.save.success"); } }
From source file:org.broadleafcommerce.openadmin.web.form.component.ListGrid.java
/** * Grabs a filtered list of toolbar actions filtered by whether or not they match the same readonly state as the listgrid * and are thus shown on the screen//from ww w.j a v a 2s. c om */ @SuppressWarnings("unchecked") public List<ListGridAction> getActiveToolbarActions() { return (List<ListGridAction>) CollectionUtils.select(getToolbarActions(), new TypedPredicate<ListGridAction>() { @Override public boolean eval(ListGridAction action) { return action.getForListGridReadOnly().equals(getReadOnly()); } }); }
From source file:org.broadleafcommerce.openadmin.web.form.component.ListGrid.java
/** * Grabs a filtered list of row actions filtered by whether or not they match the same readonly state as the listgrid * and are thus shown on the screen//from w w w .j a va 2s. c o m */ @SuppressWarnings("unchecked") public List<ListGridAction> getActiveRowActions() { return (List<ListGridAction>) CollectionUtils.select(getRowActions(), new TypedPredicate<ListGridAction>() { @Override public boolean eval(ListGridAction action) { return action.getForListGridReadOnly().equals(getReadOnly()); } }); }
From source file:org.broadleafcommerce.openadmin.web.form.component.ListGridActionGroup.java
/** * Grabs a filtered list of actions filtered by whether or not they match the same readonly state as the listgrid * and are thus shown on the screen/*from w ww .java 2s . c o m*/ */ @SuppressWarnings("unchecked") public List<ListGridAction> getActiveActions(final boolean listGridIsReadOnly) { return (List<ListGridAction>) CollectionUtils.select(getListGridActions(), new TypedPredicate<ListGridAction>() { @Override public boolean eval(ListGridAction action) { return action.getForListGridReadOnly().equals(listGridIsReadOnly); } }); }
From source file:org.citydb.plugins.CityGMLConverter.xlink.resolver.DBXlinkSplitter.java
private SurfaceObject CompareGeom(String GmlID) { final String id = GmlID; Predicate predicate = new Predicate() { public boolean evaluate(Object object) { if (((SurfaceObject) object).getPId() != null && ((SurfaceObject) object).getPId().equals(id)) return true; else/*from w ww.ja va 2 s . com*/ return ((SurfaceObject) object).getId().equals(id); } }; Collection<SurfaceObject> filtered = CollectionUtils.select(list, predicate); return (filtered.size() > 0) ? new ArrayList<SurfaceObject>(filtered).get(0) : null; }
From source file:org.dentaku.gentaku.cartridge.entity.hibernate.HibernateEntityGenerator.java
protected Collection setupClasses(CorePackage core, Stereotype classifierStereotype, UmlPackage entityPackage, ClassifierImpl odspEntity, org.omg.uml.UmlPackage umlPackage) throws GenerationException { Collection extendedElements = new LinkedList( core.getAStereotypeExtendedElement().getExtendedElement(classifierStereotype)); // pass 1: set up the classes and do the fields while we are here for (Iterator elemIterator = extendedElements.iterator(); elemIterator.hasNext();) { ModelElementImpl modelElement = (ModelElementImpl) elemIterator.next(); if (!(modelElement instanceof UmlClass)) { throw new GenerationException( "modelElement must be a UmlClass (is a " + modelElement.getClass().getName() + ")"); }/* ww w . j a v a 2 s. co m*/ ClassifierImpl classifier = (ClassifierImpl) modelElement; Utils.createTaggedValue(core, classifier, findTagdef(entityPackage.getOwnedElement(), "inheritance.strategy"), "new-table"); Utils.createTaggedValue(core, classifier, findTagdef(entityPackage.getOwnedElement(), "discriminator.strategy"), "class-name"); Utils.createTaggedValue(core, classifier, findTagdef(entityPackage.getOwnedElement(), "column.name"), "java_type"); createGeneralization(core, odspEntity, classifier); // update our superclass structure to accurately reflect what we are generating String entityName = classifier.getName(); classifier.setName(entityName + "Base"); ClassifierImpl subclass = (ClassifierImpl) Utils.findUmlClass(umlPackage, ((ModelElementImpl) classifier.getNamespace()).getFullyQualifiedName(), entityName, true); subclass.getStereotype().add(classifierStereotype); Utils.createTaggedValue(core, subclass, findTagdef(entityPackage.getOwnedElement(), "class.name"), "${parent.name}"); Utils.createTaggedValue(core, subclass, findTagdef(entityPackage.getOwnedElement(), "class.persistence-capable-superclass"), ((ModelElementImpl) classifier).getFullyQualifiedName()); Utils.createTaggedValue(core, subclass, "gentaku.generate", "false"); Utils.createTaggedValue(core, subclass, findTagdef(entityPackage.getOwnedElement(), "inheritance.strategy"), "superclass-table"); // handle the fields Collection attributes = CollectionUtils.select(classifier.getFeature(), new InstanceofPredicate(Attribute.class)); for (Iterator attIterator = attributes.iterator(); attIterator.hasNext();) { Attribute attribute = (Attribute) attIterator.next(); TaggedValue taggedValue = Utils.createTaggedValue(core, attribute, findTagdef(entityPackage.getOwnedElement(), "field.name"), "${parent.name}"); attribute.getTaggedValue().add(taggedValue); } // move the relations down to the subclass Collection links = new LinkedList(classifier.getAssociationLinks()); for (Iterator moveIterator = links.iterator(); moveIterator.hasNext();) { AssociationEnd associationEnd = (AssociationEnd) moveIterator.next(); associationEnd.setParticipant(subclass); } } return extendedElements; }