Example usage for java.math BigDecimal equals

List of usage examples for java.math BigDecimal equals

Introduction

In this page you can find the example usage for java.math BigDecimal equals.

Prototype

@Override
public boolean equals(Object x) 

Source Link

Document

Compares this BigDecimal with the specified Object for equality.

Usage

From source file:org.egov.billsaccounting.services.CreateVoucher.java

/**
 *
 * @param instrumentdetails//from   w w  w .  jav a  2  s . c o m
 */
public void validateInstrumentdetails(final List<HashMap<String, Object>> instrumentdetailsList,
        final HashMap<String, Object> receiptdetails) {
    String bankCode = null;
    BigDecimal chequeAmounts = BigDecimal.valueOf(0);
    for (final HashMap<String, Object> instrumentdetails : instrumentdetailsList) {
        if (null == instrumentdetails.get(VoucherConstant.INSTRUMENTNO))
            throw new ApplicationRuntimeException("Cheque number is null");
        if (null == instrumentdetails.get(VoucherConstant.INSTRUMENTDATE))
            throw new ApplicationRuntimeException("Cheque date is null");
        if (null == instrumentdetails.get(VoucherConstant.INSTRUMENTAMOUNT))
            throw new ApplicationRuntimeException("Cheque amount is null");
        else
            chequeAmounts = chequeAmounts
                    .add(new BigDecimal(instrumentdetails.get(VoucherConstant.INSTRUMENTAMOUNT).toString()));
        if (null != instrumentdetails.get(VoucherConstant.BANKCODE)) {
            bankCode = instrumentdetails.get(VoucherConstant.BANKCODE).toString();
            if (null == bankDAO.getBankByCode(bankCode))
                throw new ApplicationRuntimeException("not a valid bank code");
        }
    }
    if (!chequeAmounts.equals(receiptdetails.get(VoucherConstant.NETAMOUNT)))
        throw new ApplicationRuntimeException("total cheque amount is not matching with net amount");

}

From source file:pe.gob.mef.gescon.web.ui.PreguntaMB.java

