Example usage for java.math BigDecimal compareTo

List of usage examples for java.math BigDecimal compareTo

Introduction

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

Prototype

@Override
public int compareTo(BigDecimal val) 

Source Link

Document

Compares this BigDecimal with the specified BigDecimal .

Usage

From source file:com.gst.portfolio.interestratechart.data.InterestRateChartSlabDataValidator.java

public void validateChartSlabsUpdate(final JsonElement element, final DataValidatorBuilder baseDataValidator,
        final Locale locale, final Boolean isPrimaryGroupingByAmount) {

    if (this.fromApiJsonHelper.parameterExists(descriptionParamName, element)) {
        final String description = this.fromApiJsonHelper.extractStringNamed(descriptionParamName, element);
        baseDataValidator.reset().parameter(descriptionParamName).value(description).ignoreIfNull();
    }//from   w ww  .  j  a  va2s. c  o m

    if (this.fromApiJsonHelper.parameterExists(periodTypeParamName, element)) {
        final Integer periodType = this.fromApiJsonHelper.extractIntegerNamed(periodTypeParamName, element,
                locale);
        baseDataValidator.reset().parameter(periodTypeParamName).value(periodType)
                .isOneOfTheseValues(PeriodFrequencyType.integerValues());
        if (isPrimaryGroupingByAmount != null && !isPrimaryGroupingByAmount) {
            baseDataValidator.reset().parameter(periodTypeParamName).value(periodType).notNull();
        }

    }

    Integer fromPeriod = null;
    Integer toPeriod = null;

    if (this.fromApiJsonHelper.parameterExists(fromPeriodParamName, element)) {
        fromPeriod = this.fromApiJsonHelper.extractIntegerNamed(fromPeriodParamName, element, locale);
        baseDataValidator.reset().parameter(fromPeriodParamName).value(fromPeriod).integerZeroOrGreater();
        if (isPrimaryGroupingByAmount != null && !isPrimaryGroupingByAmount) {
            baseDataValidator.reset().parameter(fromPeriodParamName).value(fromPeriod).notNull();
        }
    }

    if (this.fromApiJsonHelper.parameterExists(toPeriodParamName, element)) {
        toPeriod = this.fromApiJsonHelper.extractIntegerNamed(toPeriodParamName, element, locale);
        baseDataValidator.reset().parameter(toPeriodParamName).value(toPeriod).integerGreaterThanZero();
    }

    if (fromPeriod != null && toPeriod != null) {
        if (fromPeriod > toPeriod) {
            baseDataValidator.parameter(fromPeriodParamName).value(fromPeriod)
                    .failWithCode("fromperiod.greater.than.toperiod");
        }
    }
    BigDecimal amountRangeFrom = null;
    BigDecimal amountRangeTo = null;
    if (this.fromApiJsonHelper.parameterExists(amountRangeFromParamName, element)) {
        amountRangeFrom = this.fromApiJsonHelper.extractBigDecimalNamed(amountRangeFromParamName, element,
                locale);
        baseDataValidator.reset().parameter(amountRangeFromParamName).value(amountRangeFrom)
                .zeroOrPositiveAmount();
        if (isPrimaryGroupingByAmount != null && isPrimaryGroupingByAmount) {
            baseDataValidator.reset().parameter(amountRangeFromParamName).value(amountRangeFrom).notNull();
        }
    }

    if (this.fromApiJsonHelper.parameterExists(amountRangeToParamName, element)) {
        amountRangeTo = this.fromApiJsonHelper.extractBigDecimalNamed(amountRangeToParamName, element, locale);
        baseDataValidator.reset().parameter(amountRangeToParamName).value(amountRangeTo).positiveAmount();
    }

    if (amountRangeFrom != null && amountRangeTo != null) {
        if (amountRangeFrom.compareTo(amountRangeTo) > 1) {
            baseDataValidator.parameter(fromPeriodParamName).value(fromPeriod)
                    .failWithCode("fromperiod.greater.than.toperiod");
        }
    }

    if (this.fromApiJsonHelper.parameterExists(annualInterestRateParamName, element)) {
        final BigDecimal annualInterestRate = this.fromApiJsonHelper
                .extractBigDecimalNamed(annualInterestRateParamName, element, locale);
        baseDataValidator.reset().parameter(annualInterestRateParamName).value(annualInterestRate).notNull()
                .zeroOrPositiveAmount();
    }

    if (this.fromApiJsonHelper.parameterExists(currencyCodeParamName, element)) {
        final String currencyCode = this.fromApiJsonHelper.extractStringNamed(currencyCodeParamName, element);
        baseDataValidator.reset().parameter(currencyCodeParamName).value(currencyCode).notBlank()
                .notExceedingLengthOf(3);
    }
    validateIncentives(element, baseDataValidator, locale);
}

