List of usage examples for org.apache.commons.collections CollectionUtils collect
public static Collection collect(Iterator inputIterator, Transformer transformer)
From source file:org.intermine.api.profile.TagMapperTest.java
@Test public void apacheCollectionsIntegration() { Transformer tm = TagMapper.getMapper(Field.Name); @SuppressWarnings("unchecked") Collection<String> names = CollectionUtils.collect(tags, tm); List<String> expected = Arrays.asList("tagName_0", "tagName_1", "tagName_2", "tagName_3", "tagName_4", "tagName_5", "tagName_6", "tagName_7", "tagName_8", "tagName_9"); assertEquals(expected, names);/*from w w w. j av a 2s . co m*/ }
From source file:org.itracker.services.implementations.ConfigurationServiceImpl.java
public Map<String, List<String>> getAvailableLanguages() { final TreeMap<String, List<String>> languages = new TreeMap<>(); final List<Configuration> locales = getConfigurationItemsByType(Configuration.Type.locale); for (int i = 0; i < locales.size(); i++) { String baselocalestring = locales.get(i).getValue(); if (baselocalestring.length() == 2) { List<String> languageList = new ArrayList<>(); final String l = baselocalestring; languageList.addAll(CollectionUtils.collect(locales, new Transformer() { @Override//w w w . j a v a 2 s . c o m public Object transform(Object input) { String val = ((Configuration) input).getValue(); if (val.length() > 2 && val.startsWith(l + "_")) { return val; } return null; } })); CollectionUtils.filter(languageList, NotNullPredicate.getInstance()); languages.put(baselocalestring, languageList); } } return languages; }
From source file:org.jahia.ajax.gwt.helper.ContentDefinitionHelper.java
public GWTChoiceListInitializer getInitializerValues(ExtendedPropertyDefinition epd, ExtendedNodeType contextType, JCRNodeWrapper contextNode, JCRNodeWrapper contextParent, Map<String, List<GWTJahiaNodePropertyValue>> dependentValues, Locale uiLocale) throws RepositoryException { Map<String, Object> context = new HashMap<String, Object>(); context.put("contextType", contextType); context.put("contextNode", contextNode); context.put("contextParent", contextParent); for (Map.Entry<String, List<GWTJahiaNodePropertyValue>> entry : dependentValues.entrySet()) { context.put(entry.getKey(), CollectionUtils.collect(entry.getValue(), new Transformer() { public Object transform(Object input) { return input.toString(); }//from w w w .java 2 s. c o m })); } return getChoiceListInitializerValues(epd, context, uiLocale); }
From source file:org.jahia.services.content.nodetypes.initializers.SubNodeTypesChoiceListInitializerImpl.java
@SuppressWarnings("unchecked") public List<ChoiceListValue> getChoiceListValues(ExtendedPropertyDefinition epd, String param, List<ChoiceListValue> values, Locale locale, Map<String, Object> context) { final SortedSet<ChoiceListValue> listValues = new TreeSet<ChoiceListValue>(); if (StringUtils.isEmpty(param)) { param = "jmix:editorialContent"; }// ww w. j av a 2s . c o m try { String includedTypes = StringUtils.substringBefore(param, ";"); Set<String> excludedTypes = new HashSet<String>(); String exclusion = StringUtils.substringAfter(param, ";"); if (StringUtils.isNotBlank(exclusion)) { excludedTypes.addAll(CollectionUtils.collect( Arrays.asList(Patterns.COMMA.split(StringUtils.substringAfter(param, ";"))), new Transformer() { public Object transform(Object input) { return ((String) input).trim(); } })); } for (String nodeTypeName : Patterns.COMMA.split(includedTypes)) { nodeTypeName = nodeTypeName.trim(); ExtendedNodeType nodeType = NodeTypeRegistry.getInstance().getNodeType(nodeTypeName); if (!isExcludedType(nodeType, excludedTypes)) { listValues.add(new ChoiceListValue(nodeType.getLabel(locale), nodeType.getName())); } NodeTypeIterator nti = nodeType.getSubtypes(); while (nti.hasNext()) { ExtendedNodeType type = (ExtendedNodeType) nti.next(); if (!isExcludedType(type, excludedTypes)) { listValues.add(new ChoiceListValue(type.getLabel(locale), type.getName())); } } } } catch (NoSuchNodeTypeException e) { logger.error("Cannot get type", e); } return new LinkedList<ChoiceListValue>(listValues); }
From source file:org.jahia.utils.osgi.parsers.cnd.JahiaCndReader.java
public void getDefinitionsAndReferences(Set<String> contentTypeDefinitions, Set<String> contentTypeReferences) throws RepositoryException { for (ExtendedNodeType extendedNodeType : getNodeTypesList()) { getLog().debug(filename + " Nodetype definition " + extendedNodeType.getName()); contentTypeDefinitions.add(extendedNodeType.getName()); for (String superTypeName : extendedNodeType.getDeclaredSupertypeNames()) { getLog().debug(filename + " node type super type reference " + superTypeName); contentTypeReferences.add(superTypeName); }//from w ww.j a v a2s . c o m for (String mixinExtendName : extendedNodeType.getMixinExtendNames()) { getLog().debug(filename + " node type mixin type reference " + mixinExtendName); contentTypeReferences.add(mixinExtendName); } ExtendedNodeDefinition[] childNodeDefinitions = extendedNodeType.getDeclaredChildNodeDefinitions(); for (ExtendedNodeDefinition childNodeDefinition : childNodeDefinitions) { if (childNodeDefinition.getDefaultPrimaryTypeName() != null) { getLog().debug(filename + " child node default type reference " + childNodeDefinition.getDefaultPrimaryTypeName()); contentTypeReferences.add(childNodeDefinition.getDefaultPrimaryTypeName()); } String[] requiredPrimaryTypeNames = childNodeDefinition.getRequiredPrimaryTypeNames(); for (String requiredPrimaryTypeName : requiredPrimaryTypeNames) { getLog().debug(filename + " child node required type reference " + requiredPrimaryTypeName); contentTypeReferences.add(requiredPrimaryTypeName); } Map<String, String> selectorOptions = childNodeDefinition.getSelectorOptions(); if (selectorOptions.size() > 0) { getLog().debug(filename + "Found child node selector options !!!!!!!!!!!!!!!!!!"); } } ExtendedPropertyDefinition[] propertyDefinitions = extendedNodeType.getPropertyDefinitions(); for (ExtendedPropertyDefinition propertyDefinition : propertyDefinitions) { if (ExtendedPropertyType.REFERENCE == propertyDefinition.getRequiredType() || ExtendedPropertyType.WEAKREFERENCE == propertyDefinition.getRequiredType()) { String[] valueConstraints = propertyDefinition.getValueConstraints(); for (String valueConstraint : valueConstraints) { if (valueConstraint != null) { getLog().debug(filename + " reference property value contraints " + valueConstraint); contentTypeReferences.add(valueConstraint); } } Value[] defaultValues = propertyDefinition.getDefaultValues(); for (Value defaultValue : defaultValues) { if (defaultValue != null) { getLog().debug(filename + " found reference property default value " + defaultValue.getString()); contentTypeReferences.add(defaultValue.getString()); } } } Map<String, String> selectorOptions = propertyDefinition.getSelectorOptions(); if (selectorOptions.size() > 0) { if (selectorOptions.containsKey("nodes")) { String nodeSelector = selectorOptions.get("nodes"); for (String nodeSelectorItem : Pattern.compile("|", Pattern.LITERAL).split(nodeSelector)) { String[] nodeSelectorOptions = nodeSelectorItem.split(";"); if (nodeSelectorOptions.length > 1) { if (StringUtils.isNotEmpty(nodeSelectorOptions[1])) { getLog().debug( filename + " found choicelist node type " + nodeSelectorOptions[1]); contentTypeReferences.add(nodeSelectorOptions[1]); } } } } if (selectorOptions.containsKey("nodetypes")) { String param = selectorOptions.get("nodetypes"); if (param.indexOf(";fromDependencies") > -1) { } if (param.startsWith("MIXIN")) { } else if (param.startsWith("PRIMARY")) { } else if (param.startsWith("ALL")) { } else if (StringUtils.isEmpty(param)) { } else { getLog().debug(filename + " found choicelist nodetype type " + param); contentTypeReferences.add(param); } } if (selectorOptions.containsKey("subnodetypes")) { String param = selectorOptions.get("subnodetypes"); if (StringUtils.isEmpty(param)) { param = "jmix:editorialContent"; } String includedTypes = StringUtils.substringBefore(param, ";"); Set<String> excludedTypes = new HashSet<String>(); String exclusion = StringUtils.substringAfter(param, ";"); if (StringUtils.isNotBlank(exclusion)) { excludedTypes.addAll(CollectionUtils.collect( Arrays.asList(Patterns.COMMA.split(StringUtils.substringAfter(param, ";"))), new Transformer() { public Object transform(Object input) { return ((String) input).trim(); } })); } for (String nodeTypeName : Patterns.COMMA.split(includedTypes)) { if (StringUtils.isNotEmpty(nodeTypeName)) { getLog().debug( filename + " found choicelist subnodetype included type " + nodeTypeName); contentTypeReferences.add(nodeTypeName); } } for (String nodeTypeName : excludedTypes) { if (StringUtils.isNotEmpty(nodeTypeName)) { getLog().debug( filename + " found choicelist subnodetype excluded type " + nodeTypeName); contentTypeReferences.add(nodeTypeName); } } } if (selectorOptions.containsKey("componenttypes")) { String param = selectorOptions.get("componenttypes"); Set<String> DEF_INCLUDES = new TreeSet<String>(Arrays.asList("jmix:editorialContent")); Set<String> includeTypes = DEF_INCLUDES; Set<String> excludeTypes = new TreeSet<String>(); if (StringUtils.isNotEmpty(param)) { includeTypes = getNodeTypes(StringUtils.substringBefore(param, ";")); excludeTypes = getNodeTypes(StringUtils.substringAfter(param, ";")); } for (String nodeTypeName : includeTypes) { if (StringUtils.isNotEmpty(nodeTypeName)) { getLog().debug(filename + " found choicelist component type included type " + nodeTypeName); contentTypeReferences.add(nodeTypeName); } } for (String nodeTypeName : excludeTypes) { if (StringUtils.isNotEmpty(nodeTypeName)) { getLog().debug(filename + " found choicelist component type included type " + nodeTypeName); contentTypeReferences.add(nodeTypeName); } } } } } } // remove all content type references that are defined in this file to keep only exist definitions contentTypeReferences.removeAll(contentTypeDefinitions); }
From source file:org.kuali.kra.hierarchyrouting.UnitStop.java
public String toString() { return new ToStringBuilder(this).append("id", id).append("parent", parent == null ? null : parent.id) .append("children", StringUtils.join(CollectionUtils.collect(children, new Transformer() { public Object transform(Object o) { return ((UnitStop) o).id; }// ww w . ja v a 2 s . c o m }), ',')).toString(); }
From source file:org.kuali.mobility.computerlabs.dao.ComputerLabsDaoImpl.java
@Override public List<? extends Location> getLocations(String groupId) { List<? extends Location> myLocations; if (null == groupId) { myLocations = new ArrayList<Location>(); for (LabGroup group : getLabGroups()) { myLocations.addAll(CollectionUtils.collect(group.getLocations(), new LocationTransform())); }/* w w w. j ava 2 s . c o m*/ } else { LabGroup myGroup; myGroup = getLabGroup(groupId); myLocations = myGroup.getLocations(); } return myLocations; }
From source file:org.kuali.rice.kew.doctype.service.impl.DocumentTypePermissionServiceImpl.java
/** * Converts list of RouteNodeInstance objects to a list of the route node names * @param routeNodeInstances the list RouteNodeInstance objects, may be null * @return non-null, possibly empty, Collection of routenode names *///ww w.j a v a 2s . c o m protected Collection<String> toRouteNodeNames(Collection<RouteNodeInstance> routeNodeInstances) { if (routeNodeInstances != null) { return CollectionUtils.collect(routeNodeInstances, new Transformer() { @Override public Object transform(Object input) { return ((RouteNodeInstance) input).getName(); } }); } else { return Collections.EMPTY_LIST; } }
From source file:org.lockss.util.TestFileUtil.java
List<File> listOfFiles(List lst) { return (List<File>) CollectionUtils.collect(lst, new Transformer() { public Object transform(Object o) { return new File(o.toString()); }/* w w w . ja v a 2s . c om*/ }); }
From source file:org.lockss.util.TestFileUtil.java
List<String> prepend(final String prefix, List lst) { return (List<String>) CollectionUtils.collect(lst, new Transformer() { public Object transform(Object o) { return prefix + o.toString(); }// w w w . ja v a 2 s. c o m }); }