public void onTransferPreguntas(TransferEvent event) {
    int index;/*from  w  w w .ja  v  a 2 s . c o m*/
    try {
        if (event != null) {
            BigDecimal id = this.getIdTipoConocimiento();
            if (event.isAdd()) {
                Collections.sort(this.getListaSourceVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaSourceVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaTargetVinculos() == null) {
                        this.setListaTargetVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaTargetVinculos().add(this.getListaSourceVinculos().get(index));
                    this.getListaSourceVinculos().remove(index);
                }
            }
            if (event.isRemove()) {
                Collections.sort(this.getListaTargetVinculos(), Consulta.Comparators.ID);
                for (Consulta ele : (List<Consulta>) event.getItems()) {
                    index = Collections.binarySearch(this.getListaTargetVinculos(), ele,
                            Consulta.Comparators.ID);
                    if (this.getListaSourceVinculos() == null) {
                        this.setListaSourceVinculos(new ArrayList<Consulta>());
                    }
                    this.getListaSourceVinculos().add(this.getListaTargetVinculos().get(index));
                    this.getListaTargetVinculos().remove(index);
                }
            }
            if (id.equals(Constante.BASELEGAL)) {
                this.setListaSourceVinculosBL(this.getListaSourceVinculos());
                this.setListaTargetVinculosBL(this.getListaTargetVinculos());
            } else if (id.equals(Constante.PREGUNTAS)) {
                this.setListaSourceVinculosPR(this.getListaSourceVinculos());
                this.setListaTargetVinculosPR(this.getListaTargetVinculos());
            } else if (id.equals(Constante.WIKI)) {
                this.setListaSourceVinculosWK(this.getListaSourceVinculos());
                this.setListaTargetVinculosWK(this.getListaTargetVinculos());
            } else if (id.equals(Constante.CONTENIDO)) {
                this.setListaSourceVinculosCT(this.getListaSourceVinculos());
                this.setListaTargetVinculosCT(this.getListaTargetVinculos());
            } else if (id.equals(Constante.BUENAPRACTICA)) {
                this.setListaSourceVinculosBP(this.getListaSourceVinculos());
                this.setListaTargetVinculosBP(this.getListaTargetVinculos());
            } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                this.setListaSourceVinculosOM(this.getListaSourceVinculos());
                this.setListaTargetVinculosOM(this.getListaTargetVinculos());
            }

            this.listaTargetVinculosConocimiento = new ArrayList<Consulta>();

            if (this.getListaTargetVinculosBL() == null) {
            } else {
                this.getListaTargetVinculosConocimiento().addAll(this.getListaTargetVinculosBL());
            }
            if (this.getListaTargetVinculosBP() == null) {
            } else {
                this.getListaTargetVinculosConocimiento().addAll(this.getListaTargetVinculosBP());
            }
            if (this.getListaTargetVinculosCT() == null) {
            } else {
                this.getListaTargetVinculosConocimiento().addAll(this.getListaTargetVinculosCT());
            }
            if (this.getListaTargetVinculosOM() == null) {
            } else {
                this.getListaTargetVinculosConocimiento().addAll(this.getListaTargetVinculosOM());
            }
            //                if (this.getListaTargetVinculosPR() == null) {
            //                } else {
            //                    this.getListaTargetVinculosPR().addAll(this.getListaTargetVinculosPR());
            //                }
            if (this.getListaTargetVinculosWK() == null) {
            } else {
                this.getListaTargetVinculosConocimiento().addAll(this.getListaTargetVinculosWK());
            }

        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}

From source file:nl.strohalm.cyclos.services.transactions.PaymentServiceImpl.java

private void insertFees(final LockHandler lockHandler, final Transfer transfer, final boolean forced,
        final BigDecimal originalAmount, final boolean simulation, final Set<ChargedFee> chargedFees) {
    final TransferType transferType = transfer.getType();
    final Account from = transfer.getFrom();
    final Account to = transfer.getTo();
    final TransactionFeeQuery query = new TransactionFeeQuery();
    query.setTransferType(transferType);
    final List<? extends TransactionFee> fees = transactionFeeService.search(query);
    BigDecimal totalPercentage = BigDecimal.ZERO;
    BigDecimal feeTotalAmount = BigDecimal.ZERO;
    Transfer topMost = getTopMost(transfer);
    final Calendar date = topMost.getDate();
    transfer.setChildren(new ArrayList<Transfer>());
    for (final TransactionFee fee : fees) {
        final Account fromAccount = fetchService.fetch(from, Account.Relationships.TYPE,
                MemberAccount.Relationships.MEMBER);
        final Account toAccount = fetchService.fetch(to, Account.Relationships.TYPE,
                MemberAccount.Relationships.MEMBER);

        final ChargedFee key = new ChargedFee(fee, fromAccount, toAccount);
        if (chargedFees.contains(key)) {
            throw new ValidationException("payment.error.circularFees");
        }//from w  w w. j av a  2 s  . co  m
        chargedFees.add(key);

        // Build the fee transfer
        final BuildTransferWithFeesDTO params = new BuildTransferWithFeesDTO(date, fromAccount, toAccount,
                originalAmount, fee, false);
        // rate stuff; buildTransfer MUST have these set.
        params.setEmissionDate(transfer.getEmissionDate());
        params.setExpirationDate(transfer.getExpirationDate());
        final Transfer feeTransfer = transactionFeeService.buildTransfer(params);

        // If the fee transfer is null, the fee should not be applied
        if (feeTransfer == null) {
            continue;
        }
        // Ensure the last fee when 100% will be the exact amount left
        if (fee instanceof SimpleTransactionFee && fee.getAmount().isPercentage()) {
            final BigDecimal feeValue = fee.getAmount().getValue();
            // Only when it's not a single fee
            if (!(totalPercentage.equals(BigDecimal.ZERO) && feeValue.doubleValue() == 100.0)) {
                totalPercentage = totalPercentage.add(feeValue);
                // TODO: shouldn't this be >= 0 in stead of == 0 (Rinke) ?
                if (totalPercentage.compareTo(new BigDecimal(100)) == 0 && feeTransfer != null) {
                    feeTransfer.setAmount(originalAmount.subtract(feeTotalAmount));
                }
            }
        }

        // Insert the fee transfer
        if (feeTransfer != null && feeTransfer.getAmount().floatValue() > PRECISION_DELTA) {
            feeTotalAmount = feeTotalAmount.add(feeTransfer.getAmount());
            feeTransfer.setParent(transfer);
            feeTransfer.setDate(transfer.getDate());
            feeTransfer.setStatus(transfer.getStatus());
            feeTransfer.setNextAuthorizationLevel(transfer.getNextAuthorizationLevel());
            feeTransfer.setProcessDate(transfer.getProcessDate());
            feeTransfer.setExternalTransfer(transfer.getExternalTransfer());
            feeTransfer.setBy(transfer.getBy());

            // Copy custom values of common custom fields from the parent to the fee transfer
            final List<PaymentCustomField> customFields = paymentCustomFieldService.list(feeTransfer.getType(),
                    false);
            if (!CollectionUtils.isEmpty(transfer.getCustomValues())) {
                final Collection<PaymentCustomFieldValue> feeTransferCustomValues = new ArrayList<PaymentCustomFieldValue>();
                for (final PaymentCustomFieldValue fieldValue : transfer.getCustomValues()) {
                    final CustomField field = fieldValue.getField();
                    if (customFields.contains(field)) {
                        final PaymentCustomFieldValue newFieldValue = new PaymentCustomFieldValue();
                        newFieldValue.setField(field);
                        newFieldValue.setValue(fieldValue.getValue());
                        feeTransferCustomValues.add(newFieldValue);
                    }
                }
                feeTransfer.setCustomValues(feeTransferCustomValues);
            }

            insertTransferAndPayFees(lockHandler, feeTransfer, forced, simulation, chargedFees);
            transfer.getChildren().add(feeTransfer);
        }
    }
}

From source file:org.kuali.kpme.tklm.time.detail.validation.TimeDetailValidationUtil.java

public static List<String> validateTimeEntryDetails(BigDecimal hours, BigDecimal amount, String startTimeS,
        String endTimeS, String startDateS, String endDateS, TimesheetDocument timesheetDocument,
        String selectedEarnCode, String selectedAssignment, boolean acrossDays, String timeblockId,
        String overtimePref) {//  www.j a  v a2s .com
    List<String> errors = new ArrayList<String>();
    LocalDate savedStartDate = TKUtils.formatDateString(startDateS);
    LocalDate savedEndDate = TKUtils.formatDateString(endDateS);

    if (timesheetDocument == null) {
        errors.add("No timesheet document found.");
    }
    if (errors.size() > 0)
        return errors;

    CalendarEntry payCalEntry = timesheetDocument.getCalendarEntry();
    EarnCode earnCode = null;
    if (StringUtils.isNotBlank(selectedEarnCode)) {
        earnCode = HrServiceLocator.getEarnCodeService().getEarnCode(selectedEarnCode,
                TKUtils.formatDateTimeStringNoTimezone(endDateS).toLocalDate());
    }
    boolean isTimeRecordMethod = earnCode != null
            && StringUtils.equalsIgnoreCase(earnCode.getRecordMethod(), HrConstants.EARN_CODE_TIME);

    errors.addAll(CalendarValidationUtil.validateDates(startDateS, endDateS));

    if (isTimeRecordMethod) {
        errors.addAll(CalendarValidationUtil.validateTimes(startTimeS, endTimeS));
    }
    if (errors.size() > 0)
        return errors;

    Long startTime;
    Long endTime;

    if (!isTimeRecordMethod) {
        startTimeS = "0:0";
        endTimeS = "0:0";
    }

    if (acrossDays && !endTimeS.equals("0:00")) {
        endDateS = startDateS;
    }

    startTime = TKUtils.convertDateStringToDateTimeWithoutZone(startDateS, startTimeS).getMillis();
    endTime = TKUtils.convertDateStringToDateTimeWithoutZone(endDateS, endTimeS).getMillis();

    errors.addAll(CalendarValidationUtil.validateInterval(payCalEntry, startTime, endTime));
    if (errors.size() > 0)
        return errors;

    if (isTimeRecordMethod) {
        if (startTimeS == null)
            errors.add("The start time is blank.");
        if (endTimeS == null)
            errors.add("The end time is blank.");
        if (startTime - endTime == 0)
            errors.add("Start time and end time cannot be equivalent");
    }
    if (errors.size() > 0)
        return errors;

    DateTime startTemp = new DateTime(startTime);
    DateTime endTemp = new DateTime(endTime);
    /*
     * KPME-2687:
     *
     * Removed 24 hour limitation. System creates continuous sequence of time blocks when !accrossDays,
     * hours between startTemp and endTemp may be over 24 hours.
     *
            if (errors.size() == 0 && !acrossDays && !StringUtils.equals(TkConstants.EARN_CODE_CPE, overtimePref)) {
    Hours hrs = Hours.hoursBetween(startTemp, endTemp);
    if (hrs.getHours() > 24) errors.add("One timeblock cannot exceed 24 hours");
            }
            if (errors.size() > 0) return errors;
            
     */

    //Check that assignment is valid within the timeblock span. 
    AssignmentDescriptionKey assignKey = HrServiceLocator.getAssignmentService()
            .getAssignmentDescriptionKey(selectedAssignment);
    Assignment assign = HrServiceLocator.getAssignmentService().getAssignmentForTargetPrincipal(assignKey,
            startTemp.toLocalDate());
    if (assign == null)
        errors.add("Assignment is not valid for start date " + TKUtils.formatDate(new LocalDate(startTime)));
    assign = HrServiceLocator.getAssignmentService().getAssignmentForTargetPrincipal(assignKey,
            endTemp.toLocalDate());
    if (assign == null)
        errors.add("Assignment is not valid for end date " + TKUtils.formatDate(new LocalDate(endTime)));
    if (errors.size() > 0)
        return errors;

    //------------------------
    // some of the simple validations are in the js side in order to reduce the server calls
    // 1. check if the begin / end time is empty - tk.calenadr.js
    // 2. check the time format - timeparse.js
    // 3. only allows decimals to be entered in the hour field
    //------------------------

    //------------------------
    // check if the overnight shift is across days
    //------------------------
    if (acrossDays && hours == null && amount == null) {
        if (savedEndDate.isAfter(savedStartDate) && startTemp.getHourOfDay() > endTemp.getHourOfDay()
                && !(endTemp.getDayOfYear() - startTemp.getDayOfYear() <= 1 && endTemp.getHourOfDay() == 0)) {
            errors.add("The \"apply to each day\" box should not be checked.");
        }
    }
    if (errors.size() > 0)
        return errors;

    //------------------------
    // check if the begin / end time are valid
    //------------------------
    if ((startTime.compareTo(endTime) > 0 || endTime.compareTo(startTime) < 0)) {
        errors.add("The time or date is not valid.");
    }
    if (errors.size() > 0)
        return errors;

    // KPME-1446 
    // -------------------------------
    // check if there is a weekend day when the include weekends flag is checked
    //--------------------------------

    //------------------------
    // Amount cannot be zero
    //------------------------
    if (amount != null && earnCode != null
            && StringUtils.equals(earnCode.getEarnCodeType(), HrConstants.EARN_CODE_AMOUNT)) {
        if (amount.equals(BigDecimal.ZERO)) {
            errors.add("Amount cannot be zero.");
        }
        if (amount.scale() > 2) {
            errors.add("Amount cannot have more than two digits after decimal point.");
        }
    }
    if (errors.size() > 0)
        return errors;

    //------------------------
    // check if the hours entered for hourly earn code is greater than 24 hours per day
    // Hours cannot be zero
    //------------------------
    if (hours != null && earnCode != null
            && StringUtils.equals(earnCode.getEarnCodeType(), HrConstants.EARN_CODE_HOUR)) {
        if (hours.equals(BigDecimal.ZERO)) {
            errors.add("Hours cannot be zero.");
        }
        if (hours.scale() > 2) {
            errors.add("Hours cannot have more than two digits after decimal point.");
        }
        /*
         * KPME-2671:
         * 
         * Replacing this conditional with the one below. Shouldn't matter if the date range spans more than one day,
         * hours shouldn't exceed 24.
         * 
         *          int dayDiff = endTemp.getDayOfYear() - startTemp.getDayOfYear() + 1;
                    if (hours.compareTo(new BigDecimal(dayDiff * 24)) == 1) {
        errors.add("Cannot enter more than 24 hours per day.");
                    }
         */
    }
    if (errors.size() > 0)
        return errors;

    /**
     * KPME-2671:
     * 
     * Generalize 24 limit to hour field on time entry form.
     * 
     */
    if (hours != null && hours.compareTo(new BigDecimal(24.0)) > 0) {
        errors.add("Hours cannot exceed 24.");
    }
    //------------------------
    // check if time blocks overlap with each other. Note that the tkTimeBlockId is used to
    // determine is it's updating an existing time block or adding a new one
    //------------------------

    boolean isRegularEarnCode = StringUtils.equals(assign.getJob().getPayTypeObj().getRegEarnCode(),
            selectedEarnCode);
    startTime = TKUtils.convertDateStringToDateTime(startDateS, startTimeS).getMillis();
    endTime = TKUtils.convertDateStringToDateTime(endDateS, endTimeS).getMillis();

    errors.addAll(validateOverlap(startTime, endTime, acrossDays, startDateS, endTimeS, startTemp, endTemp,
            timesheetDocument, timeblockId, isRegularEarnCode, selectedEarnCode));
    if (errors.size() > 0)
        return errors;

    // Accrual Hour Limits Validation
    //errors.addAll(TkServiceLocator.getTimeOffAccrualService().validateAccrualHoursLimitByEarnCode(timesheetDocument, selectedEarnCode));

    return errors;
}

From source file:org.egov.restapi.service.BillService.java

private void validateDetails(final BillRegister billRegister, final List<RestErrors> errors) {
    RestErrors restErrors;//from   w  w  w .  j  av a2  s . co  m
    Accountdetailtype projectCodeAccountDetailType = null;
    Boolean isProjectCodeSubledger = false;
    boolean foundNetPayable = false;
    final List<CChartOfAccounts> contractorPayableAccountList = chartOfAccountsHibernateDAO
            .getAccountCodeByPurposeName(WorksConstants.CONTRACTOR_NETPAYABLE_PURPOSE);
    final List<CChartOfAccounts> advancePayableAccountList = chartOfAccountsHibernateDAO
            .getAccountCodeByPurposeName(RestApiConstants.CONTRACTOR_ADVANCE_PURPOSE);
    BigDecimal creditAmount = BigDecimal.ZERO;
    BigDecimal debitAmount = BigDecimal.ZERO;
    for (final BillDetails billDetails : billRegister.getBillDetails())
        if (StringUtils.isBlank(billDetails.getGlcode())) {
            restErrors = new RestErrors();
            restErrors.setErrorCode(RestApiConstants.THIRD_PARTY_ERR_CODE_NO_DETAIL_GLCODE);
            restErrors.setErrorMessage(RestApiConstants.THIRD_PARTY_ERR_MSG_NO_DETAIL_GLCODE);
            errors.add(restErrors);
        } else {
            final CChartOfAccounts coa = chartOfAccountsService.getByGlCode(billDetails.getGlcode());
            if (coa == null) {
                restErrors = new RestErrors();
                restErrors.setErrorCode(RestApiConstants.THIRD_PARTY_ERR_CODE_NO_VALID_GLCODE);
                restErrors.setErrorMessage(
                        billDetails.getGlcode() + " - " + RestApiConstants.THIRD_PARTY_ERR_MSG_NO_VALID_GLCODE);
                errors.add(restErrors);
            } else if (coa.getClassification() != 4) {
                restErrors = new RestErrors();
                restErrors.setErrorCode(RestApiConstants.THIRD_PARTY_ERR_CODE_NO_VALID_DETAIL_GLCODE);
                restErrors.setErrorMessage(billDetails.getGlcode() + " - "
                        + RestApiConstants.THIRD_PARTY_ERR_MSG_NO_VALID_DETAIL_GLCODE);
                errors.add(restErrors);
            }
            if (billDetails.getDebitAmount() == null && billDetails.getCreditAmount() == null) {
                restErrors = new RestErrors();
                restErrors.setErrorCode(RestApiConstants.THIRD_PARTY_ERR_CODE_EITHER_CREDIT_DEBIT);
                restErrors.setErrorMessage(RestApiConstants.THIRD_PARTY_ERR_MSG_EITHER_CREDIT_DEBIT);
                errors.add(restErrors);
            } else if (billDetails.getCreditAmount() != null && billDetails.getDebitAmount() != null
                    && billDetails.getCreditAmount().doubleValue() > 0
                    && billDetails.getDebitAmount().doubleValue() > 0) {
                restErrors = new RestErrors();
                restErrors.setErrorCode(RestApiConstants.THIRD_PARTY_ERR_CODE_CREDIT_DEBIT_GREATER_ZERO);
                restErrors.setErrorMessage(RestApiConstants.THIRD_PARTY_ERR_MSG_CREDIT_DEBIT_GREATER_ZERO);
                errors.add(restErrors);
            }
            if (billDetails.getCreditAmount() == null
                    && billDetails.getDebitAmount().compareTo(BigDecimal.ZERO) <= 0) {
                restErrors = new RestErrors();
                restErrors.setErrorCode(RestApiConstants.THIRD_PARTY_ERR_CODE_AMOUNT_SHOULD_GREATER_THAN_ZERO);
                restErrors
                        .setErrorMessage(RestApiConstants.THIRD_PARTY_ERR_MSG_AMOUNT_SHOULD_GREATER_THAN_ZERO);
                errors.add(restErrors);
            }
            if (billDetails.getDebitAmount() != null
                    && billDetails.getDebitAmount().compareTo(BigDecimal.ZERO) > 0) {
                debitAmount = debitAmount.add(billDetails.getDebitAmount());

                if (coa != null)
                    projectCodeAccountDetailType = chartOfAccountsHibernateDAO
                            .getAccountDetailTypeIdByName(coa.getGlcode(), WorksConstants.PROJECTCODE);
                if (projectCodeAccountDetailType != null)
                    isProjectCodeSubledger = true;

                if (coa != null && !coa.getChartOfAccountDetails().isEmpty()) {
                    Boolean isProjectContractorSubLedger = false;
                    final Set<CChartOfAccountDetail> chartOfAccountDetails = coa.getChartOfAccountDetails();
                    for (final CChartOfAccountDetail detail : chartOfAccountDetails)
                        if (detail.getDetailTypeId().getName().equals(WorksConstants.PROJECTCODE)
                                || detail.getDetailTypeId().getName()
                                        .equals(WorksConstants.ACCOUNTDETAIL_TYPE_CONTRACTOR))
                            isProjectContractorSubLedger = true;
                    if (!isProjectContractorSubLedger) {
                        restErrors = new RestErrors();
                        restErrors.setErrorCode(
                                RestApiConstants.THIRD_PARTY_ERR_CODE_NOT_PROJECT_CONTRACTOR_SUBLEDGER);
                        restErrors.setErrorMessage(coa.getGlcode() + " - "
                                + RestApiConstants.THIRD_PARTY_ERR_MSG_NOT_PROJECT_CONTRACTOR_SUBLEDGER);
                        errors.add(restErrors);
                    }
                }
            } else if (billDetails.getCreditAmount() != null) {
                creditAmount = creditAmount.add(billDetails.getCreditAmount());
                if (advancePayableAccountList.contains(coa) || contractorPayableAccountList.contains(coa))
                    foundNetPayable = true;
                if (contractorPayableAccountList != null && !contractorPayableAccountList.isEmpty()
                        && contractorPayableAccountList.contains(coa)
                        && billDetails.getCreditAmount().compareTo(BigDecimal.ZERO) == -1) {
                    restErrors = new RestErrors();
                    restErrors.setErrorCode(RestApiConstants.THIRD_PARTY_ERR_CODE_AMOUNT_NEGATIVE);
                    restErrors.setErrorMessage(RestApiConstants.THIRD_PARTY_ERR_MSG_AMOUNT_NEGATIVE);
                    errors.add(restErrors);
                } else if (billDetails.getDebitAmount() == null
                        && billDetails.getCreditAmount().compareTo(BigDecimal.ZERO) <= 0) {
                    restErrors = new RestErrors();
                    restErrors.setErrorCode(
                            RestApiConstants.THIRD_PARTY_ERR_CODE_AMOUNT_SHOULD_GREATER_THAN_ZERO);
                    restErrors.setErrorMessage(
                            RestApiConstants.THIRD_PARTY_ERR_MSG_AMOUNT_SHOULD_GREATER_THAN_ZERO);
                    errors.add(restErrors);
                }
            }
        }
    if (!isProjectCodeSubledger) {
        restErrors = new RestErrors();
        restErrors.setErrorCode(RestApiConstants.THIRD_PARTY_ERR_CODE_NO_DEBIT_CODE_SUBLEDGER);
        restErrors.setErrorMessage(RestApiConstants.THIRD_PARTY_ERR_MSG_NO_DEBIT_CODE_SUBLEDGER);
        errors.add(restErrors);
    }
    if (!creditAmount.equals(debitAmount)) {
        restErrors = new RestErrors();
        restErrors.setErrorCode(RestApiConstants.THIRD_PARTY_ERR_CODE_NOTEQUAL_CREDIT_DEBIT);
        restErrors.setErrorMessage(RestApiConstants.THIRD_PARTY_ERR_MSG_NOTEQUAL_CREDIT_DEBIT);
        errors.add(restErrors);
    }
    if (!foundNetPayable) {
        restErrors = new RestErrors();
        restErrors.setErrorCode(RestApiConstants.THIRD_PARTY_ERR_CODE_NOT_ADVANCE_CONTRACTOR_PAYABLE);
        restErrors.setErrorMessage(RestApiConstants.THIRD_PARTY_ERR_MSG_NOT_ADVANCE_CONTRACTOR_PAYABLE);
        errors.add(restErrors);
    }
}

From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java

public void onListTipoConocimientoChangeWiki(AjaxBehaviorEvent event) {
    try {/*from ww w  .  j  ava 2  s .co m*/
        if (event != null) {
            final BigDecimal id = (BigDecimal) ((SelectOneMenu) event.getSource()).getValue();
            this.setIdTipoConocimiento(id);
            if (id != null) {
                HashMap filters = new HashMap();
                filters.put("ntipoconocimientoid", id);
                ConocimientoService service = (ConocimientoService) ServiceFinder
                        .findBean("ConocimientoService");
                if (this.getSelectedWiki() != null) {
                    filters.put("nconocimientoid", this.getSelectedWiki().getNconocimientoid().toString());
                    this.setListaTargetVinculos(new ArrayList());
                    List<Consulta> lista = service.getConcimientosVinculados(filters);
                    Collections.sort(lista, Consulta.Comparators.ID);
                    if (id.equals(Constante.BASELEGAL)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosBL(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosBL().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL());
                    } else if (id.equals(Constante.PREGUNTAS)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosPR(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosPR().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR());
                    } else if (id.equals(Constante.WIKI)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosWK(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosWK().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK());
                    } else if (id.equals(Constante.CONTENIDO)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosCT(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosCT().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT());
                    } else if (id.equals(Constante.BUENAPRACTICA)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosBP(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosBP().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP());
                    } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosOM(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosOM().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM());
                    }
                } else {
                    if (id.equals(Constante.BASELEGAL)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosBL());
                    } else if (id.equals(Constante.PREGUNTAS)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosPR());
                    } else if (id.equals(Constante.WIKI)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosWK());
                    } else if (id.equals(Constante.CONTENIDO)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosCT());
                    } else if (id.equals(Constante.BUENAPRACTICA)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosBP());
                    } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosOM());
                    }
                }
                if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) {
                    List<String> ids = new ArrayList<String>();
                    for (Consulta c : this.getListaTargetVinculos()) {
                        ids.add(c.getIdconocimiento().toString());
                    }
                    String filter = StringUtils.join(ids, ',');
                    if (id.equals(Constante.WIKI)) {
                        filter = filter.concat(",")
                                .concat(this.getSelectedWiki().getNconocimientoid().toString());
                    }
                    filters.put("nconocimientovinc", filter);
                }
                if (id.equals(Constante.BASELEGAL)) {
                    this.setListaSourceVinculosBL(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosBL());
                } else if (id.equals(Constante.PREGUNTAS)) {
                    this.setListaSourceVinculosPR(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosPR());
                } else if (id.equals(Constante.WIKI)) {
                    this.setListaSourceVinculosWK(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosWK());
                } else if (id.equals(Constante.CONTENIDO)) {
                    this.setListaSourceVinculosCT(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosCT());
                } else if (id.equals(Constante.BUENAPRACTICA)) {
                    this.setListaSourceVinculosBP(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosBP());
                } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                    this.setListaSourceVinculosOM(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosOM());
                }
                this.setPickListWiki(new DualListModel<Consulta>(this.getListaSourceVinculos(),
                        this.getListaTargetVinculos()));
            }
        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}

