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:com.fsoft.bn.service.impl.BNJournalArticleLocalServiceImpl.java

@SuppressWarnings("unchecked")
public List<News> getNewsInCategories(PortletRequest req, long groupId, String structureId,
        List<NewsCategory> lstNewsCate, int numberOfRecord, List<KeyValuePair> sortbys, Date fromDate,
        Date toDate) {/*ww w.  j a  va2 s .  c  o m*/
    StringBuffer categoriesId = new StringBuffer();
    for (NewsCategory newsCate : lstNewsCate) {
        categoriesId.append(newsCate.getId());
        categoriesId.append(CommonConstants.COMMA);
    }

    if (!Validator.isBlankOrNull(categoriesId) && categoriesId.length() > 0) {
        categoriesId.deleteCharAt(categoriesId.length() - 1);
    }

    List<JournalArticle> news = BNJournalArticleFinderUtil.getNewsInCategories(groupId, structureId,
            String.valueOf(categoriesId), numberOfRecord, sortbys, fromDate, toDate);

    List<News> lstNews = new ArrayList<News>();
    if (news.size() != 0) {
        lstNews = (List<News>) CollectionUtils.collect(news,
                new JournalArticle2NewsTransformer(req, structureId));
    }

    return lstNews;
}

From source file:eionet.meta.dao.mysql.TableDAOImpl.java

/**
 * {@inheritDoc}/*from www  . jav a 2s  .  c  o  m*/
 */
@Override
public List<DataSetTable> listForDatasets(List<DataSet> datasets) {
    StringBuilder sql = new StringBuilder();

    int nameAttrId = getNameAttributeId();

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("nameAttrId", nameAttrId);
    params.put("parentType", "T");

    sql.append(
            "select dst.TABLE_ID, dst.SHORT_NAME, ds.REG_STATUS, dst.IDENTIFIER, ds.IDENTIFIER, ds.DATASET_ID, ");
    sql.append(
            "(select VALUE from ATTRIBUTE where M_ATTRIBUTE_ID = :nameAttrId and DATAELEM_ID = dst.TABLE_ID ");
    sql.append("and PARENT_TYPE = :parentType limit 1 ) as fullName ");
    sql.append("from DS_TABLE as dst ");
    sql.append("inner join DST2TBL as dst2ds on dst2ds.TABLE_ID = dst.TABLE_ID ");
    sql.append("inner join DATASET as ds on dst2ds.DATASET_ID = ds.DATASET_ID ");
    sql.append("where ds.DELETED is null ");
    sql.append("and ds.WORKING_COPY = 'N' ");

    //set dataset filters
    if (datasets != null && datasets.size() > 0) {
        sql.append("and ds.DATASET_ID IN( :datasetIds ) ");
        params.put("datasetIds", CollectionUtils.collect(datasets, new BeanToPropertyValueTransformer("id")));
    }

    sql.append("order by ds.IDENTIFIER asc, ds.DATASET_ID desc, dst.IDENTIFIER asc, dst.TABLE_ID desc");

    final List<DataSetTable> resultList = new ArrayList<DataSetTable>();

    getNamedParameterJdbcTemplate().query(sql.toString(), params, new RowCallbackHandler() {

        @Override
        public void processRow(ResultSet rs) throws SQLException {
            DataSetTable table = new DataSetTable();
            table.setId(rs.getInt("dst.TABLE_ID"));
            table.setShortName(rs.getString("dst.SHORT_NAME"));
            table.setName(rs.getString("fullName"));
            table.setDataSetStatus(rs.getString("ds.REG_STATUS"));

            // skip tables that do not actually exist (ie trash from some erroneous situation)
            if (StringUtils.isEmpty(rs.getString("dst.IDENTIFIER"))) {
                return;
            }
            table.setIdentifier(rs.getString("dst.IDENTIFIER"));
            resultList.add(table);
        }
    });
    return resultList;
}

From source file:com.base2.kagura.core.ExportHandler.java

