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

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

Introduction

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

Prototype

public static void transform(Collection collection, Transformer transformer) 

Source Link

Document

Transform the collection by applying a Transformer to each element.

Usage

From source file:net.sourceforge.fenixedu.presentationTier.Action.academicAdministration.executionCourseManagement.SeperateExecutionCourseDispatchAction.java

private void transformExecutionDegreesIntoLabelValueBean(List executionDegreeList) {
    CollectionUtils.transform(executionDegreeList, new Transformer() {

        @Override/*w ww  .j av  a 2 s.  co m*/
        public Object transform(Object arg0) {
            InfoExecutionDegree infoExecutionDegree = (InfoExecutionDegree) arg0;
            /*
            TODO: DUPLICATE check really needed?
            StringBuilder label =
                new StringBuilder(infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree().getDegreeType()
                        .getLocalizedName());
            label.append(" em ");
            label.append(infoExecutionDegree.getInfoDegreeCurricularPlan().getInfoDegree().getNome());
            */

            String label = infoExecutionDegree.getInfoDegreeCurricularPlan().getDegreeCurricularPlan()
                    .getPresentationName(infoExecutionDegree.getInfoExecutionYear().getExecutionYear());

            return new LabelValueBean(label, infoExecutionDegree.getExternalId().toString());
        }

    });

    Collections.sort(executionDegreeList, new BeanComparator("label"));
    executionDegreeList.add(0,
            new LabelValueBean(BundleUtil.getString(Bundle.RENDERER, "renderers.menu.default.title"), ""));
}

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

@Test
public void testOrderAfterFirstNodeMoreThanThreeVariation2() throws RepositoryException, IOException {
    MockHierarchyManager hm = MockUtil.createHierarchyManager(
            "/node/a\n" + "/node/b\n" + "/node/c\n" + "/node/d\n" + "/node/e\n" + "/node/f\n");
    Content node = hm.getContent("/node");
    Content c = node.getContent("e");
    ContentUtil.orderAfter(c, "a");
    Collection<Content> result = node.getChildren();
    CollectionUtils.transform(result, new Transformer() {
        @Override/*from w  w w . j  a  v  a 2  s. c  om*/
        public Object transform(Object childObj) {
            return ((Content) childObj).getName();
        }
    });
    assertEquals(asList("a", "e", "b", "c", "d", "f"), result);
}

From source file:com.algoTrader.entity.marketData.BarDaoBase.java

/**
 * @see BarDao#toEntities(Collection)//  w  ww  . j a v a2  s. c om
 */
public void toEntities(final Collection<?> results) {
    if (results != null) {
        CollectionUtils.transform(results, this.ENTITYTRANSFORMER);
    }
}

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

@Test
public void testOrderAfterMidNodeMoreThanThreeVariation1() throws RepositoryException, IOException {
    MockHierarchyManager hm = MockUtil.createHierarchyManager(
            "/node/a\n" + "/node/b\n" + "/node/c\n" + "/node/d\n" + "/node/e\n" + "/node/f\n");
    Content node = hm.getContent("/node");
    Content c = node.getContent("f");
    ContentUtil.orderAfter(c, "c");
    Collection<Content> result = node.getChildren();
    CollectionUtils.transform(result, new Transformer() {
        @Override/*  w  ww. j a v  a 2 s . c o  m*/
        public Object transform(Object childObj) {
            return ((Content) childObj).getName();
        }
    });
    assertEquals(asList("a", "b", "c", "f", "d", "e"), result);
}

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

