Example usage for java.text ParseException getMessage

List of usage examples for java.text ParseException getMessage

Introduction

In this page you can find the example usage for java.text ParseException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.azyva.dragom.cliutil.CliUtil.java

/**
 * Helper method to return a ReferencePathMatcherAnd that is built from the
 * ReferencePathMatcherOr specified by RootManager and a ReferencePathMatcherOr
 * built from the --reference-path-matcher options that specify
 * ReferencePathMatcherByElement literals.
 *
 * @param commandLine CommandLine. Can be null to indicate that
 *   ReferencePathMatcherByElement's cannot be specified on the command line. In
 *   this case only the ReferencePathMatcherOr specified by RootManager is
 *   returned, equivalent to as if the one specified on the command line was "**".
 * @return ReferencePathMatcher.//  ww w .j a v a 2s  .com
 */
public static ReferencePathMatcher getReferencePathMatcher(CommandLine commandLine) {
    Model model;
    String[] arrayStringReferencePathMatcher;
    String[] arrayStringExcludeReferencePathMatcher;
    ReferencePathMatcherOr referencePathMatcherOrCommandLine;
    ReferencePathMatcherOr referencePathMatcherOrExcludeCommandLine;
    ReferencePathMatcherAnd referencePathMatcherAnd;

    model = ExecContextHolder.get().getModel();

    if (commandLine != null) {
        arrayStringReferencePathMatcher = commandLine
                .getOptionValues(CliUtil.getReferencePathMatcherCommandLineOption());
        arrayStringExcludeReferencePathMatcher = commandLine
                .getOptionValues(CliUtil.getExcludeReferencePathMatcherCommandLineOption());

        if ((arrayStringReferencePathMatcher == null) && (arrayStringExcludeReferencePathMatcher == null)) {
            UserInteractionCallbackPlugin userInteractionCallbackPlugin;

            userInteractionCallbackPlugin = ExecContextHolder.get()
                    .getExecContextPlugin(UserInteractionCallbackPlugin.class);

            userInteractionCallbackPlugin.provideInfo(MessageFormat.format(
                    CliUtil.resourceBundle
                            .getString(CliUtil.MSG_PATTERN_KEY_REFERENCE_PATH_MATCHER_NOT_SPECIFIED),
                    CliUtil.getReferencePathMatcherCommandLineOption(),
                    CliUtil.getExcludeReferencePathMatcherCommandLineOption()));

            if (!Util.handleDoYouWantToContinueSimple(
                    CliUtil.DO_YOU_WANT_TO_CONTINUE_CONTEXT_NO_REFERENCE_PATH_MATCHER)) {
                // Generally when handling "do you want to continue", we require the caller to use
                // Util.isAbort to know if the user requested to abort. But it is more convenient
                // for callers of this method to rely on an exception being thrown.
                throw new RuntimeExceptionUserError(MessageFormat.format(
                        CliUtil.resourceBundle
                                .getString(CliUtil.MSG_PATTERN_KEY_ABORT_REFERENCE_PATH_MATCHER_NOT_SPECIFIED),
                        CliUtil.getReferencePathMatcherCommandLineOption(),
                        CliUtil.getExcludeReferencePathMatcherCommandLineOption()));
            }
        }

        if (arrayStringReferencePathMatcher != null) {
            referencePathMatcherOrCommandLine = new ReferencePathMatcherOr();

            for (int i = 0; i < arrayStringReferencePathMatcher.length; i++) {
                try {
                    referencePathMatcherOrCommandLine.addReferencePathMatcher(
                            ReferencePathMatcherByElement.parse(arrayStringReferencePathMatcher[i], model));
                } catch (ParseException pe) {
                    throw new RuntimeExceptionUserError(MessageFormat.format(
                            CliUtil.getLocalizedMsgPattern(
                                    CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE_OPTION),
                            CliUtil.getReferencePathMatcherCommandLineOption(), pe.getMessage(),
                            CliUtil.getHelpCommandLineOption()));
                }
            }
        } else {
            referencePathMatcherOrCommandLine = null;
        }

        if (arrayStringExcludeReferencePathMatcher != null) {
            referencePathMatcherOrExcludeCommandLine = new ReferencePathMatcherOr();

            for (int i = 0; i < arrayStringExcludeReferencePathMatcher.length; i++) {
                try {
                    referencePathMatcherOrExcludeCommandLine
                            .addReferencePathMatcher(ReferencePathMatcherByElement
                                    .parse(arrayStringExcludeReferencePathMatcher[i], model));
                } catch (ParseException pe) {
                    throw new RuntimeExceptionUserError(MessageFormat.format(
                            CliUtil.getLocalizedMsgPattern(
                                    CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE_OPTION),
                            CliUtil.getExcludeReferencePathMatcherCommandLineOption(), pe.getMessage(),
                            CliUtil.getHelpCommandLineOption()));
                }
            }
        } else {
            referencePathMatcherOrExcludeCommandLine = null;
        }

        if ((referencePathMatcherOrCommandLine == null) && (referencePathMatcherOrExcludeCommandLine == null)) {
            return RootManager.getReferencePathMatcherOr();
        } else {
            referencePathMatcherAnd = new ReferencePathMatcherAnd();

            referencePathMatcherAnd.addReferencePathMatcher(RootManager.getReferencePathMatcherOr());

            if (referencePathMatcherOrCommandLine != null) {
                referencePathMatcherAnd.addReferencePathMatcher(referencePathMatcherOrCommandLine);
            }

            if (referencePathMatcherOrExcludeCommandLine != null) {
                referencePathMatcherAnd.addReferencePathMatcher(
                        new ReferencePathMatcherNot(referencePathMatcherOrExcludeCommandLine));
            }

            return referencePathMatcherAnd;
        }
    } else {
        return RootManager.getReferencePathMatcherOr();
    }
}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJUInt64Editor.java