/**
 * Takes the output and transforms it into a Excel file.
 * @param out Output stream.//from  ww w .j a v a  2 s. c o m
 * @param rows Rows of data from reporting-core
 * @param columns Columns to list on report
 */
public void generateXls(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
    try {
        Workbook wb = new HSSFWorkbook(); // or new XSSFWorkbook();
        String safeName = WorkbookUtil.createSafeSheetName("Report"); // returns " O'Brien's sales   "
        Sheet reportSheet = wb.createSheet(safeName);

        short rowc = 0;
        Row nrow = reportSheet.createRow(rowc++);
        short cellc = 0;
        if (rows == null)
            return;
        if (columns == null && rows.size() > 0) {
            columns = new ArrayList<ColumnDef>(CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
                @Override
                public Object transform(final Object input) {
                    return new ColumnDef() {
                        {
                            setName((String) input);
                        }
                    };
                }
            }));
        }
        if (columns != null) {
            for (ColumnDef column : columns) {
                Cell cell = nrow.createCell(cellc++);
                cell.setCellValue(column.getName());
            }
        }
        for (Map<String, Object> row : rows) {
            nrow = reportSheet.createRow(rowc++);
            cellc = 0;
            for (ColumnDef column : columns) {
                Cell cell = nrow.createCell(cellc++);
                cell.setCellValue(String.valueOf(row.get(column.getName())));
            }
        }
        wb.write(out);
    } catch (IOException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }

}

From source file:com.denimgroup.threadfix.service.queue.scheduledjob.ScheduledRemoteProviderImporter.java

@SuppressWarnings("unchecked")
public boolean addScheduledRemoteProviderImport(ScheduledRemoteProviderImport scheduledRemoteProviderImport) {

    String groupName = createGroupName();
    String jobName = createJobName(scheduledRemoteProviderImport);

    JobDetail job = JobBuilder.newJob(ScheduledRemoteProviderImportJob.class).withIdentity(jobName, groupName)
            .build();//from   w ww. ja  v  a 2 s  .c  o  m
    List<RemoteProviderType> remoteProviderTypes = remoteProviderTypeService.loadAll();
    List<Integer> idList = (List<Integer>) CollectionUtils.collect(remoteProviderTypes,
            new BeanToPropertyValueTransformer("id"));
    String remoteProviderTypeIds = StringUtils.join(idList, ",");

    job.getJobDataMap().put("remoteProviderTypeIds", remoteProviderTypeIds);
    job.getJobDataMap().put("queueSender", queueSender);

    try {
        String cronExpression = getCronExpression(scheduledRemoteProviderImport);
        if (cronExpression == null)
            return false;

        Trigger trigger = TriggerBuilder.<CronTrigger>newTrigger().forJob(jobName, groupName)
                .withIdentity(jobName, groupName).withSchedule(cronSchedule(cronExpression)).build();

        Date ft = scheduler.scheduleJob(job, trigger);
        log.info(job.getKey() + " has been scheduled to run at: " + ft + " and repeat based on expression: "
                + cronExpression);
    } catch (RuntimeException e) {
        if (e.getCause() instanceof ParseException) {
            log.error("Got ParseException while parsing cron expression.", e.getCause());
            return false;
        } else {
            throw e;
        }
    } catch (SchedulerException scheEx) {
        log.error("Error when scheduling job", scheEx);
        return false;
    }

    return true;
}

From source file:com.fsoft.bn.service.impl.BNJournalArticleLocalServiceImpl.java

