List of usage examples for org.apache.commons.collections CollectionUtils transform
public static void transform(Collection collection, Transformer transformer)
From source file:net.sourceforge.fenixedu.applicationTier.Servico.publico.inquiries.ReadOldIquiriesSummaryByDegreeID.java
@Atomic public static Collection run(String degreeID) throws FenixServiceException { Degree degree = FenixFramework.getDomainObject(degreeID); if (degree == null) { throw new FenixServiceException("nullDegreeId"); }//ww w .j a v a 2s . c o m Collection<OldInquiriesSummary> oldInquiriesSummaryList = degree.getAssociatedOldInquiriesSummariesSet(); CollectionUtils.transform(oldInquiriesSummaryList, new Transformer() { @Override public Object transform(Object oldInquiriesSummary) { InfoOldInquiriesSummary iois = new InfoOldInquiriesSummary(); try { iois.copyFromDomain((OldInquiriesSummary) oldInquiriesSummary); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } return iois; } }); return oldInquiriesSummaryList; }
From source file:info.magnolia.module.imaging.tools.ImageIOPluginsPage.java
/** * Removes duplicates and returns a sorted set of all entries in lowercase. *//* w w w .ja v a 2 s . c o m*/ protected static Collection<String> filter(String... formats) { final TreeSet<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER); set.addAll(Arrays.asList(formats)); CollectionUtils.transform(set, new Transformer() { @Override public Object transform(Object input) { return ((String) input).toLowerCase(); } }); return set; }
From source file:net.sourceforge.fenixedu.presentationTier.backBeans.manager.executionCourse.CreateCourseReportsForExecutionPeriod.java
public List getExecutionPeriods() throws FenixServiceException { List executionPeriods = ReadNotClosedExecutionPeriods.run(); CollectionUtils.transform(executionPeriods, new Transformer() { @Override//from w ww . ja va2 s.co m public Object transform(Object arg0) { InfoExecutionPeriod executionPeriod = (InfoExecutionPeriod) arg0; return new SelectItem(executionPeriod.getExternalId(), executionPeriod.getDescription()); } }); return executionPeriods; }
From source file:net.sourceforge.fenixedu.presentationTier.backBeans.manager.gratuity.UpdateGratuitySituations.java
public List getExecutionYears() { List<LabelValueBean> executionYears = (List) ReadNotClosedExecutionYears.run(); CollectionUtils.transform(executionYears, new Transformer() { @Override//from www.j a v a2 s. com public Object transform(Object arg0) { InfoExecutionYear executionYear = (InfoExecutionYear) arg0; return new SelectItem(executionYear.getYear(), executionYear.getYear()); } }); return executionYears; }
From source file:net.sourceforge.fenixedu.presentationTier.backBeans.coordinator.ListStudentThesis.java
private static List run(String degreeCurricularPlanID) throws FenixServiceException { DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID); List masterDegreeThesisDataVersions = degreeCurricularPlan.readActiveMasterDegreeThesisDataVersions(); if (masterDegreeThesisDataVersions == null || masterDegreeThesisDataVersions.isEmpty()) { throw new NonExistingServiceException("error.exception.masterDegree.nonExistingMasterDegreeThesis"); }//from ww w.j av a 2 s .c o m CollectionUtils.transform(masterDegreeThesisDataVersions, new Transformer() { @Override public Object transform(Object arg0) { MasterDegreeThesisDataVersion masterDegreeThesisDataVersion = (MasterDegreeThesisDataVersion) arg0; return InfoMasterDegreeThesisDataVersionWithGuidersAndRespAndThesis .newInfoFromDomain(masterDegreeThesisDataVersion); } }); return masterDegreeThesisDataVersions; }
From source file:fr.itldev.koya.webscript.global.CountChildren.java
@Override public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException { Map<String, String> urlParams = KoyaWebscript.getUrlParamsMap(req); String response;/* w w w . ja va 2 s .c o m*/ try { NodeRef parent = koyaNodeService .getNodeRef((String) urlParams.get(KoyaWebscript.WSCONST_PARENTNODEREF)); ObjectMapper mapper = new ObjectMapper(); Set qNameFilter = mapper.readValue(req.getContent().getReader(), new TypeReference<Set>() { }); /** * Transform Set Of Map<String,String> as Set<Qname> */ CollectionUtils.transform(qNameFilter, new Transformer() { @Override public Object transform(Object input) { Map<String, String> m = (Map<String, String>) input; return QName.createQName(m.get("namespaceURI"), m.get("localName")); } }); response = KoyaWebscript.getObjectAsJson(koyaNodeService.countChildren(parent, qNameFilter)); } catch (KoyaServiceException ex) { throw new WebScriptException("KoyaError : " + ex.getErrorCode().toString()); } res.setContentType("application/json"); res.getWriter().write(response); }
From source file:com.brightcove.zartan.common.catalog.TagSet.java
/** * If <tt>obj</tt> is a <tt>String</tt>, converts it to lower case. If * <tt>obj</tt> is a <tt>Collection</tt>, recursively calls * <tt>normalize</tt> on each of its elements. * @param obj the <tt>Object</tt> on which to perform text normalization. * @return the normalized input Object.//w w w . j ava 2s.c om */ public Object normalize(Object obj) { if (obj instanceof String) { obj = normalize((String) obj); } else if (obj instanceof Collection<?>) { Collection<?> collection = (Collection<?>) (obj); // convert all strings in the collection to lower case CollectionUtils.transform(collection, new Transformer() { public Object transform(Object input) { if (input instanceof Collection<?>) { for (Object element : ((Collection<?>) input)) { return transform(element); } // should be unreachable, but compiler error without it return null; } else if (input instanceof String) { return normalize((String) input); } else { System.out.println("Found an element that's not an " + "instance of String"); return input; } } }); } return obj; }
From source file:fr.itldev.koya.alfservice.DossierService.java
/** * * @param parent/*from ww w. j a va2 s .com*/ * @return * @throws KoyaServiceException */ public List<Dossier> list(NodeRef parent) throws KoyaServiceException { if (!nodeService.getType(parent).equals(KoyaModel.TYPE_SPACE)) { throw new KoyaServiceException(KoyaErrorCodes.DOSSIER_INVALID_PARENT_NODE); } List nodes = nodeService.getChildAssocs(parent, new HashSet<QName>() { { add(KoyaModel.TYPE_DOSSIER); } }); /** * transform List<ChildAssociationRef> to List<Dossier> */ CollectionUtils.transform(nodes, new Transformer() { @Override public Object transform(Object input) { try { return koyaNodeService.getSecuredItem(((ChildAssociationRef) input).getChildRef(), Dossier.class); } catch (KoyaServiceException ex) { return null; } } }); return nodes; }
From source file:fr.itldev.koya.services.impl.KoyaContentServiceImpl.java
@SuppressWarnings("unchecked") @Override/*from ww w.ja va 2 s.c o m*/ public List<Content> list(User user, NodeRef containerToList, Boolean onlyFolders, Integer depth) throws AlfrescoServiceException { @SuppressWarnings("rawtypes") List contents = fromJSON(new TypeReference<List<SecuredItem>>() { }, user.getRestTemplate().getForObject(getAlfrescoServerUrl() + REST_GET_LISTCONTENTTREE, String.class, containerToList, onlyFolders, depth)); // tranform SecuredItems to contents CollectionUtils.transform(contents, TRANSFORM_TO_CONTENTS); return contents; }
From source file:info.magnolia.cms.util.ContentUtilTest.java
@Test public void testOrderAfter() throws RepositoryException, IOException { MockHierarchyManager hm = MockUtil.createHierarchyManager("/node/a\n" + "/node/b\n" + "/node/c\n"); Content node = hm.getContent("/node"); Content a = node.getContent("a"); ContentUtil.orderAfter(a, "b"); Collection<Content> result = node.getChildren(); CollectionUtils.transform(result, new Transformer() { @Override//from w w w . j a va 2 s . co m public Object transform(Object childObj) { return ((Content) childObj).getName(); } }); assertEquals(Arrays.asList(new String[] { "b", "a", "c" }), result); }