public boolean isEditValid() {
    final String S_ProcName = "isEditValid";
    if (!hasValue()) {
        setValue(null);/*from  w w  w  . j a  v a2 s  .  c om*/
        return (true);
    }

    boolean retval = super.isEditValid();
    if (retval) {
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = false;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            BigDecimal v = new BigDecimal(s.toString());
            BigDecimal min = getMinValue();
            BigDecimal max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            BigDecimal v = new BigDecimal(i.toString());
            BigDecimal min = getMinValue();
            BigDecimal max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            BigDecimal v = new BigDecimal(l.toString());
            BigDecimal min = getMinValue();
            BigDecimal max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else if (obj instanceof BigDecimal) {
            BigDecimal v = (BigDecimal) obj;
            BigDecimal min = getMinValue();
            BigDecimal max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            BigDecimal v = new BigDecimal(n.toString());
            BigDecimal min = getMinValue();
            BigDecimal max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                retval = false;
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, BigDecimal or Number");
        }
    }
    return (retval);
}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJDoubleEditor.java

public boolean isEditValid() {
    final String S_ProcName = "isEditValid";
    if (!hasValue()) {
        setValue(null);//w  w w. ja va2s  .c  om
        return (true);
    }

    boolean retval = super.isEditValid();
    if (retval) {
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = false;
        } else if (obj instanceof Float) {
            Float f = (Float) obj;
            Double v = new Double(f.doubleValue());
            if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Double) {
            Double v = (Double) obj;
            if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            Double v = new Double(s.doubleValue());
            if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            Double v = new Double(i.doubleValue());
            if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            Double v = new Double(l.doubleValue());
            if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) {
                retval = false;
            }
        } else if (obj instanceof BigDecimal) {
            BigDecimal b = (BigDecimal) obj;
            Double v = new Double(b.toString());
            if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) {
                retval = false;
            }
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            Double v = new Double(n.toString());
            if ((v.compareTo(minValue) < 0) || (v.compareTo(maxValue) > 0)) {
                retval = false;
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, BigDecimal, Float, Double or Number");
        }
    }
    return (retval);
}