@SuppressWarnings({ "unchecked" })
public List<News> getListOtherNewsInDetailPage(PortletRequest req, long groupId, String structureId,
        String articleId, String categoriesId, String cateName, List<KeyValuePair> sortbys) {
    List<JournalArticle> news;
    List<JournalArticle> otherLstNews = new ArrayList<JournalArticle>();
    news = BNJournalArticleFinderUtil.getListOtherNewsInDetailPage(groupId, structureId, articleId,
            categoriesId, sortbys);/*www .  java 2  s . c  om*/
    int flag = 0;
    for (JournalArticle ja : news) {
        if (flag == 1) {
            otherLstNews.add(ja);
        }
        if (ja.getArticleId().equals(articleId)) {
            flag = 1;
        }
    }
    List<News> lstNews = (List<News>) CollectionUtils.collect(otherLstNews,
            new JournalArticle2NewsTransformer(req, structureId));
    return lstNews;

}

From source file:com.square.core.dao.implementations.PersonneMoraleDaoImplementation.java

@Override
@SuppressWarnings("unchecked")
public ResultatPaginationFullText<PersonneMorale> rechercherPersonneMoraleParCriteres(
        RemotePagingCriteriasDto<PersonneMoralCriteresRechercheDto> criteres) throws ParseException {

    final PersonneMoralCriteresRechercheDto criteresRecherche = criteres.getCriterias();

    final BooleanQuery bq = new BooleanQuery();

    if (criteresRecherche.getRaisonSociale() != null && !("".equals(criteresRecherche.getRaisonSociale()))) {
        final AnalysingCustomQueryParser parser = new AnalysingCustomQueryParser(getMatchingVersion(),
                "raisonSociale", getAnalyser(PersonneMorale.class));
        parser.setAllowLeadingWildcard(true);
        final String raisonSociale = criteresRecherche.getRaisonSociale().replaceAll(POURCENT, ETOILE);
        final org.apache.lucene.search.Query requeteLucene = parser
                .parse(raisonSociale.lastIndexOf(ETOILE) == raisonSociale.length() - 1 ? raisonSociale
                        : raisonSociale + ETOILE);
        bq.add(requeteLucene, BooleanClause.Occur.MUST);
    }//from  w  w  w .j av  a 2  s  .  c o m
    if (criteresRecherche.getEnseigneCommerciale() != null
            && !("".equals(criteresRecherche.getEnseigneCommerciale()))) {
        final AnalysingCustomQueryParser parser = new AnalysingCustomQueryParser(getMatchingVersion(),
                "enseigneCommercial", getAnalyser(PersonneMorale.class));
        parser.setAllowLeadingWildcard(true);
        final String enseigneCommerciale = criteresRecherche.getEnseigneCommerciale().replaceAll(POURCENT,
                ETOILE);
        final org.apache.lucene.search.Query requeteLucene = parser
                .parse(enseigneCommerciale.lastIndexOf(ETOILE) == enseigneCommerciale.length() - 1
                        ? enseigneCommerciale
                        : enseigneCommerciale + ETOILE);
        bq.add(requeteLucene, BooleanClause.Occur.MUST);
    }
    // Critre sur le numro de l'entreprise
    String numeroEntreprise = criteresRecherche.getNumeroEntreprise();
    if (!StringUtils.isBlank(numeroEntreprise)) {
        numeroEntreprise = numeroEntreprise.replaceAll(POURCENT, ETOILE);
        final MultiFieldQueryParser parser = new MultiFieldQueryParser(getMatchingVersion(),
                new String[] { "numSiret", "num" }, getAnalyser(PersonneMorale.class));
        parser.setAllowLeadingWildcard(true);
        final org.apache.lucene.search.Query requeteLucene = parser.parse(numeroEntreprise);
        bq.add(requeteLucene, BooleanClause.Occur.MUST);
    }
    // Critere sur le complement du nom
    if (criteresRecherche.getComplementNom() != null && !("".equals(criteresRecherche.getComplementNom()))) {
        final AnalysingCustomQueryParser parser = new AnalysingCustomQueryParser(getMatchingVersion(),
                "adresses.complementNom", getAnalyser(PersonneMorale.class));
        parser.setAllowLeadingWildcard(true);
        final String complementNom = criteresRecherche.getComplementNom().replaceAll(POURCENT, ETOILE);
        final org.apache.lucene.search.Query requeteLucene = parser
                .parse(complementNom.lastIndexOf(ETOILE) == complementNom.length() - 1 ? complementNom
                        : complementNom + ETOILE);
        bq.add(requeteLucene, BooleanClause.Occur.MUST);
    }
    // Critre sur le dpartement
    if (criteresRecherche.getListeDepartements() != null
            && !criteresRecherche.getListeDepartements().isEmpty()) {
        final List<String> listeValeurs = (List<String>) CollectionUtils
                .collect(criteresRecherche.getListeDepartements(), StringValueTransformer.getInstance());
        bq.add((Query) getInQuery("adresses.codePostalCommune.commune.departement.id", listeValeurs),
                BooleanClause.Occur.MUST);
    }
    // Critre sur la ville
    if (criteresRecherche.getListeVilles() != null && !criteresRecherche.getListeVilles().isEmpty()) {
        final List<String> listeValeurs = (List<String>) CollectionUtils
                .collect(criteresRecherche.getListeVilles(), StringValueTransformer.getInstance());
        bq.add((Query) getInQuery("adresses.codePostalCommune.commune.id", listeValeurs),
                BooleanClause.Occur.MUST);
    }
    // Critre sur le code postal
    if (criteresRecherche.getListeCodesPostaux() != null
            && !criteresRecherche.getListeCodesPostaux().isEmpty()) {
        final List<String> listeValeurs = (List<String>) CollectionUtils
                .collect(criteresRecherche.getListeCodesPostaux(), StringValueTransformer.getInstance());
        bq.add((Query) getInQuery("adresses.codePostalCommune.codePostal.id", listeValeurs),
                BooleanClause.Occur.MUST);
    }
    // Critre sur la forme juridique
    if (criteresRecherche.getListeFormesJuridiques() != null
            && !criteresRecherche.getListeFormesJuridiques().isEmpty()) {
        final List<String> listeValeurs = (List<String>) CollectionUtils
                .collect(criteresRecherche.getListeFormesJuridiques(), StringValueTransformer.getInstance());
        bq.add((Query) getInQuery("formeJuridique.id", listeValeurs), BooleanClause.Occur.MUST);
    }
    // Critre sur le commercial
    if (criteresRecherche.getListeCommerciaux() != null && !criteresRecherche.getListeCommerciaux().isEmpty()) {
        final List<String> listeValeurs = (List<String>) CollectionUtils
                .collect(criteresRecherche.getListeCommerciaux(), StringValueTransformer.getInstance());
        bq.add((Query) getInQuery("attribution.ressource.id", listeValeurs), BooleanClause.Occur.MUST);
    }
    // Critre sur l'agence
    if (criteresRecherche.getListeAgences() != null && !criteresRecherche.getListeAgences().isEmpty()) {
        final List<String> listeValeurs = (List<String>) CollectionUtils
                .collect(criteresRecherche.getListeAgences(), StringValueTransformer.getInstance());
        bq.add(getInQuery("attribution.agence.id", listeValeurs), BooleanClause.Occur.MUST);
    }
    // Critre sur la nature
    if (criteresRecherche.getListeNatures() != null && !criteresRecherche.getListeNatures().isEmpty()) {
        final List<String> listeValeurs = (List<String>) CollectionUtils
                .collect(criteresRecherche.getListeNatures(), StringValueTransformer.getInstance());
        bq.add((Query) getInQuery("naturePersonneMorale.id", listeValeurs), BooleanClause.Occur.MUST);
    }

    // Construction de la requte par defaut.
    if (criteresRecherche.getRaisonSociale() == null || "".equals(criteresRecherche.getRaisonSociale())) {
        final QueryParser parser = new QueryParser(getMatchingVersion(), "raisonSociale",
                getAnalyser(PersonnePhysique.class));
        parser.setAllowLeadingWildcard(true);
        final org.apache.lucene.search.Query requeteLucene = parser.parse("*");
        bq.add(requeteLucene, BooleanClause.Occur.MUST);
    }

    // CONSTRUCTION DE LA REQUETE
    final FullTextQuery fullTextQuery = createFullTextQuery(bq, PersonneMorale.class);

    // AJOUT DES INFORMATION DE TRI
    if (criteres.getListeSorts().size() > 0) {
        final SortField[] listeChamp = new SortField[criteres.getListeSorts().size()];
        for (int index = 0; index < criteres.getListeSorts().size(); index++) {
            listeChamp[index] = new SortField(criteres.getListeSorts().get(index).getSortField(),
                    SortField.STRING, criteres.getListeSorts().get(index)
                            .getSortAsc() == RemotePagingSort.REMOTE_PAGING_SORT_DESC);
        }
        final Sort sort = new Sort(listeChamp);
        fullTextQuery.setSort(sort);
    }

    // AJOUT DES INFORMATIONS DE PAGINATION
    fullTextQuery.setFirstResult(criteres.getFirstResult());
    fullTextQuery.setMaxResults(criteres.getMaxResult());

    // RETOURNE LA LISTE DES RESULTATS ET LE NOMBRE TOTAL DE RESULTAT (non affct par la pagination)
    return new ResultatPaginationFullText<PersonneMorale>(fullTextQuery.list(), fullTextQuery.getResultSize());
}

