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.pentaho.platform.engine.services.runtime.SimpleRuntimeElement.java

/**
 * Sets the BigDecimal property in the paramMap. Special implementation note - Null values aren't supported in
 * the Map. So, if a null value is passed in, this implementation will remove the entry from the map.
 * //w  w  w  .  j a  va2  s .  c om
 * @param key
 *          Key in the paramMap.
 * @param value
 *          The property value to set.
 */
public void setBigDecimalProperty(final String key, final BigDecimal value) {
    this.updateOk();
    trace(Messages.getInstance().getString("RTREPO.DEBUG_PROPERTY_GETSET", "setBigDecimal", key)); //$NON-NLS-1$ //$NON-NLS-2$
    Map theMap = getParamMapBD();
    if (value != null) {
        checkType(key, value.getClass().getName(), true);
        theMap.put(key, value.toString());
    } else {
        theMap.remove(key);
    }
}

From source file:org.openbravo.erpCommon.ad_reports.MInOutTraceReports.java

private String processExternalChilds(VariablesSecureApp vars, MInOutTraceReportsData dataChild, String strIn,
        boolean colorbg, String strmProductIdGlobal, Hashtable<String, Integer> calculated,
        Vector<Integer> count) throws ServletException {
    StringBuffer strHtml = new StringBuffer();
    BigDecimal movementQty = new BigDecimal(dataChild.movementqty);
    // if (log4j.isDebugEnabled()) log4j.debug("****PROCESSING EXTERNAL 1: "
    // + movementQty.toString() + " and strIn: " + strIn);
    if (strIn.equals("Y"))
        movementQty = movementQty.negate();
    if (log4j.isDebugEnabled())
        log4j.debug("****PROCESSING EXTERNAL 2: " + movementQty.toString() + " and movementType:"
                + dataChild.movementtype);

    if (dataChild.movementtype.startsWith("P") && (movementQty.compareTo(BigDecimal.ZERO) > 0)) {
        String strNewId = dataChild.mProductionlineId;
        MInOutTraceReportsData[] dataProduction;
        if (log4j.isDebugEnabled())
            log4j.debug("****PROCESSING PRODUCTIONLINE: " + strNewId + " " + strIn);
        if (strIn.equals("Y")) {
            dataProduction = MInOutTraceReportsData.selectProductionOut(this, vars.getLanguage(), strNewId);
        } else {//from   w  w  w. j  a va  2  s. c om
            dataProduction = MInOutTraceReportsData.selectProductionIn(this, vars.getLanguage(), strNewId);
        }
        if (dataProduction != null && dataProduction.length > 0) {
            strHtml.append("  <tr>\n");
            strHtml.append("    <td colspan=\"3\">\n");
            strHtml.append(insertHeaderHtml(false, "0"));
            for (int j = 0; j < dataProduction.length; j++) {
                strHtml.append("  <tr style=\"background: ").append((colorbg ? "#CCCCCC" : "#AAAAAA"))
                        .append("\">\n");
                strHtml.append(insertTabHtml(true));
                strHtml.append("    <td >\n");

                String resultado2 = "";
                strHtml.append("<table border=\"0\" cellspacing=0 cellpadding=0 width=\"100%\">\n");
                strHtml.append("  <tr>\n");
                strHtml.append("    <td class=\"DataGrid_Body_Cell\" width=\"70\">")
                        .append(dataProduction[j].movementdate).append("</td>\n");
                strHtml.append("    <td class=\"DataGrid_Body_Cell\" width=\"100\">")
                        .append(StringEscapeUtils.escapeHtml(dataProduction[j].movementtypeName))
                        .append("</td>\n");
                strHtml.append("    <td class=\"DataGrid_Body_Cell\" width=\"100\">")
                        .append(dataProduction[j].locatorName).append("</td>\n");
                strHtml.append("    <td class=\"DataGrid_Body_Cell_Amount\" width=\"90\">")
                        .append(dataProduction[j].movementqty).append("&nbsp;")
                        .append(StringEscapeUtils.escapeHtml(dataProduction[j].uomName)).append("</td>\n");
                strHtml.append("    <td class=\"DataGrid_Body_Cell\" width=\"90\">")
                        .append(dataProduction[j].quantityorder).append("&nbsp;")
                        .append(StringEscapeUtils.escapeHtml(dataProduction[j].productUomName))
                        .append("</td>\n");
                resultado2 = dataProduction[j].productName;
                strHtml.append(
                        "    <td class=\"DataGrid_Body_Cell\"><a href=\"#\" onclick=\"submitCommandForm('INVERSE', true, null, 'MInOutTraceReports.html?inpmProductId2="
                                + dataProduction[j].mProductId + "&inpmAttributeSetInstanceId2="
                                + dataProduction[j].mAttributesetinstanceId + "&inpIn2="
                                + (strIn.equals("Y") ? "N" : "Y")
                                + "', '_self');return true;\" class=\"LabelLink\">");
                if (!resultado2.equals(""))
                    strHtml.append(StringEscapeUtils.escapeHtml(resultado2));
                strHtml.append("&nbsp;</a></td>\n");
                resultado2 = dataProduction[j].attributeName;
                strHtml.append("    <td class=\"DataGrid_Body_Cell\" width=\"120\">");
                if (!resultado2.equals(""))
                    strHtml.append(StringEscapeUtils.escapeHtml(resultado2));
                strHtml.append("&nbsp;</td>\n");
                strHtml.append("</tr></table>");

                strHtml.append("  </td></tr>\n");
                if (!dataProduction[j].mAttributesetinstanceId.equals("0")) {
                    String strCalculate = dataProduction[j].mProductId + "&"
                            + dataProduction[j].mAttributesetinstanceId + "&" + dataProduction[j].mLocatorId;
                    if (log4j.isDebugEnabled())
                        log4j.debug("******** Hashtable.production: " + strCalculate);
                    if (log4j.isDebugEnabled())
                        log4j.debug(
                                "******** Production, hashtable calculated: " + calculated.get(strCalculate));
                    Integer isnull = calculated.get(strCalculate);
                    if (isnull == null) {
                        String strPartial = processChilds(vars, dataProduction[j].mAttributesetinstanceId,
                                dataProduction[j].mProductId, dataProduction[j].mLocatorId, strIn, !colorbg,
                                strmProductIdGlobal, calculated, count);
                        if (!strPartial.equals("")) {
                            strHtml.append("  <tr style=\"background: ")
                                    .append((colorbg ? "#CCCCCC" : "#AAAAAA")).append("\">\n");
                            strHtml.append(insertTabHtml(false));
                            strHtml.append("    <td>\n");
                            strHtml.append(strPartial);
                            strHtml.append("    </td>\n");
                            strHtml.append("  </tr>\n");
                        }
                    }
                }
            }
            strHtml.append(insertHeaderHtml(true, ""));
            strHtml.append("</td></tr>\n");
        }
    }

    if (dataChild.movementtype.startsWith("M") && (movementQty.compareTo(BigDecimal.ZERO) > 0)) {
        String strNewId = dataChild.mMovementlineId;
        MInOutTraceReportsData[] dataMovement;
        if (log4j.isDebugEnabled())
            log4j.debug("****PROCESSING MOVEMENTLINE: " + strNewId + " " + strIn);
        dataMovement = MInOutTraceReportsData.selectMovement(this, vars.getLanguage(),
                strIn.equals("Y") ? "M+" : "M-", strNewId);
        if (dataMovement != null && dataMovement.length > 0) {
            strHtml.append("  <tr>\n");
            strHtml.append("    <td colspan=\"3\">\n");
            strHtml.append(insertHeaderHtml(false, "1"));
            for (int j = 0; j < dataMovement.length; j++) {
                strHtml.append("  <tr style=\"background: ").append((colorbg ? "#CCCCCC" : "#AAAAAA"))
                        .append("\">\n");
                strHtml.append(insertTabHtml(true));
                strHtml.append("    <td >\n");

                String resultado2 = "";
                strHtml.append("<table border=\"0\" cellspacing=0 cellpadding=0 width=\"100%\">\n");
                strHtml.append("  <tr>\n");
                strHtml.append("    <td class=\"DataGrid_Body_Cell\" width=\"70\">")
                        .append(dataMovement[j].movementdate).append("</td>\n");
                strHtml.append("    <td class=\"DataGrid_Body_Cell\" width=\"100\">")
                        .append(dataMovement[j].movementtypeName).append("</td>\n");
                strHtml.append("    <td class=\"DataGrid_Body_Cell\" width=\"100\">")
                        .append(dataMovement[j].locatorName).append("</td>\n");
                strHtml.append("    <td class=\"DataGrid_Body_Cell_Amount\" width=\"90\">")
                        .append(dataMovement[j].movementqty).append("&nbsp;").append(dataMovement[j].uomName)
                        .append("</td>\n");
                strHtml.append("    <td class=\"DataGrid_Body_Cell\" width=\"90\">")
                        .append(dataMovement[j].quantityorder).append("&nbsp;")
                        .append(dataMovement[j].productUomName).append("</td>\n");
                resultado2 = dataMovement[j].productName;
                strHtml.append("    <td class=\"DataGrid_Body_Cell\">");
                if (!resultado2.equals(""))
                    strHtml.append(resultado2);
                strHtml.append("&nbsp;</td>\n");
                resultado2 = dataMovement[j].attributeName;
                strHtml.append("    <td class=\"DataGrid_Body_Cell\" width=\"120\">");
                if (!resultado2.equals(""))
                    strHtml.append(resultado2);
                strHtml.append("&nbsp;</td>\n");
                strHtml.append("</tr></table>");

                // strHtml.append(getData(dataProduction[j], "Bordes"));
                strHtml.append("  </td></tr>\n");
                if (!dataMovement[j].mAttributesetinstanceId.equals("0")) {
                    String strPartial = "";
                    if (!dataMovement[j].mProductId.equals(strmProductIdGlobal)) {
                        if (log4j.isDebugEnabled())
                            log4j.debug("******** hashtable.production: Prod: " + dataMovement[j].mProductId
                                    + " Attr " + dataMovement[j].mAttributesetinstanceId + " Loc: "
                                    + dataMovement[j].mLocatorId);
                        String strCalculate = dataMovement[j].mProductId + "&"
                                + dataMovement[j].mAttributesetinstanceId + "&" + dataMovement[j].mLocatorId;
                        if (log4j.isDebugEnabled())
                            log4j.debug(
                                    "******** Movement, hashtable calculated: " + calculated.get(strCalculate));
                        if (calculated.get(strCalculate) == null) {
                            strPartial = processChilds(vars, dataMovement[j].mAttributesetinstanceId,
                                    dataMovement[j].mProductId, dataMovement[j].mLocatorId, strIn, !colorbg,
                                    strmProductIdGlobal, calculated, count);
                        }
                    }
                    if (!strPartial.equals("")) {
                        strHtml.append("  <tr style=\"background: ").append((colorbg ? "#CCCCCC" : "#AAAAAA"))
                                .append("\">\n");
                        strHtml.append(insertTabHtml(false));
                        strHtml.append("    <td>\n");
                        strHtml.append(strPartial);
                        strHtml.append("    </td>\n");
                        strHtml.append("  </tr>\n");
                    }
                }
            }
            strHtml.append(insertHeaderHtml(true, ""));
            strHtml.append("</td></tr>\n");
        }
    }
    return strHtml.toString();
}