From source file:org.egov.wtms.service.es.WaterChargeDocumentService.java

public WaterChargeDocument updateWaterChargeIndex(final WaterChargeDocument waterChargeDocument,
        final WaterConnectionDetails waterConnectionDetails, final AssessmentDetails assessmentDetails,
        final BigDecimal amountTodisplayInIndex) {

    Iterator<OwnerName> ownerNameItr = assessmentDetails.getOwnerNames().iterator();
    Long monthlyRate = null;//  w  w  w  . ja v  a 2  s. c o  m
    String consumername = "";
    String aadharNumber = "";
    String mobilNumber = "";
    final SimpleDateFormat dateFormatter = new SimpleDateFormat(ES_DATE_FORMAT);
    String createdDate = null;

    if (waterConnectionDetails.getLegacy()) {
        if (waterConnectionDetails.getApplicationDate() != null)
            createdDate = dateFormatter.format(waterConnectionDetails.getApplicationDate());
    } else
        createdDate = dateFormatter.format(waterConnectionDetails.getExecutionDate());
    monthlyRate = monthlyRateFirld(waterConnectionDetails);
    if (ownerNameItr != null && ownerNameItr.hasNext())
        ownerNameItr.next().getMobileNumber();
    ownerNameItr = assessmentDetails.getOwnerNames().iterator();
    if (ownerNameItr.hasNext()) {
        final OwnerName ownerName = ownerNameItr.next();
        consumername = ownerName.getOwnerName();
        mobilNumber = ownerName.getMobileNumber();
        aadharNumber = ownerName.getAadhaarNumber() != null ? ownerName.getAadhaarNumber() : "";
        while (ownerNameItr.hasNext()) {
            final OwnerName multipleOwner = ownerNameItr.next();
            consumername = consumername.concat(",".concat(multipleOwner.getOwnerName()));
            aadharNumber = aadharNumber.concat(","
                    .concat(multipleOwner.getAadhaarNumber() != null ? multipleOwner.getAadhaarNumber() : ""));
        }
    }
    final Map<String, Object> cityInfo = cityService.cityDataAsMap();
    try {
        waterChargeDocument.setZone(assessmentDetails.getBoundaryDetails().getZoneName());
        waterChargeDocument.setRevenueWard(assessmentDetails.getBoundaryDetails().getWardName());
        waterChargeDocument.setAdminWard(assessmentDetails.getBoundaryDetails().getAdminWardName());
        waterChargeDocument.setDoorNo(assessmentDetails.getHouseNo());
        waterChargeDocument.setTotalDue(assessmentDetails.getPropertyDetails().getTaxDue().longValue());
        waterChargeDocument.setLegacy(waterConnectionDetails.getLegacy());
        waterChargeDocument.setCityGrade(defaultString((String) cityInfo.get(CITY_CORP_GRADE_KEY)));
        waterChargeDocument.setRegionName(defaultString((String) cityInfo.get(CITY_REGION_NAME_KEY)));
        waterChargeDocument.setClosureType(waterConnectionDetails.getCloseConnectionType() != null
                ? waterConnectionDetails.getCloseConnectionType()
                : "");
        waterChargeDocument.setLocality(assessmentDetails.getBoundaryDetails().getLocalityName() != null
                ? assessmentDetails.getBoundaryDetails().getLocalityName()
                : "");
        waterChargeDocument.setPropertyId(waterConnectionDetails.getConnection().getPropertyIdentifier());
        waterChargeDocument.setApplicationCode(waterConnectionDetails.getApplicationType().getCode());
        waterChargeDocument.setCreatedDate(dateFormatter.parse(createdDate));
        waterChargeDocument.setMobileNumber(mobilNumber);
        waterChargeDocument.setStatus(waterConnectionDetails.getConnectionStatus().name());
        waterChargeDocument.setDistrictName(defaultString((String) cityInfo.get(CITY_DIST_NAME_KEY)));
        waterChargeDocument.setConnectionType(waterConnectionDetails.getConnectionType().name());
        waterChargeDocument.setWaterTaxDue(amountTodisplayInIndex.longValue());
        waterChargeDocument.setUsage(waterConnectionDetails.getUsageType().getName());
        waterChargeDocument.setConsumerCode(waterConnectionDetails.getConnection().getConsumerCode());
        waterChargeDocument.setWaterSource(waterConnectionDetails.getWaterSource().getWaterSourceType());
        waterChargeDocument.setPropertyType(waterConnectionDetails.getPropertyType().getName());
        waterChargeDocument.setCategory(waterConnectionDetails.getCategory().getName());
        waterChargeDocument.setCityName(defaultString((String) cityInfo.get(CITY_NAME_KEY)));
        waterChargeDocument.setCityCode(defaultString((String) cityInfo.get(cityService.getCityCode())));

        waterChargeDocument.setSumpCapacity(waterConnectionDetails.getSumpCapacity());
        waterChargeDocument.setPipeSize(waterConnectionDetails.getPipeSize().getCode());
        waterChargeDocument.setNumberOfPerson(waterConnectionDetails.getNumberOfPerson() != null
                ? Long.valueOf(waterConnectionDetails.getNumberOfPerson())
                : 0l);
        waterChargeDocument.setCurrentDue(waterConnectionDetailsService
                .getTotalAmountTillCurrentFinYear(waterConnectionDetails)
                .subtract(
                        waterConnectionDetailsService.getTotalAmountTillPreviousFinYear(waterConnectionDetails))
                .longValue());
        waterChargeDocument.setArrearsDue(waterConnectionDetailsService
                .getTotalAmountTillPreviousFinYear(waterConnectionDetails).longValue());
        waterChargeDocument.setCurrentDemand(waterConnectionDetailsService
                .getTotalDemandTillCurrentFinYear(waterConnectionDetails)
                .subtract(waterConnectionDetailsService.getArrearsDemand(waterConnectionDetails)).longValue());
        waterChargeDocument.setArrearsDemand(
                waterConnectionDetailsService.getArrearsDemand(waterConnectionDetails).longValue());
        waterChargeDocument.setMonthlyRate(monthlyRate);
        waterChargeDocument.setConsumerName(consumername);
        waterChargeDocument.setAadhaarNumber(aadharNumber);
        waterChargeDocument.setWardlocation(commonWardlocationField(assessmentDetails));
        waterChargeDocument.setPropertylocation(commonPropertylocationField(assessmentDetails));
    } catch (final ParseException exp) {
        LOGGER.error("Exception parsing Date " + exp.getMessage());
    }
    createWaterChargeDocument(waterChargeDocument);
    return waterChargeDocument;

}