From source file:com.gst.portfolio.savings.data.DepositProductDataValidator.java

private void validateDepositAmountForUpdate(JsonElement element, DataValidatorBuilder baseDataValidator) {
    BigDecimal depositAmount = null;

    if (this.fromApiJsonHelper.parameterExists(depositAmountParamName, element)) {
        depositAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(depositAmountParamName,
                element);//w  w  w .ja v a 2s. c o m
        baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount).notNull()
                .positiveAmount();
    }

    BigDecimal depositMinAmount = null;
    if (this.fromApiJsonHelper.parameterExists(depositMinAmountParamName, element)) {
        depositMinAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(depositMinAmountParamName,
                element);
        baseDataValidator.reset().parameter(depositMinAmountParamName).value(depositMinAmount).notNull()
                .positiveAmount();
    }

    BigDecimal depositMaxAmount = null;
    if (this.fromApiJsonHelper.parameterExists(depositMaxAmountParamName, element)) {
        depositMaxAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(depositMaxAmountParamName,
                element);
        baseDataValidator.reset().parameter(depositMaxAmountParamName).value(depositMaxAmount).notNull()
                .positiveAmount();
    }

    if (depositAmount != null) {
        if (depositMaxAmount != null && depositMaxAmount.compareTo(BigDecimal.ZERO) != -1) {
            if (depositMinAmount != null && depositMinAmount.compareTo(BigDecimal.ZERO) != -1) {
                baseDataValidator.reset().parameter(depositMaxAmountParamName).value(depositMaxAmount)
                        .notLessThanMin(depositMinAmount);
                if (depositMinAmount.compareTo(depositMaxAmount) <= 0) {
                    baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount)
                            .inMinAndMaxAmountRange(depositMinAmount, depositMaxAmount);
                }
            } else {
                baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount)
                        .notGreaterThanMax(depositMaxAmount);
            }
        } else if (depositMinAmount != null && depositMinAmount.compareTo(BigDecimal.ZERO) != -1) {
            baseDataValidator.reset().parameter(depositAmountParamName).value(depositAmount)
                    .notLessThanMin(depositMinAmount);
        }
    }
}

From source file:org.apache.carbondata.core.scan.filter.FilterUtil.java

private static int compareFilterMembersBasedOnActualDataType(String filterMember1, String filterMember2,
        DataType dataType) {/*w  ww  . j  av a  2 s.com*/
    try {
        if (dataType == DataTypes.SHORT || dataType == DataTypes.INT || dataType == DataTypes.LONG
                || dataType == DataTypes.DOUBLE) {
            if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(filterMember1)) {
                return 1;
            }
            Double d1 = Double.parseDouble(filterMember1);
            Double d2 = Double.parseDouble(filterMember2);
            return d1.compareTo(d2);
        } else if (DataTypes.isDecimal(dataType)) {
            if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(filterMember1)) {
                return 1;
            }
            java.math.BigDecimal val1 = new BigDecimal(filterMember1);
            java.math.BigDecimal val2 = new BigDecimal(filterMember2);
            return val1.compareTo(val2);
        } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
            if (CarbonCommonConstants.MEMBER_DEFAULT_VAL.equals(filterMember1)) {
                return 1;
            }
            String format = null;
            if (dataType == DataTypes.DATE) {
                format = CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_DATE_FORMAT,
                        CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT);
            } else {
                format = CarbonProperties.getInstance().getProperty(
                        CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
                        CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT);
            }
            SimpleDateFormat parser = new SimpleDateFormat(format);
            Date date1 = null;
            Date date2 = null;
            date1 = parser.parse(filterMember1);
            date2 = parser.parse(filterMember2);
            return date1.compareTo(date2);
        } else {
            return filterMember1.compareTo(filterMember2);
        }
    } catch (ParseException | NumberFormatException e) {
        return -1;
    }
}

From source file:com.alibaba.wasp.jdbc.TestJdbcResultSet.java

