Example usage for java.math BigDecimal toString

List of usage examples for java.math BigDecimal toString

Introduction

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

Prototype

@Override
public String toString() 

Source Link

Document

Returns the string representation of this BigDecimal , using scientific notation if an exponent is needed.

Usage

From source file:org.kuali.student.enrollment.registration.search.service.impl.CourseRegistrationSearchServiceImpl.java

private SearchResultInfo searchForCoAndAoInfoByCoId(SearchRequestInfo searchRequestInfo)
        throws MissingParameterException, OperationFailedException {
    SearchRequestHelper requestHelper = new SearchRequestHelper(searchRequestInfo);
    SearchResultInfo resultInfo = new SearchResultInfo();

    String queryStr = "SELECT co.ID coId, coId.LUI_CD coCode, coId.DIVISION coDivision, coId.LNG_NAME, co.CLU_ID,"
            + "co.DESCR_FORMATTED, coRes.RESULT_VAL_GRP_ID, "
            + "coClId.LUI_ID coClId, coClId.LUI_CD coClCode, coClId.DIVISION coClDivision, "
            + "co.ATP_ID coAtpId, ao.ATP_ID aoAtpId, "
            + "ao.ID aoId, ao.LUI_TYPE, aoType.NAME, aoId.LUI_CD aoCode, ao.MAX_SEATS, "
            + "(SELECT COUNT(*) FROM KSEN_LPR lpr " + "  WHERE lpr.LUI_ID = ao.ID " + "    AND lpr.LPR_TYPE = '"
            + LprServiceConstants.REGISTRANT_AO_LPR_TYPE_KEY + "' " + "    AND lpr.LPR_STATE = '"
            + LprServiceConstants.ACTIVE_STATE_KEY + "') numRegisteredForAo, "
            + "cwl.CWL_STATE as wlState, cwl.MAX_SIZE wlMaxSize, " + "(SELECT COUNT(*) FROM KSEN_LPR lpr_wl "
            + "  WHERE lpr_wl.LUI_ID = rg.ID " + "    AND lpr_wl.LPR_TYPE = '"
            + LprServiceConstants.WAITLIST_RG_LPR_TYPE_KEY + "' " + "    AND lpr_wl.LPR_STATE = '"
            + LprServiceConstants.ACTIVE_STATE_KEY + "') numWaitlistedForRG, "
            + "rg.ID as rgId, rg.NAME as rgCode, " + "schedCmp.TBA_IND, room.ROOM_CD, rBldg.BUILDING_CD, "
            + "schedTmslt.WEEKDAYS, schedTmslt.START_TIME_MS, schedTmslt.END_TIME_MS, "
            + "honorsCd.value as honorsFlag " + "FROM KSEN_LUI co, KSEN_LUI_IDENT coId " +
            // looking for grading and credit options for given CO
            "LEFT OUTER JOIN KSEN_LUI_RESULT_VAL_GRP coRes " + "ON coRes.LUI_ID = coId.LUI_ID " +
            // getStudentRegGradingOptionsStr only includes Audit and Pass/Fail (as Letter is default), so want to add Letter to display
            "AND (coRes.RESULT_VAL_GRP_ID in (:rvgIds)" + "     OR coRes.RESULT_VAL_GRP_ID LIKE '"
            + LrcServiceConstants.RESULT_GROUP_KEY_KUALI_CREDITTYPE_CREDIT_BASE + "%') " +
            // looking for cross-listed courses for given CO
            "LEFT OUTER JOIN KSEN_LUI_IDENT coClId " + "ON coClId.LUI_ID = coId.LUI_ID "
            + "AND coClId.LUI_CD != coId.LUI_CD " + "AND coClId.LUI_ID_TYPE in ('"
            + LuiServiceConstants.LUI_IDENTIFIER_CROSSLISTED_TYPE_KEY + "','"
            + LuiServiceConstants.LUI_IDENTIFIER_OFFICIAL_TYPE_KEY + "') " + "AND coClId.LUI_ID_STATE = '"
            + LuiServiceConstants.LUI_IDENTIFIER_ACTIVE_STATE_KEY + "' " +
            // finding all AOs for the given CO
            // looking for FO for given CO
            "LEFT OUTER JOIN KSEN_LUILUI_RELTN co2fo " + "ON co2fo.LUI_ID = coId.LUI_ID "
            + "AND co2fo.LUILUI_RELTN_TYPE = '"
            + LuiServiceConstants.LUI_LUI_RELATION_DELIVERED_VIA_CO_TO_FO_TYPE_KEY + "' " +
            // looking for AOs for given FO (CO)
            "LEFT OUTER JOIN KSEN_LUILUI_RELTN fo2ao " + "ON fo2ao.LUI_ID = co2fo.RELATED_LUI_ID "
            + "AND fo2ao.LUILUI_RELTN_TYPE = '"
            + LuiServiceConstants.LUI_LUI_RELATION_DELIVERED_VIA_FO_TO_AO_TYPE_KEY + "' "
            + "LEFT OUTER JOIN KSEN_LUI ao " + "ON ao.ID = fo2ao.RELATED_LUI_ID " + "AND ao.LUI_STATE = '"
            + LuiServiceConstants.LUI_AO_STATE_OFFERED_KEY + "' " + "LEFT OUTER JOIN KSEN_LUI_IDENT aoId "
            + "ON aoId.LUI_ID = ao.ID " +
            // looking up ao type for given AO
            "LEFT OUTER JOIN KSEN_TYPE aoType " + "ON ao.LUI_TYPE = aoType.TYPE_KEY " +
            // looking for reg groups for given AO
            "LEFT OUTER JOIN KSEN_LUILUI_RELTN rg2ao " + "ON rg2ao.RELATED_LUI_ID = aoId.LUI_ID "
            + "AND rg2ao.LUILUI_RELTN_TYPE = '"
            + LuiServiceConstants.LUI_LUI_RELATION_REGISTERED_FOR_VIA_RG_TO_AO_TYPE_KEY + "' "
            + "LEFT OUTER JOIN KSEN_LUI rg " + "ON rg.ID = rg2ao.LUI_ID " + "AND rg.LUI_STATE = '"
            + LuiServiceConstants.REGISTRATION_GROUP_OFFERED_STATE_KEY + "' " +
            // WL for AO
            "LEFT OUTER JOIN KSEN_CWL_ACTIV_OFFER cwl2ao " + "ON cwl2ao.ACTIV_OFFER_ID = ao.id "
            + "LEFT OUTER JOIN KSEN_CWL cwl " + "ON cwl.id = cwl2ao.CWL_ID " +
            // Schedules for AOs
            "LEFT OUTER JOIN KSEN_LUI_SCHEDULE aoSched " + "ON aoSched.LUI_ID = ao.ID "
            + "LEFT OUTER JOIN KSEN_SCHED_CMP schedCmp " + "ON schedCmp.SCHED_ID = aoSched.SCHED_ID "
            + "LEFT OUTER JOIN KSEN_ROOM room " + "ON room.ID = schedCmp.ROOM_ID "
            + "LEFT OUTER JOIN KSEN_ROOM_BUILDING rBldg " + "ON rBldg.ID = room.BUILDING_ID "
            + "LEFT OUTER JOIN KSEN_SCHED_CMP_TMSLOT schedCmpTmslt "
            + "ON schedCmpTmslt.SCHED_CMP_ID = schedCmp.ID " + "LEFT OUTER JOIN KSEN_SCHED_TMSLOT schedTmslt "
            + "ON schedTmslt.ID = schedCmpTmslt.TM_SLOT_ID " +
            // Honors
            "left outer join KSEN_LUI_LU_CD honorsCd "
            + "on honorsCd.lui_id = ao.id and honorsCd.lui_lucd_type = '" + LuiServiceConstants.HONORS_LU_CODE
            + "' " + "WHERE coId.LUI_ID = co.ID " +
            //                        "  AND coId.LUI_ID_TYPE = '" + LuiServiceConstants.LUI_IDENTIFIER_OFFICIAL_TYPE_KEY + "' " +
            "  AND coId.LUI_ID_STATE = '" + LuiServiceConstants.LUI_IDENTIFIER_ACTIVE_STATE_KEY + "' "
            + "  AND co.LUI_TYPE = '" + LuiServiceConstants.COURSE_OFFERING_TYPE_KEY + "' "
            + "  AND co.ID = :courseOfferingId " + "  AND coId.LUI_CD = :courseCode " + " ORDER BY aoId.LUI_CD";

    Query query = getEntityManager().createNativeQuery(queryStr);
    query.setParameter(SearchParameters.CO_ID, requestHelper.getParamAsString(SearchParameters.CO_ID));
    query.setParameter(SearchParameters.COURSE_CODE,
            requestHelper.getParamAsString(SearchParameters.COURSE_CODE));
    query.setParameter(SearchParameters.RVG_IDS, getRvgIds());

    @SuppressWarnings("unchecked")
    List<Object[]> results = query.getResultList();

    for (Object[] resultRow : results) {
        int i = 0;
        SearchResultRowInfo row = new SearchResultRowInfo();
        row.addCell(SearchResultColumns.CO_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CO_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CO_SUBJECT_AREA, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CO_LONG_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CO_CLU_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CO_DESC_FORMATTED, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.RES_VAL_GROUP_KEY, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CO_CROSSLISTED_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CO_CROSSLISTED_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CO_CROSSLISTED_SUBJECT_AREA, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.CO_ATP_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.AO_ATP_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.AO_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.AO_TYPE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.AO_NAME, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.AO_CODE, (String) resultRow[i++]);
        BigDecimal aoMaxSeats = (BigDecimal) resultRow[i++];
        if (aoMaxSeats != null) {
            row.addCell(SearchResultColumns.AO_MAX_SEATS, String.valueOf(aoMaxSeats.intValue()));
        } else {/*from w  ww.ja  v  a 2  s.com*/
            row.addCell(SearchResultColumns.AO_MAX_SEATS, null);
        }
        BigDecimal aoSeatCount = (BigDecimal) resultRow[i++];
        if (aoSeatCount != null) {
            row.addCell(SearchResultColumns.SEAT_COUNT, String.valueOf(aoSeatCount.intValue()));
        } else {
            row.addCell(SearchResultColumns.SEAT_COUNT, null);
        }
        row.addCell(SearchResultColumns.CWL_STATE, (String) resultRow[i++]);
        BigDecimal aoWlMaxSize = (BigDecimal) resultRow[i++];
        if (aoWlMaxSize != null) {
            row.addCell(SearchResultColumns.CWL_MAX_SIZE, String.valueOf(aoWlMaxSize.intValue()));
        } else {
            row.addCell(SearchResultColumns.CWL_MAX_SIZE, null);
        }
        BigDecimal aoWlCount = (BigDecimal) resultRow[i++];
        if (aoWlCount != null) {
            row.addCell(SearchResultColumns.RG_WAITLIST_COUNT, String.valueOf(aoWlCount.intValue()));
        } else {
            row.addCell(SearchResultColumns.RG_WAITLIST_COUNT, null);
        }
        row.addCell(SearchResultColumns.RG_ID, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.RG_CODE, (String) resultRow[i++]);
        BigDecimal tbaInd = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.TBA_IND, (tbaInd == null) ? "" : tbaInd.toString());
        row.addCell(SearchResultColumns.ROOM_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.BUILDING_CODE, (String) resultRow[i++]);
        row.addCell(SearchResultColumns.WEEKDAYS, (String) resultRow[i++]);
        BigDecimal startTimeMs = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.START_TIME_MS, (startTimeMs == null) ? "" : startTimeMs.toString());
        BigDecimal endTimeMs = (BigDecimal) resultRow[i++];
        row.addCell(SearchResultColumns.END_TIME_MS, (endTimeMs == null) ? "" : endTimeMs.toString());
        row.addCell(SearchResultColumns.HONORS_FLAG, (String) resultRow[i]);

        resultInfo.getRows().add(row);
    }

    return resultInfo;
}