From source file:com.neusoft.mid.clwapi.service.pushRule.PushRuleServiceImpl.java

/**
 * ???/* w  ww. j  a  va 2s . c o m*/
 * 
 * @param token
 *            
 * @param eTag
 *            ?
 * @return ?
 */
@Override
public Object getRule(String token, String eTag) {
    // ??
    boolean checkEtag = true;
    // ?ID
    String usrId = context.getHttpHeaders().getHeaderString("usr_id");
    String enId = context.getHttpHeaders().getHeaderString("enterprise_id");
    String plaETag = context.getHttpHeaders().getHeaderString("rule_ETag");
    logger.info("???[" + usrId + "]?");
    logger.info("?ETag:" + eTag);
    logger.info("??ETag:" + plaETag);

    if (eTag == null) {
        logger.error("If-None-Match");
        throw new ApplicationException(ErrorConstant.ERROR10001, Response.Status.BAD_REQUEST);
    }

    // ?
    Date dateTer = null;
    // ??
    Date datePla = null;

    // 
    if (!eTag.equals("0")) {
        try {
            dateTer = BeanUtil.checkTimeForm(eTag, HttpConstant.TIME_FORMAT);
        } catch (ParseException e) {
            logger.error("??" + e.getMessage());
            throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST);
        }
        // ??
        try {
            datePla = BeanUtil.checkTimeForm(plaETag, HttpConstant.TIME_FORMAT);
        } catch (ParseException e) {
            logger.error("???" + e.getMessage());
            throw new ApplicationException(ErrorConstant.ERROR90000, Response.Status.INTERNAL_SERVER_ERROR);
        }
    } else {
        // ???
        checkEtag = false;
    }

    logger.info("??");
    // ??
    List<PushRuleInfo> list = iPushRuleMapper.getPushRules(usrId, enId);
    logger.info("???");
    logger.debug("list = " + (list == null ? "NULL" : list.size()));

    // ?
    if (list == null || list.size() == 0) {

        logger.info("?????");
        // ??
        List<PushRuleInfo> enList = iPushRuleMapper
                .getEnterpriseRule(context.getHttpHeaders().getHeaderString("enterprise_id"));
        // ???
        if (enList == null || enList.size() == 0) {
            logger.error("??");
            throw new ApplicationException(ErrorConstant.ERROR10104, Response.Status.NOT_FOUND);
        }
        logger.info("??");

        // ?UUID
        String[] uuids = BeanUtil.getUUIDs(enList.size());

        // ????
        Iterator<PushRuleInfo> it = enList.iterator();
        logger.info("??");
        int i = 0;
        // 
        List<PushRuleInfo> temp = new ArrayList<PushRuleInfo>();
        while (it.hasNext()) {
            PushRuleInfo iPushRuleInfo = it.next();
            // ?
            iPushRuleInfo.setUsrId(usrId);
            iPushRuleInfo.setRuleId(uuids[i++]);
            temp.add(iPushRuleInfo);
        }

        logger.debug("???:");
        if (logger.isDebugEnabled()) {
            it = temp.iterator();
            while (it.hasNext()) {
                PushRuleInfo iPushRuleInfo = it.next();
                logger.debug(iPushRuleInfo.toString());
            }
        }

        // ???
        iPushRuleMapper.insertPersonalRule(temp);

        // ???
        list = iPushRuleMapper.getPushRules(usrId, enId);
        if (list == null || list.size() == 0) {
            logger.error("??");
            throw new ApplicationException(ErrorConstant.ERROR10010, Response.Status.NOT_FOUND);
        }
        logger.info("?");
        plaETag = list.get(0).getOperateTime();
        logger.debug("??" + plaETag);
        // ??
        upUserETag(token, usrId, plaETag);
        logger.info("???");
    } else {
        logger.debug("?");
        if (logger.isDebugEnabled()) {
            Iterator<PushRuleInfo> it = list.iterator();
            int i = 0;
            while (it.hasNext()) {
                PushRuleInfo iPushRuleInfo = it.next();
                logger.debug(++i + iPushRuleInfo.toString());
            }
        }
        // ??
        String e = list.get(0).getOperateTime();
        logger.info("????");
        logger.debug("???" + e);
        logger.debug("??" + plaETag);
        // ?
        if (!StringUtils.equals(e, plaETag)) {
            logger.info("?");
            // ??ETag
            upUserETag(token, usrId, e);
            plaETag = e;
        }
    }

    logger.info("???");

    // ?
    if ((list == null || list.size() == 0) && !plaETag.equals("0")) {
        logger.info("??");
        return Response.noContent().build();
    } else if (checkEtag && dateTer.compareTo(datePla) == 0) {
        // ??
        logger.info("???");
        return Response.notModified().build();
    } else if (checkEtag && dateTer.compareTo(datePla) > 0) {
        logger.error("???");
        throw new ApplicationException(ErrorConstant.ERROR10103, Response.Status.BAD_REQUEST);
    }

    // ?
    PushRuleResp iPushRuleResp = new PushRuleResp();
    iPushRuleResp.seteTag(plaETag);
    iPushRuleResp.setRuleContent(list);
    return JacksonUtils.toJsonRuntimeException(iPushRuleResp);
}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJUInt64Editor.java