@Test
public void testDoubleFloat() throws SQLException, IOException {
    trace("test DOUBLE - FLOAT");

    ResultInHBasePrinter.printFMETA(TEST_UTIL.getConfiguration(), LOG);
    ResultInHBasePrinter.printMETA(TEST_UTIL.getConfiguration(), LOG);
    ResultSet rs;/*from   w  w w  .  j  a va 2s.c o  m*/
    Object o;

    stat = conn.createStatement();
    stat.execute(
            "INSERT INTO test (column1,column5,column4,column2,column3) VALUES(11, -1, -1, 2, 'testDoubleFloat')");
    stat.execute(
            "INSERT INTO test (column1,column5,column4,column2,column3) VALUES(12,.0, .0, 2, 'testDoubleFloat')");
    stat.execute(
            "INSERT INTO test (column1,column5,column4,column2,column3) VALUES(13, 1., 1., 2, 'testDoubleFloat')");
    stat.execute(
            "INSERT INTO test (column1,column5,column4,column2,column3) VALUES(14, 12345678.89, 12345678.89, 2, 'testDoubleFloat')");
    stat.execute(
            "INSERT INTO test (column1,column5,column4,column2,column3) VALUES(15, 99999999.99, 99999999.99, 2, 'testDoubleFloat')");
    stat.execute(
            "INSERT INTO test (column1,column5,column4,column2,column3) VALUES(16, -99999999.99, -99999999.99, 2, 'testDoubleFloat')");
    stat.execute(
            "INSERT INTO test (column1,column5,column4,column2,column3) VALUES(17, -99999999.99, -99999999.99, 2, 'testDoubleFloat')");
    // stat.execute("INSERT INTO test (column1,column5,column4,column2,column3) VALUES(8, NULL, NULL, 2, 'testDoubleFloat')");

    rs = stat.executeQuery(
            "SELECT column1,column5,column4 FROM test where column3='testDoubleFloat'  ORDER BY column1");
    // assertResultSetMeta(rs, 3, new String[] { "ID", "D", "R" }, new int[] {
    // Types.INTEGER, Types.DOUBLE, Types.REAL }, new int[] { 10, 17, 7 },
    // new int[] { 0, 0, 0 });
    BigDecimal bd;
    rs.next();
    assertTrue(rs.getInt(1) == 11);
    assertTrue(!rs.wasNull());
    assertTrue(rs.getInt(2) == -1);
    assertTrue(rs.getInt(3) == -1);
    assertTrue(!rs.wasNull());
    bd = rs.getBigDecimal(2);
    assertTrue(bd.compareTo(new BigDecimal("-1.00")) == 0);
    assertTrue(!rs.wasNull());
    o = rs.getObject(2);
    trace(o.getClass().getName());
    assertTrue(o instanceof Double);
    assertTrue(((Double) o).compareTo(new Double("-1.00")) == 0);
    o = rs.getObject(3);
    trace(o.getClass().getName());
    assertTrue(o instanceof Float);
    assertTrue(((Float) o).compareTo(new Float("-1.00")) == 0);
    rs.next();
    assertTrue(rs.getInt(1) == 12);
    assertTrue(!rs.wasNull());
    assertTrue(rs.getInt(2) == 0);
    assertTrue(!rs.wasNull());
    assertTrue(rs.getInt(3) == 0);
    assertTrue(!rs.wasNull());
    bd = rs.getBigDecimal(2);
    assertTrue(bd.compareTo(new BigDecimal("0.00")) == 0);
    assertTrue(!rs.wasNull());
    bd = rs.getBigDecimal(3);
    assertTrue(bd.compareTo(new BigDecimal("0.00")) == 0);
    assertTrue(!rs.wasNull());
    rs.next();
    assertEquals(1.0, rs.getDouble(2));
    assertEquals(1.0f, rs.getFloat(3));
    rs.next();
    assertEquals(12345678.89, rs.getDouble(2));
    assertEquals(12345678.89f, rs.getFloat(3));
    rs.next();
    assertEquals(99999999.99, rs.getDouble(2));
    assertEquals(99999999.99f, rs.getFloat(3));
    rs.next();
    assertEquals(-99999999.99, rs.getDouble(2));
    assertEquals(-99999999.99f, rs.getFloat(3));
    // rs.next();
    // checkColumnBigDecimal(rs, 2, 0, null);
    // checkColumnBigDecimal(rs, 3, 0, null);
    // assertTrue(!rs.next());
    // stat.execute("DROP TABLE test");
}