From source file:net.big_oh.algorithms.graph.clique.MaximalCliqueFinderFunctionalTest.java

private void testFindMaximalCliques_MultipleCliques_WithNoise(int numNonCliqueNodes, int... cliqueSizes) {
    if (numNonCliqueNodes < 0) {
        throw new IllegalArgumentException("numNonCliqueNodes cannot be less than zero.");
    }//  w ww.  j  a v a 2 s  .  c om

    if (cliqueSizes.length <= 0) {
        throw new IllegalArgumentException("must provide one or more cliqueSize arguments.");
    }

    final CliqueTestGraphBuilder graphBuilder = new CliqueTestGraphBuilder();
    for (int cliqueSize : cliqueSizes) {
        graphBuilder.addClique(cliqueSize);
    }
    graphBuilder.setNumNonCliqueNodes(numNonCliqueNodes);

    final JungUndirectedGraph multiCliqueGraph = graphBuilder.build();

    // find cliques of size 3 or greater; can't use size 2 because of noise
    // nodes that are connected to one node in each clique
    Set<Set<JungVertex>> maximalCliques = cliqueFinder.findMaximalCliques(multiCliqueGraph, 3);

    assertNotNull(maximalCliques);
    assertEquals("Failed to find expected number of maximal cliques.", cliqueSizes.length,
            maximalCliques.size());

    // extract the _sizes_ of all discovered maximal cliques
    @SuppressWarnings("unchecked")
    Collection<Integer> maximalCliqueSizes = CollectionUtils.collect(maximalCliques, new Transformer() {
        public Object transform(Object input) {
            Set<JungVertex> clique = (Set<JungVertex>) input;
            return Integer.valueOf(clique.size());
        }
    });

    // the collection of input clique sizes should be equal to the
    // collection of discovered clique sizes
    assertTrue(CollectionUtils.isEqualCollection(Arrays.asList(ArrayUtils.toObject(cliqueSizes)),
            maximalCliqueSizes));
}

