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

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

Introduction

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

Prototype

public static void select(Collection inputCollection, Predicate predicate, Collection outputCollection) 

Source Link

Document

Selects all elements from input collection which match the given predicate and adds them to outputCollection.

Usage

From source file:edu.scripps.fl.pubchem.db.PCAssayPanel.java

@Transient
public XRef getTarget() {
    List<PCAssayXRef> list = new ArrayList();
    CollectionUtils.select(assay.getAssayXRefs(), new Predicate() {
        public boolean evaluate(Object object) {
            PCAssayXRef xref = (PCAssayXRef) object;
            if (xref.getPanel() != null)
                if (xref.getPanel().getPanelNumber() == getPanelNumber() && xref.isTarget() == true)
                    return true;
            return false;
        }/*w  w w  .  j  ava  2 s.co m*/
    }, list);
    return list.size() > 0 ? list.get(0).getXRef() : null;
}

From source file:bard.pubchem.model.PCAssayPanel.java

public XRef getTarget() {
    List<PCAssayXRef> list = new ArrayList<PCAssayXRef>();
    CollectionUtils.select(assay.getAssayXRefs(), new Predicate() {
        public boolean evaluate(Object object) {
            PCAssayXRef xref = (PCAssayXRef) object;
            if (xref.getPanel() != null)
                if (xref.getPanel().getPanelNumber() == getPanelNumber() && xref.isTarget() == true)
                    return true;
            return false;
        }// w  w  w.  j  a  v a  2  s .c  o  m
    }, list);
    return list.size() > 0 ? list.get(0).getXRef() : null;
}

From source file:net.sourceforge.fenixedu.domain.candidacyProcess.erasmus.ApprovedLearningAgreementDocumentFile.java

protected List<ApprovedLearningAgreementExecutedAction> getViewedLearningAgreementActions() {
    List<ApprovedLearningAgreementExecutedAction> executedActionList = new ArrayList<ApprovedLearningAgreementExecutedAction>();

    CollectionUtils.select(getExecutedActionsSet(), new Predicate() {

        @Override/*from w ww .  j a v a  2 s.  c  om*/
        public boolean evaluate(Object arg0) {
            return ((ApprovedLearningAgreementExecutedAction) arg0).isViewedLearningAgreementAction();
        };

    }, executedActionList);

    Collections.sort(executedActionList, Collections.reverseOrder(ExecutedAction.WHEN_OCCURED_COMPARATOR));

    return executedActionList;
}

From source file:net.sourceforge.fenixedu.domain.student.importation.ExportExistingStudentsFromImportationProcess.java

public static List<ExportExistingStudentsFromImportationProcess> readDoneJobs(
        final ExecutionYear executionYear) {
    List<ExportExistingStudentsFromImportationProcess> jobList = new ArrayList<ExportExistingStudentsFromImportationProcess>();

    CollectionUtils.select(executionYear.getDgesBaseProcessSet(), new Predicate() {

        @Override//from w  w  w .  j av  a 2 s  . co m
        public boolean evaluate(Object arg0) {
            return (arg0 instanceof ExportExistingStudentsFromImportationProcess)
                    && ((QueueJob) arg0).getDone();
        }
    }, jobList);

    return jobList;
}

From source file:net.sourceforge.fenixedu.domain.residence.StudentsPerformanceReport.java

public static StudentsPerformanceReport readPendingReport(final ExecutionSemester executionSemester) {
    List<StudentsPerformanceReport> pendingReports = new ArrayList<StudentsPerformanceReport>();

    CollectionUtils.select(executionSemester.getStudentsPerformanceReportsSet(), new Predicate() {

        @Override/*from w  w w  . jav  a2s .c  om*/
        public boolean evaluate(Object arg0) {
            return ((StudentsPerformanceReport) arg0).getIsNotDoneAndNotCancelled();
        }

    }, pendingReports);

    if (pendingReports.isEmpty()) {
        return null;
    }

    Collections.sort(pendingReports, Collections.reverseOrder(COMPARE_BY_REQUEST_DATE));

    return pendingReports.iterator().next();
}

From source file:edu.scripps.fl.pubchem.db.PCAssayPanel.java