From source file:com.heliumv.api.inventory.InventoryApi.java

/**
 * Mengen &uuml;berpr&uuml;fen</b>
 * <p>Die Gesamtsumme der identity.amount muss ident mit der angegebenen Menge sein<p>
 * <p>Es d&uuml;rfen nur positive Mengen in den identities vorhanden sein.</p>
 * <p>Seriennummernbehaftete Artikel d&uuml;rfen nur die Menge 1.0 haben</p>
 * @param amount//ww w.  jav a  2  s .co m
 * @param identities
 * @return
 */
private boolean verifyAmounts(ArtikelDto itemDto, BigDecimal amount, List<IdentityAmountEntry> identities) {
    if (!itemDto.istArtikelSnrOderchargentragend())
        return true;
    if (identities == null || identities.size() == 0) {
        respondBadRequestValueMissing("identities");
        return false;
    }

    BigDecimal amountIdentities = BigDecimal.ZERO;
    for (IdentityAmountEntry entry : identities) {
        if (entry.getAmount() == null) {
            respondBadRequestValueMissing("amount");
            appendBadRequestData(entry.getIdentity(), "amount missing");
            return false;
        }

        if (entry.getAmount().signum() != 1) {
            respondBadRequest("amount", "positive");
            appendBadRequestData(entry.getIdentity(), entry.getAmount().toPlainString());
            return false;
        }

        if (itemDto.isSeriennrtragend()) {
            if (BigDecimal.ONE.compareTo(entry.getAmount()) != 0) {
                respondBadRequest("snr-amount", "1 (is: " + entry.getAmount().toPlainString() + ")");
                return false;
            }
        }

        amountIdentities = amountIdentities.add(entry.getAmount());
    }

    if (amountIdentities.compareTo(amount.abs()) != 0) {
        respondBadRequest("totalamount != identityamount", amount.toPlainString());
        appendBadRequestData("identityamount", amountIdentities.toPlainString());
        return false;
    }

    return true;
}

From source file:com.alibaba.wasp.jdbc.TestJdbcResultSet.java

private void checkColumnBigDecimal(ResultSet rs, int column, int i, String bd) throws SQLException {
    BigDecimal bd1 = rs.getBigDecimal(column);
    int i1 = rs.getInt(column);
    if (bd == null) {
        trace("should be: null");
        assertTrue(rs.wasNull());/*from w  w  w  . j  a v  a  2  s.  c om*/
    } else {
        trace("BigDecimal i=" + i + " bd=" + bd + " ; i1=" + i1 + " bd1=" + bd1);
        assertTrue(!rs.wasNull());
        assertTrue(i1 == i);
        assertTrue(bd1.compareTo(new BigDecimal(bd)) == 0);
    }
}

From source file:org.apache.carbondata.core.scan.filter.FilterUtil.java

public static int compareFilterKeyBasedOnDataType(String dictionaryVal, String memberVal, DataType dataType) {
    try {//from   ww  w .  j a va  2 s  . c o m
        if (dataType == DataTypes.BOOLEAN) {
            return Boolean.compare((Boolean.parseBoolean(dictionaryVal)), (Boolean.parseBoolean(memberVal)));
        } else if (dataType == DataTypes.SHORT) {
            return Short.compare((Short.parseShort(dictionaryVal)), (Short.parseShort(memberVal)));
        } else if (dataType == DataTypes.INT) {
            return Integer.compare((Integer.parseInt(dictionaryVal)), (Integer.parseInt(memberVal)));
        } else if (dataType == DataTypes.DOUBLE) {
            return Double.compare((Double.parseDouble(dictionaryVal)), (Double.parseDouble(memberVal)));
        } else if (dataType == DataTypes.LONG) {
            return Long.compare((Long.parseLong(dictionaryVal)), (Long.parseLong(memberVal)));
        } else if (dataType == DataTypes.BOOLEAN) {
            return Boolean.compare((Boolean.parseBoolean(dictionaryVal)), (Boolean.parseBoolean(memberVal)));
        } else if (dataType == DataTypes.DATE || dataType == DataTypes.TIMESTAMP) {
            String format = CarbonUtil.getFormatFromProperty(dataType);
            SimpleDateFormat parser = new SimpleDateFormat(format);
            Date dateToStr;
            Date dictionaryDate;
            dateToStr = parser.parse(memberVal);
            dictionaryDate = parser.parse(dictionaryVal);
            return dictionaryDate.compareTo(dateToStr);
        } else if (DataTypes.isDecimal(dataType)) {
            java.math.BigDecimal javaDecValForDictVal = new java.math.BigDecimal(dictionaryVal);
            java.math.BigDecimal javaDecValForMemberVal = new java.math.BigDecimal(memberVal);
            return javaDecValForDictVal.compareTo(javaDecValForMemberVal);
        } else {
            return -1;
        }
    } catch (ParseException | NumberFormatException e) {
        return -1;
    }
}