From source file:org.pentaho.platform.repository.runtime.RuntimeElement.java

/**
 * Sets the BigDecimal property in the paramMap. Special implementation note - Null values aren't supported in
 * the Map. So, if a null value is passed in, this implementation will remove the entry from the map.
 * /*from w  ww .  j  a va  2s.c o  m*/
 * @param key
 *          Key in the paramMap.
 * @param value
 *          The property value to set.
 */
public void setBigDecimalProperty(final String key, final BigDecimal value) {
    this.updateOk();
    trace(Messages.getInstance().getString("RTREPO.DEBUG_PROPERTY_GETSET", "setBigDecimal", key)); //$NON-NLS-1$ //$NON-NLS-2$
    checkType(key, value.getClass().getName(), true);
    Map theMap = getParamMapBD();
    if (value != null) {
        theMap.put(key, value.toString());
    } else {
        theMap.remove(key);
    }
}

From source file:com.jive.myco.seyren.core.util.graphite.GraphiteHttpClient.java

public byte[] getChart(String target, int width, int height, String from, String to, LegendState legendState,
        AxesState axesState, BigDecimal warnThreshold, BigDecimal errorThreshold) throws Exception {
    URI baseUri = new URI(graphiteScheme, graphiteHost, graphitePath + "/render/", null, null);
    URIBuilder uriBuilder = new URIBuilder(baseUri).addParameter("target", target).addParameter("from", from)
            .addParameter("width", String.valueOf(width)).addParameter("height", String.valueOf(height))
            .addParameter("uniq", String.valueOf(new DateTime().getMillis()))
            .addParameter("hideLegend", legendState == LegendState.HIDE ? "true" : "false")
            .addParameter("hideAxes", axesState == AxesState.HIDE ? "true" : "false");

    if (warnThreshold != null) {
        uriBuilder.addParameter("target",
                String.format(THRESHOLD_TARGET, warnThreshold.toString(), "yellow", "warn level"));
    }//www.  j a v  a 2 s.c  o  m

    if (errorThreshold != null) {
        uriBuilder.addParameter("target",
                String.format(THRESHOLD_TARGET, errorThreshold.toString(), "red", "error level"));
    }

    HttpGet get = new HttpGet(uriBuilder.build());

    try {
        return client.execute(get, chartBytesHandler, context);
    } catch (Exception e) {
        throw new GraphiteReadException("Failed to read from Graphite", e);
    } finally {
        get.releaseConnection();
    }
}