public BigDecimal getUInt64Value() {
    final String S_ProcName = "getUInt64Value";
    BigDecimal retval;//from ww  w  .ja v  a 2 s .  c o  m
    String text = getText();
    if ((text == null) || (text.length() <= 0)) {
        retval = null;
    } else {
        if (!super.isEditValid()) {
            throw CFLib.getDefaultExceptionFactory().newInvalidArgumentException(getClass(), S_ProcName,
                    "Field is not valid");
        }
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = null;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            BigDecimal v = new BigDecimal(s.toString());
            BigDecimal min = getMinValue();
            BigDecimal max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = v;
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            BigDecimal v = new BigDecimal(i.toString());
            BigDecimal min = getMinValue();
            BigDecimal max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = v;
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            BigDecimal v = new BigDecimal(l.toString());
            BigDecimal min = getMinValue();
            BigDecimal max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = v;
        } else if (obj instanceof BigDecimal) {
            BigDecimal v = (BigDecimal) obj;
            BigDecimal min = getMinValue();
            BigDecimal max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = v;
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            BigDecimal v = new BigDecimal(n.toString());
            BigDecimal min = getMinValue();
            BigDecimal max = getMaxValue();
            if ((v.compareTo(min) < 0) || (v.compareTo(max) > 0)) {
                throw CFLib.getDefaultExceptionFactory().newArgumentRangeException(getClass(), S_ProcName, 0,
                        "EditedValue", v, min, max);
            }
            retval = v;
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, BigDecimal or Number");
        }
    }
    return (retval);
}

