List of usage examples for java.math BigDecimal toPlainString
public String toPlainString()
From source file:com.google.enterprise.connector.salesforce.storetype.DBStore.java
public DocListEntry getDocsImmediatelyAfter(String checkpoint) { DatabaseMetaData dbm = null;/*w ww. j a va 2 s . c o m*/ Connection connection = null; try { connection = ds.getConnection(); connection.setAutoCommit(true); dbm = connection.getMetaData(); //get the most recent database row after 'checkpoint' if (dbm.getDatabaseProductName().equals("MySQL")) { Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); String update_stmt = "select crawl_set,insert_timestamp,UNCOMPRESS(crawl_data) as cdata from " + this.instance_table + " where crawl_set>" + checkpoint + " LIMIT 1"; logger.log(Level.FINER, update_stmt); ResultSet rs = statement.executeQuery(update_stmt); boolean ret_rows = rs.first(); if (!ret_rows) { logger.log(Level.FINER, "No Rows Returned."); connection.close(); return null; } BigDecimal crawl_set = null; String crawl_data = null; while (ret_rows) { crawl_set = rs.getBigDecimal("crawl_set"); //crawl_data = rs.getString("crawl_data"); crawl_data = rs.getString("cdata"); ret_rows = rs.next(); } rs.close(); statement.close(); connection.close(); //BASE64 DECODE byte[] byte_decoded_entry = org.apache.commons.codec.binary.Base64 .decodeBase64(crawl_data.getBytes()); crawl_data = new String(byte_decoded_entry); logger.log(Level.INFO, "Returning from DBStore. Index Value: " + crawl_set.toPlainString()); logger.log(Level.FINEST, "Returning from DBStore. " + crawl_data); DocListEntry dret = new DocListEntry(crawl_set.toPlainString(), crawl_data); return dret; } } catch (Exception ex) { logger.log(Level.SEVERE, "Unable to retrieve docListEntry " + ex); } return new DocListEntry(checkpoint, null); }
From source file:org.ojai.json.impl.JsonDocumentBuilder.java
@Override public JsonDocumentBuilder add(BigDecimal value) { try {//from w w w. ja v a 2 s .c o m prepareAdd(); if (jsonOptions.isWithTags()) { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField(Types.TAG_DECIMAL, value.toPlainString()); jsonGenerator.writeEndObject(); } else { jsonGenerator.writeNumber(value); } return this; } catch (IOException ie) { throw transformIOException(ie); } }
From source file:org.codice.ddf.spatial.ogc.wfs.catalog.converter.impl.AbstractFeatureConverter.java
private String convertToBytes(HierarchicalStreamReader reader, String unit) { BigDecimal resourceSize = new BigDecimal(reader.getValue()); resourceSize = resourceSize.setScale(1, BigDecimal.ROUND_HALF_UP); switch (unit) { case B://from w w w . j a v a 2 s . c o m break; case KB: resourceSize = resourceSize.multiply(new BigDecimal(BYTES_PER_KB)); break; case MB: resourceSize = resourceSize.multiply(new BigDecimal(BYTES_PER_MB)); break; case GB: resourceSize = resourceSize.multiply(new BigDecimal(BYTES_PER_GB)); break; case TB: resourceSize = resourceSize.multiply(new BigDecimal(BYTES_PER_TB)); break; case PB: resourceSize = resourceSize.multiply(new BigDecimal(BYTES_PER_PB)); break; default: break; } String resourceSizeAsString = resourceSize.toPlainString(); LOGGER.debug("resource size in bytes: {}", resourceSizeAsString); return resourceSizeAsString; }
From source file:com.etcc.csc.dao.OraclePaymentDAO.java
public boolean veaExists(BigDecimal docId, String docType, String dbSessionId, String ipAddress, String loginId, String licPlate, String licState) throws Exception { try {/*from w ww .ja v a 2s . c om*/ setConnection(Util.getDbConnection()); BigDecimal[] O_VEA_EXIST = new BigDecimal[] { new BigDecimal(0) }; OLC_ERROR_MSG_ARR[] O_ERROR_MSG_ARR = new OLC_ERROR_MSG_ARR[] { new OLC_ERROR_MSG_ARR() }; OLCSC_ACCT_MGMT pkg = new OLCSC_ACCT_MGMT(conn); int result = pkg.VEA_EXIST_INFO(docId.toPlainString(), docType, dbSessionId, ipAddress, loginId, licPlate, licState, O_VEA_EXIST, O_ERROR_MSG_ARR).intValue(); if (result == 1) { if (!ArrayUtils.isEmpty(O_VEA_EXIST)) { return O_VEA_EXIST[0].intValue() == 1; } } throw new EtccException("PaymentWS::veaExists fatal error"); } finally { closeConnection(); } }
From source file:org.gbif.ipt.model.Resource.java
/** * Find and return a VersionHistory with specific version. * * @param version version of VersionHistory searched for * * @return VersionHistory with specific version or null if not found *//*from w w w.ja va2 s . co m*/ public VersionHistory findVersionHistory(BigDecimal version) { if (version != null) { for (VersionHistory vh : getVersionHistory()) { if (version.toPlainString().equals(new BigDecimal(vh.getVersion()).toPlainString())) { return vh; } } } return null; }
From source file:org.gbif.ipt.model.Resource.java
/** * Set the replacedEmlVersion, only if that version exists in VersionHistory. * * @param replacedEmlVersion version to be replaced, or that has been replaced *///ww w. ja va2 s .c o m public void setReplacedEmlVersion(BigDecimal replacedEmlVersion) { VersionHistory vh = findVersionHistory(replacedEmlVersion); if (vh == null) { log.error("Replaced version (" + replacedEmlVersion.toPlainString() + ") does not exist in version history!"); } else { this.replacedEmlVersion = replacedEmlVersion; } }
From source file:org.openbravo.erpCommon.ad_forms.DocCostAdjustment.java
/** * Create Facts (the accounting logic) for MMS, MMR. * //w ww. j a va 2 s . co m * <pre> * Shipment * CoGS DR * Inventory CR * Shipment of Project Issue * CoGS DR * Project CR * Receipt * Inventory DR * NotInvoicedReceipt CR * </pre> * * @param as * accounting schema * @return Fact */ public Fact createFact(AcctSchema as, ConnectionProvider conn, Connection con, VariablesSecureApp vars) throws ServletException { // Select specific definition String strClassname = AcctServerData.selectTemplateDoc(conn, as.m_C_AcctSchema_ID, DocumentType); if (StringUtils.isEmpty(strClassname)) { strClassname = AcctServerData.selectTemplate(conn, as.m_C_AcctSchema_ID, AD_Table_ID); } else { try { DocCostAdjustmentTemplate newTemplate = (DocCostAdjustmentTemplate) Class.forName(strClassname) .newInstance(); return newTemplate.createFact(this, as, conn, con, vars); } catch (Exception e) { log4j.error("Error while creating new instance for DocCostAdjustmentTemplate - ", e); } } C_Currency_ID = as.getC_Currency_ID(); // create Fact Header Fact fact = new Fact(this, as, Fact.POST_Actual); String Fact_Acct_Group_ID = SequenceIdData.getUUID(); String amtDebit = "0"; String amtCredit = "0"; // Lines for (int i = 0; p_lines != null && i < p_lines.length; i++) { DocLine_CostAdjustment line = (DocLine_CostAdjustment) p_lines[i]; String transactionType = line.getTransactionType(); BigDecimal amount = new BigDecimal(line.getAmount()); ProductInfo p = new ProductInfo(line.m_M_Product_ID, conn); log4jDocCostAdjustment.debug("antes del creteline, line.getAmount(): " + line.getAmount() + " - TransactionType: " + transactionType); if (transactionType.equals(DocLine_CostAdjustment.TRXTYPE_SHIPMENT)) { // Cogs DR // Inventory Asset CR log4jDocCostAdjustment.debug("********** DocCostAdjustment - factAcct - account - " + p.getAccount(ProductInfo.ACCTTYPE_P_Cogs, as, conn).C_ValidCombination_ID); if (line.isTransactionNegative()) { amtDebit = ""; amtCredit = amount.toPlainString(); } else { amtDebit = amount.toPlainString(); amtCredit = ""; } fact.createLine(line, p.getAccount(ProductInfo.ACCTTYPE_P_Cogs, as, conn), line.m_C_Currency_ID, amtDebit, amtCredit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); fact.createLine(line, p.getAccount(ProductInfo.ACCTTYPE_P_Asset, as, conn), line.m_C_Currency_ID, amtCredit, amtDebit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); } else if (transactionType.equals(DocLine_CostAdjustment.TRXTYPE_RECEIPT)) { Account acct = null; // Inventory Asset DR if (line.getIsSource() && ("PDC").equals(line.getSourceProcess())) { // Price Diff // Correction // Invoice Price Variance CR acct = p.getAccount(ProductInfo.ACCTTYPE_P_IPV, as, conn); } else if (line.getIsSource() && ("LC").equals(line.getSourceProcess())) { throw new IllegalStateException(OBMessageUtils.messageBD("LCNotAccounting")); } else { // Product Exp CR acct = getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn); } log4jDocCostAdjustment.debug("********** DocCostAdjustment - factAcct - account - " + p.getAccount(ProductInfo.ACCTTYPE_P_Expense, as, conn).C_ValidCombination_ID); if (line.isTransactionNegative()) { amtDebit = amount.toPlainString(); amtCredit = ""; } else { amtDebit = ""; amtCredit = amount.toPlainString(); } fact.createLine(line, acct, line.m_C_Currency_ID, amtDebit, amtCredit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); fact.createLine(line, p.getAccount(ProductInfo.ACCTTYPE_P_Asset, as, conn), line.m_C_Currency_ID, amtCredit, amtDebit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); } else if (transactionType.equals(DocLine_CostAdjustment.TRXTYPE_INVENTORY)) { // Inventory Asset DR // Inventory Adjustment CR log4jDocCostAdjustment.debug("********** DocCostAdjustment - factAcct - account - " + getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn).C_ValidCombination_ID); if (line.isTransactionNegative()) { amtDebit = amount.toPlainString(); amtCredit = ""; } else { amtDebit = ""; amtCredit = amount.toPlainString(); } fact.createLine(line, getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn), line.m_C_Currency_ID, amtDebit, amtCredit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); fact.createLine(line, p.getAccount(ProductInfo.ACCTTYPE_P_Asset, as, conn), line.m_C_Currency_ID, amtCredit, amtDebit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); } else if (transactionType.equals(DocLine_CostAdjustment.TRXTYPE_INTERNALMOVEMENTFROM)) { // Inventory Asset DR // Inventory Adjustment CR M_Warehouse_ID = line.getWarehouseId(); log4jDocCostAdjustment.debug("********** DocCostAdjustment - factAcct - account - " + getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn).C_ValidCombination_ID); if (line.isTransactionNegative()) { amtDebit = amount.negate().toPlainString(); amtCredit = ""; } else { amtDebit = ""; amtCredit = amount.negate().toPlainString(); } fact.createLine(line, p.getAccount(ProductInfo.ACCTTYPE_P_Asset, as, conn), line.m_C_Currency_ID, amtDebit, amtCredit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); fact.createLine(line, getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn), line.m_C_Currency_ID, amtCredit, amtDebit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); } else if (transactionType.equals(DocLine_CostAdjustment.TRXTYPE_INTERNALMOVEMENTTO)) { // Inventory Asset DR // Inventory Adjustment CR M_Warehouse_ID = line.getWarehouseId(); log4jDocCostAdjustment.debug("********** DocCostAdjustment - factAcct - account - " + getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn).C_ValidCombination_ID); if (line.isTransactionNegative()) { amtDebit = amount.toPlainString(); amtCredit = ""; } else { amtDebit = ""; amtCredit = amount.toPlainString(); } fact.createLine(line, getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn), line.m_C_Currency_ID, amtDebit, amtCredit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); fact.createLine(line, p.getAccount(ProductInfo.ACCTTYPE_P_Asset, as, conn), line.m_C_Currency_ID, amtCredit, amtDebit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); } else if (transactionType.equals(DocLine_CostAdjustment.TRXTYPE_INTERNALCONSUMPTION)) { // Inventory Asset DR // Inventory Adjustment CR M_Warehouse_ID = line.getWarehouseId(); log4jDocCostAdjustment.debug("********** DocCostAdjustment - factAcct - account - " + getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn).C_ValidCombination_ID); if (line.isTransactionNegative()) { amtDebit = amount.toPlainString(); amtCredit = ""; } else { amtDebit = ""; amtCredit = amount.toPlainString(); } fact.createLine(line, p.getAccount(ProductInfo.ACCTTYPE_P_Asset, as, conn), line.m_C_Currency_ID, amtDebit, amtCredit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); fact.createLine(line, getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn), line.m_C_Currency_ID, amtCredit, amtDebit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); } else if (transactionType.equals(DocLine_CostAdjustment.TRXTYPE_BOM)) { // Inventory Asset DR // Inventory Adjustment CR M_Warehouse_ID = line.getWarehouseId(); log4jDocCostAdjustment.debug("********** DocCostAdjustment - factAcct - account - " + getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn).C_ValidCombination_ID); if (line.isTransactionNegative()) { amtDebit = amount.toPlainString(); amtCredit = ""; } else { amtDebit = ""; amtCredit = amount.toPlainString(); } fact.createLine(line, getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn), line.m_C_Currency_ID, amtDebit, amtCredit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); fact.createLine(line, p.getAccount(ProductInfo.ACCTTYPE_P_Asset, as, conn), line.m_C_Currency_ID, amtCredit, amtDebit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); } else if (transactionType.equals(DocLine_CostAdjustment.TRXTYPE_MANUFACTURING)) { // Inventory Asset DR // Inventory Adjustment CR M_Warehouse_ID = line.getWarehouseId(); log4jDocCostAdjustment.debug("********** DocCostAdjustment - factAcct - account - " + getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn).C_ValidCombination_ID); if (line.isTransactionNegative()) { amtDebit = amount.toPlainString(); amtCredit = ""; } else { amtDebit = ""; amtCredit = amount.toPlainString(); } fact.createLine(line, getAccountByWarehouse(AcctServer.ACCTTYPE_InvDifferences, as, line.getWarehouseId(), conn), line.m_C_Currency_ID, amtDebit, amtCredit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); fact.createLine(line, p.getAccount(ProductInfo.ACCTTYPE_P_Asset, as, conn), line.m_C_Currency_ID, amtCredit, amtDebit, Fact_Acct_Group_ID, nextSeqNo(SeqNo), DocumentType, line.m_DateAcct, null, conn); } } // lines SeqNo = "0"; return fact; }
From source file:au.org.ala.delta.editor.slotfile.directive.DirOutDefault.java
private void writeNumberList(DirectiveArguments directiveArgs) { int prevNo = Integer.MAX_VALUE; int curNo = Integer.MAX_VALUE; List<DirectiveArgument<?>> args; if (directiveArgs.size() > 0) { args = directiveArgs.getDirectiveArguments(); Collections.sort(args);/* ww w . j a v a 2 s . c o m*/ List<Integer> dataList = new ArrayList<Integer>(); BigDecimal curVal = BigDecimal.ZERO; BigDecimal prevVal = BigDecimal.ZERO; for (int i = 0; i <= args.size(); i++) { // Note that i is allowed to go up to directiveArgs.size() // This allows the last value to be handled correctly within the // loop. if (i != args.size()) { DirectiveArgument<?> arg = args.get(i); curNo = (Integer) arg.getId(); curVal = arg.getValue(); } if (i == 0 || (prevNo == curNo - 1 && prevVal.equals(curVal))) { dataList.add(curNo); } else { _textBuffer.append(' '); appendRange(dataList, ' ', false, _textBuffer); _textBuffer.append(','); _textBuffer.append(prevVal.toPlainString()); dataList = new ArrayList<Integer>(); dataList.add(curNo); } prevNo = curNo; prevVal = curVal; } } }
From source file:org.codice.ddf.spatial.ogc.wfs.transformer.handlebars.HandlebarsWfsFeatureTransformer.java
private String convertToBytes(String value, String unit) { BigDecimal resourceSize = new BigDecimal(value); resourceSize = resourceSize.setScale(1, BigDecimal.ROUND_HALF_UP); switch (unit) { case B:/* w ww . ja v a 2 s .c o m*/ break; case KB: resourceSize = resourceSize.multiply(new BigDecimal(BYTES_PER_KB)); break; case MB: resourceSize = resourceSize.multiply(new BigDecimal(BYTES_PER_MB)); break; case GB: resourceSize = resourceSize.multiply(new BigDecimal(BYTES_PER_GB)); break; case TB: resourceSize = resourceSize.multiply(new BigDecimal(BYTES_PER_TB)); break; case PB: resourceSize = resourceSize.multiply(new BigDecimal(BYTES_PER_PB)); break; default: break; } String resourceSizeAsString = resourceSize.toPlainString(); LOGGER.debug("resource size in bytes: {}", resourceSizeAsString); return resourceSizeAsString; }
From source file:com.etcc.csc.dao.OraclePaymentDAO.java
public OLC_PAYMENT_INFO_RECBean getPaymentInfo(BigDecimal docId, String docType, String dbSessionId, String ipAddress, String loginId) throws EtccErrorMessageException, Exception { OLC_PAYMENT_INFO_RECBean olcPaymentInfoRecBean = null; try {//from w w w . j av a2s. c o m setConnection(Util.getDbConnection()); OLC_PAYMENT_INFO_REC[] O_PAYMENT_INFO_REC = new OLC_PAYMENT_INFO_REC[] { new OLC_PAYMENT_INFO_REC() }; OLC_ERROR_MSG_ARR[] O_ERROR_MSG_ARR = new OLC_ERROR_MSG_ARR[] { new OLC_ERROR_MSG_ARR() }; OLCSC_ACCT_MGMT plsql = new OLCSC_ACCT_MGMT(conn); int result = plsql.GET_PAYMENT_INFO(docId.toPlainString(), docType, dbSessionId, ipAddress, loginId, O_PAYMENT_INFO_REC, O_ERROR_MSG_ARR).intValue(); if (result == 1) { if (!ArrayUtils.isEmpty(O_PAYMENT_INFO_REC)) { olcPaymentInfoRecBean = new OLC_PAYMENT_INFO_RECBean(O_PAYMENT_INFO_REC[0]); } } else { if (O_ERROR_MSG_ARR[0] != null && O_ERROR_MSG_ARR[0].getArray() != null && O_ERROR_MSG_ARR[0].getArray().length > 0) { OLC_ERROR_MSG_REC[] errorMsgRecs = O_ERROR_MSG_ARR[0].getArray(); EtccErrorMessageException em = new EtccErrorMessageException( "PaymentWS::getPaymentInfo error message"); for (int i = 0; i < errorMsgRecs.length; i++) { em.addRecoverable(errorMsgRecs[i].getERROR_MSG()); } throw em; } else { throw new EtccException("PaymentWS::getPaymentInfo fatal error"); } } } finally { closeConnection(); } return olcPaymentInfoRecBean; }