From source file:oscar.oscarBilling.ca.on.data.RAData.java

public String getAmountPaid(ArrayList a, String billingNo, String serviceCode) {
    BigDecimal total = new BigDecimal("0.00").setScale(2, BigDecimal.ROUND_HALF_UP);
    for (int i = 0; i < a.size(); i++) {
        Hashtable h = (Hashtable) a.get(i);
        if (!(h.get("billing_no").equals(billingNo)) || !(h.get("service_code").equals(serviceCode))) {
            continue;
        }// w w w. j  a  v a  2 s  .  c o m
        BigDecimal valueToAdd = new BigDecimal("0.00");
        try {
            String amount = "" + h.get("amountpay");
            amount = amount.trim();
            valueToAdd = new BigDecimal(amount).setScale(2, BigDecimal.ROUND_HALF_UP);
        } catch (Exception badValueException) {
            MiscUtils.getLogger().debug(" Error calculating value for " + h.get("billing_no"));
            MiscUtils.getLogger().error("Error", badValueException);
        }
        total = total.add(valueToAdd);
    }
    return total.toString();
}

From source file:org.fenixedu.academic.domain.mobility.outbound.OutboundMobilityCandidacyContestGroup.java

public Spreadsheet getCandidatesInformationSpreadSheet(final OutboundMobilityCandidacyPeriod period) {
    final String filename = BundleUtil.getString(Bundle.ACADEMIC,
            "label.mobility.candidates.information.filename");

    final Spreadsheet spreadsheetCurricularInfo = new Spreadsheet(filename);
    final Spreadsheet spreadsheetOptions = spreadsheetCurricularInfo
            .addSpreadsheet(BundleUtil.getString(Bundle.ACADEMIC, "label.mobility.candidates.options"));
    final Spreadsheet spreadsheetContactInformation = spreadsheetOptions
            .addSpreadsheet(BundleUtil.getString(Bundle.ACADEMIC, "label.contact.information"));
    final Spreadsheet spreadsheetOtherCurricularInfo = spreadsheetOptions
            .addSpreadsheet(BundleUtil.getString(Bundle.ACADEMIC, "label.other.curricular.info"));

    final Set<Registration> processed = new HashSet<Registration>();
    for (final OutboundMobilityCandidacyContest contest : getOutboundMobilityCandidacyContestSet()) {
        for (final OutboundMobilityCandidacy candidacy : contest.getOutboundMobilityCandidacySet()) {
            final OutboundMobilityCandidacySubmission submission = candidacy
                    .getOutboundMobilityCandidacySubmission();
            final Registration registration = submission.getRegistration();
            final Calculator calculator = new Calculator(registration.getStudent());

            if (!processed.contains(registration)) {
                final Person person = registration.getPerson();

                final Row row = spreadsheetCurricularInfo.addRow();
                final BigDecimal candidacyGrade = submission.getGrade(this);
                //                    final ICurriculum curriculum = registration.getCurriculum();
                row.setCell(getString("label.username"), person.getUsername());
                row.setCell(getString("label.name"), person.getName());
                row.setCell(getString("label.degree"), registration.getDegree().getSigla());
                row.setCell(getString("label.candidate.classification"),
                        candidacyGrade == null ? "" : candidacyGrade.toString());

                row.setCell(getString("label.ects.first.cycle"), calculator.completedECTSCycle1.toString());
                row.setCell(getString("label.ects.average"), calculator.getEctsAverage().toString());
                row.setCell(getString("label.ects.average.first.and.second.cycle"),
                        calculator.getEctsEverateFirstAndSecondCycle().toString());
                row.setCell(getString("label.ects.completed"), calculator.completedECTS.toString());
                //row.setCell(getString("label.ects.pending"), calculator.getPendingEcts().toString());
                row.setCell(getString("label.ects.enrolled"), calculator.enrolledECTS.toString());

                for (final Registration otherRegistration : registration.getStudent().getRegistrationsSet()) {
                    final Row rowOCI = spreadsheetOtherCurricularInfo.addRow();
                    final ICurriculum curriculumOther = otherRegistration.getCurriculum();
                    rowOCI.setCell(getString("label.username"), person.getUsername());
                    rowOCI.setCell(getString("label.name"), person.getName());
                    rowOCI.setCell(getString("label.degree"), otherRegistration.getDegree().getSigla());
                    rowOCI.setCell(getString("label.curricular.year"), curriculumOther.getCurricularYear());
                    rowOCI.setCell(getString("label.ects.completed.degree"),
                            curriculumOther.getSumEctsCredits().toString());
                    rowOCI.setCell(getString("label.average.degree"), curriculumOther.getRawGrade().getValue());
                    fillCycleDetails(rowOCI, CycleType.FIRST_CYCLE, otherRegistration,
                            getString("label.ects.completed.cycle.first"),
                            getString("label.average.cycle.first"));
                    fillCycleDetails(rowOCI, CycleType.SECOND_CYCLE, otherRegistration,
                            getString("label.ects.completed.cycle.second"),
                            getString("label.average.cycle.second"));
                }//from  w  w  w  .  java  2  s  .  c  o  m

                for (final OutboundMobilityCandidacy c : submission.getSortedOutboundMobilityCandidacySet()) {
                    final OutboundMobilityCandidacyContest contestFromCandidacy = c
                            .getOutboundMobilityCandidacyContest();
                    final MobilityAgreement mobilityAgreement = contestFromCandidacy.getMobilityAgreement();
                    final UniversityUnit unit = mobilityAgreement.getUniversityUnit();
                    final Country country = unit.getCountry();

                    final Row row2 = spreadsheetOptions.addRow();
                    row2.setCell(getString("label.username"), person.getUsername());
                    row2.setCell(getString("label.preference.order"), c.getPreferenceOrder());
                    row2.setCell(getString("label.degrees"),
                            contestFromCandidacy.getOutboundMobilityCandidacyContestGroup().getDescription());
                    row2.setCell(getString("label.mobility.program"), mobilityAgreement.getMobilityProgram()
                            .getRegistrationProtocol().getDescription().getContent());
                    row2.setCell(getString("label.country"), country == null ? "" : country.getName());
                    row2.setCell(getString("label.university"), unit.getPresentationName());
                }

                final Row contactRow = spreadsheetContactInformation.addRow();
                contactRow.setCell(getString("label.username"), person.getUsername());
                contactRow.setCell(getString("label.name"), person.getName());
                contactRow.setCell(getString("label.email"), person.getEmailForSendingEmails());
                contactRow.setCell(getString("label.phone"), person.getDefaultPhoneNumber());
                contactRow.setCell(getString("label.mobile"), person.getDefaultMobilePhoneNumber());

                processed.add(registration);
            }
        }
    }

    return spreadsheetCurricularInfo;
}