From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java

public void onListTipoConocimientoChangeOmejora(AjaxBehaviorEvent event) {
    try {//  www .  j  a  v  a 2 s.c  om
        if (event != null) {
            final BigDecimal id = (BigDecimal) ((SelectOneMenu) event.getSource()).getValue();
            this.setIdTipoConocimiento(id);
            if (id != null) {
                HashMap filters = new HashMap();
                filters.put("ntipoconocimientoid", id);
                ConocimientoService service = (ConocimientoService) ServiceFinder
                        .findBean("ConocimientoService");
                if (this.getSelectedOmejora() != null) {
                    filters.put("nconocimientoid", this.getSelectedOmejora().getNconocimientoid().toString());
                    this.setListaTargetVinculos(new ArrayList());
                    List<Consulta> lista = service.getConcimientosVinculados(filters);
                    Collections.sort(lista, Consulta.Comparators.ID);
                    if (id.equals(Constante.BASELEGAL)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosBL(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosBL().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL());
                    } else if (id.equals(Constante.PREGUNTAS)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosPR(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosPR().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR());
                    } else if (id.equals(Constante.WIKI)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosWK(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosWK().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK());
                    } else if (id.equals(Constante.CONTENIDO)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosCT(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosCT().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT());
                    } else if (id.equals(Constante.BUENAPRACTICA)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosBP(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosBP().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP());
                    } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosOM(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosOM().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM());
                    }
                } else {
                    if (id.equals(Constante.BASELEGAL)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosBL());
                    } else if (id.equals(Constante.PREGUNTAS)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosPR());
                    } else if (id.equals(Constante.WIKI)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosWK());
                    } else if (id.equals(Constante.CONTENIDO)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosCT());
                    } else if (id.equals(Constante.BUENAPRACTICA)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosBP());
                    } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosOM());
                    }
                }
                if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) {
                    List<String> ids = new ArrayList<String>();
                    for (Consulta c : this.getListaTargetVinculos()) {
                        ids.add(c.getIdconocimiento().toString());
                    }
                    String filter = StringUtils.join(ids, ',');
                    if (id.equals(Constante.WIKI)) {
                        filter = filter.concat(",")
                                .concat(this.getSelectedOmejora().getNconocimientoid().toString());
                    }
                    filters.put("nconocimientovinc", filter);
                }
                if (id.equals(Constante.BASELEGAL)) {
                    this.setListaSourceVinculosBL(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosBL());
                } else if (id.equals(Constante.PREGUNTAS)) {
                    this.setListaSourceVinculosPR(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosPR());
                } else if (id.equals(Constante.WIKI)) {
                    this.setListaSourceVinculosWK(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosWK());
                } else if (id.equals(Constante.CONTENIDO)) {
                    this.setListaSourceVinculosCT(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosCT());
                } else if (id.equals(Constante.BUENAPRACTICA)) {
                    this.setListaSourceVinculosBP(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosBP());
                } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                    this.setListaSourceVinculosOM(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosOM());
                }
                this.setPickListOmejora(new DualListModel<Consulta>(this.getListaSourceVinculos(),
                        this.getListaTargetVinculos()));
            }
        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}

