Search in sources :

Example 11 with Predicate

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;
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) DependencyMaterialInstance(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialInstance) Predicate(org.apache.commons.collections.Predicate)

Example 12 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)

Example 13 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 14 with Predicate

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;
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) ValueListElement(org.mifos.dto.domain.ValueListElement) Predicate(org.apache.commons.collections.Predicate)

Example 15 with Predicate

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);
        }
    }
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) Predicate(org.apache.commons.collections.Predicate)

Aggregations

Predicate (org.apache.commons.collections.Predicate)24 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)3 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 EnvironmentVariableConfig (com.thoughtworks.go.config.EnvironmentVariableConfig)2 EnvironmentVariable (com.thoughtworks.go.domain.EnvironmentVariable)2 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)2 GoCipher (com.thoughtworks.go.security.GoCipher)2 PipelineScheduleOptions (com.thoughtworks.go.server.domain.PipelineScheduleOptions)2 MaterialUpdateSuccessfulMessage (com.thoughtworks.go.server.materials.MaterialUpdateSuccessfulMessage)2 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)2 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