From source file:org.apache.directory.fortress.web.panel.AuditModListPanel.java

private void loadTree(List<Mod> mods) {
    for (Mod mod : mods) {
        Date start = null;/*from   ww  w. j a v  a2 s . c  o  m*/
        try {
            start = TUtil.decodeGeneralizedTime(mod.getReqStart());
        } catch (ParseException pe) {
            LOG.warn("ParseException=" + pe.getMessage());
        }
        if (start != null) {
            SimpleDateFormat formatter = new SimpleDateFormat(GlobalIds.AUDIT_TIMESTAMP_FORMAT);
            String formattedDate = formatter.format(start);
            mod.setReqStart(formattedDate);
        }
        rootNode.add(new DefaultMutableTreeNode(mod));
    }
}

From source file:org.egov.wtms.service.es.WaterChargeDocumentService.java

public WaterChargeDocument createWaterChargeIndex(final WaterConnectionDetails waterConnectionDetails,
        final AssessmentDetails assessmentDetails, final BigDecimal amountTodisplayInIndex) {
    WaterChargeDocument waterChargeDocument = null;
    final Map<String, Object> cityInfo = cityService.cityDataAsMap();
    final SimpleDateFormat dateFormatter = new SimpleDateFormat(ES_DATE_FORMAT);

    if (waterConnectionDetails.getConnection() != null
            && waterConnectionDetails.getConnection().getConsumerCode() != null)
        waterChargeDocument = waterChargeIndexRepository.findByConsumerCodeAndCityName(
                waterConnectionDetails.getConnection().getConsumerCode(),
                defaultString((String) cityInfo.get(CITY_NAME_KEY)));
    if (waterChargeDocument == null) {
        Iterator<OwnerName> ownerNameItr = assessmentDetails.getOwnerNames().iterator();
        Long monthlyRate = null;//from   w  ww  . j  a  va  2s . c  o  m
        String consumername = "";
        String aadharNumber = "";
        String mobilNumber = "";
        String createdDateStr = "";
        monthlyRate = monthlyRateFirld(waterConnectionDetails);
        if (ownerNameItr != null && ownerNameItr.hasNext())
            ownerNameItr.next().getMobileNumber();
        ownerNameItr = assessmentDetails.getOwnerNames().iterator();
        if (ownerNameItr.hasNext()) {
            final OwnerName ownerName = ownerNameItr.next();
            consumername = ownerName.getOwnerName();
            mobilNumber = ownerName.getMobileNumber();
            aadharNumber = ownerName.getAadhaarNumber() != null ? ownerName.getAadhaarNumber() : "";
            while (ownerNameItr.hasNext()) {
                final OwnerName multipleOwner = ownerNameItr.next();
                consumername = consumername.concat(",".concat(multipleOwner.getOwnerName()));
                aadharNumber = aadharNumber.concat(",".concat(
                        multipleOwner.getAadhaarNumber() != null ? multipleOwner.getAadhaarNumber() : ""));
            }
        }
        if (waterConnectionDetails.getExecutionDate() != null)
            createdDateStr = dateFormatter.format(waterConnectionDetails.getExecutionDate());
        try {
            waterChargeDocument = WaterChargeDocument.builder()
                    .withZone(assessmentDetails.getBoundaryDetails().getZoneName())
                    .withRevenueWard(assessmentDetails.getBoundaryDetails().getWardName())
                    .withAdminward(assessmentDetails.getBoundaryDetails().getAdminWardName())
                    .withDoorNo(assessmentDetails.getHouseNo())
                    .withTotaldue(assessmentDetails.getPropertyDetails().getTaxDue().longValue())
                    .withLegacy(waterConnectionDetails.getLegacy())
                    .withCityGrade(defaultString((String) cityInfo.get(CITY_CORP_GRADE_KEY)))
                    .withRegionname(defaultString((String) cityInfo.get(CITY_REGION_NAME_KEY)))
                    .withClosureType(waterConnectionDetails.getCloseConnectionType() != null
                            ? waterConnectionDetails.getCloseConnectionType()
                            : "")
                    .withLocality(assessmentDetails.getBoundaryDetails().getLocalityName() != null
                            ? assessmentDetails.getBoundaryDetails().getLocalityName()
                            : "")
                    .withPropertyid(waterConnectionDetails.getConnection().getPropertyIdentifier())
                    .withApplicationcode(waterConnectionDetails.getApplicationType().getCode())
                    .withCreatedDate(
                            createdDateStr.isEmpty() ? new Date() : dateFormatter.parse(createdDateStr))
                    .withMobileNumber(mobilNumber)
                    .withStatus(waterConnectionDetails.getConnectionStatus().name())
                    .withDistrictName(defaultString((String) cityInfo.get(CITY_DIST_NAME_KEY)))
                    .withConnectiontype(waterConnectionDetails.getConnectionType().name())
                    .withWaterTaxDue(amountTodisplayInIndex.longValue())
                    .withUsage(waterConnectionDetails.getUsageType().getName())
                    .withConsumerCode(waterConnectionDetails.getConnection().getConsumerCode())
                    .withWatersource(waterConnectionDetails.getWaterSource().getWaterSourceType())
                    .withPropertytype(waterConnectionDetails.getPropertyType().getName())
                    .withCategory(waterConnectionDetails.getCategory().getName())
                    .withCityName(defaultString((String) cityInfo.get(CITY_NAME_KEY)))
                    .withCityCode(defaultString((String) cityInfo.get(cityService.getCityCode())))
                    .withSumpcapacity(waterConnectionDetails.getSumpCapacity())
                    .withPipesize(waterConnectionDetails.getPipeSize().getCode())
                    .withNumberOfPerson(waterConnectionDetails.getNumberOfPerson() != null
                            ? Long.valueOf(waterConnectionDetails.getNumberOfPerson())
                            : 0l)
                    .withCurrentDue(waterConnectionDetailsService
                            .getTotalAmountTillCurrentFinYear(waterConnectionDetails)
                            .subtract(waterConnectionDetailsService
                                    .getTotalAmountTillPreviousFinYear(waterConnectionDetails))
                            .longValue())
                    .withArrearsDue(waterConnectionDetailsService
                            .getTotalAmountTillPreviousFinYear(waterConnectionDetails).longValue())
                    .withCurrentDemand(waterConnectionDetailsService
                            .getTotalDemandTillCurrentFinYear(waterConnectionDetails)
                            .subtract(waterConnectionDetailsService.getArrearsDemand(waterConnectionDetails))
                            .longValue())
                    .withArrearsDemand(
                            waterConnectionDetailsService.getArrearsDemand(waterConnectionDetails).longValue())
                    .withMonthlyRate(monthlyRate).withConsumername(consumername).withAadhaarnumber(aadharNumber)
                    .withWardlocation(commonWardlocationField(assessmentDetails))
                    .withPropertylocation(commonPropertylocationField(assessmentDetails)).build();
        } catch (final ParseException exp) {
            LOGGER.error("Exception parsing Date " + exp.getMessage());
        }
        createWaterChargeDocument(waterChargeDocument);
    } else
        updateWaterChargeIndex(waterChargeDocument, waterConnectionDetails, assessmentDetails,
                amountTodisplayInIndex);
    return waterChargeDocument;
}