From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java

public void onListTipoConocimientoChangeBpractica(AjaxBehaviorEvent event) {
    try {/*  w  w  w .  ja  va  2s . c om*/
        if (event != null) {
            final BigDecimal id = (BigDecimal) ((SelectOneMenu) event.getSource()).getValue();
            this.setIdTipoConocimiento(id);
            if (id != null) {
                HashMap filters = new HashMap();
                filters.put("ntipoconocimientoid", id);
                ConocimientoService service = (ConocimientoService) ServiceFinder
                        .findBean("ConocimientoService");
                if (this.getSelectedBpractica() != null) {
                    filters.put("nconocimientoid", this.getSelectedBpractica().getNconocimientoid().toString());
                    this.setListaTargetVinculos(new ArrayList());
                    List<Consulta> lista = service.getConcimientosVinculados(filters);
                    Collections.sort(lista, Consulta.Comparators.ID);
                    if (id.equals(Constante.BASELEGAL)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosBL(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosBL().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL());
                    } else if (id.equals(Constante.PREGUNTAS)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosPR(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosPR().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR());
                    } else if (id.equals(Constante.WIKI)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosWK(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosWK().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK());
                    } else if (id.equals(Constante.CONTENIDO)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosCT(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosCT().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT());
                    } else if (id.equals(Constante.BUENAPRACTICA)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosBP(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosBP().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP());
                    } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosOM(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosOM().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM());
                    }
                } else {
                    if (id.equals(Constante.BASELEGAL)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosBL());
                    } else if (id.equals(Constante.PREGUNTAS)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosPR());
                    } else if (id.equals(Constante.WIKI)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosWK());
                    } else if (id.equals(Constante.CONTENIDO)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosCT());
                    } else if (id.equals(Constante.BUENAPRACTICA)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosBP());
                    } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosOM());
                    }
                }
                if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) {
                    List<String> ids = new ArrayList<String>();
                    for (Consulta c : this.getListaTargetVinculos()) {
                        ids.add(c.getIdconocimiento().toString());
                    }
                    String filter = StringUtils.join(ids, ',');
                    if (id.equals(Constante.WIKI)) {
                        filter = filter.concat(",")
                                .concat(this.getSelectedBpractica().getNconocimientoid().toString());
                    }
                    filters.put("nconocimientovinc", filter);
                }
                if (id.equals(Constante.BASELEGAL)) {
                    this.setListaSourceVinculosBL(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosBL());
                } else if (id.equals(Constante.PREGUNTAS)) {
                    this.setListaSourceVinculosPR(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosPR());
                } else if (id.equals(Constante.WIKI)) {
                    this.setListaSourceVinculosWK(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosWK());
                } else if (id.equals(Constante.CONTENIDO)) {
                    this.setListaSourceVinculosCT(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosCT());
                } else if (id.equals(Constante.BUENAPRACTICA)) {
                    this.setListaSourceVinculosBP(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosBP());
                } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                    this.setListaSourceVinculosOM(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosOM());
                }
                this.setPickListBpractica(new DualListModel<Consulta>(this.getListaSourceVinculos(),
                        this.getListaTargetVinculos()));
            }
        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}