From source file:net.sourceforge.fenixedu.domain.mobility.outbound.OutboundMobilityCandidacyContestGroup.java

public Spreadsheet getCandidatesInformationSpreadSheet(final OutboundMobilityCandidacyPeriod period) {
    final String filename = BundleUtil.getString(Bundle.ACADEMIC,
            "label.mobility.candidates.information.filename");

    final Spreadsheet spreadsheetCurricularInfo = new Spreadsheet(filename);
    final Spreadsheet spreadsheetOptions = spreadsheetCurricularInfo
            .addSpreadsheet(BundleUtil.getString(Bundle.ACADEMIC, "label.mobility.candidates.options"));
    final Spreadsheet spreadsheetContactInformation = spreadsheetOptions
            .addSpreadsheet(BundleUtil.getString(Bundle.ACADEMIC, "label.contact.information"));
    final Spreadsheet spreadsheetOtherCurricularInfo = spreadsheetOptions
            .addSpreadsheet(BundleUtil.getString(Bundle.ACADEMIC, "label.other.curricular.info"));

    final Set<Registration> processed = new HashSet<Registration>();
    for (final OutboundMobilityCandidacyContest contest : getOutboundMobilityCandidacyContestSet()) {
        for (final OutboundMobilityCandidacy candidacy : contest.getOutboundMobilityCandidacySet()) {
            final OutboundMobilityCandidacySubmission submission = candidacy
                    .getOutboundMobilityCandidacySubmission();
            final Registration registration = submission.getRegistration();
            final Calculator calculator = new Calculator(registration.getStudent());

            if (!processed.contains(registration)) {
                final Person person = registration.getPerson();

                final Row row = spreadsheetCurricularInfo.addRow();
                final BigDecimal candidacyGrade = submission.getGrade(this);
                //                    final ICurriculum curriculum = registration.getCurriculum();
                row.setCell(getString("label.username"), person.getUsername());
                row.setCell(getString("label.name"), person.getName());
                row.setCell(getString("label.degree"), registration.getDegree().getSigla());
                row.setCell(getString("label.candidate.classification"),
                        candidacyGrade == null ? "" : candidacyGrade.toString());

                row.setCell(getString("label.ects.first.cycle"), calculator.completedECTSCycle1.toString());
                row.setCell(getString("label.ects.average"), calculator.getEctsAverage().toString());
                row.setCell(getString("label.ects.average.first.and.second.cycle"),
                        calculator.getEctsEverateFirstAndSecondCycle().toString());
                row.setCell(getString("label.ects.completed"), calculator.completedECTS.toString());
                //row.setCell(getString("label.ects.pending"), calculator.getPendingEcts().toString());
                row.setCell(getString("label.ects.enrolled"), calculator.enrolledECTS.toString());

                for (final Registration otherRegistration : registration.getStudent().getRegistrationsSet()) {
                    final Row rowOCI = spreadsheetOtherCurricularInfo.addRow();
                    final ICurriculum curriculumOther = otherRegistration.getCurriculum();
                    rowOCI.setCell(getString("label.username"), person.getUsername());
                    rowOCI.setCell(getString("label.name"), person.getName());
                    rowOCI.setCell(getString("label.degree"), otherRegistration.getDegree().getSigla());
                    rowOCI.setCell(getString("label.curricular.year"), curriculumOther.getCurricularYear());
                    rowOCI.setCell(getString("label.ects.completed.degree"),
                            curriculumOther.getSumEctsCredits().toString());
                    rowOCI.setCell(getString("label.average.degree"), curriculumOther.getAverage().toString());
                    fillCycleDetails(rowOCI, CycleType.FIRST_CYCLE, otherRegistration,
                            getString("label.ects.completed.cycle.first"),
                            getString("label.average.cycle.first"));
                    fillCycleDetails(rowOCI, CycleType.SECOND_CYCLE, otherRegistration,
                            getString("label.ects.completed.cycle.second"),
                            getString("label.average.cycle.second"));
                }/*from  w  w  w.ja  v  a  2  s .c o  m*/

                for (final OutboundMobilityCandidacy c : submission.getSortedOutboundMobilityCandidacySet()) {
                    final OutboundMobilityCandidacyContest contestFromCandidacy = c
                            .getOutboundMobilityCandidacyContest();
                    final MobilityAgreement mobilityAgreement = contestFromCandidacy.getMobilityAgreement();
                    final UniversityUnit unit = mobilityAgreement.getUniversityUnit();
                    final Country country = unit.getCountry();

                    final Row row2 = spreadsheetOptions.addRow();
                    row2.setCell(getString("label.username"), person.getUsername());
                    row2.setCell(getString("label.preference.order"), c.getPreferenceOrder());
                    row2.setCell(getString("label.degrees"),
                            contestFromCandidacy.getOutboundMobilityCandidacyContestGroup().getDescription());
                    row2.setCell(getString("label.mobility.program"), mobilityAgreement.getMobilityProgram()
                            .getRegistrationProtocol().getDescription().getContent());
                    row2.setCell(getString("label.country"), country == null ? "" : country.getName());
                    row2.setCell(getString("label.university"), unit.getPresentationName());
                }

                final Row contactRow = spreadsheetContactInformation.addRow();
                contactRow.setCell(getString("label.username"), person.getUsername());
                contactRow.setCell(getString("label.name"), person.getName());
                contactRow.setCell(getString("label.email"), person.getEmailForSendingEmails());
                contactRow.setCell(getString("label.phone"), person.getDefaultPhoneNumber());
                contactRow.setCell(getString("label.mobile"), person.getDefaultMobilePhoneNumber());

                processed.add(registration);
            }
        }
    }

    return spreadsheetCurricularInfo;
}

