List of usage examples for java.lang Integer equals
public boolean equals(Object obj)
From source file:jp.primecloud.auto.service.impl.LoadBalancerServiceImpl.java
/** * {@inheritDoc}//from w w w . jav a 2s . c o m */ @Override public void updateListener(Long loadBalancerNo, Integer originalLoadBalancerPort, Integer loadBalancerPort, Integer servicePort, String protocol, Long sslKeyNo) { // ? if (loadBalancerNo == null) { throw new AutoApplicationException("ECOMMON-000003", "loadBalancerNo"); } if (originalLoadBalancerPort == null) { throw new AutoApplicationException("ECOMMON-000003", "originalLoadBalancerPort"); } if (loadBalancerPort == null) { throw new AutoApplicationException("ECOMMON-000003", "loadBalancerPort"); } if (servicePort == null) { throw new AutoApplicationException("ECOMMON-000003", "servicePort"); } if (protocol == null || protocol.length() == 0) { throw new AutoApplicationException("ECOMMON-000003", "protocol"); } // ??? LoadBalancerListener listener = loadBalancerListenerDao.read(loadBalancerNo, originalLoadBalancerPort); if (listener == null) { // ????? throw new AutoApplicationException("ESERVICE-000613", originalLoadBalancerPort); } // ????????? if (LoadBalancerListenerStatus.fromStatus(listener.getStatus()) != LoadBalancerListenerStatus.STOPPED) { // ????? throw new AutoApplicationException("ESERVICE-000627"); } if (!originalLoadBalancerPort.equals(loadBalancerPort)) { // ????? long countListener = loadBalancerListenerDao.countByLoadBalancerNoAndLoadBalancerPort(loadBalancerNo, loadBalancerPort); if (countListener != 0) { // ???????? throw new AutoApplicationException("ESERVICE-000609", loadBalancerPort); } } // AWS????? LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo); if (PCCConstant.LOAD_BALANCER_ELB.equals(loadBalancer.getType())) { // ???? if (loadBalancerPort != 80 && loadBalancerPort != 443 && (loadBalancerPort < 1024 || 65535 < loadBalancerPort)) { // ????? throw new AutoApplicationException("ESERVICE-000610"); } //SSL?(HTTPS????) if ("HTTPS".equals(protocol)) { if (sslKeyNo == null) { throw new AutoApplicationException("ECOMMON-000003", "sslKey"); } } } // ??? if (servicePort < 1 || 65535 < servicePort) { // ???? throw new AutoApplicationException("ESERVICE-000611"); } // ?? List<String> protocols = Arrays.asList("TCP", "HTTP", "HTTPS"); if (!protocols.contains(protocol)) { // ??????? throw new AutoApplicationException("ESERVICE-000612"); } // ? if (originalLoadBalancerPort.equals(loadBalancerPort)) { listener.setServicePort(servicePort); listener.setProtocol(protocol); listener.setSslKeyNo(sslKeyNo); loadBalancerListenerDao.update(listener); } else { // ???????? LoadBalancerListener listener2 = new LoadBalancerListener(); listener2.setLoadBalancerNo(loadBalancerNo); listener2.setLoadBalancerPort(loadBalancerPort); listener2.setServicePort(servicePort); listener2.setProtocol(protocol); listener2.setSslKeyNo(sslKeyNo); listener2.setEnabled(listener.getEnabled()); listener2.setStatus(listener.getStatus()); listener2.setConfigure(listener.getConfigure()); loadBalancerListenerDao.create(listener2); loadBalancerListenerDao.delete(listener); } // Farm farm = farmDao.read(loadBalancer.getFarmNo()); eventLogger.log(EventLogLevel.INFO, farm.getFarmNo(), farm.getFarmName(), null, null, null, null, "LoadBalancerListenerUpdate", null, null, new Object[] { loadBalancer.getLoadBalancerName(), loadBalancerPort }); }
From source file:edu.ku.brc.specify.tasks.WorkbenchTask.java
/** * @param wbt/*from w w w .j av a 2s . c om*/ * @param rs * @return */ protected boolean wbCanAcceptRecordSet(final WorkbenchTemplate wbt, final RecordSetIFace rs) { Integer wbTblId = getRootTblId(wbt); return wbTblId != null && wbTblId.equals(rs.getDbTableId()); }
From source file:com.gst.portfolio.loanaccount.serialization.LoanApplicationCommandFromApiJsonHelper.java
public void validateForModify(final String json, final LoanProduct loanProduct, final Loan existingLoanApplication) { if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }/*from ww w.j ava 2 s. c o m*/ final Type typeOfMap = new TypeToken<Map<String, Object>>() { }.getType(); this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters); final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors) .resource("loan"); final JsonElement element = this.fromApiJsonHelper.parse(json); boolean atLeastOneParameterPassedForUpdate = false; final String clientIdParameterName = "clientId"; if (this.fromApiJsonHelper.parameterExists(clientIdParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Long clientId = this.fromApiJsonHelper.extractLongNamed(clientIdParameterName, element); baseDataValidator.reset().parameter(clientIdParameterName).value(clientId).notNull() .integerGreaterThanZero(); } final String groupIdParameterName = "groupId"; if (this.fromApiJsonHelper.parameterExists(groupIdParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Long groupId = this.fromApiJsonHelper.extractLongNamed(groupIdParameterName, element); baseDataValidator.reset().parameter(groupIdParameterName).value(groupId).notNull() .integerGreaterThanZero(); } final String productIdParameterName = "productId"; if (this.fromApiJsonHelper.parameterExists(productIdParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Long productId = this.fromApiJsonHelper.extractLongNamed(productIdParameterName, element); baseDataValidator.reset().parameter(productIdParameterName).value(productId).notNull() .integerGreaterThanZero(); } final String accountNoParameterName = "accountNo"; if (this.fromApiJsonHelper.parameterExists(accountNoParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final String accountNo = this.fromApiJsonHelper.extractStringNamed(accountNoParameterName, element); baseDataValidator.reset().parameter(accountNoParameterName).value(accountNo).notBlank() .notExceedingLengthOf(20); } final String externalIdParameterName = "externalId"; if (this.fromApiJsonHelper.parameterExists(externalIdParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final String externalId = this.fromApiJsonHelper.extractStringNamed(externalIdParameterName, element); baseDataValidator.reset().parameter(externalIdParameterName).value(externalId).ignoreIfNull() .notExceedingLengthOf(100); } final String fundIdParameterName = "fundId"; if (this.fromApiJsonHelper.parameterExists(fundIdParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Long fundId = this.fromApiJsonHelper.extractLongNamed(fundIdParameterName, element); baseDataValidator.reset().parameter(fundIdParameterName).value(fundId).ignoreIfNull() .integerGreaterThanZero(); } final String loanOfficerIdParameterName = "loanOfficerId"; if (this.fromApiJsonHelper.parameterExists(loanOfficerIdParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Long loanOfficerId = this.fromApiJsonHelper.extractLongNamed(loanOfficerIdParameterName, element); baseDataValidator.reset().parameter(loanOfficerIdParameterName).value(loanOfficerId).ignoreIfNull() .integerGreaterThanZero(); } final String transactionProcessingStrategyIdParameterName = "transactionProcessingStrategyId"; if (this.fromApiJsonHelper.parameterExists(transactionProcessingStrategyIdParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Long transactionProcessingStrategyId = this.fromApiJsonHelper .extractLongNamed(transactionProcessingStrategyIdParameterName, element); baseDataValidator.reset().parameter(transactionProcessingStrategyIdParameterName) .value(transactionProcessingStrategyId).notNull().integerGreaterThanZero(); } final String principalParameterName = "principal"; BigDecimal principal = null; if (this.fromApiJsonHelper.parameterExists(principalParameterName, element)) { atLeastOneParameterPassedForUpdate = true; principal = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(principalParameterName, element); baseDataValidator.reset().parameter(principalParameterName).value(principal).notNull().positiveAmount(); } final String inArrearsToleranceParameterName = "inArrearsTolerance"; if (this.fromApiJsonHelper.parameterExists(inArrearsToleranceParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final BigDecimal inArrearsTolerance = this.fromApiJsonHelper .extractBigDecimalWithLocaleNamed(inArrearsToleranceParameterName, element); baseDataValidator.reset().parameter(inArrearsToleranceParameterName).value(inArrearsTolerance) .ignoreIfNull().zeroOrPositiveAmount(); } final String loanTermFrequencyParameterName = "loanTermFrequency"; if (this.fromApiJsonHelper.parameterExists(loanTermFrequencyParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Integer loanTermFrequency = this.fromApiJsonHelper .extractIntegerWithLocaleNamed(loanTermFrequencyParameterName, element); baseDataValidator.reset().parameter(loanTermFrequencyParameterName).value(loanTermFrequency).notNull() .integerGreaterThanZero(); } final String loanTermFrequencyTypeParameterName = "loanTermFrequencyType"; if (this.fromApiJsonHelper.parameterExists(loanTermFrequencyTypeParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Integer loanTermFrequencyType = this.fromApiJsonHelper .extractIntegerWithLocaleNamed(loanTermFrequencyTypeParameterName, element); baseDataValidator.reset().parameter(loanTermFrequencyTypeParameterName).value(loanTermFrequencyType) .notNull().inMinMaxRange(0, 3); } final String numberOfRepaymentsParameterName = "numberOfRepayments"; if (this.fromApiJsonHelper.parameterExists(numberOfRepaymentsParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Integer numberOfRepayments = this.fromApiJsonHelper .extractIntegerWithLocaleNamed(numberOfRepaymentsParameterName, element); baseDataValidator.reset().parameter(numberOfRepaymentsParameterName).value(numberOfRepayments).notNull() .integerGreaterThanZero(); } final String repaymentEveryParameterName = "repaymentEvery"; if (this.fromApiJsonHelper.parameterExists(repaymentEveryParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Integer repaymentEvery = this.fromApiJsonHelper .extractIntegerWithLocaleNamed(repaymentEveryParameterName, element); baseDataValidator.reset().parameter(repaymentEveryParameterName).value(repaymentEvery).notNull() .integerGreaterThanZero(); } final String repaymentEveryTypeParameterName = "repaymentFrequencyType"; if (this.fromApiJsonHelper.parameterExists(repaymentEveryTypeParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Integer repaymentEveryType = this.fromApiJsonHelper .extractIntegerWithLocaleNamed(repaymentEveryTypeParameterName, element); baseDataValidator.reset().parameter(repaymentEveryTypeParameterName).value(repaymentEveryType).notNull() .inMinMaxRange(0, 3); } final String repaymentFrequencyNthDayTypeParameterName = "repaymentFrequencyNthDayType"; final String repaymentFrequencyDayOfWeekTypeParameterName = "repaymentFrequencyDayOfWeekType"; CalendarUtils.validateNthDayOfMonthFrequency(baseDataValidator, repaymentFrequencyNthDayTypeParameterName, repaymentFrequencyDayOfWeekTypeParameterName, element, this.fromApiJsonHelper); final String interestTypeParameterName = "interestType"; Integer interestType = null; if (this.fromApiJsonHelper.parameterExists(interestTypeParameterName, element)) { atLeastOneParameterPassedForUpdate = true; interestType = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(interestTypeParameterName, element); baseDataValidator.reset().parameter(interestTypeParameterName).value(interestType).notNull() .inMinMaxRange(0, 1); } if (loanProduct.isLinkedToFloatingInterestRate()) { if (this.fromApiJsonHelper.parameterExists("interestRatePerPeriod", element)) { baseDataValidator.reset().parameter("interestRatePerPeriod").failWithCode( "not.supported.loanproduct.linked.to.floating.rate", "interestRatePerPeriod param is not supported, selected Loan Product is linked with floating interest rate."); } Boolean isFloatingInterestRate = existingLoanApplication.getIsFloatingInterestRate(); if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.isFloatingInterestRate, element)) { isFloatingInterestRate = this.fromApiJsonHelper .extractBooleanNamed(LoanApiConstants.isFloatingInterestRate, element); atLeastOneParameterPassedForUpdate = true; } if (isFloatingInterestRate != null) { if (isFloatingInterestRate && !loanProduct.getFloatingRates().isFloatingInterestRateCalculationAllowed()) { baseDataValidator.reset().parameter(LoanApiConstants.isFloatingInterestRate).failWithCode( "true.not.supported.for.selected.loanproduct", "isFloatingInterestRate value of true not supported for selected Loan Product."); } } else { baseDataValidator.reset().parameter(LoanApiConstants.isFloatingInterestRate) .trueOrFalseRequired(false); } if (interestType == null) { interestType = existingLoanApplication.getLoanProductRelatedDetail().getInterestMethod().getValue(); } if (interestType != null && interestType.equals(InterestMethod.FLAT.getValue())) { baseDataValidator.reset().parameter(interestTypeParameterName).failWithCode( "should.be.0.for.selected.loan.product", "interestType should be DECLINING_BALANCE for selected Loan Product as it is linked to floating rates."); } final String interestRateDifferentialParameterName = LoanApiConstants.interestRateDifferential; BigDecimal interestRateDifferential = existingLoanApplication.getInterestRateDifferential(); if (this.fromApiJsonHelper.parameterExists(interestRateDifferentialParameterName, element)) { interestRateDifferential = this.fromApiJsonHelper .extractBigDecimalWithLocaleNamed(interestRateDifferentialParameterName, element); atLeastOneParameterPassedForUpdate = true; } baseDataValidator.reset().parameter(interestRateDifferentialParameterName) .value(interestRateDifferential).notNull().zeroOrPositiveAmount() .inMinAndMaxAmountRange(loanProduct.getFloatingRates().getMinDifferentialLendingRate(), loanProduct.getFloatingRates().getMaxDifferentialLendingRate()); } else { if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.isFloatingInterestRate, element)) { baseDataValidator.reset().parameter(LoanApiConstants.isFloatingInterestRate).failWithCode( "not.supported.loanproduct.not.linked.to.floating.rate", "isFloatingInterestRate param is not supported, selected Loan Product is not linked with floating interest rate."); } if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.interestRateDifferential, element)) { baseDataValidator.reset().parameter(LoanApiConstants.interestRateDifferential).failWithCode( "not.supported.loanproduct.not.linked.to.floating.rate", "interestRateDifferential param is not supported, selected Loan Product is not linked with floating interest rate."); } final String interestRatePerPeriodParameterName = "interestRatePerPeriod"; BigDecimal interestRatePerPeriod = existingLoanApplication.getLoanProductRelatedDetail() .getNominalInterestRatePerPeriod(); if (this.fromApiJsonHelper.parameterExists(interestRatePerPeriodParameterName, element)) { this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(interestRatePerPeriodParameterName, element); atLeastOneParameterPassedForUpdate = true; } baseDataValidator.reset().parameter(interestRatePerPeriodParameterName).value(interestRatePerPeriod) .notNull().zeroOrPositiveAmount(); } Integer interestCalculationPeriodType = loanProduct.getLoanProductRelatedDetail() .getInterestCalculationPeriodMethod().getValue(); final String interestCalculationPeriodTypeParameterName = "interestCalculationPeriodType"; if (this.fromApiJsonHelper.parameterExists(interestCalculationPeriodTypeParameterName, element)) { atLeastOneParameterPassedForUpdate = true; interestCalculationPeriodType = this.fromApiJsonHelper .extractIntegerWithLocaleNamed(interestCalculationPeriodTypeParameterName, element); baseDataValidator.reset().parameter(interestCalculationPeriodTypeParameterName) .value(interestCalculationPeriodType).notNull().inMinMaxRange(0, 1); } final String amortizationTypeParameterName = "amortizationType"; if (this.fromApiJsonHelper.parameterExists(amortizationTypeParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Integer amortizationType = this.fromApiJsonHelper .extractIntegerWithLocaleNamed(amortizationTypeParameterName, element); baseDataValidator.reset().parameter(amortizationTypeParameterName).value(amortizationType).notNull() .inMinMaxRange(0, 1); } final String expectedDisbursementDateParameterName = "expectedDisbursementDate"; LocalDate expectedDisbursementDate = null; if (this.fromApiJsonHelper.parameterExists(expectedDisbursementDateParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final String expectedDisbursementDateStr = this.fromApiJsonHelper .extractStringNamed(expectedDisbursementDateParameterName, element); baseDataValidator.reset().parameter(expectedDisbursementDateParameterName) .value(expectedDisbursementDateStr).notBlank(); expectedDisbursementDate = this.fromApiJsonHelper .extractLocalDateNamed(expectedDisbursementDateParameterName, element); baseDataValidator.reset().parameter(expectedDisbursementDateParameterName) .value(expectedDisbursementDate).notNull(); } // grace validation if (this.fromApiJsonHelper.parameterExists("graceOnPrincipalPayment", element)) { final Integer graceOnPrincipalPayment = this.fromApiJsonHelper .extractIntegerWithLocaleNamed("graceOnPrincipalPayment", element); baseDataValidator.reset().parameter("graceOnPrincipalPayment").value(graceOnPrincipalPayment) .zeroOrPositiveAmount(); } if (this.fromApiJsonHelper.parameterExists("graceOnInterestPayment", element)) { final Integer graceOnInterestPayment = this.fromApiJsonHelper .extractIntegerWithLocaleNamed("graceOnInterestPayment", element); baseDataValidator.reset().parameter("graceOnInterestPayment").value(graceOnInterestPayment) .zeroOrPositiveAmount(); } if (this.fromApiJsonHelper.parameterExists("graceOnInterestCharged", element)) { final Integer graceOnInterestCharged = this.fromApiJsonHelper .extractIntegerWithLocaleNamed("graceOnInterestCharged", element); baseDataValidator.reset().parameter("graceOnInterestCharged").value(graceOnInterestCharged) .zeroOrPositiveAmount(); } if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.graceOnArrearsAgeingParameterName, element)) { final Integer graceOnArrearsAgeing = this.fromApiJsonHelper .extractIntegerWithLocaleNamed(LoanProductConstants.graceOnArrearsAgeingParameterName, element); baseDataValidator.reset().parameter(LoanProductConstants.graceOnArrearsAgeingParameterName) .value(graceOnArrearsAgeing).zeroOrPositiveAmount(); } final String interestChargedFromDateParameterName = "interestChargedFromDate"; if (this.fromApiJsonHelper.parameterExists(interestChargedFromDateParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final LocalDate interestChargedFromDate = this.fromApiJsonHelper .extractLocalDateNamed(interestChargedFromDateParameterName, element); baseDataValidator.reset().parameter(interestChargedFromDateParameterName).value(interestChargedFromDate) .ignoreIfNull(); } final String repaymentsStartingFromDateParameterName = "repaymentsStartingFromDate"; if (this.fromApiJsonHelper.parameterExists(repaymentsStartingFromDateParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final LocalDate repaymentsStartingFromDate = this.fromApiJsonHelper .extractLocalDateNamed(repaymentsStartingFromDateParameterName, element); baseDataValidator.reset().parameter(repaymentsStartingFromDateParameterName) .value(repaymentsStartingFromDate).ignoreIfNull(); if (!existingLoanApplication.getLoanTermVariations().isEmpty()) { baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode( "cannot.modify.application.due.to.variable.installments"); } } final String submittedOnDateParameterName = "submittedOnDate"; if (this.fromApiJsonHelper.parameterExists(submittedOnDateParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final LocalDate submittedOnDate = this.fromApiJsonHelper .extractLocalDateNamed(submittedOnDateParameterName, element); baseDataValidator.reset().parameter(submittedOnDateParameterName).value(submittedOnDate).notNull(); } final String submittedOnNoteParameterName = "submittedOnNote"; if (this.fromApiJsonHelper.parameterExists(submittedOnNoteParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final String submittedOnNote = this.fromApiJsonHelper.extractStringNamed(submittedOnNoteParameterName, element); baseDataValidator.reset().parameter(submittedOnNoteParameterName).value(submittedOnNote).ignoreIfNull() .notExceedingLengthOf(500); } final String linkAccountIdParameterName = "linkAccountId"; if (this.fromApiJsonHelper.parameterExists(submittedOnNoteParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final Long linkAccountId = this.fromApiJsonHelper.extractLongNamed(linkAccountIdParameterName, element); baseDataValidator.reset().parameter(linkAccountIdParameterName).value(linkAccountId).ignoreIfNull() .longGreaterThanZero(); } // charges final String chargesParameterName = "charges"; if (element.isJsonObject() && this.fromApiJsonHelper.parameterExists(chargesParameterName, element)) { atLeastOneParameterPassedForUpdate = true; final JsonObject topLevelJsonElement = element.getAsJsonObject(); final String dateFormat = this.fromApiJsonHelper.extractDateFormatParameter(topLevelJsonElement); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement); if (topLevelJsonElement.get(chargesParameterName).isJsonArray()) { final Type arrayObjectParameterTypeOfMap = new TypeToken<Map<String, Object>>() { }.getType(); final Set<String> supportedParameters = new HashSet<>(Arrays.asList("id", "chargeId", "amount", "chargeTimeType", "chargeCalculationType", "dueDate")); final JsonArray array = topLevelJsonElement.get("charges").getAsJsonArray(); for (int i = 1; i <= array.size(); i++) { final JsonObject loanChargeElement = array.get(i - 1).getAsJsonObject(); final String arrayObjectJson = this.fromApiJsonHelper.toJson(loanChargeElement); this.fromApiJsonHelper.checkForUnsupportedParameters(arrayObjectParameterTypeOfMap, arrayObjectJson, supportedParameters); final Long chargeId = this.fromApiJsonHelper.extractLongNamed("chargeId", loanChargeElement); baseDataValidator.reset().parameter("charges").parameterAtIndexArray("chargeId", i) .value(chargeId).notNull().integerGreaterThanZero(); final BigDecimal amount = this.fromApiJsonHelper.extractBigDecimalNamed("amount", loanChargeElement, locale); baseDataValidator.reset().parameter("charges").parameterAtIndexArray("amount", i).value(amount) .notNull().positiveAmount(); this.fromApiJsonHelper.extractLocalDateNamed("dueDate", loanChargeElement, dateFormat, locale); } } } // collateral final String collateralParameterName = "collateral"; if (element.isJsonObject() && this.fromApiJsonHelper.parameterExists(collateralParameterName, element)) { final JsonObject topLevelJsonElement = element.getAsJsonObject(); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement); if (topLevelJsonElement.get("collateral").isJsonArray()) { final Type collateralParameterTypeOfMap = new TypeToken<Map<String, Object>>() { }.getType(); final Set<String> supportedParameters = new HashSet<>( Arrays.asList("id", "type", "value", "description")); final JsonArray array = topLevelJsonElement.get("collateral").getAsJsonArray(); for (int i = 1; i <= array.size(); i++) { final JsonObject collateralItemElement = array.get(i - 1).getAsJsonObject(); final String collateralJson = this.fromApiJsonHelper.toJson(collateralItemElement); this.fromApiJsonHelper.checkForUnsupportedParameters(collateralParameterTypeOfMap, collateralJson, supportedParameters); final Long collateralTypeId = this.fromApiJsonHelper.extractLongNamed("type", collateralItemElement); baseDataValidator.reset().parameter("collateral").parameterAtIndexArray("type", i) .value(collateralTypeId).notNull().integerGreaterThanZero(); final BigDecimal collateralValue = this.fromApiJsonHelper.extractBigDecimalNamed("value", collateralItemElement, locale); baseDataValidator.reset().parameter("collateral").parameterAtIndexArray("value", i) .value(collateralValue).ignoreIfNull().positiveAmount(); final String description = this.fromApiJsonHelper.extractStringNamed("description", collateralItemElement); baseDataValidator.reset().parameter("collateral").parameterAtIndexArray("description", i) .value(description).notBlank().notExceedingLengthOf(500); } } else { baseDataValidator.reset().parameter(collateralParameterName).expectedArrayButIsNot(); } } boolean meetingIdRequired = false; // validate syncDisbursement final String syncDisbursementParameterName = "syncDisbursementWithMeeting"; if (this.fromApiJsonHelper.parameterExists(syncDisbursementParameterName, element)) { final Boolean syncDisbursement = this.fromApiJsonHelper .extractBooleanNamed(syncDisbursementParameterName, element); if (syncDisbursement == null) { baseDataValidator.reset().parameter(syncDisbursementParameterName).value(syncDisbursement) .trueOrFalseRequired(false); } else if (syncDisbursement.booleanValue()) { meetingIdRequired = true; } } final String calendarIdParameterName = "calendarId"; // if disbursement is synced then must have a meeting (calendar) if (meetingIdRequired || this.fromApiJsonHelper.parameterExists(calendarIdParameterName, element)) { final Long calendarId = this.fromApiJsonHelper.extractLongNamed(calendarIdParameterName, element); baseDataValidator.reset().parameter(calendarIdParameterName).value(calendarId).notNull() .integerGreaterThanZero(); } if (!atLeastOneParameterPassedForUpdate) { final Object forceError = null; baseDataValidator.reset().anyOfNotNull(forceError); } if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.emiAmountParameterName, element)) { if (!(loanProduct.canDefineInstallmentAmount() || loanProduct.isMultiDisburseLoan())) { List<String> unsupportedParameterList = new ArrayList<>(); unsupportedParameterList.add(LoanApiConstants.emiAmountParameterName); throw new UnsupportedParameterException(unsupportedParameterList); } final BigDecimal emiAnount = this.fromApiJsonHelper .extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, element); baseDataValidator.reset().parameter(LoanApiConstants.emiAmountParameterName).value(emiAnount) .ignoreIfNull().positiveAmount(); } if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.maxOutstandingBalanceParameterName, element)) { final BigDecimal maxOutstandingBalance = this.fromApiJsonHelper .extractBigDecimalWithLocaleNamed(LoanApiConstants.maxOutstandingBalanceParameterName, element); baseDataValidator.reset().parameter(LoanApiConstants.maxOutstandingBalanceParameterName) .value(maxOutstandingBalance).ignoreIfNull().positiveAmount(); } if (loanProduct.canUseForTopup()) { if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.isTopup, element)) { final Boolean isTopup = this.fromApiJsonHelper.extractBooleanNamed(LoanApiConstants.isTopup, element); baseDataValidator.reset().parameter(LoanApiConstants.isTopup).value(isTopup).ignoreIfNull() .validateForBooleanValue(); if (isTopup != null && isTopup) { final Long loanId = this.fromApiJsonHelper.extractLongNamed(LoanApiConstants.loanIdToClose, element); baseDataValidator.reset().parameter(LoanApiConstants.loanIdToClose).value(loanId).notNull() .longGreaterThanZero(); } } } validateLoanMultiDisbursementdate(element, baseDataValidator, expectedDisbursementDate, principal); validatePartialPeriodSupport(interestCalculationPeriodType, baseDataValidator, element, loanProduct); if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } }
From source file:ucar.unidata.idv.control.chart.MyXYPlot.java
/** * A utility method that returns a list of datasets that are mapped to a * particular axis./* w w w .j a v a 2 s . c o m*/ * * @param axisIndex the axis index (<code>null</code> not permitted). * * @return A list of datasets. */ private List getDatasetsMappedToRangeAxis(Integer axisIndex) { if (axisIndex == null) { throw new IllegalArgumentException("Null 'axisIndex' argument."); } List result = new ArrayList(); for (int i = 0; i < this.datasets.size(); i++) { Integer mappedAxis = (Integer) this.datasetToRangeAxisMap.get(new Integer(i)); if (mappedAxis == null) { if (axisIndex.equals(ZERO)) { result.add(this.datasets.get(i)); } } else { if (mappedAxis.equals(axisIndex)) { result.add(this.datasets.get(i)); } } } return result; }
From source file:ucar.unidata.idv.control.chart.MyXYPlot.java
/** * A utility method that returns a list of datasets that are mapped to a * particular axis.// w ww . j a va 2 s . co m * * @param axisIndex the axis index (<code>null</code> not permitted). * * @return A list of datasets. */ private List getDatasetsMappedToDomainAxis(Integer axisIndex) { if (axisIndex == null) { throw new IllegalArgumentException("Null 'axisIndex' argument."); } List result = new ArrayList(); for (int i = 0; i < this.datasets.size(); i++) { Integer mappedAxis = (Integer) this.datasetToDomainAxisMap.get(new Integer(i)); if (mappedAxis == null) { if (axisIndex.equals(ZERO)) { result.add(this.datasets.get(i)); } } else { if (mappedAxis.equals(axisIndex)) { result.add(this.datasets.get(i)); } } } return result; }
From source file:com.vmware.bdd.manager.ClusterManager.java
/** * set cluster parameters synchronously// w w w. j av a2s .co m * * @param clusterName * @param activeComputeNodeNum * @param minComputeNodeNum * @param maxComputeNodeNum * @param enableAuto * @param ioPriority * @return * @throws Exception */ @SuppressWarnings("unchecked") public List<String> syncSetParam(String clusterName, Integer activeComputeNodeNum, Integer minComputeNodeNum, Integer maxComputeNodeNum, Boolean enableAuto, Priority ioPriority) throws Exception { //allow set ioshare only. if (enableAuto != null || activeComputeNodeNum != null || maxComputeNodeNum != null || minComputeNodeNum != null) { opsBlocker.blockUnsupportedOpsByCluster("syncSetElasticity", clusterName); } ClusterEntity cluster = clusterEntityMgr.findByName(clusterName); ClusterRead clusterRead = getClusterByName(clusterName, false); if (cluster == null) { logger.error("cluster " + clusterName + " does not exist"); throw BddException.NOT_FOUND("Cluster", clusterName); } ValidationUtils.validateVersion(clusterEntityMgr, clusterName); clusterEntityMgr.cleanupActionError(clusterName); //update vm ioshares if (ioPriority != null) { prioritizeCluster(clusterName, ioPriority); } // as prioritizeCluster will update clusterEntity, here we need to refresh to avoid overriding cluster = clusterEntityMgr.findByName(clusterName); if (enableAuto != null && enableAuto != cluster.getAutomationEnable()) { if (enableAuto && cluster.getDistroVendor().equalsIgnoreCase(Constants.MAPR_VENDOR)) { logger.error("cluster " + clusterName + " is a MAPR distro, which cannot be auto scaled"); throw BddException.NOT_ALLOWED_SCALING("cluster", clusterName); } cluster.setAutomationEnable(enableAuto); } if (minComputeNodeNum != null && minComputeNodeNum != cluster.getVhmMinNum()) { cluster.setVhmMinNum(minComputeNodeNum); } if (maxComputeNodeNum != null && maxComputeNodeNum != cluster.getVhmMaxNum()) { cluster.setVhmMaxNum(maxComputeNodeNum); } List<String> nodeGroupNames = new ArrayList<String>(); if ((enableAuto != null || minComputeNodeNum != null || maxComputeNodeNum != null || activeComputeNodeNum != null) && !clusterRead.validateSetManualElasticity(nodeGroupNames)) { throw BddException.INVALID_PARAMETER("cluster", clusterName); } if (activeComputeNodeNum != null) { if (!activeComputeNodeNum.equals(cluster.getVhmTargetNum())) { cluster.setVhmTargetNum(activeComputeNodeNum); } } //enableAuto is only set during cluster running status and //other elasticity attributes are only set during cluster running/stop status if ((enableAuto != null) && !cluster.getStatus().isActiveServiceStatus()) { logger.error("Cannot change elasticity mode, when cluster " + clusterName + " is in " + cluster.getStatus() + " status"); throw ClusterManagerException.SET_AUTO_ELASTICITY_NOT_ALLOWED_ERROR(clusterName, "The cluster's status must be RUNNING"); } if (!cluster.getStatus().isActiveServiceStatus() && !ClusterStatus.SERVICE_STOPPED.equals(cluster.getStatus()) && !ClusterStatus.STOPPED.equals(cluster.getStatus())) { logger.error("Cannot change elasticity parameters, when cluster " + clusterName + " is in " + cluster.getStatus() + " status"); throw ClusterManagerException.SET_AUTO_ELASTICITY_NOT_ALLOWED_ERROR(clusterName, "The cluster's status must be RUNNING, SERVICE_WARNING, SERVICE_ERROR or STOPPED"); } clusterEntityMgr.update(cluster); //update vhm extra config file if (enableAuto != null || minComputeNodeNum != null || maxComputeNodeNum != null) { boolean success = clusteringService.setAutoElasticity(clusterName, false); if (!success) { throw ClusterManagerException.FAILED_TO_SET_AUTO_ELASTICITY_ERROR(clusterName, "Could not update elasticity configuration file"); } } //waitForManual if switch to Manual and targetNodeNum is null if (enableAuto != null && !enableAuto && cluster.getVhmTargetNum() == null) { JobUtils.waitForManual(clusterName, executionService); } return nodeGroupNames; }
From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java
/** * Update a data package in PASTA and return a resource map of the created * resources./* w ww. ja v a 2 s. c o m*/ * * @param emlFile * The EML document to be created in the metadata catalog * @param scope * The scope value * @param identifier * The identifier value * @param user * The user value * @param authToken * The authorization token * @param transaction * The transaction identifier * @return The resource map generated as a result of updating the data * package. */ public String updateDataPackage(File emlFile, String scope, Integer identifier, String user, AuthToken authToken, String transaction) throws ClientProtocolException, FileNotFoundException, IOException, UserErrorException, Exception { boolean isEvaluate = false; String resourceMap = null; // Construct an EMLDataPackage object DataPackage dataPackage = parseEml(emlFile, isEvaluate); // Parse EML if (dataPackage != null) { EMLDataPackage levelZeroDataPackage = new EMLDataPackage(dataPackage); // Get the packageId from the EMLDataPackage object String packageId = levelZeroDataPackage.getPackageId(); String emlScope = levelZeroDataPackage.getScope(); if (!scope.equals(emlScope)) { String message = "The scope value specified in the URL ('" + scope + "') does not match the scope value specified in the EML packageId attribute ('" + emlScope + "')."; throw new UserErrorException(message); } Integer emlIdentifier = levelZeroDataPackage.getIdentifier(); if (!identifier.equals(emlIdentifier)) { String message = "The identifier value specified in the URL ('" + identifier + "') does not match the identifier value specified in the EML packageId attribute ('" + emlIdentifier + "')."; throw new UserErrorException(message); } /* Is this a Level 1 data package? if (levelZeroDataPackage.isLevelOne()) { String message = "The data package you are attempting to update, '" + packageId + "', is a Level-1 data package. Only Level-0 data packages may be " + "inserted into PASTA."; throw new UserErrorException(message); } */ // Is this discovery-level EML? if (!levelZeroDataPackage.hasEntity()) { String message = "The data package you are attempting to insert, '" + packageId + "', does not describe a data entity. You may be attempting to " + "insert a discovery-level data package into PASTA. Please note " + "that only Level-0 data packages containing at least one data " + "entity may be inserted into PASTA."; throw new UserErrorException(message); } DataPackageRegistry dataPackageRegistry = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword); /* * If we have the data package but it was previously deleted (i.e. * de-activated) */ boolean isDeactivatedDataPackage = dataPackageRegistry.isDeactivatedDataPackage(scope, identifier); if (isDeactivatedDataPackage) { String message = "Attempting to update a data package that was previously deleted from PASTA: " + levelZeroDataPackage.getDocid(); throw new ResourceDeletedException(message); } // Do we already have this data package in PASTA? boolean hasDataPackage = dataPackageRegistry.hasDataPackage(scope, identifier); /* * If we do not have this data package in PASTA, throw an exception */ if (!hasDataPackage) { String message = "Attempting to update a data package that does not exist in PASTA: " + levelZeroDataPackage.getDocid(); throw new ResourceNotFoundException(message); } /* * Get the newest revision for this data package; is the revision higher * than the newest revision in PASTA? */ Integer revision = levelZeroDataPackage.getRevision(); Integer newestRevision = dataPackageRegistry.getNewestRevision(scope, identifier); if (revision <= newestRevision) { String message = "Attempting to update a data package to revision '" + revision + "' but an equal or higher revision ('" + newestRevision + "') " + "already exists in PASTA: " + packageId; throw new ResourceExistsException(message); } /* * Check whether user is authorized to update the data package by looking * at the access control rules for the newest revision */ String entityId = null; String resourceId = composeResourceId(ResourceType.dataPackage, scope, identifier, newestRevision, entityId); Authorizer authorizer = new Authorizer(dataPackageRegistry); boolean isAuthorized = authorizer.isAuthorized(authToken, resourceId, Rule.Permission.write); if (!isAuthorized) { String message = "User " + user + " does not have permission to update this data package: " + resourceId; throw new UnauthorizedException(message); } // Is this data package actively being worked on in PASTA? WorkingOn workingOn = dataPackageRegistry.makeWorkingOn(); boolean isActive = workingOn.isActive(scope, identifier, revision); /* * If this data package is already active in PASTA, throw an exception */ if (isActive) { String message = "Attempting to update a data package that is currently being processed in PASTA: " + levelZeroDataPackage.getDocid(); throw new UserErrorException(message); } boolean isUpdate = true; resourceMap = createDataPackageAux(emlFile, levelZeroDataPackage, dataPackageRegistry, packageId, scope, identifier, revision, user, authToken, isUpdate, isEvaluate, transaction); } // Return the resource map return resourceMap; }
From source file:ffsutils.TaskUtils.java
public static ArrayList<TaskImage> getTaskImage(Connection connconn, UserAccount UserName, String tranid1) throws SQLException { System.out.println("getTaskImage " + tranid1); String tranid2 = ""; Integer comp = 2;//from w w w . j a v a 2 s . c o m Integer tranlen = tranid1.length(); if (tranlen.equals(1)) { tranid2 = "0" + tranid1; } if (tranlen.equals(2)) { tranid2 = tranid1; } if (tranlen > 2) { tranid2 = tranid1.substring(tranid1.length() - 2); } String sql = "Select tranid,user,imagedesc,imagetype,dateup from " + UserName.getcompany() + ".taskimag" + tranid2 + " a where a.taskid =?"; PreparedStatement pstm = connconn.prepareStatement(sql); pstm.setString(1, tranid1); ResultSet rs = pstm.executeQuery(); ArrayList<TaskImage> list = new ArrayList<TaskImage>(); while (rs.next()) { String Tranid = rs.getString("tranid"); String User = rs.getString("user"); String ImageDesc = rs.getString("imagedesc"); String ImageType = rs.getString("imagetype"); Date date = new Date(); Calendar calendar = new GregorianCalendar(); calendar.setTime(rs.getTimestamp("dateup")); String year = Integer.toString(calendar.get(Calendar.YEAR)); String month = Integer.toString(calendar.get(Calendar.MONTH) + 1); String day = Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)); String hour = Integer.toString(calendar.get(Calendar.HOUR_OF_DAY)); String minute = Integer.toString(calendar.get(Calendar.MINUTE)); int length = month.length(); if (length == 1) { month = "0" + month; } int length2 = day.length(); if (length2 == 1) { day = "0" + day; } int length3 = hour.length(); if (length3 == 1) { hour = "0" + hour; } int length4 = minute.length(); if (length4 == 1) { minute = "0" + minute; } String thistime = year + "/" + month + "/" + day; String DateUp = thistime; TaskImage taskimage = new TaskImage(); taskimage.setTranid(Tranid); taskimage.setUser(User); taskimage.setImageDesc(ImageDesc); taskimage.setImageType(ImageType); taskimage.setDateUp(DateUp); list.add(taskimage); } return list; }
From source file:com.enonic.vertical.adminweb.handlers.ContentBaseHandlerServlet.java
public final Document getContentDocument(AdminService admin, User user, int contentKey, int categoryKey, int versionKey, Integer populateContentDataFromVersion) { Document asW3cDoc;//from ww w . j a v a 2 s. c om if (contentKey != -1) { CategoryAccessResolver categoryAccessResolver = new CategoryAccessResolver(groupDao); ContentAccessResolver contentAccessResolver = new ContentAccessResolver(groupDao); ContentXMLCreator contentXMLCreator = new ContentXMLCreator(); contentXMLCreator.setIncludeAccessRightsInfo(true); contentXMLCreator.setIncludeUserRightsInfo(true, categoryAccessResolver, contentAccessResolver); contentXMLCreator.setIncludeUserRightsInfoForRelated(true, categoryAccessResolver, contentAccessResolver); contentXMLCreator.setIncludeVersionsInfoForAdmin(true); contentXMLCreator.setIncludeRelatedContentsInfo(true); contentXMLCreator.setIncludeRepositoryPathInfo(true); contentXMLCreator.setIncludeAssignment(true); contentXMLCreator.setIncludeDraftInfo(true); contentXMLCreator.setOrderByCreatedAtDescending(true); ContentVersionEntity version = contentVersionDao.findByKey(new ContentVersionKey(versionKey)); ContentVersionEntity versionToPopulateContentDataFrom; if (populateContentDataFromVersion != null && !populateContentDataFromVersion.equals(versionKey)) { versionToPopulateContentDataFrom = contentVersionDao .findByKey(new ContentVersionKey(populateContentDataFromVersion)); } else { versionToPopulateContentDataFrom = version; } UserEntity runningUser = securityService.getUser(user); RelatedChildrenContentQuery relatedChildrenContentQuery = new RelatedChildrenContentQuery( timeService.getNowAsDateTime().toDate()); relatedChildrenContentQuery.setContentVersion(versionToPopulateContentDataFrom); relatedChildrenContentQuery.setChildrenLevel(1); relatedChildrenContentQuery.setIncludeOffline(); /* * Include related content even if running user doesn't have access - if not the user will not see related content. */ relatedChildrenContentQuery.setUser(null); RelatedContentResultSet relatedContents = contentService .queryRelatedContent(relatedChildrenContentQuery); XMLDocument contentsDocAsXMLDocument = contentXMLCreator.createContentsDocument(runningUser, version, relatedContents); if (populateContentDataFromVersion != null && !populateContentDataFromVersion.equals(versionKey)) { // Fetching the content-XML without related content. This XML is only used to get the elements from // the version to populate from, and replacing them in the draft version which is being edited. org.jdom.Document contentsDocAsJdomDocument = contentsDocAsXMLDocument.getAsJDOMDocument(); org.jdom.Document contentXmlFromVersionToPopulateFrom = contentXMLCreator .createContentsDocument(runningUser, versionToPopulateContentDataFrom, null) .getAsJDOMDocument(); org.jdom.Element contentElInOriginal = contentsDocAsJdomDocument.getRootElement() .getChild("content"); // Replace <contentdata> org.jdom.Element contentdataElInVersionToPopulateFrom = contentXmlFromVersionToPopulateFrom .getRootElement().getChild("content").getChild("contentdata"); contentElInOriginal.removeChild("contentdata"); contentElInOriginal.addContent(contentdataElInVersionToPopulateFrom.detach()); // Replace <binaries> org.jdom.Element binariesElInVersionToPopulateFrom = contentXmlFromVersionToPopulateFrom .getRootElement().getChild("content").getChild("binaries"); contentElInOriginal.removeChild("binaries"); contentElInOriginal.addContent(binariesElInVersionToPopulateFrom.detach()); asW3cDoc = XMLDocumentFactory.create(contentsDocAsJdomDocument).getAsDOMDocument(); } else { asW3cDoc = contentsDocAsXMLDocument.getAsDOMDocument(); } } else { // Blank form, make dummy document asW3cDoc = XMLTool.createDocument("contents"); String xmlAccessRights = admin.getDefaultAccessRights(user, AccessRight.CONTENT, categoryKey); XMLTool.mergeDocuments(asW3cDoc, xmlAccessRights, true); } return asW3cDoc; }
From source file:com.square.tarificateur.noyau.service.implementations.TarificateurServiceImpl.java
@Override public List<Long> rechercherIdsOpportunitesByCritere(CriteresRechercheOpportuniteDto criteres) { final List<Long> listeIdsOpportunitesSquare = new ArrayList<Long>(); // Rcupration des opportunits du tarificateur square correspondant aux critres final List<Opportunite> listeOpportunites = opportuniteDao.rechercherOpportunitesByCritere(criteres); // Filtre sur les opportunits sant si critre spcifi if (listeOpportunites != null && listeOpportunites.size() > 0 && criteres.getIsOppSante() != null && criteres.getIsOppSante()) { final Long idFinaliteAcceptee = tarificateurSquareMappingService.getIdFinaliteAcceptee(); final Long idFinaliteTransformee = tarificateurSquareMappingService.getIdFinaliteTransformee(); final Integer idCategorieGammeSante = tarificateurMappingService.getIdentifiantCategorieSante(); for (Opportunite opportunite : listeOpportunites) { final List<Devis> listeDevis = devisDao.getListeDevisByOpportunite(opportunite.getId()); if (listeDevis != null && listeDevis.size() > 0) { boucleDevis: for (Devis devis : listeDevis) { if (idFinaliteTransformee.equals(devis.getFinalite().getId()) && devis.getListeLigneDevis() != null && devis.getListeLigneDevis().size() > 0) { for (LigneDevis ligneDevis : devis.getListeLigneDevis()) { if (ligneDevis.getFinalite() != null && idFinaliteAcceptee.equals(ligneDevis.getFinalite().getId())) { // on regarde si le produit associ la ligne de devis est de type sant final Integer idProduit = ligneDevis.getEidProduit(); final ProduitCriteresDto critereProduit = new ProduitCriteresDto(); critereProduit.setIdentifiantProduit(idProduit); final List<ProduitDto> listeProduits = produitService .getListeProduits(critereProduit); if (listeProduits == null || listeProduits.size() != 1) { throw new BusinessException(messageSourceUtil.get( MessageKeyUtil.ERROR_IMPOSSIBLE_RECUPERER_PRODUIT, new String[] { String.valueOf(listeProduits.get(0).getIdentifiant()) })); }//from w w w .j a v a2 s . c o m if (idCategorieGammeSante .equals(listeProduits.get(0).getGamme().getIdCategorie())) { listeIdsOpportunitesSquare .add(Long.valueOf(opportunite.getEidOpportunite())); break boucleDevis; } } } } } } } } else { if (listeOpportunites != null && listeOpportunites.size() > 0) { for (Opportunite opportunite : listeOpportunites) { listeIdsOpportunitesSquare.add(Long.valueOf(opportunite.getEidOpportunite())); } } } return listeIdsOpportunitesSquare; }