From source file:com.visionet.platform.cooperation.service.TransformationService.java

/**
 * ?? ??/*from  w  ww . j  a va 2s.c om*/
 *
 * @param orderNo
 * @param amount
 * @param partnerOrderNo
 * @param couponAmount
 * @param chargeSettleAmount
 * @param giftSettleAmount
 * @param customerCreditcardAmount
 * @param driverPay
 * @param ticketAmount
 * @param channel
 * @return
 * @throws Exception
 * @author zhouwei
 */
public JSONObject payNotify(String orderNo, String amount, String partnerOrderNo, String couponAmount,
        String chargeSettleAmount, String giftSettleAmount, String customerCreditcardAmount, String driverPay,
        String ticketAmount, String channel) throws Exception {
    // ????
    Order result = orderMapper.selectByPrimaryKey(partnerOrderNo);
    BigDecimal invoiceAmt = new BigDecimal(0);
    Customer customer = customerMapper.selectOneByPhone(result.getCustomerPhone());
    if (customer != null) {
        if (result.getTotalPrice() < customer.getInvoiceBalance()) {
            invoiceAmt = new BigDecimal(result.getTotalPrice());
        } else {
            invoiceAmt = new BigDecimal(customer.getInvoiceBalance());
        }
    }
    Map<String, String> params = new HashMap<String, String>();
    params.put("orderNo", orderNo);
    params.put("amount", amount);
    params.put("partnerOrderNo", partnerOrderNo);
    params.put("couponAmount", couponAmount);
    params.put("chargeSettleAmount", chargeSettleAmount);
    params.put("giftSettleAmount", giftSettleAmount);
    params.put("customerCreditcardAmount", customerCreditcardAmount);
    params.put("driverPay", driverPay);
    params.put("ticketAmount", invoiceAmt.toString());
    params.put("channel", channel);
    String ret = HttpClient.postEncrypt(PARTNER_PAYNOTIFY_URL, params);
    log.info("[dzcx_partner]--  ?? ??--:_"
            + ret);
    return JSONObject.parseObject(ret);
}

