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);
}
});
}
});
}
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;
}
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());
}
}
}
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;
}
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();
}
Aggregations