Example usage for java.lang Integer equals

List of usage examples for java.lang Integer equals

Introduction

In this page you can find the example usage for java.lang Integer equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:gov.nih.nci.cabig.caaers.web.ae.CreateAdverseEventAjaxFacade.java

public AjaxOutput deleteReviewComment(Integer commentId, String reportIdString) {
    Integer reportId = Integer.parseInt(reportIdString);
    //       ExpeditedAdverseEventInputCommand command = (ExpeditedAdverseEventInputCommand) extractCommand();
    String userId = getUserId();/*  w  ww .  j a va  2 s  . co  m*/
    Report report = null;
    if (reportId != null || !reportId.equals(""))
        report = reportDao.getById(reportId);
    //       Report report = null;
    //       for(Report r: command.getAeReport().getActiveReports())
    //          if(r.getId().equals(reportId))
    //             report = r;
    adverseEventRoutingAndReviewRepository.deleteReportReviewComment(report, commentId);
    return fetchPreviousComments(reportId, userId);
}

From source file:net.neurowork.cenatic.centraldir.workers.XMLRestWorker.java

private FormaJuridica importFormaJuridica(String xmlString, Integer id)
        throws ParserConfigurationException, SAXException, IOException {
    Document doc = XmlParserUtil.createDocumentFromString(xmlString);
    FormaJuridica ret = null;//w w w.ja v  a 2  s  .  com
    NodeList nodeLst = doc.getElementsByTagName("organizationType");

    for (int s = 0; s < nodeLst.getLength(); s++) {
        Node fstNode = nodeLst.item(s);
        if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
            Element elPDU = (Element) fstNode;
            String code = XmlParserUtil.getAttribute(elPDU, "code");
            NodeList fstNm = elPDU.getChildNodes();
            String organizationType = null;

            if (fstNm.getLength() > 0) {
                organizationType = ((Node) fstNm.item(0)).getNodeValue();

                Integer orgId = getId(code);
                FormaJuridica formaJuridica = null;
                try {
                    List<FormaJuridica> lFJ = formaJuridicaService.findByName(organizationType);

                    if (lFJ != null && lFJ.size() > 0) {
                        formaJuridica = lFJ.get(0);
                    } else {
                        formaJuridica = new FormaJuridica();
                        formaJuridica.setName(organizationType);
                        formaJuridicaService.save(formaJuridica);
                    }

                    if (orgId != null && orgId.equals(id)) {
                        ret = formaJuridica;
                    }
                } catch (ServiceException e) {
                    logger.error(e.getMessage());
                }
            }
        }
    }
    return ret;
}

From source file:com.alfaariss.oa.profile.saml2.profile.sso.protocol.AuthenticationRequestProtocol.java