From source file:com.genscript.gsscm.epicorwebservice.service.ErpSalesOrderService.java

@Traced
public BigDecimal getPartStorageNumber(String catalogNo) {
    InventoryQtyAdjService inventoryQtyAdjService = new InventoryQtyAdjService();
    InventoryQtyAdjServiceSoap port = inventoryQtyAdjService.getInventoryQtyAdjServiceSoap();
    assertUserNameToken(port);//  w ww .  ja v a 2s.c  o m

    System.out.println("Invoking getInventoryQtyAdjBrw...");
    java.lang.String _getInventoryQtyAdjBrw_companyID = "GSUS";
    java.lang.String _getInventoryQtyAdjBrw_partNum = catalogNo;
    java.lang.String _getInventoryQtyAdjBrw_wareHouseCode = "US";
    com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType _getInventoryQtyAdjBrw_callContextIn = null;
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.InventoryQtyAdjBrwDataSetType> _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.InventoryQtyAdjBrwDataSetType>();
    javax.xml.ws.Holder<java.lang.String> _getInventoryQtyAdjBrw_primaryBin = new javax.xml.ws.Holder<java.lang.String>();
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType> _getInventoryQtyAdjBrw_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType>();
    try {
        port.getInventoryQtyAdjBrw(_getInventoryQtyAdjBrw_companyID, _getInventoryQtyAdjBrw_partNum,
                _getInventoryQtyAdjBrw_wareHouseCode, _getInventoryQtyAdjBrw_callContextIn,
                _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult, _getInventoryQtyAdjBrw_primaryBin,
                _getInventoryQtyAdjBrw_callContextOut);
    } catch (Exception e) {

    }
    if (_getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult.value == null) {
        return null;
    }
    List<BigDecimal> qtyList = new ArrayList<BigDecimal>();
    for (Object obj : _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult.value.getInventoryQtyAdjBrwDataSet()
            .getInventoryQtyAdjBrwOrWebServiceErrors()) {
        InventoryQtyAdjBrwDataSetType.InventoryQtyAdjBrwDataSet.InventoryQtyAdjBrw inventoryQtyAdjBrw = (InventoryQtyAdjBrwDataSetType.InventoryQtyAdjBrwDataSet.InventoryQtyAdjBrw) obj;
        qtyList.add(inventoryQtyAdjBrw.getBaseOnHandQty());
    }
    BigDecimal maxQty = new BigDecimal(0);
    for (BigDecimal d : qtyList) {
        if (d.compareTo(maxQty) > 0) {
            maxQty = d;
        }
    }
    return maxQty;
}

From source file:com.genscript.gsscm.epicorwebservice.service.ErpSalesOrderService.java

