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:net.sourceforge.fenixedu.domain.candidacyProcess.mobility.MobilityIndividualApplication.java

public List<ApprovedLearningAgreementDocumentFile> getActiveApprovedLearningAgreements() {
    List<ApprovedLearningAgreementDocumentFile> activeDocuments = new ArrayList<ApprovedLearningAgreementDocumentFile>();
    CollectionUtils.select(getApprovedLearningAgreementsSet(), new Predicate() {

        @Override//from w  w  w . j  a v  a  2  s.com
        public boolean evaluate(Object arg0) {
            ApprovedLearningAgreementDocumentFile document = (ApprovedLearningAgreementDocumentFile) arg0;
            return document.getCandidacyFileActive();
        }

    }, activeDocuments);

    return activeDocuments;
}

From source file:module.mailtracking.domain.MailTracking.java

public java.util.List<CorrespondenceEntry> simpleSearch(CorrespondenceType type, final String key,
        boolean onlyActiveEntries) {
    java.util.List<CorrespondenceEntry> entries = new java.util.ArrayList<CorrespondenceEntry>();

    if (Strings.isNullOrEmpty(key)) {
        return entries;
    }/*from   www .j a  v  a 2  s.  co m*/

    CollectionUtils.select(this.getAbleToViewEntries(type, onlyActiveEntries), new Predicate() {

        @Override
        public boolean evaluate(Object arg0) {
            return Helper.matchGivenSearchToken((CorrespondenceEntry) arg0, key);
        }

    }, entries);

    return entries;
}

From source file:com.projity.configuration.FieldDictionary.java

/**
 * Extract fields that have extra status, and also optionally that have validOnOjbectCreate status
 *///from  w  w  w . j a va  2  s.c  om
public static LinkedList extractExtraFields(Collection from, final boolean mustBeValidOnObjectCreate) {
    LinkedList result = new LinkedList();
    CollectionUtils.select(from, new Predicate() {
        public boolean evaluate(Object arg0) {
            Field f = (Field) arg0;
            return f.isExtra() && (!mustBeValidOnObjectCreate || f.isValidOnObjectCreate());
        }
    }, result);
    return result;
}

From source file:module.mailtracking.domain.CorrespondenceEntry.java

public static java.util.List<CorrespondenceEntry> getActiveEntries() {
    java.util.Collection<CorrespondenceEntry> allEntries = Bennu.getInstance().getCorrespondenceEntriesSet();
    java.util.List<CorrespondenceEntry> activeEntries = new java.util.ArrayList<CorrespondenceEntry>();

    CollectionUtils.select(allEntries, new Predicate() {

        @Override//  w w  w.jav  a2s  .  com
        public boolean evaluate(Object arg0) {
            return CorrespondenceEntryState.ACTIVE.equals(((CorrespondenceEntry) arg0).getState());
        }

    }, activeEntries);

    return activeEntries;
}

From source file:net.sf.wickedshell.ui.shell.viewer.proposal.CompletionController.java

/**
 * Identifies all possible enviromental value completion for the given
 * prefix./*from   ww w . ja  v  a2 s  .co  m*/
 * 
 * @return the <code>List</code> of <code>Completions</code> referring
 *         to the given prefix
 */
@SuppressWarnings("unchecked")
public static List getEnviromentalValueCompletions(IShellDescriptor descriptor,
        final String environmentalValuePrefix, final String command) {
    List currentEnviromentalValueCompletions = new ArrayList();
    CollectionUtils.select(descriptor.getEnviromentalValues().entrySet(), new Predicate() {
        public boolean evaluate(Object object) {
            Entry entry = (Entry) object;
            String enviromentalValue = (String) entry.getKey();
            return enviromentalValue.toLowerCase().startsWith(environmentalValuePrefix.toLowerCase());
        }
    }, currentEnviromentalValueCompletions);
    CollectionUtils.transform(currentEnviromentalValueCompletions, new Transformer() {
        public Object transform(Object object) {
            Entry entry = (Entry) object;
            String completion = command + (String) entry.getKey();
            String description = (String) entry.getKey() + " <" + (String) entry.getValue()
                    + "> - Environmental value (Cascading completion)";
            String imagePath = "img/environmentalValue.gif";
            return ICompletion.Factory.newInstance(completion, description, imagePath);
        }
    });

    Collections.sort(currentEnviromentalValueCompletions, new CompletionComparator());
    return currentEnviromentalValueCompletions;
}