@Transient
public XRef getTaxonomy() {
    List<PCAssayXRef> list = new ArrayList();
    CollectionUtils.select(assay.getAssayXRefs(), new Predicate() {
        public boolean evaluate(Object object) {
            PCAssayXRef xref = (PCAssayXRef) object;
            if (xref.getPanel() != null)
                if (xref.getPanel().getPanelNumber() == getPanelNumber())
                    if (xref.getXRef() != null && "taxonomy".equals(xref.getXRef().getDatabase()))
                        return true;
            return false;
        }// ww  w. j  a v  a  2s .  com
    }, list);
    return list.size() > 0 ? list.get(0).getXRef() : null;
}

From source file:com.webcrawler.MailCrawlerService.java

/**
 * Gets the absolute mail urls./*from   w  ww . jav a 2  s.  com*/
 *
 * @param linkElements the link elements
 * @param searchToken the search token
 * @return the absolute mail urls
 * @throws IOException Signals that an I/O exception has occurred.
 */
private List<String> getAbsoluteMailUrls(Elements linkElements, String searchToken) throws IOException {
    List<String> absoluteURLList = new ArrayList<String>();
    List<Element> relativeURLList = new ArrayList<Element>();
    for (Element linkElement : linkElements) {
        String absouleUrl = linkElement.attr("abs:href");
        Elements anchorElements = getLinkElements(Jsoup.connect(absouleUrl).get(), "a");
        CollectionUtils.select(anchorElements, getLinkFilterPredicate(getRegexMailUrlPattern(searchToken)),
                relativeURLList);
    }
    for (Element element : relativeURLList) {
        absoluteURLList.add(element.attr("abs:href"));
    }
    if (log.isDebugEnabled()) {
        log.debug("Absolute URL List: " + absoluteURLList.toString());
    }
    return absoluteURLList;
}

From source file:bard.pubchem.model.PCAssayPanel.java

public XRef getTaxonomy() {
    List<PCAssayXRef> list = new ArrayList<PCAssayXRef>();
    CollectionUtils.select(assay.getAssayXRefs(), new Predicate() {
        public boolean evaluate(Object object) {
            PCAssayXRef xref = (PCAssayXRef) object;
            if (xref.getPanel() != null)
                if (xref.getPanel().getPanelNumber() == getPanelNumber())
                    if (xref.getXRef() != null && "taxonomy".equals(xref.getXRef().getDatabase()))
                        return true;
            return false;
        }//from   w w w.  java 2 s . c o  m
    }, list);
    return list.size() > 0 ? list.get(0).getXRef() : null;
}

From source file:net.sourceforge.fenixedu.domain.student.importation.ExportDegreeCandidaciesByDegreeForPasswordGeneration.java

public static List<ExportDegreeCandidaciesByDegreeForPasswordGeneration> readAllJobs(
        final ExecutionYear executionYear) {
    List<ExportDegreeCandidaciesByDegreeForPasswordGeneration> jobList = new ArrayList<ExportDegreeCandidaciesByDegreeForPasswordGeneration>();

    CollectionUtils.select(executionYear.getDgesBaseProcessSet(), new Predicate() {

        @Override/*from w  w w .j  a  v  a2 s  .co  m*/
        public boolean evaluate(Object arg0) {
            return arg0 instanceof ExportDegreeCandidaciesByDegreeForPasswordGeneration;
        }
    }, jobList);

    return jobList;
}

From source file:gov.nih.nci.cabig.caaers.domain.AdditionalInformationDocument.java

public static Map<String, List<AdditionalInformationDocument>> groupDocumentsByDocumentType(
        List<AdditionalInformationDocument> additionalInformationDocuments) {
    Map<String, List<AdditionalInformationDocument>> documents = new HashMap<String, List<AdditionalInformationDocument>>();

    for (final AdditionalInformationDocumentType documentType : AdditionalInformationDocumentType.values()) {
        List<AdditionalInformationDocument> select = new ArrayList<AdditionalInformationDocument>();

        CollectionUtils.select(additionalInformationDocuments, new Predicate() {
            public boolean evaluate(Object o) {
                AdditionalInformationDocument additionalInformationDocument = (AdditionalInformationDocument) o;
                return additionalInformationDocument.getAdditionalInformationDocumentType()
                        .equals(documentType);
            }/*  www .  jav  a  2  s . c om*/
        }, select);

        if (!select.isEmpty()) {
            documents.put(String.format("%s", documentType.getCode()), select);
        }
    }

    return documents;
}