From source file:com.magnet.android.mms.controller.RequestPrimitiveTest.java

@SmallTest
public void testSingleListBigDecimalPostParam() throws JSONException {
    ControllerHandler handler = new ControllerHandler();
    String methodName = "postBigDecimals";
    JMethod method = new JMethod();
    JMeta metaInfo = new JMeta(methodName, API_METHOD_POST + methodName, POST);
    method.setMetaInfo(metaInfo);/*from ww  w  . j  av  a2 s  .c  om*/

    // int
    method.addParam("param0", PLAIN, List.class, BigDecimal.class, "", false);

    List<BigDecimal> values = new ArrayList<BigDecimal>();
    values.add(BigDecimal.TEN);
    values.add(BigDecimal.valueOf(101.99));

    String uriString = handler.buildUri(method, new Object[] { values });
    String bodyString = handler.buildRequestBodyString(method, new Object[] { values });

    String expected = API_METHOD_POST + methodName;
    logger.log(Level.INFO, "uriString=" + uriString);
    logger.log(Level.INFO, "bodyString=" + bodyString);
    assertEquals(expected, uriString);

    JSONArray jarray = new JSONArray(bodyString);
    int idx = 0;
    for (BigDecimal value : values) {
        assertEquals(jarray.getString(idx), value.toString());
        idx++;
    }
}