private void resolveResponseTarget(AuthnRequest authnRequest, ISessionAttributes oAttributes)
        throws StatusException {
    String sAssertionConsumerServiceURL = authnRequest.getAssertionConsumerServiceURL();
    if (sAssertionConsumerServiceURL != null) {
        //The supplied value must associate with the requestor, 
        //it can be trusted if request is signed or value is available 
        //in SP metadata (saml-core-2.0-os r2061)
        if (!authnRequest.isSigned()) {
            if (_spSSODescriptor != null) {
                List<AssertionConsumerService> listACS = _spSSODescriptor.getAssertionConsumerServices();
                for (AssertionConsumerService acs : listACS) {
                    String sResponseLocation = acs.getResponseLocation();
                    if (sAssertionConsumerServiceURL.equals(acs.getLocation())) {
                        _sAssertionConsumerServiceURL = sResponseLocation;
                        if (_sAssertionConsumerServiceURL == null)
                            _sAssertionConsumerServiceURL = sAssertionConsumerServiceURL;
                        break;
                    } else if (sResponseLocation != null
                            && sAssertionConsumerServiceURL.equals(sResponseLocation)) {
                        _sAssertionConsumerServiceURL = sAssertionConsumerServiceURL;
                        break;
                    }/*from   w w  w.j  av  a 2 s.c o m*/
                }
            }

            if (_sAssertionConsumerServiceURL == null) {
                StringBuffer sbError = new StringBuffer("Can't trust AssertionConsumerServiceURL '");
                sbError.append(sAssertionConsumerServiceURL);
                sbError.append("' supplied in request: ");
                sbError.append(authnRequest.getID());
                _logger.debug(sbError.toString());
            }
        } else
            _sAssertionConsumerServiceURL = sAssertionConsumerServiceURL;
    }

    _sBindingURI = authnRequest.getProtocolBinding();

    if (_sAssertionConsumerServiceURL == null) {
        if (_spSSODescriptor == null) {
            _logger.error("No SPSSODescriptor in metadata: Can't resolve response target for request: "
                    + authnRequest.getID());

            throw new StatusException(RequestorEvent.REQUEST_INVALID, StatusCode.RESPONDER_URI);
        }

        Integer intAssertionConsumerServiceIndex = authnRequest.getAssertionConsumerServiceIndex();
        if (intAssertionConsumerServiceIndex != null) {
            List<AssertionConsumerService> listACS = _spSSODescriptor.getAssertionConsumerServices();
            if (listACS == null) {
                _logger.error(
                        "No AssertionConsumerServices in metadata for requestor: " + _session.getRequestorId());
                throw new StatusException(RequestorEvent.REQUEST_INVALID, StatusCode.RESPONDER_URI);
            }

            AssertionConsumerService acs = null;

            for (AssertionConsumerService acsCandidate : listACS) {
                if (intAssertionConsumerServiceIndex.equals(acsCandidate.getIndex())) {
                    acs = acsCandidate;
                    break;
                }
            }

            if (acs == null) {
                StringBuffer sbError = new StringBuffer("Invalid AssertionConsumerServiceIndex '");
                sbError.append(intAssertionConsumerServiceIndex);
                sbError.append("' supplied in request: ");
                sbError.append(authnRequest.getID());
                _logger.error(sbError.toString());

                throw new StatusException(RequestorEvent.REQUEST_INVALID, StatusCode.RESPONDER_URI);
            }

            _sAssertionConsumerServiceURL = acs.getResponseLocation();
            if (_sAssertionConsumerServiceURL == null) {
                _sAssertionConsumerServiceURL = acs.getLocation();
                _logger.debug("No 'ResponseLocation' found, using Location: " + _sAssertionConsumerServiceURL);
            }
            _sBindingURI = acs.getBinding();
        } else {
            AssertionConsumerService acs = _spSSODescriptor.getDefaultAssertionConsumerService();
            if (acs == null) {
                _logger.error("No default AssertionConsumerServices in metadata for requestor: "
                        + _session.getRequestorId());
                throw new StatusException(RequestorEvent.REQUEST_INVALID, StatusCode.RESPONDER_URI);
            }

            _sAssertionConsumerServiceURL = acs.getResponseLocation();
            if (_sAssertionConsumerServiceURL == null) {
                _sAssertionConsumerServiceURL = acs.getLocation();
                _logger.error("No 'ResponseLocation' found, using Location: " + _sAssertionConsumerServiceURL);
            }
            _sBindingURI = acs.getBinding();
        }
    }

    if (_sAssertionConsumerServiceURL != null) {
        oAttributes.put(AuthenticationRequestProtocol.class, SESSION_REQUEST_ASSERTION_CONSUMER_SERVICE_URL,
                _sAssertionConsumerServiceURL);

        _logger.debug("AssertionConsumerServiceURL: " + _sAssertionConsumerServiceURL);
    } else {
        _logger.error("No AssertionConsumerServiceURL as target for response available for request: "
                + authnRequest.getID());
        throw new StatusException(RequestorEvent.REQUEST_INVALID, StatusCode.RESPONDER_URI);
    }

    if (_sBindingURI != null) {
        oAttributes.put(AuthenticationRequestProtocol.class, SESSION_REQUEST_PROTOCOLBINDING, _sBindingURI);

        _logger.debug("ProtocolBinding: " + _sBindingURI);
    } else {
        _logger.error("No ProtocolBinding for response available for request: " + authnRequest.getID());
        throw new StatusException(RequestorEvent.REQUEST_INVALID, StatusCode.RESPONDER_URI);
    }
}