From source file:applica.framework.modules.LicenseModule.java

@Action(value = "generate", description = "Generate a new license file")
public void generate(Properties properties) {
    File file = new File(LicenseManager.LICENSE_FILE);
    if (file.exists()) {
        p("Cannot create license file: %s already exists", LicenseManager.LICENSE_FILE);
        return;//  w  w  w.  ja va  2  s .  c om
    }

    String user = properties.getProperty("user");

    if (StringUtils.isEmpty(user)) {
        p("Please specify a user (-Duser={user}");
        return;
    }

    String dateString = properties.getProperty("validity");

    if (StringUtils.isEmpty(dateString)) {
        p("Please specify a user (-validity={yyyy-MM-dd}");
        return;
    }

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date date = null;
    try {
        date = dateFormat.parse(dateString);
    } catch (ParseException e) {
        p("Bad date format. Use yyyy-MM-dd");
        return;
    }

    if (date != null) {
        try {
            LicenseManager.instance().generateLicenseFile(user, date, file.getAbsolutePath());

            p("License generated: %s", file.getAbsolutePath());
        } catch (LicenseGenerationException e) {
            p("Error generating license file: %s", e.getMessage());
        }
    }
}

From source file:com.siblinks.ws.service.impl.VideoSubscriptionsServiceImpl.java