From source file:is.idega.idegaweb.egov.gumbo.webservice.client.business.DOFWSClientRealWebservice.java

public List<Item> getStrandveidiVesselsForUser(String companyPersonalID) {
    // get all open cases for user
    boolean showShips = true;
    try {//from   w w w. j  a  va2 s . c  o m
        User user = getUserBusiness().getUser(companyPersonalID);
        // INPR,PEND,UBEH,OMPR,WFPA,WAIT
        List<String> statusesToShow = new ArrayList<String>();
        statusesToShow.add("INPR");
        statusesToShow.add("PEND");
        statusesToShow.add("UBEH");
        statusesToShow.add("OMPR");
        statusesToShow.add("WFPA");
        statusesToShow.add("WAIT");

        List<String> names = new ArrayList<String>();
        names.add("string_ownerSocialNumber");

        List<Integer> ids = getCaseManagersProvider().getCaseManager().getCaseIds(user,
                CasesRetrievalManager.CASE_LIST_TYPE_OPEN, null, null, statusesToShow, false, false);
        if (ids != null) {
            List<CaseProcInstBind> binds = getCasesBPMDAO().getCasesProcInstBindsByCasesIds(ids);
            for (CaseProcInstBind caseProcInstBind : binds) {
                ProcessInstanceW inst = getBPMFactory().getProcessInstanceW(caseProcInstBind.getProcInstId());
                if ("Strandveidileyfi".equals(inst.getProcessDefinitionW().getProcessDefinition().getName())) {
                    List<Long> procIds = new ArrayList<Long>();
                    procIds.add(inst.getProcessInstanceId());
                    Collection<VariableInstanceInfo> info = getVariablesQuerier()
                            .getVariablesByProcessInstanceIdAndVariablesNames(procIds, names);
                    if (info != null) {
                        for (VariableInstanceInfo variableInstanceInfo : info) {
                            if (((String) variableInstanceInfo.getValue()).equals(companyPersonalID)) {
                                showShips = false;
                                break;
                            }
                        }
                    }
                }

                if (!showShips) {
                    break;
                }
            }
        }
    } catch (IBOLookupException e) {
        e.printStackTrace();
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (FinderException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

    List<Item> items = null;
    if (showShips) {
        BigDecimal shipNr[] = getStrandveidiShipNrByCompanySSN(companyPersonalID);
        if (shipNr != null && shipNr.length > 0) {
            items = new ArrayList<Item>(shipNr.length);
            for (BigDecimal nr : shipNr) {
                SkipInfoTypeUser vessel = getShipInfo(nr.toString());
                if (vessel != null) {
                    items.add(new Item(vessel.getSkipNr().toString(),
                            "(" + vessel.getSkipNr().toString() + ") " + vessel.getNafn()));
                }
            }
        }
    }
    return items;
}

From source file:org.ethereum.rpc.Web3Impl.java

public String eth_netHashrate() {
    BigInteger hashesPerHour = this.worldManager.getHashRateCalculator().calculateNetHashRate(1L,
            TimeUnit.HOURS);//  w ww . j  av  a 2 s  . co m
    BigDecimal hashesPerSecond = new BigDecimal(hashesPerHour)
            .divide(new BigDecimal(TimeUnit.HOURS.toSeconds(1)), 3, RoundingMode.HALF_UP);

    String result = hashesPerSecond.toString();

    if (logger.isDebugEnabled())
        logger.debug("eth_netHashrate(): " + result);

    return result;
}

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

@Traced
public String getPartStorageLocation(String catalogNo, String company) {
    //      PartService partService = new PartService();
    //      PartServiceSoap port = partService.getPartServiceSoap();
    //      assertUserNameToken(port);
    //      //from w ww  . j  ava 2  s .c om
    //      System.out.println("Invoking getByID...");
    //      java.lang.String _getByID_companyID = "GSUS";
    //      java.lang.String _getByID_partNum = catalogNo;
    //      com.genscript.gsscm.epicorwebservice.stub.part.CallContextDataSetType _getByID_callContextIn = null;
    //      javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.part.PartDataSetType> _getByID_getByIDResult = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.part.PartDataSetType>();
    //      javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.part.CallContextDataSetType> _getByID_callContextOut = new javax.xml.ws.Holder<com.genscript.gsscm.epicorwebservice.stub.part.CallContextDataSetType>();
    //      try{
    //      port.getByID(_getByID_companyID, _getByID_partNum,
    //            _getByID_callContextIn, _getByID_getByIDResult,
    //            _getByID_callContextOut);
    //      }catch(Exception e){
    //         e.printStackTrace();
    //      }
    //      if(_getByID_getByIDResult.value == null){
    //         return null;
    //      }
    //      PartWhse partWhse = (PartWhse)_getByID_getByIDResult.value.getPartDataSet().getPartOrPartAttchOrPartCOO().get(2);
    //      return partWhse.getWarehouseCode()+"-"+partWhse.getPrimBinNum();
    InventoryQtyAdjService inventoryQtyAdjService = new InventoryQtyAdjService();
    InventoryQtyAdjServiceSoap port = inventoryQtyAdjService.getInventoryQtyAdjServiceSoap();
    assertUserNameToken(port);

    System.out.println("Invoking getInventoryQtyAdjBrw...");
    java.lang.String _getInventoryQtyAdjBrw_companyID = company;
    java.lang.String _getInventoryQtyAdjBrw_partNum = catalogNo;

    java.lang.String _getInventoryQtyAdjBrw_wareHouseCode = "US";
    if (company.equalsIgnoreCase("GSHK")) {
        _getInventoryQtyAdjBrw_wareHouseCode = "HK";
    }
    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) {
        e.printStackTrace();
    }
    if (_getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult.value == null) {
        return null;
    }
    List<BigDecimal> qtyList = new ArrayList<BigDecimal>();
    Map<String, String> map1 = new HashMap<String, String>();
    Map<String, String> map2 = new HashMap<String, String>();
    for (Object obj : _getInventoryQtyAdjBrw_getInventoryQtyAdjBrwResult.value.getInventoryQtyAdjBrwDataSet()
            .getInventoryQtyAdjBrwOrWebServiceErrors()) {
        InventoryQtyAdjBrwDataSetType.InventoryQtyAdjBrwDataSet.InventoryQtyAdjBrw inventoryQtyAdjBrw = (InventoryQtyAdjBrwDataSetType.InventoryQtyAdjBrwDataSet.InventoryQtyAdjBrw) obj;
        System.out.println(inventoryQtyAdjBrw.toString());
        qtyList.add(inventoryQtyAdjBrw.getBaseOnHandQty());
        map1.put(inventoryQtyAdjBrw.getBaseOnHandQty() + "", inventoryQtyAdjBrw.getWareHseCode());
        map2.put(inventoryQtyAdjBrw.getBaseOnHandQty() + "", inventoryQtyAdjBrw.getBinNum());
    }
    BigDecimal maxQty = new BigDecimal(0);
    for (BigDecimal d : qtyList) {
        if (d.compareTo(maxQty) > 0) {
            maxQty = d;
        }
    }
    return map1.get(maxQty.toString()) + "-" + map2.get(maxQty.toString());
}

From source file:org.egov.works.web.controller.lineestimate.UpdateLineEstimateController.java

@RequestMapping(value = "/update/{lineEstimateId}", method = RequestMethod.POST)
public String update(@Valid @ModelAttribute("lineEstimate") final LineEstimate lineEstimate,
        final BindingResult errors, final RedirectAttributes redirectAttributes, final Model model,
        final HttpServletRequest request, @RequestParam final String removedLineEstimateDetailsIds,
        @RequestParam("file") final MultipartFile[] files) throws ApplicationException, IOException {

    String mode = "";
    String workFlowAction = "";
    LineEstimate newLineEstimate = null;

    validateBudgetHead(lineEstimate, errors);

    if (request.getParameter("mode") != null)
        mode = request.getParameter("mode");

    if (request.getParameter("workFlowAction") != null)
        workFlowAction = request.getParameter("workFlowAction");

    Long approvalPosition = 0l;/*w  w w. j  av a 2s  .com*/
    String approvalComment = "";

    if (request.getParameter("approvalComent") != null)
        approvalComment = request.getParameter("approvalComent");

    if (request.getParameter("approvalPosition") != null && !request.getParameter("approvalPosition").isEmpty())
        approvalPosition = Long.valueOf(request.getParameter("approvalPosition"));

    // For Get Configured ApprovalPosition from workflow history
    if (approvalPosition == null || approvalPosition.equals(Long.valueOf(0)))
        approvalPosition = lineEstimateService.getApprovalPositionByMatrixDesignation(lineEstimate,
                approvalPosition, null, mode, workFlowAction);

    if ((approvalPosition == null || approvalPosition.equals(Long.valueOf(0)))
            && request.getParameter("approvalPosition") != null
            && !request.getParameter("approvalPosition").isEmpty())
        approvalPosition = Long.valueOf(request.getParameter("approvalPosition"));

    if (lineEstimate.getStatus().getCode().equals(LineEstimateStatus.ADMINISTRATIVE_SANCTIONED.toString()))
        validateTechSanctionDetails(lineEstimate, errors);

    if (lineEstimate.getStatus().getCode().equals(LineEstimateStatus.BUDGET_SANCTIONED.toString())
            && !workFlowAction.equalsIgnoreCase(WorksConstants.REJECT_ACTION.toString()))
        validateAdminSanctionDetail(lineEstimate, errors);

    if (lineEstimate.getStatus().getCode().equals(LineEstimateStatus.CHECKED.toString())
            && !workFlowAction.equalsIgnoreCase(WorksConstants.REJECT_ACTION.toString()))
        if (!BudgetControlType.BudgetCheckOption.NONE.toString()
                .equalsIgnoreCase(budgetControlTypeService.getConfigValue()))
            validateBudgetAmount(lineEstimate, errors);
    if (errors.hasErrors()) {
        setDropDownValues(model);
        model.addAttribute("removedLineEstimateDetailsIds", removedLineEstimateDetailsIds);
        return loadViewData(model, request, lineEstimate);
    } else {
        if (null != workFlowAction)
            try {
                final CFinancialYear financialYear = lineEstimateService
                        .getCurrentFinancialYear(lineEstimate.getLineEstimateDate());
                newLineEstimate = lineEstimateService.updateLineEstimateDetails(lineEstimate, approvalPosition,
                        approvalComment, null, workFlowAction, mode, null, removedLineEstimateDetailsIds, files,
                        financialYear);
            } catch (final ValidationException e) {
                final List<Long> budgetheadid = new ArrayList<Long>();
                budgetheadid.add(lineEstimate.getBudgetHead().getId());

                final BigDecimal budgetAvailable = budgetDetailsDAO.getPlanningBudgetAvailable(
                        lineEstimateService.getCurrentFinancialYear(new Date()).getId(),
                        Integer.parseInt(lineEstimate.getExecutingDepartment().getId().toString()),
                        lineEstimate.getFunction().getId(), null,
                        lineEstimate.getScheme() == null ? null
                                : Integer.parseInt(lineEstimate.getScheme().getId().toString()),
                        lineEstimate.getSubScheme() == null ? null
                                : Integer.parseInt(lineEstimate.getSubScheme().getId().toString()),
                        null, budgetheadid, Integer.parseInt(lineEstimate.getFund().getId().toString()));
                BigDecimal totalEstimateAmount = BigDecimal.ZERO;

                for (final LineEstimateDetails led : lineEstimate.getLineEstimateDetails())
                    totalEstimateAmount = led.getEstimateAmount().add(totalEstimateAmount);

                final String errorMessage = messageSource.getMessage("error.budgetappropriation.amount",
                        new String[] { budgetAvailable.toString(), totalEstimateAmount.toString() }, null);
                model.addAttribute("message", errorMessage);
                return "lineestimate-success";
            }
        redirectAttributes.addFlashAttribute("lineEstimate", newLineEstimate);

        final String pathVars = worksUtils.getPathVars(newLineEstimate.getStatus(), newLineEstimate.getState(),
                newLineEstimate.getId(), approvalPosition);

        return "redirect:/lineestimate/lineestimate-success?pathVars=" + pathVars;
    }
}

From source file:org.egov.ptis.actions.recovery.RecoveryAction.java

@ValidationErrorPage(value = "warrantApplicationView")
public String generateWarrantApplicaton() {
    String noticeNo = propertyTaxNumberGenerator
            .generateRecoveryNotice(PropertyTaxConstants.WARRANT_APPLICATION);
    recovery.getBasicProperty()/*from  w ww .  j  av  a2s  .  c o m*/
            .setStatus(getPropStatusByStatusCode(PropertyTaxConstants.RECOVERY_WARRANTAPPROVED));
    recovery.setStatus(getEgwStatusForModuleAndCode(PropertyTaxConstants.RECOVERY_MODULE,
            PropertyTaxConstants.RECOVERY_WARRANTAPPROVED));

    updateWfstate(PropertyTaxConstants.WARRANT_APPLICATION);
    BigDecimal courtFee = BigDecimal.ZERO;
    BigDecimal noticeFee = BigDecimal.ZERO;
    BigDecimal warrantFee = BigDecimal.ZERO;
    for (WarrantFee fee : recovery.getWarrant().getWarrantFees()) {
        if (fee.getDemandReason().getEgDemandReasonMaster().getCode()
                .equalsIgnoreCase(DEMANDRSN_CODE_WARRANT_FEE)) {
            warrantFee = fee.getAmount();
        } else if (fee.getDemandReason().getEgDemandReasonMaster().getCode()
                .equalsIgnoreCase(DEMANDRSN_CODE_COURT_FEE)) {
            courtFee = fee.getAmount();
        } else if (fee.getDemandReason().getEgDemandReasonMaster().getCode()
                .equalsIgnoreCase(DEMANDRSN_CODE_NOTICE_FEE)) {
            noticeFee = fee.getAmount();
        }
    }
    Map<String, Object> paramMap = new HashMap<String, Object>();
    CFinancialYear currentFinancialYear = propertyTaxUtil.getFinancialYearforDate(getCurrentDate());
    String currFinYear = currentFinancialYear.getFinYearRange();
    paramMap.put("paasoon", currFinYear);
    paramMap.put("noticeDate", new Date());
    paramMap.put("billNo", recovery.getBill().getBillNo());
    paramMap.put("warrantFee", warrantFee.toString());
    paramMap.put("courtFee", courtFee.toString());
    paramMap.put("noticeFee", noticeFee.toString());
    paramMap.put("zoneNum", recovery.getBasicProperty().getPropertyID().getZone().getBoundaryNum().toString());
    paramMap.put("noticeNo", noticeNo);
    PropertyTaxUtil propertyTaxUtil = new PropertyTaxUtil();
    Map<String, Map<String, BigDecimal>> reasonwiseDues = propertyTaxUtil
            .getDemandDues(recovery.getBasicProperty().getUpicNo());
    PropertyBillInfo propertyBillInfo = new PropertyBillInfo(reasonwiseDues, recovery.getBasicProperty(), null);
    BigDecimal totalRecoverAmt = (propertyBillInfo.getGrandTotal().add(courtFee.add(warrantFee))).setScale(2);
    paramMap.put("totalAmt", totalRecoverAmt.toString());
    ReportRequest reportRequest = new ReportRequest(PropertyTaxConstants.WARRANT_APPLICATION, propertyBillInfo,
            paramMap);
    reportRequest.setPrintDialogOnOpenReport(true);
    ReportOutput reportOutput = reportService.createReport(reportRequest);
    reportId = addingReportToSession(reportOutput);
    if (reportOutput != null && reportOutput.getReportOutputData() != null) {
        InputStream warrantApplPDF = new ByteArrayInputStream(reportOutput.getReportOutputData());
        PtNotice ptNotice = noticeService.saveNotice(null, noticeNo, PropertyTaxConstants.WARRANT_APPLICATION,
                recovery.getBasicProperty(), warrantApplPDF);
        recovery.getWarrant().setNotice(ptNotice);
    }
    return PRINT;
}

From source file:org.openhab.binding.km200.internal.KM200Comm.java

/**
 * This function parses the receviced JSON Data and return the right state
 *
 *//*  w  ww  .j  ava 2  s  .  c om*/
public State parseJSONData(String decodedData, String type, String item, KM200BindingProvider provider) {
    JSONObject nodeRoot = null;
    State state = null;
    Class<? extends Item> itemType = provider.getItemType(item);
    String service = checkParameterReplacement(provider, item);
    KM200CommObject object = device.serviceMap.get(service);
    logger.debug("parseJSONData service: {}, data: {}", service, decodedData);
    /* Now parsing of the JSON String depending on its type and the type of binding item */
    try {
        if (decodedData.length() > 0) {
            nodeRoot = new JSONObject(decodedData);
        } else {
            logger.warn("Get empty reply");
            return null;
        }

        switch (type) {
        case "stringValue": /* Check whether the type is a single value containing a string value */
            logger.debug("initDevice: type string value: {}", decodedData);
            String sVal = nodeRoot.getString("value");
            device.serviceMap.get(service).setValue(sVal);
            /* SwitchItem Binding */
            if (itemType.isAssignableFrom(SwitchItem.class)) {
                if (provider.getParameter(item).containsKey("on")) {
                    if (sVal.equals(provider.getParameter(item).get("off"))) {
                        state = OnOffType.OFF;
                    } else if (sVal.equals(provider.getParameter(item).get("on"))) {
                        state = OnOffType.ON;
                    }
                } else {
                    logger.warn("Switch-Item only on configured on/off string values: {}", decodedData);
                    return null;
                }

                /* NumberItem Binding */
            } else if (itemType.isAssignableFrom(NumberItem.class)) {
                try {
                    state = new DecimalType(Float.parseFloat(sVal));
                } catch (NumberFormatException e) {
                    logger.error(
                            "Conversion of the string value to Decimal wasn't possible, data: {} error: {}",
                            decodedData, e);
                    return null;
                }
                /* DateTimeItem Binding */
            } else if (itemType.isAssignableFrom(DateTimeItem.class)) {
                try {
                    state = new DateTimeType(sVal);
                } catch (IllegalArgumentException e) {
                    logger.error(
                            "Conversion of the string value to DateTime wasn't possible, data: {} error: {}",
                            decodedData, e);
                    return null;
                }

                /* StringItem Binding */
            } else if (itemType.isAssignableFrom(StringItem.class)) {
                state = new StringType(sVal);

            } else {
                logger.warn("Bindingtype not supported for string values: {}", itemType.getClass());
                return null;
            }
            return state;

        case "floatValue": /* Check whether the type is a single value containing a float value */
            logger.debug("state of type float value: {}", decodedData);
            BigDecimal bdVal = nodeRoot.getBigDecimal("value");
            device.serviceMap.get(service).setValue(bdVal);
            /* NumberItem Binding */
            if (itemType.isAssignableFrom(NumberItem.class)) {
                state = new DecimalType(bdVal.floatValue());

                /* StringItem Binding */
            } else if (itemType.isAssignableFrom(StringItem.class)) {
                state = new StringType(bdVal.toString());
            } else {
                logger.warn("Bindingtype not supported for float values: {}", itemType.getClass());
                return null;
            }
            return state;

        case "switchProgram": /* Check whether the type is a switchProgram */
            KM200SwitchProgramService sPService = null;
            logger.debug("state of type switchProgram: {}", decodedData);
            /* Get the KM200SwitchProgramService class object with all specific parameters */
            if (object.getVirtual() == 0) {
                sPService = ((KM200SwitchProgramService) object.getValueParameter());
            } else {
                sPService = ((KM200SwitchProgramService) device.serviceMap.get(object.getParent())
                        .getValueParameter());
            }
            /* Update the switches insode the KM200SwitchProgramService */
            sPService.updateSwitches(nodeRoot);

            /* the parsing of switch program-services have to be outside, using json in strings */
            if (object.getVirtual() == 1) {
                return this.getVirtualState(object, itemType, service);
            } else {
                /* if access to the parent non virtual service the return the switchPoints jsonarray */
                if (itemType.isAssignableFrom(StringItem.class)) {
                    state = new StringType(nodeRoot.getJSONArray("switchPoints").toString());
                } else {
                    logger.warn(
                            "Bindingtype not supported for switchProgram, only json over strings supported: {}",
                            itemType.getClass());
                    return null;
                }
                return state;
            }

        case "errorList": /* Check whether the type is a errorList */
            KM200ErrorService eService = null;
            logger.debug("state of type errorList: {}", decodedData);
            /* Get the KM200ErrorService class object with all specific parameters */
            if (object.getVirtual() == 0) {
                eService = ((KM200ErrorService) object.getValueParameter());
            } else {
                eService = ((KM200ErrorService) device.serviceMap.get(object.getParent()).getValueParameter());
            }
            /* Update the switches insode the KM200SwitchProgramService */
            eService.updateErrors(nodeRoot);

            /* the parsing of switch program-services have to be outside, using json in strings */
            if (object.getVirtual() == 1) {
                return this.getVirtualState(object, itemType, service);
            } else {
                /* if access to the parent non virtual service the return the switchPoints jsonarray */
                if (itemType.isAssignableFrom(StringItem.class)) {
                    state = new StringType(nodeRoot.getJSONArray("values").toString());
                } else {
                    logger.warn(
                            "Bindingtype not supported for error list, only json over strings is supported: {}",
                            itemType.getClass());
                    return null;
                }
                return state;
            }

        case "yRecording": /* Check whether the type is a yRecording */
            logger.info("state of: type yRecording is not supported yet: {}", decodedData);
            /* have to be completed */
            break;

        case "systeminfo": /* Check whether the type is a systeminfo */
            logger.info("state of: type systeminfo is not supported yet: {}", decodedData);
            /* have to be completed */
            break;

        case "arrayData": /* Check whether the type is a arrayData */
            logger.info("state of: type arrayData is not supported yet: {}", decodedData);
            /* have to be completed */
            break;
        }
    } catch (JSONException e) {
        logger.error("Parsingexception in JSON, data: {} error: {} ", decodedData, e.getMessage());
    }
    return null;
}

From source file:org.egov.works.web.controller.lineestimate.UpdateLineEstimateController.java

private void validateBudgetAmount(final LineEstimate lineEstimate, final BindingResult errors) {

    final List<Long> budgetheadid = new ArrayList<Long>();
    budgetheadid.add(lineEstimate.getBudgetHead().getId());

    try {//w ww .  j a v a2s.c o m
        final BigDecimal budgetAvailable = budgetDetailsDAO.getPlanningBudgetAvailable(
                lineEstimateService.getCurrentFinancialYear(new Date()).getId(),
                Integer.parseInt(lineEstimate.getExecutingDepartment().getId().toString()),
                lineEstimate.getFunction().getId(), null,
                lineEstimate.getScheme() == null ? null
                        : Integer.parseInt(lineEstimate.getScheme().getId().toString()),
                lineEstimate.getSubScheme() == null ? null
                        : Integer.parseInt(lineEstimate.getSubScheme().getId().toString()),
                null, budgetheadid, Integer.parseInt(lineEstimate.getFund().getId().toString()));

        BigDecimal totalEstimateAmount = BigDecimal.ZERO;

        for (final LineEstimateDetails led : lineEstimate.getLineEstimateDetails())
            totalEstimateAmount = led.getEstimateAmount().add(totalEstimateAmount);

        if (BudgetControlType.BudgetCheckOption.MANDATORY.toString()
                .equalsIgnoreCase(budgetControlTypeService.getConfigValue())
                && budgetAvailable.compareTo(totalEstimateAmount) == -1)

            errors.reject("error.budgetappropriation.amount",
                    new String[] { budgetAvailable.toString(), totalEstimateAmount.toString() }, null);
    } catch (final ValidationException e) {
        // TODO: Used ApplicationRuntimeException for time being since there
        // is issue in session after
        // budgetDetailsDAO.getPlanningBudgetAvailable API call
        // TODO: needs to replace with errors.reject
        for (final ValidationError error : e.getErrors())
            throw new ApplicationRuntimeException(error.getKey());
        /*
         * for (final ValidationError error : e.getErrors())
         * errors.reject(error.getMessage());
         */
    }
}

From source file:org.apache.manifoldcf.crawler.connectors.cmis.CmisRepositoryConnector.java

/** Process a set of documents.
* This is the method that should cause each document to be fetched, processed, and the results either added
* to the queue of documents for the current job, and/or entered into the incremental ingestion manager.
* The document specification allows this class to filter what is done based on the job.
* The connector will be connected before this method can be called.
*@param documentIdentifiers is the set of document identifiers to process.
*@param statuses are the currently-stored document versions for each document in the set of document identifiers
* passed in above.//  w  w w .j  a  v  a 2  s . co  m
*@param activities is the interface this method should use to queue up new document references
* and ingest documents.
*@param jobMode is an integer describing how the job is being run, whether continuous or once-only.
*@param usesDefaultAuthority will be true only if the authority in use for these documents is the default one.
*/
@Override
public void processDocuments(String[] documentIdentifiers, IExistingVersions statuses, Specification spec,
        IProcessActivity activities, int jobMode, boolean usesDefaultAuthority)
        throws ManifoldCFException, ServiceInterruption {

    // Extract what we need from the spec
    String cmisQuery = StringUtils.EMPTY;
    for (int i = 0; i < spec.getChildCount(); i++) {
        SpecificationNode sn = spec.getChild(i);
        if (sn.getType().equals(JOB_STARTPOINT_NODE_TYPE)) {
            cmisQuery = sn.getAttributeValue(CmisConfig.CMIS_QUERY_PARAM);
            break;
        }
    }

    for (String documentIdentifier : documentIdentifiers) {

        if (Logging.connectors.isDebugEnabled())
            Logging.connectors.debug("CMIS: Processing document identifier '" + documentIdentifier + "'");

        getSession();

        // Load the object.  If this fails, it has been deleted.
        CmisObject cmisObject;
        try {
            cmisObject = session.getObject(documentIdentifier);
        } catch (CmisObjectNotFoundException e) {
            cmisObject = null;
        }

        if (cmisObject == null) {
            //System.out.println(" doesn't exist");
            activities.deleteDocument(documentIdentifier);
            continue;
        }

        String versionString;

        if (cmisObject.getBaseType().getId().equals(CMIS_DOCUMENT_BASE_TYPE)) {
            Document document = (Document) cmisObject;

            // Since documents that are not current have different node id's, we can return a constant version,
            // EXCEPT when the document is not the current one (in which case we delete)
            boolean isCurrentVersion;
            try {
                Document d = document.getObjectOfLatestVersion(false);
                isCurrentVersion = d.getId().equals(documentIdentifier);
            } catch (CmisObjectNotFoundException e) {
                isCurrentVersion = false;
            }
            if (isCurrentVersion) {
                //System.out.println(" is latest version");
                versionString = documentIdentifier + ":" + cmisQuery;
            } else {
                //System.out.println(" is NOT latest vrersion");
                activities.deleteDocument(documentIdentifier);
                continue;
            }
        } else {
            //a CMIS folder will always be processed
            //System.out.println(" is folder");
            versionString = StringUtils.EMPTY;
        }

        if (versionString.length() == 0
                || activities.checkDocumentNeedsReindexing(documentIdentifier, versionString)) {
            // Index this document
            String errorCode = null;
            String errorDesc = null;
            Long fileLengthLong = null;
            long startTime = System.currentTimeMillis();
            try {
                String baseTypeId = cmisObject.getBaseType().getId();

                if (baseTypeId.equals(CMIS_FOLDER_BASE_TYPE)) {

                    // adding all the children for a folder

                    Folder folder = (Folder) cmisObject;
                    ItemIterable<CmisObject> children = folder.getChildren();
                    for (CmisObject child : children) {
                        activities.addDocumentReference(child.getId(), documentIdentifier, RELATIONSHIP_CHILD);
                    }
                } else if (baseTypeId.equals(CMIS_DOCUMENT_BASE_TYPE)) {
                    // content ingestion

                    Document document = (Document) cmisObject;

                    Date createdDate = document.getCreationDate().getTime();
                    Date modifiedDate = document.getLastModificationDate().getTime();
                    long fileLength = document.getContentStreamLength();
                    String fileName = document.getContentStreamFileName();
                    String mimeType = document.getContentStreamMimeType();
                    //documentURI
                    String documentURI = CmisRepositoryConnectorUtils.getDocumentURL(document, session);

                    // Do any filtering (which will save us work)
                    if (!activities.checkURLIndexable(documentURI)) {
                        activities.noDocument(documentIdentifier, versionString);
                        errorCode = activities.EXCLUDED_URL;
                        errorDesc = "Excluding due to URL ('" + documentURI + "')";
                        continue;
                    }

                    if (!activities.checkMimeTypeIndexable(mimeType)) {
                        activities.noDocument(documentIdentifier, versionString);
                        errorCode = activities.EXCLUDED_MIMETYPE;
                        errorDesc = "Excluding due to mime type (" + mimeType + ")";
                        continue;
                    }

                    if (!activities.checkLengthIndexable(fileLength)) {
                        activities.noDocument(documentIdentifier, versionString);
                        errorCode = activities.EXCLUDED_LENGTH;
                        errorDesc = "Excluding due to length (" + fileLength + ")";
                        continue;
                    }

                    if (!activities.checkDateIndexable(modifiedDate)) {
                        activities.noDocument(documentIdentifier, versionString);
                        errorCode = activities.EXCLUDED_DATE;
                        errorDesc = "Excluding due to date (" + modifiedDate + ")";
                        continue;
                    }

                    RepositoryDocument rd = new RepositoryDocument();
                    rd.setFileName(fileName);
                    rd.setMimeType(mimeType);
                    rd.setCreatedDate(createdDate);
                    rd.setModifiedDate(modifiedDate);

                    InputStream is;
                    try {
                        if (fileLength > 0)
                            is = document.getContentStream().getStream();
                        else
                            is = null;
                    } catch (CmisObjectNotFoundException e) {
                        // Document gone
                        activities.deleteDocument(documentIdentifier);
                        continue;
                    }

                    try {
                        //binary
                        if (is != null) {
                            rd.setBinary(is, fileLength);
                        } else {
                            rd.setBinary(new NullInputStream(0), 0);
                        }

                        //properties
                        List<Property<?>> properties = document.getProperties();
                        String id = StringUtils.EMPTY;
                        for (Property<?> property : properties) {
                            String propertyId = property.getId();

                            if (CmisRepositoryConnectorUtils.existsInSelectClause(cmisQuery, propertyId)) {

                                if (propertyId.endsWith(Constants.PARAM_OBJECT_ID)) {
                                    id = (String) property.getValue();

                                    if (property.getValue() != null || property.getValues() != null) {
                                        PropertyType propertyType = property.getType();

                                        switch (propertyType) {

                                        case STRING:
                                        case ID:
                                        case URI:
                                        case HTML:
                                            if (property.isMultiValued()) {
                                                List<String> htmlPropertyValues = (List<String>) property
                                                        .getValues();
                                                for (String htmlPropertyValue : htmlPropertyValues) {
                                                    rd.addField(propertyId, htmlPropertyValue);
                                                }
                                            } else {
                                                String stringValue = (String) property.getValue();
                                                if (StringUtils.isNotEmpty(stringValue)) {
                                                    rd.addField(propertyId, stringValue);
                                                }
                                            }
                                            break;

                                        case BOOLEAN:
                                            if (property.isMultiValued()) {
                                                List<Boolean> booleanPropertyValues = (List<Boolean>) property
                                                        .getValues();
                                                for (Boolean booleanPropertyValue : booleanPropertyValues) {
                                                    rd.addField(propertyId, booleanPropertyValue.toString());
                                                }
                                            } else {
                                                Boolean booleanValue = (Boolean) property.getValue();
                                                if (booleanValue != null) {
                                                    rd.addField(propertyId, booleanValue.toString());
                                                }
                                            }
                                            break;

                                        case INTEGER:
                                            if (property.isMultiValued()) {
                                                List<BigInteger> integerPropertyValues = (List<BigInteger>) property
                                                        .getValues();
                                                for (BigInteger integerPropertyValue : integerPropertyValues) {
                                                    rd.addField(propertyId, integerPropertyValue.toString());
                                                }
                                            } else {
                                                BigInteger integerValue = (BigInteger) property.getValue();
                                                if (integerValue != null) {
                                                    rd.addField(propertyId, integerValue.toString());
                                                }
                                            }
                                            break;

                                        case DECIMAL:
                                            if (property.isMultiValued()) {
                                                List<BigDecimal> decimalPropertyValues = (List<BigDecimal>) property
                                                        .getValues();
                                                for (BigDecimal decimalPropertyValue : decimalPropertyValues) {
                                                    rd.addField(propertyId, decimalPropertyValue.toString());
                                                }
                                            } else {
                                                BigDecimal decimalValue = (BigDecimal) property.getValue();
                                                if (decimalValue != null) {
                                                    rd.addField(propertyId, decimalValue.toString());
                                                }
                                            }
                                            break;

                                        case DATETIME:
                                            if (property.isMultiValued()) {
                                                List<GregorianCalendar> datePropertyValues = (List<GregorianCalendar>) property
                                                        .getValues();
                                                for (GregorianCalendar datePropertyValue : datePropertyValues) {
                                                    rd.addField(propertyId, ISO8601_DATE_FORMATTER
                                                            .format(datePropertyValue.getTime()));
                                                }
                                            } else {
                                                GregorianCalendar dateValue = (GregorianCalendar) property
                                                        .getValue();
                                                if (dateValue != null) {
                                                    rd.addField(propertyId,
                                                            ISO8601_DATE_FORMATTER.format(dateValue.getTime()));
                                                }
                                            }
                                            break;

                                        default:
                                            break;
                                        }
                                    }

                                }

                            }
                        }

                        //ingestion

                        try {
                            activities.ingestDocumentWithException(documentIdentifier, versionString,
                                    documentURI, rd);
                            fileLengthLong = new Long(fileLength);
                            errorCode = "OK";
                        } catch (IOException e) {
                            errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
                            errorDesc = e.getMessage();
                            handleIOException(e, "reading file input stream");
                        }
                    } finally {
                        try {
                            if (is != null) {
                                is.close();
                            }
                        } catch (IOException e) {
                            errorCode = e.getClass().getSimpleName().toUpperCase(Locale.ROOT);
                            errorDesc = e.getMessage();
                            handleIOException(e, "closing file input stream");
                        }
                    }
                } else {
                    // Unrecognized document type
                    activities.noDocument(documentIdentifier, versionString);
                    errorCode = "UNKNOWNTYPE";
                    errorDesc = "Document type is unrecognized: '" + baseTypeId + "'";
                }
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    errorCode = null;
                throw e;
            } finally {
                if (errorCode != null)
                    activities.recordActivity(new Long(startTime), ACTIVITY_READ, fileLengthLong,
                            documentIdentifier, errorCode, errorDesc, null);
            }
        }
    }

}