From source file:edu.upenn.cis.orchestra.workloadgenerator.Generator.java

public void deletePeers(int numberOfPeersToDelete) {
    Set<Integer> peersToDelete = new HashSet<Integer>(numberOfPeersToDelete);
    List<Integer> candidatePeersToDelete = new LinkedList<Integer>();

    for (int i = 0; i < _previousGeneration.getPeers().size(); i++) {
        if (null != _previousGeneration.getPeers().get(i)) {
            candidatePeersToDelete.add(i);
        }/*w  w w.  j a  va  2  s . c om*/
    }
    while (peersToDelete.size() < numberOfPeersToDelete && candidatePeersToDelete.size() > 0) {
        peersToDelete.add(candidatePeersToDelete.remove(_random.nextInt(candidatePeersToDelete.size())));
    }
    for (Integer peerToDelete : peersToDelete) {
        // _logicalSchemas.set(_peers.get(peerToDelete.intValue()), null);
        _peers.set(peerToDelete.intValue(), null);
        for (int i = 0; i < _mappings.size(); i++) {
            List<Object> mapping = _mappings.get(i);
            if (peerToDelete.equals(getSource(mapping)) || peerToDelete.equals(getTarget(mapping))) {
                _mappings.set(i, null);
            }
        }
        _journal.deletePeer(_generation, peerToDelete);
    }
}

From source file:it.drwolf.ridire.session.JobManager.java

public boolean filterStatus(Object current) {
    if (this.filterStatusValue == null || this.filterStatusValue < 0) {
        return true;
    }//from  w w  w.j  a  v  a 2  s . c om
    Job j = (Job) current;
    Integer statusId = this.allStatusMap.get(j.getJobStage());
    if (statusId == null || statusId.equals(this.filterStatusValue)) {
        return true;
    }
    return false;
}

From source file:edu.ucla.cs.scai.canali.core.index.BuildIndex.java

private void loadClassHierarchy() throws Exception {
    System.out.println("Loading class parents and building the hierarchy");
    //firs, we initialize class parents
    classParents = new HashSet[classIdFromUri.size() + 1];
    for (int i = 1; i < classParents.length; i++) {
        classParents[i] = new HashSet<>();
        //we don't initialize class ancestors because the null value is used to check if the class has not been processed yet
    }//from   www  .  j a va 2s .c  o  m
    try (BufferedReader in = new BufferedReader(new FileReader(basePathInput + "class_parents"))) {
        String l = in.readLine();
        while (l != null) {
            if (l.length() > 0) {
                StringTokenizer st = new StringTokenizer(l, "\t<>");
                String claz = st.nextToken().trim();
                String parent = st.nextToken().trim();
                //we are interested only in the hierarchical relationships between
                //classes defined inside our ontology
                Integer cId = classIdFromUri.get(claz);
                Integer pId = classIdFromUri.get(parent);
                if (cId != null && pId != null && !pId.equals(cId)) {
                    classParents[cId].add(pId);
                }
            }
            l = in.readLine();
        }
        //now add Thing to empty sets of parents
        for (int cId = 1; cId < classParents.length; cId++) {
            if (classParents[cId].isEmpty()) {
                classParents[cId].add(thingId);
            }
        }
        classParents[thingId].clear();
        //now, for each class compute the set of its ancestors
        classAncestors = new HashSet[classIdFromUri.size() + 1];
        for (int cId = 1; cId < classAncestors.length; cId++) {
            computeClassAncestors(cId);
        }
        //now, reduce the set of class parents, by keeping only the most specific classes
        for (int cId = 1; cId < classParents.length; cId++) {
            HashSet<Integer> currentParents = classParents[cId];
            HashSet<Integer> reducedParents = new HashSet<>();
            for (Integer pId : currentParents) {
                //check if reducedParents contains an ancestor of parent,
                //or if parent is an ancestor of any class in reducedParents
                boolean add = true;
                for (Iterator<Integer> it = reducedParents.iterator(); it.hasNext();) {
                    Integer c = it.next();
                    if (classAncestors[c].contains(pId)) {
                        add = false; //we don't add parent, beacause c is a descendant of parent
                        break;
                    } else if (classAncestors[pId].contains(c)) {
                        it.remove(); //we remove c beacause parent is a descendant of c
                    }
                }
                if (add) {
                    reducedParents.add(pId);
                }
            }
            classParents[cId] = reducedParents;
        }
        //now, compute the class children for each class
        classChildren = new HashSet[classIdFromUri.size() + 1];
        for (int cId = 1; cId < classChildren.length; cId++) {
            classChildren[cId] = new HashSet<>();
        }
        for (int cId = 1; cId < classParents.length; cId++) {
            for (Integer pId : classParents[cId]) {
                classChildren[pId].add(cId);
            }
        }
        //now compute the class descendants for each class
        classDescendants = new HashSet[classIdFromUri.size() + 1];
        for (int cId = 1; cId < classDescendants.length; cId++) {
            computeClassDescendants(cId);
        }
    }
}

