use of org.apache.commons.collections.Predicate in project gocd by gocd.
the class MaterialRepository method pmrModificationsKey.
private List<String> pmrModificationsKey(Modification modification, List<PipelineMaterialRevision> pmrs) {
final long id = modification.getId();
final MaterialInstance materialInstance = modification.getMaterialInstance();
Collection<PipelineMaterialRevision> matchedPmrs = (Collection<PipelineMaterialRevision>) CollectionUtils.select(pmrs, new Predicate() {
@Override
public boolean evaluate(Object o) {
PipelineMaterialRevision pmr = (PipelineMaterialRevision) o;
long from = pmr.getFromModification().getId();
long to = pmr.getToModification().getId();
MaterialInstance pmi = findMaterialInstance(pmr.getMaterial());
return from <= id && id <= to && materialInstance.equals(pmi);
}
});
List<String> keys = new ArrayList<>(matchedPmrs.size());
for (PipelineMaterialRevision matchedPmr : matchedPmrs) {
keys.add(pmrModificationsKey(matchedPmr));
}
return keys;
}
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();
}
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 head by mifos.
the class LoanAccountAction method populateClientDetailsFromLoan.
List<LoanAccountDetailsDto> populateClientDetailsFromLoan(final List<ClientBO> activeClientsUnderGroup, final List<LoanBO> individualLoans, final List<ValueListElement> businessActivities) {
List<LoanAccountDetailsDto> clientDetails = new ArrayList<LoanAccountDetailsDto>();
for (final ClientBO client : activeClientsUnderGroup) {
LoanAccountDetailsDto clientDetail = new LoanAccountDetailsDto();
clientDetail.setClientId(getStringValue(client.getCustomerId()));
clientDetail.setClientName(client.getDisplayName());
LoanBO loanAccount = (LoanBO) CollectionUtils.find(individualLoans, new Predicate() {
@Override
public boolean evaluate(final Object object) {
return client.getCustomerId().equals(((LoanBO) object).getCustomer().getCustomerId());
}
});
if (loanAccount != null) {
final Integer businessActivityId = loanAccount.getBusinessActivityId();
if (businessActivityId != null) {
clientDetail.setBusinessActivity(Integer.toString(businessActivityId));
ValueListElement businessActivityElement = (ValueListElement) CollectionUtils.find(businessActivities, new Predicate() {
@Override
public boolean evaluate(final Object object) {
return ((ValueListElement) object).getId().equals(businessActivityId);
}
});
if (businessActivityElement != null) {
clientDetail.setBusinessActivityName(businessActivityElement.getName());
}
}
clientDetail.setLoanAmount(loanAccount.getLoanAmount() != null ? loanAccount.getLoanAmount().toString() : "0.0");
}
clientDetails.add(clientDetail);
}
return clientDetails;
}
use of org.apache.commons.collections.Predicate in project head by mifos.
the class LoanAccountAction method handleIndividualLoans.
void handleIndividualLoans(final LoanBO loanBO, final LoanAccountActionForm loanAccountActionForm, final boolean isRepaymentIndepOfMeetingEnabled, final List<LoanAccountDetailsDto> loanAccountDetailsList, final List<LoanBO> individualLoans, final Locale locale) throws AccountException, ServiceException {
List<Integer> foundLoans = new ArrayList<Integer>();
for (final LoanAccountDetailsDto loanAccountDetail : loanAccountDetailsList) {
Predicate predicateOldGlim = new Predicate() {
@Override
public boolean evaluate(final Object object) {
return ((LoanBO) object).getCustomer().getCustomerId().toString().equals(loanAccountDetail.getClientId());
}
};
LoanBO individualLoan = (LoanBO) CollectionUtils.find(individualLoans, predicateOldGlim);
if (individualLoan == null) {
// glimLoanUpdater.createIndividualLoan(loanAccountActionForm, loanBO, isRepaymentIndepOfMeetingEnabled,
// loanAccountDetail);
} else {
foundLoans.add(individualLoan.getAccountId());
try {
if (!AccountingRules.isGroupLoanWithMembers() && loanAccountActionForm.getLoanAmount() != null) {
loanAccountDetail.setLoanAmount(loanAccountActionForm.getLoanAmountAsBigDecimal().divide(individualLoan.calcFactorOfEntireLoan(), 10, RoundingMode.HALF_UP).toString());
}
glimLoanUpdater.updateIndividualLoan(loanAccountActionForm.getDisbursementDateValue(locale), loanAccountActionForm.getInterestDoubleValue(), loanAccountActionForm.getNoOfInstallmentsValue(), loanAccountDetail, individualLoan);
} catch (InvalidDateException e) {
e.printStackTrace();
}
}
}
for (LoanBO loan : individualLoans) {
if (!foundLoans.contains(loan.getAccountId())) {
glimLoanUpdater.delete(loan);
}
}
}
Aggregations