@Traced
public BigDecimal getPartStorageNumberForAddItem(String catalogNo) {
    InventoryQtyAdjService inventoryQtyAdjService = new InventoryQtyAdjService();
    InventoryQtyAdjServiceSoap port = inventoryQtyAdjService.getInventoryQtyAdjServiceSoap();
    assertUserNameToken(port);/*from w  ww .  ja  v a2s.co  m*/

    System.out.println("Invoking getInventoryQtyAdjBrw...");
    java.lang.String _getInventoryQtyAdjBrw_companyID = "GSUS";
    java.lang.String _getInventoryQtyAdjBrw_partNum = catalogNo;
    java.lang.String _getInventoryQtyAdjBrw_wareHouseCode = "US";
    com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType _getInventoryQtyAdjBrw_callContextIn = null;
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.InventoryQtyAdjBrwDataSetType> _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.InventoryQtyAdjBrwDataSetType>();
    javax.xml.ws.Holder<java.lang.String> _getInventoryQtyAdjBrw_primaryBin = new javax.xml.ws.Holder<java.lang.String>();
    javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType> _getInventoryQtyAdjBrw_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.inventory.CallContextDataSetType>();
    try {
        port.getInventoryQtyAdjBrw(_getInventoryQtyAdjBrw_companyID, _getInventoryQtyAdjBrw_partNum,
                _getInventoryQtyAdjBrw_wareHouseCode, _getInventoryQtyAdjBrw_callContextIn,
                _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult, _getInventoryQtyAdjBrw_primaryBin,
                _getInventoryQtyAdjBrw_callContextOut);
    } catch (Exception e) {
        throw new BussinessException(BussinessException.ADD_ITEM_ERROR);
    }
    if (_getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult.value == null) {
        return null;
    }
    List<BigDecimal> qtyList = new ArrayList<BigDecimal>();
    for (Object obj : _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult.value.getInventoryQtyAdjBrwDataSet()
            .getInventoryQtyAdjBrwOrWebServiceErrors()) {
        InventoryQtyAdjBrwDataSetType.InventoryQtyAdjBrwDataSet.InventoryQtyAdjBrw inventoryQtyAdjBrw = (InventoryQtyAdjBrwDataSetType.InventoryQtyAdjBrwDataSet.InventoryQtyAdjBrw) obj;
        qtyList.add(inventoryQtyAdjBrw.getBaseOnHandQty());
    }
    BigDecimal maxQty = new BigDecimal(0);
    for (BigDecimal d : qtyList) {
        if (d.compareTo(maxQty) > 0) {
            maxQty = d;
        }
    }
    return maxQty;
}

From source file:com.aimluck.eip.project.ProjectTaskFormData.java

/**
 * ????// w  w w.j  a  v a 2 s  . c  o  m
 * 
 * @param rundata
 *          RunData
 * @param context
 *          Context
 * @param msgList
 *          
 * @return TRUE ? FALSE 
 */
@Override
protected boolean setFormData(RunData rundata, Context context, List<String> msgList)
        throws ALPageNotFoundException, ALDBErrorException {
    boolean res = super.setFormData(rundata, context, msgList);
    try {
        if (res) {

            String members[] = rundata.getParameters().getStrings("task_member");
            String workload[] = rundata.getParameters().getStrings("workload");
            if (members != null) {
                for (int i = 0; i < members.length; i++) {
                    if (members[i] == null || members[i].length() == 0) {
                        continue;
                    }

                    // 
                    ALEipUser user = ALEipUtils.getALEipUser(Integer.valueOf(members[i]));

                    // 
                    BigDecimal w = BigDecimal.valueOf(0);
                    try {
                        if (workload[i] != null && workload[i].length() > 0) {
                            w = new BigDecimal(workload[i]);
                        }

                        if (w.compareTo(BigDecimal.valueOf(0)) < 0) {
                            msgList.add(getl10n("PROJECT_VALIDATE_WORKLOAD"));
                        } else if (w.precision() - w.scale() > 5) {
                            msgList.add(getl10n("PROJECT_VALIDATE_WORKLOAD_RATIONAL_INTEGER"));
                        } else if (w.scale() > 3) {
                            msgList.add(getl10n("PROJECT_VALIDATE_WORKLOAD_DECIMAL"));
                        }
                    } catch (Exception e) {
                        msgList.add(getl10n("PROJECT_VALIDATE_WORKLOAD_INTEGER"));
                    }

                    ProjectTaskMemberResultData member = new ProjectTaskMemberResultData();
                    member.initField();
                    member.setUserId(user.getUserId().getValue());
                    member.setUserName(user.getAliasName().getValue());
                    member.setWorkload(w);

                    taskMembers.add(member);
                }
            }

            planWorkloadString = rundata.getParameters().getString("plan_workload");

            // 
            fileuploadList = pfile.getFileuploadList(rundata);

            if (ALEipConstants.MODE_NEW_FORM.equals(getMode())) {
                String nullStr = null;
                start_date_check.setValue("TRUE");
                start_date.setValue(nullStr);
                end_date_check.setValue("TRUE");
                end_date.setValue(nullStr);
            }
        }
    } catch (RuntimeException ex) {
        logger.error("RuntimeException", ex);
        res = false;
    } catch (Exception ex) {
        logger.error("Exception", ex);
        res = false;
    }
    return res;
}