From source file:com.cloud.hypervisor.vmware.mo.HypervisorHostHelper.java

private static void setupPVlanPair(DistributedVirtualSwitchMO dvSwitchMo, ManagedObjectReference morDvSwitch,
        Integer vid, Integer spvlanid) throws Exception {
    Map<Integer, HypervisorHostHelper.PvlanType> vlanmap = dvSwitchMo.retrieveVlanPvlan(vid, spvlanid,
            morDvSwitch);//from   www. j a  va 2  s  .  co m
    if (!vlanmap.isEmpty()) {
        // Then either vid or pvlanid or both are already being used. Check how.
        // First the primary pvlan id.
        if (vlanmap.containsKey(vid) && !vlanmap.get(vid).equals(HypervisorHostHelper.PvlanType.promiscuous)) {
            // This VLAN ID is already setup as a non-promiscuous vlan id on the DVS. Throw an exception.
            String msg = "Specified primary PVLAN ID " + vid + " is already in use as a "
                    + vlanmap.get(vid).toString() + " VLAN on the DVSwitch";
            s_logger.error(msg);
            throw new Exception(msg);
        }
        // Next the secondary pvlan id.
        if (spvlanid.equals(vid)) {
            if (vlanmap.containsKey(spvlanid)
                    && !vlanmap.get(spvlanid).equals(HypervisorHostHelper.PvlanType.promiscuous)) {
                String msg = "Specified secondary PVLAN ID " + spvlanid + " is already in use as a "
                        + vlanmap.get(spvlanid).toString() + " VLAN in the DVSwitch";
                s_logger.error(msg);
                throw new Exception(msg);
            }
        } else {
            if (vlanmap.containsKey(spvlanid)
                    && !vlanmap.get(spvlanid).equals(HypervisorHostHelper.PvlanType.isolated)) {
                // This PVLAN ID is already setup as a non-isolated vlan id on the DVS. Throw an exception.
                String msg = "Specified secondary PVLAN ID " + spvlanid + " is already in use as a "
                        + vlanmap.get(spvlanid).toString() + " VLAN in the DVSwitch";
                s_logger.error(msg);
                throw new Exception(msg);
            }
        }
    }

    // First create a DVSconfig spec.
    VMwareDVSConfigSpec dvsSpec = new VMwareDVSConfigSpec();
    // Next, add the required primary and secondary vlan config specs to the dvs config spec.
    if (!vlanmap.containsKey(vid)) {
        VMwareDVSPvlanConfigSpec ppvlanConfigSpec = createDVPortPvlanConfigSpec(vid, vid, PvlanType.promiscuous,
                PvlanOperation.add);
        dvsSpec.getPvlanConfigSpec().add(ppvlanConfigSpec);
    }
    if (!vid.equals(spvlanid) && !vlanmap.containsKey(spvlanid)) {
        VMwareDVSPvlanConfigSpec spvlanConfigSpec = createDVPortPvlanConfigSpec(vid, spvlanid,
                PvlanType.isolated, PvlanOperation.add);
        dvsSpec.getPvlanConfigSpec().add(spvlanConfigSpec);
    }

    if (dvsSpec.getPvlanConfigSpec().size() > 0) {
        // We have something to configure on the DVS... so send it the command.
        // When reconfiguring a vmware DVSwitch, we need to send in the configVersion in the spec.
        // Let's retrieve this switch's configVersion first.
        String dvsConfigVersion = dvSwitchMo.getDVSConfigVersion(morDvSwitch);
        dvsSpec.setConfigVersion(dvsConfigVersion);

        // Reconfigure the dvs using this spec.
        try {
            dvSwitchMo.updateVMWareDVSwitchGetTask(morDvSwitch, dvsSpec);
        } catch (AlreadyExistsFaultMsg e) {
            s_logger.info("Specified vlan id (" + vid + ") private vlan id (" + spvlanid
                    + ") tuple already configured on VMWare DVSwitch");
            // Do nothing, good if the tuple's already configured on the dvswitch.
        } catch (Exception e) {
            // Rethrow the exception
            s_logger.error("Failed to configure vlan/pvlan tuple on VMware DVSwitch: " + vid + "/" + spvlanid
                    + ", failure message: ", e);
            throw e;
        }
    }

}

