Example usage for org.apache.commons.collections CollectionUtils collect

List of usage examples for org.apache.commons.collections CollectionUtils collect

Introduction

In this page you can find the example usage for org.apache.commons.collections CollectionUtils collect.

Prototype

public static Collection collect(Iterator inputIterator, Transformer transformer) 

Source Link

Document

Transforms all elements from the inputIterator with the given transformer and adds them to the outputCollection.

Usage

From source file:net.sourceforge.fenixedu.dataTransferObject.InfoExam.java

public List getAssociatedRooms() {
    return (List) CollectionUtils.collect(super.getWrittenEvaluationSpaceOccupations(), new Transformer() {

        @Override// w ww.j  a v a2  s .c  o  m
        public Object transform(Object arg0) {
            InfoRoomOccupation roomOccupation = (InfoRoomOccupation) arg0;
            return roomOccupation.getInfoRoom();
        }
    });
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.curriculumHistoric.ReadActiveDegreeCurricularPlansByExecutionYear.java

protected List run(String executionYearID) throws FenixServiceException {
    ExecutionYear executionYear = FenixFramework.getDomainObject(executionYearID);

    Collection executionDegrees = null;
    if (executionYear != null) {
        executionDegrees = executionYear.getExecutionDegreesSet();
    }//from  w  w w .  j  a v a  2 s . co  m

    if (executionDegrees == null) {
        throw new FenixServiceException("nullDegree");
    }

    List infoDegreeCurricularPlans = (List) CollectionUtils.collect(executionDegrees, new Transformer() {
        @Override
        public Object transform(Object obj) {
            ExecutionDegree cursoExecucao = (ExecutionDegree) obj;
            DegreeCurricularPlan degreeCurricularPlan = cursoExecucao.getDegreeCurricularPlan();
            return InfoDegreeCurricularPlan.newInfoFromDomain(degreeCurricularPlan);
        }
    });

    return infoDegreeCurricularPlans;
}

From source file:com.zuora.api.object.Dynamic.java

/**
 * Answers the name and values of the dynamic properties of this object
 * @return the dynamic properties, as string-object pairs
 */// w  w w.  ja va 2  s.c  o  m
public Collection<Entry<String, Object>> dynamicProperties() {
    return CollectionUtils.collect(getAny(), new Transformer() {
        public Object transform(Object input) {
            Element e = (Element) input;
            return new DefaultMapEntry(e.getLocalName(), e.getTextContent());
        }
    });
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.teacher.professorship.ResponsibleForValidator.java

public void validateResponsibleForList(Teacher teacher, ExecutionCourse executionCourse,
        Professorship responsibleForAdded) throws MaxResponsibleForExceed, InvalidCategory {

    List responsibleFors = executionCourse.responsibleFors();

    if ((!responsibleFors.contains(responsibleForAdded))
            && (responsibleFors.size() >= MAX_RESPONSIBLEFOR_BY_EXECUTION_COURSE)) {
        List infoResponsibleFors = (List) CollectionUtils.collect(responsibleFors, new Transformer() {

            @Override//from  ww  w .java  2 s . co m
            public Object transform(Object input) {
                Professorship responsibleFor = (Professorship) input;
                InfoProfessorship infoResponsibleFor = InfoProfessorship.newInfoFromDomain(responsibleFor);
                return infoResponsibleFor;
            }
        });

        InfoExecutionCourse infoExecutionCourse = InfoExecutionCourse.newInfoFromDomain(executionCourse);
        throw new MaxResponsibleForExceed(infoExecutionCourse, infoResponsibleFors);
    }
}

From source file:com.jaspersoft.jasperserver.repository.test.RepositoryServiceDependentResourcesTest.java

@Test
public void shouldFindAllDependantReportsForDataSource() {
    assertNotNull("RepositoryService service is not wired.", getRepositoryService());
    assertNotNull("SearchCriteriaFactory service is not wired.", searchCriteriaFactory);

    String uri = "/datasources/JServerJNDIDS";

    List<ResourceLookup> resources = getRepositoryService().getDependentResources(null, uri,
            searchCriteriaFactory, 0, 20);

    assertEquals("Should find 9 dependant resources.", 9, resources.size());

    assertEquals("All resources should be lookup's.", 9,
            CollectionUtils.countMatches(resources, PredicateUtils.instanceofPredicate(ResourceLookup.class)));

    Collection types = CollectionUtils.collect(resources,
            TransformerUtils.invokerTransformer("getResourceType"));

    assertEquals("All lookup's should have type ReportUnit.", 9,
            CollectionUtils.countMatches(types, PredicateUtils.equalPredicate(
                    "com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit")));

    String sortOrder = ArrayUtils.toString(
            CollectionUtils.collect(resources, TransformerUtils.invokerTransformer("getURIString")).toArray());

    assertEquals("Resources should be sorted in order.", expectedOrder, sortOrder);
}

From source file:ar.com.zauber.commons.mom.MapObjectMapper.java

public List<Map<String, Object>> toMap(final Object[] objects) {
    return (List<Map<String, Object>>) CollectionUtils.collect(Arrays.asList(objects), toMap);
}

From source file:com.redhat.rhn.frontend.action.errata.EditAction.java

/**
 * This method acts as the default if the dispatch parameter is not in the map
 * It also represents the SetupAction//from   w  w w  . ja v a2 s .  c  om
 * @param mapping ActionMapping
 * @param formIn ActionForm
 * @param request HttpServletRequest
 * @param response HttpServletResponse
 * @return ActionForward, the forward for the jsp
 */
public ActionForward unspecified(ActionMapping mapping, ActionForm formIn, HttpServletRequest request,
        HttpServletResponse response) {

    RequestContext requestContext = new RequestContext(request);
    Errata errata = requestContext.lookupErratum();

    DynaActionForm form = (DynaActionForm) formIn;

    String keywordDisplay = StringUtil.join(LocalizationService.getInstance().getMessage("list delimiter"),
            IteratorUtils.getIterator(CollectionUtils.collect(errata.getKeywords(), new Transformer() {
                public Object transform(Object o) {
                    return o.toString();
                }
            })));

    //pre-populate form with current values
    form.set("synopsis", errata.getSynopsis());
    form.set("advisoryName", errata.getAdvisoryName());
    form.set("advisoryRelease", errata.getAdvisoryRel().toString());
    form.set("advisoryType", errata.getAdvisoryType());
    form.set("advisoryTypeLabels", ErrataManager.advisoryTypeLabels());
    form.set("product", errata.getProduct());
    form.set("errataFrom", errata.getErrataFrom());
    form.set("topic", errata.getTopic());
    form.set("description", errata.getDescription());
    form.set("solution", errata.getSolution());
    form.set("refersTo", errata.getRefersTo());
    form.set("notes", errata.getNotes());
    form.set("keywords", keywordDisplay);

    return setupPage(request, mapping, errata);
}

From source file:com.michelin.cio.hudson.plugins.clearcaseucmbaseline.ClearCaseUcmBaselineParameterDefinitionTest.java

/**
 * This method is more about building an algorithm than testing the method
 * which uses it.//from  w  w w  .  j  av a  2  s .co  m
 */
public void testGetBaselines() {
    List<String> expectedBaselines = new ArrayList<String>() {
        {
            add("xyz_v2.4.0_20051205");
            add("xyz_v2.3.1_20050531");
            add("xyz_v2.3.0_20050309");
            add("xyz_v2.2.3_20050503");
            add("xyz_v2.2.2_20041025");
            add("xyz_v2.2.1_20040806");
            add("xyz_v2.2.0_20040503");
            add("xyz_v2.1.2_20040607");
            add("xyz_v2.1.1_20040211");
            add("xyz_v2.1.0_20031016");
            add("xyz_v2.0.2_20040113");
            add("xyz_v2.0.1_20030929");
            add("xyz_v2.0.0_20030626");
            add("xyz_v2.x_init");
            add("xyz_INITIAL");
        }
    };

    String cleartoolOutput = "20051124.145458 xyz_INITIAL\n" + "20051124.163732 xyz_v2.x_init\n"
            + "20051128.085745 xyz_v2.0.0_20030626\n" + "20051128.135749 xyz_v2.0.1_20030929\n"
            + "20051128.140834 xyz_v2.0.2_20040113\n" + "20051128.175618 xyz_v2.1.1_20040211\n"
            + "20051128.160803 xyz_v2.1.0_20031016\n" + "20051129.094900 xyz_v2.1.2_20040607\n"
            + "20051129.115212 xyz_v2.2.0_20040503\n" + "20051129.141546 xyz_v2.2.1_20040806\n"
            + "20051129.143813 xyz_v2.2.2_20041025\n" + "20051129.145120 xyz_v2.2.3_20050503\n"
            + "20051130.110900 xyz_v2.3.1_20050531\n" + "20051130.091037 xyz_v2.3.0_20050309\n"
            + "20060228.152608 xyz_v2.4.0_20051205\n";

    List<String> baselines = Arrays.asList(cleartoolOutput.split("\n"));
    Collections.sort(baselines, new Comparator() {
        // reverse comparator so that we get the latest baselines first
        public int compare(Object o1, Object o2) {
            return -1 * ((String) o1).compareTo((String) o2);
        }
    });

    baselines = (List<String>) CollectionUtils.collect(baselines, new Transformer() {
        public Object transform(Object input) {
            return ((String) input).substring(16);
        }
    });

    if (expectedBaselines.size() != baselines.size()) {
        fail();
    }

    for (int i = expectedBaselines.size() - 1; i >= 0; i--) {
        if (!expectedBaselines.get(i).equals(baselines.get(i))) {
            fail();
        }
    }
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.teacher.professorship.ReadDetailedTeacherProfessorshipsAbstractService.java

protected List getDetailedProfessorships(List professorships, final List responsibleFors) {

    List detailedProfessorshipList = (List) CollectionUtils.collect(professorships,
            new Professorships2DetailProfessorship());

    return detailedProfessorshipList;
}

From source file:info.magnolia.cms.util.WebXmlUtil.java

public Collection getServletMappings(String servletName) {
    final String servletMappingXPathExpr = "/webxml:web-app/webxml:servlet-mapping[webxml:servlet-name='"
            + servletName + "']/webxml:url-pattern";
    final List servletMappings = getElementsFromXPath(servletMappingXPathExpr);

    return CollectionUtils.collect(servletMappings, new Transformer() {
        @Override/*from   w  w  w. j a  v  a 2  s . com*/
        public Object transform(Object input) {
            final Element servletMapping = (Element) input;
            return servletMapping.getText();
        }
    });
}