From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java

public void onListTipoConocimientoChangeCT(AjaxBehaviorEvent event) {
    try {// www. j  a  v  a  2s .  c om
        if (event != null) {
            final BigDecimal id = (BigDecimal) ((SelectOneMenu) event.getSource()).getValue();
            this.setIdTipoConocimiento(id);
            if (id != null) {
                HashMap filters = new HashMap();
                filters.put("ntipoconocimientoid", id);
                ConocimientoService service = (ConocimientoService) ServiceFinder
                        .findBean("ConocimientoService");
                if (this.getSelectedContenido() != null) {
                    filters.put("nconocimientoid", this.getSelectedContenido().getNconocimientoid().toString());
                    this.setListaTargetVinculos(new ArrayList());
                    List<Consulta> lista = service.getConcimientosVinculados(filters);
                    Collections.sort(lista, Consulta.Comparators.ID);
                    if (id.equals(Constante.BASELEGAL)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosBL(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosBL().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL());
                    } else if (id.equals(Constante.PREGUNTAS)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosPR(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosPR().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR());
                    } else if (id.equals(Constante.WIKI)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosWK(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosWK().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK());
                    } else if (id.equals(Constante.CONTENIDO)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosCT(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosCT().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT());
                    } else if (id.equals(Constante.BUENAPRACTICA)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosBP(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosBP().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP());
                    } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosOM(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosOM().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM());
                    }
                } else {
                    if (id.equals(Constante.BASELEGAL)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosBL());
                    } else if (id.equals(Constante.PREGUNTAS)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosPR());
                    } else if (id.equals(Constante.WIKI)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosWK());
                    } else if (id.equals(Constante.CONTENIDO)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosCT());
                    } else if (id.equals(Constante.BUENAPRACTICA)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosBP());
                    } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosOM());
                    }
                }
                if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) {
                    List<String> ids = new ArrayList<String>();
                    for (Consulta c : this.getListaTargetVinculos()) {
                        ids.add(c.getIdconocimiento().toString());
                    }
                    String filter = StringUtils.join(ids, ',');
                    if (id.equals(Constante.WIKI)) {
                        filter = filter.concat(",")
                                .concat(this.getSelectedContenido().getNconocimientoid().toString());
                    }
                    filters.put("nconocimientovinc", filter);
                }
                if (id.equals(Constante.BASELEGAL)) {
                    this.setListaSourceVinculosBL(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosBL());
                } else if (id.equals(Constante.PREGUNTAS)) {
                    this.setListaSourceVinculosPR(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosPR());
                } else if (id.equals(Constante.WIKI)) {
                    this.setListaSourceVinculosWK(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosWK());
                } else if (id.equals(Constante.CONTENIDO)) {
                    this.setListaSourceVinculosCT(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosCT());
                } else if (id.equals(Constante.BUENAPRACTICA)) {
                    this.setListaSourceVinculosBP(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosBP());
                } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                    this.setListaSourceVinculosOM(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosOM());
                }
                this.setPickListContenido(new DualListModel<Consulta>(this.getListaSourceVinculos(),
                        this.getListaTargetVinculos()));
            }
        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}