From source file:org.orcid.frontend.web.controllers.FundingsController.java

private void setAmountWithTheCorrectFormat(FundingForm funding) throws Exception {
    if (!PojoUtil.isEmpty(funding.getAmount())) {
        String amount = funding.getAmount().getValue();
        BigDecimal bigDecimal = getAmountAsBigDecimal(amount);
        funding.setAmount(Text.valueOf(bigDecimal.toString()));
    }/*from  w w w.j a  va 2 s .c om*/
}

From source file:org.openvpms.esci.adapter.map.invoice.InvoiceMapperImpl.java

/**
 * Verifies that the invoice line item's <em>PackQuantity</em> is specified correctly, if present.
 *
 * @param line     the invoice line/*  www .java2  s .c  o  m*/
 * @param unitCode the expected unit code
 */
private void checkPackQuantity(UBLInvoiceLine line, String unitCode) {
    BigDecimal quantity = line.getPackQuantity();
    if (quantity != null) {
        if (quantity.compareTo(BigDecimal.ONE) != 0) {
            ErrorContext context = new ErrorContext(line, "PackQuantity");
            throw new ESCIAdapterException(ESCIAdapterMessages.ublInvalidValue(context.getPath(),
                    context.getType(), context.getID(), "1", quantity.toString()));
        }
        String packageUnits = line.getPackQuantityUnitCode();
        if (packageUnits != null && !ObjectUtils.equals(unitCode, packageUnits)) {
            ErrorContext context = new ErrorContext(line, "PackQuantity@unitCode");
            throw new ESCIAdapterException(ESCIAdapterMessages.ublInvalidValue(context.getPath(),
                    context.getType(), context.getID(), unitCode, packageUnits));
        }
    }
}