Example usage for org.apache.commons.collections Predicate Predicate

List of usage examples for org.apache.commons.collections Predicate Predicate

Introduction

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

Prototype

Predicate

Source Link

Usage

From source file:gov.nih.nci.cabig.caaers.web.ae.AdditionalInformationTab.java

@Override
public Map<String, Object> referenceData(HttpServletRequest request,
        ExpeditedAdverseEventInputCommand command) {
    Map<String, Object> refdata = super.referenceData(command);

    Map<String, List<AdditionalInformationDocument>> documents = new HashMap<String, List<AdditionalInformationDocument>>();

    Integer additionalInformationId = command.getAeReport().getAdditionalInformation().getId();
    List<AdditionalInformationDocument> additionalInformationDocuments = additionalInformationDocumentService
            .findByAdditionalInformationId(additionalInformationId);

    String baseName = "aeReport.additionalInformation";

    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);
            }//ww  w .  j  a  v  a 2  s  .  c om
        }, select);

        documents.put(String.format("%s.%s", baseName, documentType.getCode()), select);
    }

    refdata.put("documents", documents);
    refdata.put("additionalInformationId", additionalInformationId);

    return refdata;
}

From source file:net.sourceforge.fenixedu.domain.phd.ExternalPhdProgram.java

public static List<ExternalPhdProgram> readExternalPhdProgramsForCollaborationType(
        final PhdIndividualProgramCollaborationType type) {
    List<ExternalPhdProgram> phdProgramList = new ArrayList<ExternalPhdProgram>();

    CollectionUtils.select(Bennu.getInstance().getExternalPhdProgramsSet(), new Predicate() {

        @Override//from  w  w  w. jav  a2 s.co m
        public boolean evaluate(Object arg0) {
            return ((ExternalPhdProgram) arg0).isForCollaborationType(type);
        }

    }, phdProgramList);

    return phdProgramList;
}

From source file:module.workflow.domain.utils.WorkflowCommentCounter.java

/**
 * @param user user//from   w ww. j a v a2  s  .  co m
 * @param className classname
 * @return the processes of unread comments for the given person for the
 *         given classToFilter type of process NOTE: It relies on the logs
 *         of the user to retrieve the comments (as it should be more
 *         efficient and there is a direct relation between a comment and a
 *         log)
 */
public Set<WorkflowProcess> getProcessesWithUnreadComments(final User user, final String className) {

    Set<WorkflowProcess> processes = new HashSet<WorkflowProcess>();
    Predicate searchPredicate = new Predicate() {

        @Override
        public boolean evaluate(Object arg0) {
            if (className != null && classToFilter.toString().contentEquals(className)) {
                return classToFilter.isAssignableFrom(arg0.getClass())
                        && ((WorkflowProcess) arg0).hasUnreadCommentsForUser(user);
            } else if (className != null) {
                return false;
            }
            return classToFilter.isAssignableFrom(arg0.getClass())
                    && ((WorkflowProcess) arg0).hasUnreadCommentsForUser(user);
        }
    };

    for (WorkflowLog log : user.getUserLogsSet()) {
        WorkflowProcess process = log.getProcess();
        if (searchPredicate.evaluate(process)) {
            processes.add(process);
        }
    }
    return processes;

}

From source file:com.daimler.spm.b2bacceleratoraddon.actions.CheckOrderEntryCostCentersActive.java

protected Collection<AbstractOrderEntryModel> getExpiredCostCenterEntries(final OrderModel cart) {
    return CollectionUtils.select(cart.getEntries(), new Predicate() {
        @Override//from   ww  w  .j a  v a2 s.  com
        public boolean evaluate(final Object object) {
            final B2BCostCenterModel costCenter = ((AbstractOrderEntryModel) object).getCostCenter();
            if (costCenter != null && BooleanUtils.isFalse(costCenter.getActive())) {
                return true;
            }
            return false;
        }
    });

}

From source file:com.newlandframework.avatarmq.consumer.ConsumerClusters.java

public void detachRemoteChannelData(String clientId) {
    channelMap.remove(clientId);/*  w w w  .  j a v a 2 s.c o  m*/

    Predicate predicate = new Predicate() {
        public boolean evaluate(Object object) {
            String id = ((RemoteChannelData) object).getClientId();
            return id.compareTo(clientId) == 0;
        }
    };

    RemoteChannelData data = (RemoteChannelData) CollectionUtils.find(channelList, predicate);
    if (data != null) {
        channelList.remove(data);
    }
}

From source file:com.michelin.cio.jenkins.plugin.rrod.RequestRenameOrDeletePlugin.java

public void addRequest(final Request request) {
    boolean alreadyRequested = CollectionUtils.exists(requests, new Predicate() {

        public boolean evaluate(Object object) {
            return request.equals(object);
        }//from   w ww .  j a  v a 2  s . co m
    });

    if (!alreadyRequested) {
        requests.add(request);
        persistPendingRequests();
    }
}

From source file:com.assignmentone.util.persondb.AbstractDbManager.java

@SuppressWarnings("unchecked")
public synchronized T find(final int id) {
    T entity = (T) CollectionUtils.find(entityList, new Predicate() {
        @Override/*w w  w  . java 2 s.  c  o  m*/
        public boolean evaluate(Object object) {
            return ((T) object).getId() == id;
        }
    });
    try {
        return (T) entity.clone();
    } catch (CloneNotSupportedException e) {
        throw new RuntimeException(e);
    }
}

From source file:edu.kit.rest.usergroupmanagement.test.UserGroupTestService.java

private UserGroup findGroupById(final Long id) {
    return (UserGroup) CollectionUtils.find(groups, new Predicate() {

        @Override/*from   w  w  w .ja  va 2 s  .  c  o  m*/
        public boolean evaluate(Object o) {
            return Objects.equals(((UserGroup) o).getId(), id);
        }
    });
}

From source file:net.sourceforge.fenixedu.domain.teacher.Advise.java

public TeacherAdviseService getTeacherAdviseServiceByExecutionPeriod(
        final ExecutionSemester executionSemester) {
    return (TeacherAdviseService) CollectionUtils.find(getTeacherAdviseServicesSet(), new Predicate() {
        @Override/*from  w ww.  j  a  va  2 s.  co m*/
        public boolean evaluate(Object arg0) {
            TeacherAdviseService teacherAdviseService = (TeacherAdviseService) arg0;
            return teacherAdviseService.getTeacherService().getExecutionPeriod() == executionSemester;
        }
    });
}

From source file:com.seyren.api.bean.ChecksBean.java

private void filterByEnabled(final List<Check> checks, final boolean enabled) {
    CollectionUtils.filter(checks, new Predicate() {
        @Override//from  w ww .  ja  v a  2 s . co m
        public boolean evaluate(Object object) {
            return ((Check) object).isEnabled() == enabled;
        }
    });
}