From source file:pe.gob.mef.gescon.web.ui.PendienteMB.java

public void onListTipoConocimientoChange(AjaxBehaviorEvent event) {
    try {/* w w w  .j a v a2s .co m*/
        if (event != null) {
            final BigDecimal id = (BigDecimal) ((SelectOneMenu) event.getSource()).getValue();
            this.setIdTipoConocimiento(id);
            if (id != null) {
                HashMap filters = new HashMap();
                filters.put("ntipoconocimientoid", id);
                filters.put("npreguntaid", this.getSelectedPregunta().getNpreguntaid());
                PreguntaService service = (PreguntaService) ServiceFinder.findBean("PreguntaService");
                if (this.getSelectedPregunta() != null) {
                    filters.put("nconocimientoid", this.getSelectedPregunta().getNpreguntaid().toString());
                    this.setListaTargetVinculos(new ArrayList());
                    List<Consulta> lista = service.getConcimientosVinculados(filters);
                    Collections.sort(lista, Consulta.Comparators.ID);
                    if (id.equals(Constante.BASELEGAL)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosBL(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosBL().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBL());
                    } else if (id.equals(Constante.PREGUNTAS)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosPR(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosPR().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosPR());
                    } else if (id.equals(Constante.WIKI)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosWK(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosWK().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosWK());
                    } else if (id.equals(Constante.CONTENIDO)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosCT(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosCT().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosCT());
                    } else if (id.equals(Constante.BUENAPRACTICA)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosBP(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosBP().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosBP());
                    } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                        for (Consulta ele : lista) {
                            int pos = Collections.binarySearch(this.getListaTargetVinculosOM(), ele,
                                    Consulta.Comparators.ID);
                            if (pos < 0) {
                                this.getListaTargetVinculosOM().add(ele);
                            }
                        }
                        this.getListaTargetVinculos().addAll(this.getListaTargetVinculosOM());
                    }
                } else {
                    if (id.equals(Constante.BASELEGAL)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosBL());
                    } else if (id.equals(Constante.PREGUNTAS)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosPR());
                    } else if (id.equals(Constante.WIKI)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosWK());
                    } else if (id.equals(Constante.CONTENIDO)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosCT());
                    } else if (id.equals(Constante.BUENAPRACTICA)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosBP());
                    } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                        this.setListaTargetVinculos(this.getListaTargetVinculosOM());
                    }
                }
                if (org.apache.commons.collections.CollectionUtils.isNotEmpty(this.getListaTargetVinculos())) {
                    List<String> ids = new ArrayList<String>();
                    for (Consulta c : this.getListaTargetVinculos()) {
                        ids.add(c.getIdconocimiento().toString());
                    }
                    String filter = StringUtils.join(ids, ',');
                    if (id.equals(Constante.WIKI)) {
                        filter = filter.concat(",")
                                .concat(this.getSelectedPregunta().getNpreguntaid().toString());
                    }
                    filters.put("nconocimientovinc", filter);
                }
                if (id.equals(Constante.BASELEGAL)) {
                    this.setListaSourceVinculosBL(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosBL());
                } else if (id.equals(Constante.PREGUNTAS)) {
                    this.setListaSourceVinculosPR(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosPR());
                } else if (id.equals(Constante.WIKI)) {
                    this.setListaSourceVinculosWK(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosWK());
                } else if (id.equals(Constante.CONTENIDO)) {
                    this.setListaSourceVinculosCT(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosCT());
                } else if (id.equals(Constante.BUENAPRACTICA)) {
                    this.setListaSourceVinculosBP(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosBP());
                } else if (id.equals(Constante.OPORTUNIDADMEJORA)) {
                    this.setListaSourceVinculosOM(service.getConcimientosDisponibles(filters));
                    this.setListaSourceVinculos(this.getListaSourceVinculosOM());
                }
                this.setPickListPregunta(new DualListModel<Consulta>(this.getListaSourceVinculos(),
                        this.getListaTargetVinculos()));
            }
        }
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
}