From source file:module.mailtracking.domain.CorrespondenceEntry.java

public static java.util.List<CorrespondenceEntry> getActiveEntries(final CorrespondenceType type) {
    java.util.Collection<CorrespondenceEntry> allEntries = Bennu.getInstance().getCorrespondenceEntriesSet();
    java.util.List<CorrespondenceEntry> activeEntries = new java.util.ArrayList<CorrespondenceEntry>();

    CollectionUtils.select(allEntries, new Predicate() {

        @Override//  w  ww  . j  av  a 2s.  co m
        public boolean evaluate(Object arg0) {
            CorrespondenceEntry entry = (CorrespondenceEntry) arg0;
            return CorrespondenceEntryState.ACTIVE.equals(entry.getState())
                    && (type == null || type.equals(entry.getType()));
        }

    }, activeEntries);

    return activeEntries;
}

From source file:net.sourceforge.fenixedu.domain.accounting.events.export.SIBSOutgoingPaymentFile.java

public static List<SIBSOutgoingPaymentFile> readSuccessfulSentPaymentFiles() {
    List<SIBSOutgoingPaymentFile> files = new ArrayList<SIBSOutgoingPaymentFile>();

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

        @Override/*from   w ww.j a  v a 2 s. c  o m*/
        public boolean evaluate(Object arg0) {
            return ((SIBSOutgoingPaymentFile) arg0).getSuccessfulSentDate() != null;
        }
    }, files);

    return files;
}

From source file:module.mailtracking.domain.MailTracking.java

public static Set<MailTracking> getMailTrackingsWhereUserHasSomeRole(final User user) {

    if (user.getPerson() == null && Group.dynamic("managers").isMember(Authenticate.getUser())) {
        return Bennu.getInstance().getMailTrackingsSet();
    }// ww w .j a va2 s.c  o  m

    java.util.Set<MailTracking> unitsWithMailTrackings = new java.util.HashSet<MailTracking>();
    CollectionUtils.select(Bennu.getInstance().getMailTrackingsSet(), new Predicate() {

        @Override
        public boolean evaluate(Object arg0) {
            return ((MailTracking) arg0).isUserWithSomeRoleOnThisMailTracking(user);
        }

    }, unitsWithMailTrackings);

    return unitsWithMailTrackings;
}

From source file:net.sourceforge.fenixedu.domain.candidacyProcess.IndividualCandidacyProcess.java

public List<IndividualCandidacyDocumentFile> getActiveDocumentFiles() {
    List<IndividualCandidacyDocumentFile> documentList = new ArrayList<IndividualCandidacyDocumentFile>();

    CollectionUtils.select(getCandidacy().getDocumentsSet(), new Predicate() {

        @Override/*from   www  . j a  va2  s  .  c o m*/
        public boolean evaluate(Object arg0) {
            IndividualCandidacyDocumentFile file = (IndividualCandidacyDocumentFile) arg0;

            return file.getCandidacyFileActive();
        }

    }, documentList);

    return documentList;
}

From source file:net.sourceforge.fenixedu.domain.candidacyProcess.mobility.MobilityIndividualApplicationProcess.java

public List<ErasmusAlert> getAlertsNotViewed() {
    List<ErasmusAlert> alertsNotViewed = new ArrayList<ErasmusAlert>();

    CollectionUtils.select(getAlertSet(), arg0 -> {
        ErasmusAlert alert = (ErasmusAlert) arg0;
        return alert.isToFire();
    }, alertsNotViewed);//  w  ww  . ja  va2  s. co m

    Collections.sort(alertsNotViewed, Collections.reverseOrder(ErasmusAlert.WHEN_CREATED_COMPARATOR));

    return alertsNotViewed;
}