List of usage examples for org.apache.commons.collections CollectionUtils collect
public static Collection collect(Iterator inputIterator, final Transformer transformer, final Collection outputCollection)
From source file:org.kuali.mobility.people.service.DirectoryServiceImpl.java
/** * Searches for a person//from w ww . j a v a2s . co m */ @POST @Path("/person/search") public List<PersonImpl> personSearch(@FormParam("searchText") final String searchText, @FormParam("firstName") final String firstName, @FormParam("lastName") final String lastName, @FormParam("username") final String username, @FormParam("exactness") final String exactness, @FormParam("status") final String status, @FormParam("location") final String location) { List<PersonImpl> people = new ArrayList<PersonImpl>(); SearchCriteria searchCriteria = new SearchCriteria(); searchCriteria = new SearchCriteria(); searchCriteria.setExactness(exactness); searchCriteria.setFirstName(firstName); searchCriteria.setLastName(lastName); searchCriteria.setLocation(location); searchCriteria.setSearchText(searchText); searchCriteria.setStatus(status); searchCriteria.setUserName(username); CollectionUtils.collect((getDirectoryDao().findEntries(searchCriteria)).getPeople(), getPersonTransform(), people); return people; }
From source file:org.kuali.mobility.people.service.DirectoryServiceImpl.java
/** * Searches for groups//from www.jav a2 s. c o m */ @GET @Path("/group/search") @Override public List<GroupImpl> findSimpleGroup(@QueryParam("searchTerms") final String groupId) { List<GroupImpl> groups = new ArrayList<GroupImpl>(); CollectionUtils.collect(directoryDao.findSimpleGroup(groupId), getGroupTransform(), groups); return groups; }
From source file:org.openmrs.module.distrotools.metadata.bundle.CoreConstructors.java
/** * Constructs a role/*from w ww . j a va 2 s .co m*/ * @param role the role * @param description the description * @param inherited the inherited roles * @param privileges the privileges * @return the transient object */ public static Role role(String role, String description, Set<String> inherited, Set<String> privileges) { Role obj = new Role(); obj.setRole(role); obj.setDescription(description); if (CollectionUtils.isNotEmpty(inherited)) { obj.setInheritedRoles((Set) CollectionUtils.collect(inherited, new Transformer() { @Override public Object transform(Object o) { return MetadataUtils.existing(Role.class, (String) o); } }, new HashSet())); } if (CollectionUtils.isNotEmpty(privileges)) { obj.setPrivileges((Set) CollectionUtils.collect(privileges, new Transformer() { @Override public Object transform(Object o) { return MetadataUtils.existing(Privilege.class, (String) o); } }, new HashSet())); } return obj; }
From source file:org.openmrs.module.metadatadeploy.bundle.CoreConstructors.java
/** * Constructs a role/*ww w . jav a 2s . c om*/ * @param role the role * @param description the description * @param inherited the inherited roles * @param privileges the privileges * @return the transient object */ public static Role role(String role, String description, Set<String> inherited, Set<String> privileges, String uuid) { Role obj = new Role(); obj.setRole(role); obj.setDescription(description); if (StringUtils.isNotBlank(uuid)) { obj.setUuid(uuid); } if (CollectionUtils.isNotEmpty(inherited)) { obj.setInheritedRoles((Set) CollectionUtils.collect(inherited, new Transformer() { @Override public Object transform(Object o) { return MetadataUtils.existing(Role.class, (String) o); } }, new HashSet())); } if (CollectionUtils.isNotEmpty(privileges)) { obj.setPrivileges((Set) CollectionUtils.collect(privileges, new Transformer() { @Override public Object transform(Object o) { return MetadataUtils.existing(Privilege.class, (String) o); } }, new HashSet())); } return obj; }
From source file:org.openmrs.module.metadatasharing.Package.java
/** * Imperfect check to see what modules are required for the items in this package (based on * looking for java package names like org.openmrs.module.XYZ). * /* ww w.j a v a2s . c om*/ * @param pack * @return the requiredModules[moduleId, version] * @should get modules ids and versions * @since 1.0 */ public Map<String, String> getRequiredModules() { Set<String> classNames = new HashSet<String>(); Transformer getClassnameTransform = new Transformer() { @Override public Object transform(Object item) { try { return ((Item) item).getClassname(); } catch (Exception ex) { throw new RuntimeException("Programming Error: expected ItemSummary or ImportedItem", ex); } } }; CollectionUtils.collect(items, getClassnameTransform, classNames); CollectionUtils.collect(relatedItems, getClassnameTransform, classNames); // org.openmrs.module.(group 1: moduleId)[.more.packages].(group 2: SimpleClassName) Pattern regex = Pattern.compile("org\\.openmrs\\.module\\.(\\w+)[\\.\\w+]*\\.(\\w+)"); Map<String, String> requiredModules = new HashMap<String, String>(); for (String cn : classNames) { Matcher m = regex.matcher(cn); if (m.matches()) { String moduleId = m.group(1); requiredModules.put(moduleId, modules.get(moduleId)); } } return requiredModules; }
From source file:org.s23m.cell.repository.RelationalDatabaseRepository.java
@SuppressWarnings("unchecked") private List<String> mergeUUIDMapsToList(final String uuid, final Map map1, final Map map2) { final List<String> uuidLst = new ArrayList<String>(); if (map2 != null) { for (final Object k : map2.keySet()) { map1.put(k, k);/*from w w w . j a v a 2 s . c o m*/ } } map1.remove(uuid); CollectionUtils.collect(new ArrayList<Object>(map1.values()), new ObjectToStringTransformer(), uuidLst); return uuidLst; }
From source file:org.sipfoundry.sipxconfig.acd.stats.AcdStatistics.java
static Set<String> toName(Collection namedObjects) { Set<String> names = new HashSet<String>(namedObjects.size()); CollectionUtils.collect(namedObjects, new NamedObject.ToName(), names); return names; }
From source file:org.sparkcommerce.admin.server.service.handler.SkuCustomPersistenceHandler.java
/** * Returns a {@link Property} filled out with a delimited list of the <b>values</b> that are passed in. This should be * invoked on a fetch and the returned property should be added to the fetched {@link Entity} dto. * //from w w w .j ava2s. c o m * @param values * @return * @see {@link #createConsolidatedOptionField(Class)}; */ public static Property getConsolidatedOptionProperty(List<ProductOptionValue> values) { Property optionValueProperty = new Property(); optionValueProperty.setName(CONSOLIDATED_PRODUCT_OPTIONS_FIELD_NAME); //order the values by the display order of their correspond product option // Collections.sort(values, new Comparator<ProductOptionValue>() { // // @Override // public int compare(ProductOptionValue value1, ProductOptionValue value2) { // return new CompareToBuilder().append(value1.getProductOption().getDisplayOrder(), // value2.getProductOption().getDisplayOrder()).toComparison(); // } // }); ArrayList<String> stringValues = new ArrayList<String>(); CollectionUtils.collect(values, new Transformer() { @Override public Object transform(Object input) { return ((ProductOptionValue) input).getAttributeValue(); } }, stringValues); optionValueProperty.setValue(StringUtils.join(stringValues, CONSOLIDATED_PRODUCT_OPTIONS_DELIMETER)); return optionValueProperty; }
From source file:org.squashtest.tm.service.internal.batchimport.Model.java
@SuppressWarnings("unchecked") private <TARGET extends Target> List<String> collectPaths(List<TARGET> targets) { return (List<String>) CollectionUtils.collect(targets, PathCollector.INSTANCE, new ArrayList<String>(targets.size())); }
From source file:org.squashtest.tm.service.internal.batchimport.Model.java
@SuppressWarnings("unchecked") private List<String> collectRequirementPaths(List<RequirementVersionTarget> targets) { return (List<String>) CollectionUtils.collect(targets, RequirementPathCollector.INSTANCE, new ArrayList<String>(targets.size())); }