From source file:com.gst.portfolio.loanaccount.loanschedule.service.LoanScheduleAssembler.java

public void assempleVariableScheduleFrom(final Loan loan, final String json) {
    this.variableLoanScheduleFromApiJsonValidator.validateSchedule(json, loan);

    List<LoanTermVariations> variations = loan.getLoanTermVariations();
    List<LoanTermVariations> newVariations = new ArrayList<>();
    extractLoanTermVariations(loan, json, newVariations);

    final Map<LocalDate, LocalDate> adjustDueDateVariations = new HashMap<>();

    if (!variations.isEmpty()) {
        List<LoanTermVariations> retainVariations = adjustExistingVariations(variations, newVariations,
                adjustDueDateVariations);
        newVariations = retainVariations;
    }// ww w .ja  v  a2s. com
    variations.addAll(newVariations);
    //Collections.sort(variations, new LoanTermVariationsComparator());

    /*
     * List<LoanTermVariationsData> loanTermVariationsDatas = new
     * ArrayList<>();
     * loanTermVariationsDatas.addAll(loanApplicationTerms.getLoanTermVariations
     * ().getExceptionData()); loanApplicationTerms =
     * LoanApplicationTerms.assembleFrom(loanApplicationTerms,
     * loanTermVariationsDatas);
     */

    // date validations
    List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
    Set<LocalDate> dueDates = new TreeSet<>();
    LocalDate graceApplicable = loan.getExpectedDisbursedOnLocalDate();
    Integer graceOnPrincipal = loan.getLoanProductRelatedDetail().graceOnPrincipalPayment();
    if (graceOnPrincipal == null) {
        graceOnPrincipal = 0;
    }
    LocalDate lastDate = loan.getExpectedDisbursedOnLocalDate();
    for (LoanRepaymentScheduleInstallment installment : installments) {
        dueDates.add(installment.getDueDate());
        if (lastDate.isBefore(installment.getDueDate())) {
            lastDate = installment.getDueDate();
        }
        if (graceOnPrincipal.equals(installment.getInstallmentNumber())) {
            graceApplicable = installment.getDueDate();
        }
    }
    Collection<LocalDate> keySet = adjustDueDateVariations.keySet();
    dueDates.addAll(keySet);
    for (final LocalDate date : keySet) {
        LocalDate removeDate = adjustDueDateVariations.get(date);
        if (removeDate != null) {
            dueDates.remove(removeDate);
        }
    }

    Set<LocalDate> actualDueDates = new TreeSet<>(dueDates);
    final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
    final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
            .resource("loan");
    List<LocalDate> overlappings = new ArrayList<>();
    for (LoanTermVariations termVariations : variations) {
        switch (termVariations.getTermType()) {
        case INSERT_INSTALLMENT:
            if (dueDates.contains(termVariations.fetchTermApplicaDate())) {
                overlappings.add(termVariations.fetchTermApplicaDate());
            } else {
                dueDates.add(termVariations.fetchTermApplicaDate());
            }
            if (!graceApplicable.isBefore(termVariations.fetchTermApplicaDate())) {
                baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                        "variable.schedule.insert.not.allowed.before.grace.period",
                        "Loan schedule insert request invalid");
            }
            if (termVariations.fetchTermApplicaDate().isAfter(lastDate)) {
                baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                        "variable.schedule.insert.not.allowed.after.last.period.date",
                        "Loan schedule insert request invalid");
            } else if (termVariations.fetchTermApplicaDate().isBefore(loan.getExpectedDisbursedOnLocalDate())) {
                baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                        "variable.schedule.insert.not.allowed.before.disbursement.date",
                        "Loan schedule insert request invalid");
            }
            break;
        case DELETE_INSTALLMENT:
            if (dueDates.contains(termVariations.fetchTermApplicaDate())) {
                dueDates.remove(termVariations.fetchTermApplicaDate());
            } else {
                baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                        "variable.schedule.remove.date.invalid", "Loan schedule remove request invalid");
            }
            if (termVariations.fetchTermApplicaDate().isEqual(lastDate)) {
                baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                        "variable.schedule.delete.not.allowed.for.last.period.date",
                        "Loan schedule remove request invalid");
            }
            break;
        case DUE_DATE:
            if (dueDates.contains(termVariations.fetchTermApplicaDate())) {

                if (overlappings.contains(termVariations.fetchTermApplicaDate())) {
                    overlappings.remove(termVariations.fetchTermApplicaDate());
                } else {
                    dueDates.remove(termVariations.fetchTermApplicaDate());
                }
            } else {
                baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                        "variable.schedule.modify.date.invalid",
                        "Loan schedule modify due date request invalid");
            }
            if (dueDates.contains(termVariations.fetchDateValue())) {
                overlappings.add(termVariations.fetchDateValue());
            } else {
                dueDates.add(termVariations.fetchDateValue());
            }
            if (termVariations.fetchDateValue().isBefore(loan.getExpectedDisbursedOnLocalDate())) {
                baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                        "variable.schedule.insert.not.allowed.before.disbursement.date",
                        "Loan schedule insert request invalid");
            }
            if (termVariations.fetchTermApplicaDate().isEqual(lastDate)) {
                lastDate = termVariations.fetchDateValue();
            }
            break;
        case PRINCIPAL_AMOUNT:
        case EMI_AMOUNT:
            if (!graceApplicable.isBefore(termVariations.fetchTermApplicaDate())) {
                baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                        "variable.schedule.amount.update.not.allowed.before.grace.period",
                        "Loan schedule modify request invalid");
            }
            if (!dueDates.contains(termVariations.fetchTermApplicaDate())) {
                baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                        "variable.schedule.amount.update.from.date.invalid",
                        "Loan schedule modify request invalid");
            }
            if (termVariations.fetchTermApplicaDate().isEqual(lastDate)) {
                baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                        "variable.schedule.amount.update.not.allowed.for.last.period",
                        "Loan schedule modify request invalid");
            }
            break;

        default:
            break;

        }

    }
    if (!overlappings.isEmpty()) {
        baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode(
                "variable.schedule.modify.date.can.not.be.due.date", overlappings);
    }
    LoanProductVariableInstallmentConfig installmentConfig = loan.loanProduct()
            .loanProductVariableInstallmentConfig();
    final CalendarInstance loanCalendarInstance = calendarInstanceRepository
            .findCalendarInstaneByEntityId(loan.getId(), CalendarEntityType.LOANS.getValue());
    Calendar loanCalendar = null;
    if (loanCalendarInstance != null) {
        loanCalendar = loanCalendarInstance.getCalendar();
    }
    Boolean isSkipRepaymentOnFirstMonth = false;
    Integer numberOfDays = 0;
    boolean isSkipRepaymentOnFirstMonthEnabled = configurationDomainService
            .isSkippingMeetingOnFirstDayOfMonthEnabled();
    if (isSkipRepaymentOnFirstMonthEnabled) {
        isSkipRepaymentOnFirstMonth = this.loanUtilService.isLoanRepaymentsSyncWithMeeting(loan.group(),
                loanCalendar);
        if (isSkipRepaymentOnFirstMonth) {
            numberOfDays = configurationDomainService.retreivePeroidInNumberOfDaysForSkipMeetingDate()
                    .intValue();
        }
    }
    final Integer minGap = installmentConfig.getMinimumGap();
    final Integer maxGap = installmentConfig.getMaximumGap();

    LocalDate previousDate = loan.getDisbursementDate();
    for (LocalDate duedate : dueDates) {
        int gap = Days.daysBetween(previousDate, duedate).getDays();
        previousDate = duedate;
        if (gap < minGap || (maxGap != null && gap > maxGap)) {
            baseDataValidator.reset().value(duedate).failWithCodeNoParameterAddedToErrorCode(
                    "variable.schedule.date.must.be.in.min.max.range", "Loan schedule date invalid");
        } else if (loanCalendar != null && !actualDueDates.contains(duedate)
                && !loanCalendar.isValidRecurringDate(duedate, isSkipRepaymentOnFirstMonth, numberOfDays)) {
            baseDataValidator.reset().value(duedate).failWithCodeNoParameterAddedToErrorCode(
                    "variable.schedule.date.not.meeting.date",
                    "Loan schedule date not in sync with meeting date");
        }
    }
    if (!dataValidationErrors.isEmpty()) {
        throw new PlatformApiDataValidationException(dataValidationErrors);
    }
    if (loan.getExpectedFirstRepaymentOnDate() == null) {
        loan.setExpectedFirstRepaymentOnDate(loan.fetchRepaymentScheduleInstallment(1).getDueDate().toDate());
    }
    final LocalDate recalculateFrom = null;
    ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan,
            recalculateFrom);
    AppUser currentUser = this.context.getAuthenticatedUserIfPresent();
    loan.regenerateRepaymentSchedule(scheduleGeneratorDTO, currentUser);
}