/**
 * {@inheritDoc}/*  w  ww .  jav  a 2s . c o  m*/
 */
@Override
@RequestMapping(value = "/getListVideoOfWeek", method = RequestMethod.POST)
public ResponseEntity<Response> getListVideoOfWeek(@RequestParam("subjectId") final String subjectId) {
    SimpleResponse response = null;
    try {
        String method = "getListVideoOfWeek()";

        logger.debug(method + " start");

        String entityName = null;
        List<Object> readObject = null;
        String currentDate = "";
        String firstDayOfCurrentWeek = "";

        try {
            Calendar cal = Calendar.getInstance();
            cal.setTime(new Date());
            cal.setFirstDayOfWeek(Calendar.MONDAY);
            cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
            Date firstDayOfTheWeek = cal.getTime();

            currentDate = DateUtil.date2YYYYMMDD000000(new Date());
            firstDayOfCurrentWeek = DateUtil.date2YYYYMMDD000000(firstDayOfTheWeek);

            System.out.println(firstDayOfCurrentWeek);

            entityName = SibConstants.SqlMapper.SQL_SIB_GET_LIST_VIDEO_OF_WEEK;

            Object[] queryParams = { subjectId, firstDayOfCurrentWeek, currentDate };

            readObject = dao.readObjects(entityName, queryParams);

        } catch (ParseException e) {
            e.printStackTrace();
        }

        response = new SimpleResponse("true", readObject);
    } catch (Exception e) {
        logger.error(e.getMessage());
        response = new SimpleResponse(SibConstants.FAILURE, "videoAdmission", "getVideoTuttorialAdmission",
                e.getMessage());
    }
    return new ResponseEntity<Response>(response, HttpStatus.OK);
}