@Test
public void testOrderAfterMidNodeMoreThanThreeVariation2() throws RepositoryException, IOException {
    MockHierarchyManager hm = MockUtil.createHierarchyManager(
            "/node/a\n" + "/node/b\n" + "/node/c\n" + "/node/d\n" + "/node/e\n" + "/node/f\n");
    Content node = hm.getContent("/node");
    Content c = node.getContent("e");
    ContentUtil.orderAfter(c, "b");
    Collection<Content> result = node.getChildren();
    CollectionUtils.transform(result, new Transformer() {
        @Override//from  w  w w .  ja  v a  2  s .co m
        public Object transform(Object childObj) {
            return ((Content) childObj).getName();
        }
    });
    assertEquals(asList("a", "b", "e", "c", "d", "f"), result);
}

From source file:hr.fer.zemris.vhdllab.platform.manager.workspace.DefaultWorkspaceManager.java

@Override
public List<Project> getProjects(Predicate filter, Transformer transformer) {
    List<Project> projects = new ArrayList<Project>(getProjects());
    CollectionUtils.filter(projects, filter);
    CollectionUtils.transform(projects, transformer);
    return projects;
}

From source file:com.algoTrader.entity.marketData.BarDaoBase.java

/**
 * {@inheritDoc}//from www. java 2s .  c o  m
 */
@Override
public final Collection toBarVOCollection(Collection<?> entities) {
    Collection result = new ArrayList<BarVO>();
    if (entities != null) {
        CollectionUtils.transform(entities, this.BARVO_TRANSFORMER);
        result.addAll((Collection) entities);
    }
    return result;
}

From source file:ddf.catalog.source.solr.SolrMetacardClient.java

public void deleteByIds(String fieldName, List<? extends Serializable> identifiers, boolean forceCommit)
        throws IOException, SolrServerException {
    if (identifiers == null || identifiers.size() == 0) {
        return;/*from w w w  . jav  a  2 s  .  c  o  m*/
    }

    if (Metacard.ID.equals(fieldName)) {
        CollectionUtils.transform(identifiers, new Transformer() {
            @Override
            public Object transform(Object o) {
                return o.toString();
            }
        });
        client.deleteById((List<String>) identifiers);
    } else {
        if (identifiers.size() < SolrCatalogProvider.MAX_BOOLEAN_CLAUSES) {
            client.deleteByQuery(getIdentifierQuery(fieldName, identifiers));
        } else {
            int i = 0;
            for (i = SolrCatalogProvider.MAX_BOOLEAN_CLAUSES; i < identifiers
                    .size(); i += SolrCatalogProvider.MAX_BOOLEAN_CLAUSES) {
                client.deleteByQuery(getIdentifierQuery(fieldName,
                        identifiers.subList(i - SolrCatalogProvider.MAX_BOOLEAN_CLAUSES, i)));
            }
            client.deleteByQuery(getIdentifierQuery(fieldName,
                    identifiers.subList(i - SolrCatalogProvider.MAX_BOOLEAN_CLAUSES, identifiers.size())));
        }
    }

    if (forceCommit) {
        client.commit();
    }
}

From source file:hr.fer.zemris.vhdllab.platform.manager.workspace.DefaultWorkspaceManager.java

@Override
public Set<File> getFilesForProject(Project project, Predicate filter, Transformer transformer) {
    Set<File> files = new HashSet<File>(getFilesForProject(project));
    CollectionUtils.filter(files, filter);
    CollectionUtils.transform(files, transformer);
    return files;
}

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

@Test
public void testOrderBeforeFirstNodeVariation1() throws RepositoryException, IOException {
    MockHierarchyManager hm = MockUtil.createHierarchyManager(
            "/node/a\n" + "/node/b\n" + "/node/c\n" + "/node/d\n" + "/node/e\n" + "/node/f\n");
    Content node = hm.getContent("/node");
    Content c = node.getContent("c");
    ContentUtil.orderBefore(c, "a");
    Collection<Content> result = node.getChildren();
    CollectionUtils.transform(result, new Transformer() {
        @Override//from w  w  w  .  ja v a  2s  . co  m
        public Object transform(Object childObj) {
            return ((Content) childObj).getName();
        }
    });
    assertEquals(asList("c", "a", "b", "d", "e", "f"), result);
}