From source file:com.gst.infrastructure.dataqueries.service.ReadWriteNonCoreDataServiceImpl.java

private boolean isSurveyCategory(final Integer category) {
    return category.equals(DataTableApiConstant.CATEGORY_PPI);
}

From source file:com.aurel.track.exchange.excel.ExcelImportBL.java

/**
 * Return the lookup objectID based in the label
 * /*from   w  w  w  . ja v a2  s.c om*/
 * @param stringValue
 * @param fieldTypeRT
 * @param fieldID
 * @param systemLookups
 * @param projectSpecificLookups
 * @param serializableBeanAllowedContext
 * @param componentPartsMap
 * @param invalidValueHandlingMap
 * @param locale
 * @return
 * @throws ExcelImportNotExistingCellValueException
 * @throws ExcelImportNotAllowedCellValueException
 * @throws ExcelImportException
 */
private static Integer getLookupValue(String stringValue, IFieldTypeRT fieldTypeRT, Integer fieldID,
        Map<Integer, Map<String, ILabelBean>> systemLookups,
        Map<Integer, Map<Integer, Map<String, ILabelBean>>> projectSpecificLookups,
        SerializableBeanAllowedContext serializableBeanAllowedContext, Map<Integer, Integer> componentPartsMap,
        Map<Integer, Integer> invalidValueHandlingMap, Locale locale)
        throws ExcelImportNotExistingCellValueException, ExcelImportNotAllowedCellValueException {
    if (stringValue != null && !"".equals(stringValue)) {
        ILookup lookup = (ILookup) fieldTypeRT;
        Integer lookupKey = lookup.getDropDownMapFieldKey(fieldID);
        Map<String, ILabelBean> lookupBeansMap = null;
        // try to find the objectID from dropDownContainer, to avoid to go
        // to database for each entry in turn
        if (lookupKey.equals(SystemFields.RELEASE)) {
            // project specific: can be that two
            // subprojects/classes/releases have the same
            // label in different projects: we should work project specific
            if (projectSpecificLookups != null) {
                Map<Integer, Map<String, ILabelBean>> projectspecificLookup = projectSpecificLookups
                        .get(serializableBeanAllowedContext.getProjectID());
                if (projectspecificLookup != null) {
                    lookupBeansMap = projectspecificLookup.get(lookupKey);
                }
            }
        } else {
            lookupBeansMap = systemLookups.get(lookupKey);
        }
        String trimmedString = stringValue.trim();
        // first try to match the trimmed string values
        Integer objectIDByLabel = lookup.getLookupIDByLabel(fieldID,
                serializableBeanAllowedContext.getProjectID(), serializableBeanAllowedContext.getIssueTypeID(),
                locale, trimmedString, lookupBeansMap, componentPartsMap);
        if (objectIDByLabel == null) {
            // now try the original (non trimmed) value also
            //stringValue = stringValue.trim();
            objectIDByLabel = lookup.getLookupIDByLabel(fieldID, serializableBeanAllowedContext.getProjectID(),
                    serializableBeanAllowedContext.getIssueTypeID(), locale, stringValue, lookupBeansMap,
                    componentPartsMap);
        }
        if (objectIDByLabel == null) {
            // lookup entity does not exist, but we may have default values
            if (invalidValueHandlingMap.containsKey(fieldID)) {
                if (REJECT_IF_NOT_EXIST_OR_EMPTY.equals(invalidValueHandlingMap.get(fieldID))) {
                    LOGGER.debug("Reject field " + fieldID + " with label " + stringValue);
                    throw new ExcelImportNotExistingCellValueException(stringValue);
                } else {
                    // get the default value
                    LOGGER.debug("Field " + fieldID + " with label " + stringValue
                            + " does not exist. The default value will be taken");
                    // attributeValue = defaultValuesMap.get(fieldID);
                }
            } else {
                LOGGER.debug("The value " + stringValue + " does not exist for field " + fieldID);
                throw new ExcelImportNotExistingCellValueException(stringValue);
            }
        } else {
            boolean allowed = lookup.lookupBeanAllowed(objectIDByLabel, serializableBeanAllowedContext);
            if (allowed) {
                return objectIDByLabel;
            } else {
                if (invalidValueHandlingMap.containsKey(fieldID)) {
                    if (REJECT_IF_NOT_EXIST_OR_EMPTY.equals(invalidValueHandlingMap.get(fieldID))) {
                        LOGGER.debug("Reject field " + fieldID + " with label " + stringValue);
                        throw new ExcelImportNotAllowedCellValueException(stringValue);
                    } else {
                        // get the default value
                        LOGGER.debug("Field " + fieldID + " with label " + stringValue
                                + " does not exist. The default value will be taken");
                    }
                } else {
                    LOGGER.debug("The value " + stringValue + " is not allowed for field " + fieldID);
                    throw new ExcelImportNotAllowedCellValueException(stringValue);
                }
            }
        }
    }
    return null;
}