From source file:com.topsec.tsm.sim.report.web.ReportController.java

/**
 * //w w  w.  j av  a 2s  . c  om
 */
@RequestMapping("getReportTree")
@ResponseBody
public Object getReportTree(SID sid, HttpServletRequest request) {
    if (null == auditor) {
        if (null == nodeMgrFacade) {
            nodeMgrFacade = (NodeMgrFacade) SpringContextServlet.springCtx.getBean("nodeMgrFacade");
        }
        auditor = nodeMgrFacade.getKernelAuditor(false);
    }
    TreeModel tree = new TreeModel("basic", "", "open");
    tree.putAttribute("type", ReportUiConfig.ReportTreeType.TRUNK);
    Set<AuthUserDevice> devices = sid.getUserDevice() == null ? Collections.<AuthUserDevice>emptySet()
            : sid.getUserDevice();
    if (dataSourceService == null) {
        dataSourceService = (DataSourceService) FacadeUtil.getFacadeBean(request, null, "dataSourceService");
    }
    if (reportService == null) {
        reportService = (ReportService) FacadeUtil.getFacadeBean(request, null, "reportService");
    }
    if (sid.isAuditor() || sid.hasAuditorRole()) {
        TreeModel selfAudit = new TreeModel(LogKeyInfo.LOG_SYSTEM_TYPE, "", "closed");
        selfAudit.putAttribute("dvcType", LogKeyInfo.LOG_SYSTEM_TYPE);
        selfAudit.putAttribute("type", ReportUiConfig.ReportTreeType.TRUNK);
        List<Map> rptMapList = reportService.getRptMaster("Comprehensive" + LogKeyInfo.LOG_SYSTEM_TYPE);
        if (!GlobalUtil.isNullOrEmpty(rptMapList)) {
            Map trunkMap = rptMapList.get(0);
            selfAudit.putAttribute("viewItem", trunkMap.get("viewItem"));
        }
        List<TreeModel> schildren = createTreeModel(reportService, LogKeyInfo.LOG_SYSTEM_TYPE);
        selfAudit.setChildren(schildren);
        tree.addChild(selfAudit);
    }
    if (sid.hasOperatorRole() || sid.isOperator()) {
        TreeModel system = new TreeModel(LogKeyInfo.LOG_SYSTEM_RUN_TYPE, "", "closed");
        system.putAttribute("dvcType", LogKeyInfo.LOG_SYSTEM_RUN_TYPE);
        system.putAttribute("type", ReportUiConfig.ReportTreeType.TRUNK);
        List<Map> rptMapList = reportService.getRptMaster("Comprehensive" + LogKeyInfo.LOG_SYSTEM_RUN_TYPE);
        if (!GlobalUtil.isNullOrEmpty(rptMapList)) {
            Map trunkMap = rptMapList.get(0);
            system.putAttribute("viewItem", trunkMap.get("viewItem"));
        }
        List<TreeModel> syschildren = createTreeModel(reportService, LogKeyInfo.LOG_SYSTEM_RUN_TYPE);
        system.setChildren(syschildren);
        tree.addChild(system);
        TreeModel event = new TreeModel(LogKeyInfo.LOG_SIM_EVENT + "", "", "closed");
        event.putAttribute("dvcType", LogKeyInfo.LOG_SIM_EVENT);
        event.putAttribute("type", ReportUiConfig.ReportTreeType.TRUNK);
        List<Map> rptMapEvList = reportService.getRptMaster("Comprehensive" + LogKeyInfo.LOG_SIM_EVENT);
        if (!GlobalUtil.isNullOrEmpty(rptMapEvList)) {
            Map trunkMap = rptMapEvList.get(0);
            event.putAttribute("viewItem", trunkMap.get("viewItem"));
        }
        List<TreeModel> echildren = createTreeModel(reportService, LogKeyInfo.LOG_SIM_EVENT);
        event.setChildren(echildren);
        tree.addChild(event);
    }
    TreeModel log = new TreeModel(LogKeyInfo.LOG_GLOBAL_DETAIL, "", "open");
    log.putAttribute("dvcType", LogKeyInfo.LOG_GLOBAL_DETAIL);
    log.putAttribute("type", ReportUiConfig.ReportTreeType.TRUNK);
    List<TreeModel> children = createTreeModel(reportService, LogKeyInfo.LOG_GLOBAL_DETAIL);
    log.addChild(children.get(0));

    List<SimDatasource> simDatasources = dataSourceService.getDataSource(DataSourceService.CMD_ALL);
    List<String> dvcTypes = null;
    if (sid.isOperator()) {
        dvcTypes = dataSourceService.getDistinctDvcType(DataSourceService.CMD_ALL);
    } else {
        dvcTypes = new ArrayList<String>();
        BeanToPropertyValueTransformer trans = new BeanToPropertyValueTransformer("ip");
        Collection<String> userDeviceIPs = (Collection<String>) CollectionUtils.collect(devices, trans);
        for (SimDatasource simDatasource : simDatasources) {
            Device device = AssetFacade.getInstance().getAssetByIp(simDatasource.getDeviceIp());
            if (device != null && userDeviceIPs.contains(simDatasource.getDeviceIp())) {
                if (!dvcTypes.contains(simDatasource.getSecurityObjectType())) {
                    dvcTypes.add(simDatasource.getSecurityObjectType());
                }
            }
        }
    }

    if (!GlobalUtil.isNullOrEmpty(dvcTypes) && (sid.hasOperatorRole() || sid.isOperator())) {
        for (String dvc : dvcTypes) {
            if (!LogKeyInfo.LOG_SYSTEM_TYPE.equals(dvc) && !LogKeyInfo.LOG_SYSTEM_RUN_TYPE.equals(dvc)) {
                String name = DeviceTypeNameUtil.getDeviceTypeName(dvc, request.getLocale());
                TreeModel trees = new TreeModel(dvc, name);
                trees.putAttribute("dvcType", dvc);
                trees.putAttribute("type", ReportUiConfig.ReportTreeType.TRUNK);
                List<Map> rptMapList = reportService.getRptMaster("Comprehensive" + dvc);
                if (!GlobalUtil.isNullOrEmpty(rptMapList)) {
                    Map trunkMap = rptMapList.get(0);
                    trees.putAttribute("viewItem", trunkMap.get("viewItem"));
                }

                List<TreeModel> bchildren = createTreeModel(reportService, dvc);
                trees.setChildren(bchildren);
                trees.setState(bchildren.isEmpty() ? "open" : "closed");
                log.addChild(trees);
            }
        }
        tree.addChild(log);
    }

    JSONArray jsonArray = new JSONArray(1);
    jsonArray.add(tree);
    return jsonArray;
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.manager.executionCourseManagement.SeperateExecutionCourse.java

private static Set<String> getExecutionCourseCodes(ExecutionSemester executionSemester) {
    Collection<ExecutionCourse> executionCourses = executionSemester.getAssociatedExecutionCoursesSet();
    return new HashSet<String>(CollectionUtils.collect(executionCourses, new Transformer() {
        @Override/*from w  w w. jav  a2  s .c  o m*/
        public Object transform(Object arg0) {
            ExecutionCourse executionCourse = (ExecutionCourse) arg0;
            return executionCourse.getSigla().toUpperCase();
        }
    }));
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.department.ReadPersonProfessorshipsByExecutionYearAction.java

List getDetailedProfessorships(User userView, String personId, DynaActionForm actionForm,
        HttpServletRequest request) throws FenixServiceException {

    Collection<Professorship> professorshipList = ((Person) FenixFramework.getDomainObject(personId))
            .getProfessorshipsSet();//from  w  w w .  j  a v  a 2  s  .c o m

    String executionYearID = (String) actionForm.get("executionYearId");
    ExecutionYear executionYear = (!StringUtils.isEmpty(executionYearID)
            ? (ExecutionYear) FenixFramework.getDomainObject(executionYearID)
            : null);
    if (executionYear == null) {
        executionYear = ExecutionYear.readCurrentExecutionYear();
    }
    final List<Professorship> responsibleFors = new ArrayList();
    for (final Professorship professorship : professorshipList) {
        if (professorship.getExecutionCourse().getExecutionPeriod().getExecutionYear() == executionYear) {
            responsibleFors.add(professorship);
        }
    }

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

    request.setAttribute("args", new TreeMap());
    return detailedProfessorshipList;
}