Search in sources :

Example 1 with Predicate

use of org.apache.commons.collections.Predicate in project head by mifos.

the class LegacyPersonnelDao method getActiveBranchManagersUnderOffice.

@SuppressWarnings("unchecked")
public List<PersonnelBO> getActiveBranchManagersUnderOffice(Short officeId, final RoleBO role) throws PersistenceException {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put(CustomerSearchConstants.OFFICEID, officeId);
    params.put(CustomerSearchConstants.PERSONNELSTATUSID, PersonnelStatus.ACTIVE.getValue());
    List activeBranchManagers = executeNamedQuery(NamedQueryConstants.GET_ACTIVE_BRANCH_MANAGER_UNDER_OFFICE, params);
    return (List<PersonnelBO>) CollectionUtils.select(activeBranchManagers, new Predicate() {

        @Override
        public boolean evaluate(Object object) {
            Set<PersonnelRoleEntity> applicableRoles = ((PersonnelBO) object).getPersonnelRoles();
            return CollectionUtils.exists(applicableRoles, new Predicate() {

                @Override
                public boolean evaluate(Object object) {
                    return ((PersonnelRoleEntity) object).getRole().equals(role);
                }
            });
        }
    });
}
Also used : HashMap(java.util.HashMap) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) PersonnelRoleEntity(org.mifos.customers.personnel.business.PersonnelRoleEntity) ArrayList(java.util.ArrayList) List(java.util.List) Predicate(org.apache.commons.collections.Predicate)

Example 2 with Predicate

use of org.apache.commons.collections.Predicate in project head by mifos.

the class LoanAccountAction method populateDetailsForSelectedClients.

private List<LoanAccountDetailsDto> populateDetailsForSelectedClients(final List<LoanAccountDetailsDto> clientDetails, final List<String> selectedClients) {
    List<LoanAccountDetailsDto> loanAccountDetailsView = new ArrayList<LoanAccountDetailsDto>();
    for (final String clientId : selectedClients) {
        if (StringUtils.isNotEmpty(clientId)) {
            LoanAccountDetailsDto matchingClientDetail = (LoanAccountDetailsDto) CollectionUtils.find(clientDetails, new Predicate() {

                @Override
                public boolean evaluate(final Object object) {
                    return ((LoanAccountDetailsDto) object).getClientId().equals(clientId);
                }
            });
            if (matchingClientDetail != null) {
                setGovernmentIdAndPurpose(matchingClientDetail);
                loanAccountDetailsView.add(matchingClientDetail);
            }
        }
    }
    return loanAccountDetailsView;
}
Also used : ArrayList(java.util.ArrayList) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) Predicate(org.apache.commons.collections.Predicate)

Example 3 with Predicate

use of org.apache.commons.collections.Predicate in project head by mifos.

the class BranchReportPersistenceIntegrationTest method testExtractStaffingSummaryLevels.

@Test
public void testExtractStaffingSummaryLevels() throws Exception {
    List<BranchReportStaffingLevelSummaryBO> staffingLevels = branchReportPersistence.extractBranchReportStaffingLevelSummary(LOAN_OFFICER_ID_SHORT);
    Assert.assertEquals(2, staffingLevels.size());
    Assert.assertNull("Should not extract roles with zero personnel count", org.apache.commons.collections.CollectionUtils.find(staffingLevels, new Predicate() {

        @Override
        public boolean evaluate(Object arg0) {
            BranchReportStaffingLevelSummaryBO summary = (BranchReportStaffingLevelSummaryBO) arg0;
            return !TOTAL_STAFF_ROLENAME_STR.equals(summary.getTitleName()) && Integer.valueOf(0).equals((summary).getPersonnelCount());
        }
    }));
    for (BranchReportStaffingLevelSummaryBO summaryBO : staffingLevels) {
        if (TOTAL_STAFF_ROLENAME_STR.equals(summaryBO.getTitleName())) {
            Assert.assertEquals(Integer.valueOf(2), summaryBO.getPersonnelCount());
        }
    }
}
Also used : BranchReportStaffingLevelSummaryBO(org.mifos.reports.branchreport.BranchReportStaffingLevelSummaryBO) Predicate(org.apache.commons.collections.Predicate) Test(org.junit.Test)

Example 4 with Predicate

use of org.apache.commons.collections.Predicate in project gocd by gocd.

the class FanInGraph method findScmRevisionsThatDiffer.

private Collection<StageIdFaninScmMaterialPair> findScmRevisionsThatDiffer(List<StageIdFaninScmMaterialPair> pIdScmMaterialList) {
    for (final StageIdFaninScmMaterialPair pIdScmPair : pIdScmMaterialList) {
        final Collection<StageIdFaninScmMaterialPair> matWithSameFingerprint = CollectionUtils.select(pIdScmMaterialList, new Predicate() {

            @Override
            public boolean evaluate(Object o) {
                return pIdScmPair.equals(o);
            }
        });
        boolean diffRevFound = false;
        for (StageIdFaninScmMaterialPair pair : matWithSameFingerprint) {
            if (pair.stageIdentifier == pIdScmPair.stageIdentifier) {
                continue;
            }
            if (pair.faninScmMaterial.revision.equals(pIdScmPair.faninScmMaterial.revision)) {
                continue;
            }
            diffRevFound = true;
            break;
        }
        if (diffRevFound) {
            return matWithSameFingerprint;
        }
    }
    return Collections.EMPTY_LIST;
}
Also used : Predicate(org.apache.commons.collections.Predicate)

Example 5 with Predicate

use of org.apache.commons.collections.Predicate in project gocd by gocd.

the class DefaultPluginJarLocationMonitor method removePluginJarChangeListener.

@Override
public void removePluginJarChangeListener(final PluginJarChangeListener listener) {
    Object referenceOfListenerToBeRemoved = CollectionUtils.find(pluginJarChangeListener, new Predicate() {

        @Override
        public boolean evaluate(Object object) {
            WeakReference<PluginJarChangeListener> listenerWeakReference = (WeakReference<PluginJarChangeListener>) object;
            PluginJarChangeListener registeredListener = listenerWeakReference.get();
            return registeredListener != null && registeredListener == listener;
        }
    });
    pluginJarChangeListener.remove(referenceOfListenerToBeRemoved);
    removeClearedWeakReferences();
}
Also used : WeakReference(java.lang.ref.WeakReference) Predicate(org.apache.commons.collections.Predicate)

Aggregations

Predicate (org.apache.commons.collections.Predicate)22 ArrayList (java.util.ArrayList)9 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)3 Iterator (java.util.Iterator)2 List (java.util.List)2 Resource (org.apache.sling.api.resource.Resource)2 MultiInstanceofPredicate (org.jumpmind.db.util.MultiInstanceofPredicate)2 LoanBO (org.mifos.accounts.loan.business.LoanBO)2 RestParameter (com.iggroup.oss.restdoclet.doclet.type.RestParameter)1 Uri (com.iggroup.oss.restdoclet.doclet.type.Uri)1 NameValuePair (com.iggroup.oss.restdoclet.doclet.util.NameValuePair)1 ParameterNamePredicate (com.iggroup.oss.restdoclet.doclet.util.ParameterNamePredicate)1 RequestMappingParamsParser (com.iggroup.oss.restdoclet.doclet.util.RequestMappingParamsParser)1 AnnotationValue (com.sun.javadoc.AnnotationValue)1 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 DependencyMaterialInstance (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialInstance)1 File (java.io.File)1 WeakReference (java.lang.ref.WeakReference)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1