diff --git a/org.adempiere.base.process/src/org/adempiere/process/InOutGenerateRMA.java b/org.adempiere.base.process/src/org/adempiere/process/InOutGenerateRMA.java index 553dfb2181..5abc47d3a2 100644 --- a/org.adempiere.base.process/src/org/adempiere/process/InOutGenerateRMA.java +++ b/org.adempiere.base.process/src/org/adempiere/process/InOutGenerateRMA.java @@ -265,8 +265,7 @@ public class InOutGenerateRMA extends SvrProcess } // Add processing information to process log - addLog(shipment.getM_InOut_ID(), shipment.getMovementDate(), null, processMsg.toString(),shipment.get_Table_ID(),shipment.getM_InOut_ID() -); + addBufferLog(shipment.getM_InOut_ID(), shipment.getMovementDate(), null, processMsg.toString(),shipment.get_Table_ID(),shipment.getM_InOut_ID()); m_created++; } diff --git a/org.adempiere.base.process/src/org/adempiere/process/InvoiceGenerateRMA.java b/org.adempiere.base.process/src/org/adempiere/process/InvoiceGenerateRMA.java index d5a2e4e089..3d31ad9641 100644 --- a/org.adempiere.base.process/src/org/adempiere/process/InvoiceGenerateRMA.java +++ b/org.adempiere.base.process/src/org/adempiere/process/InvoiceGenerateRMA.java @@ -216,7 +216,7 @@ public class InvoiceGenerateRMA extends SvrProcess // Add processing information to process log String message = Msg.parseTranslation(getCtx(), "@InvoiceProcessed@ " + processMsg.toString()); - addLog(invoice.getC_Invoice_ID(), invoice.getDateInvoiced(), null, message, invoice.get_Table_ID(), invoice.getC_Invoice_ID()); + addBufferLog(invoice.getC_Invoice_ID(), invoice.getDateInvoiced(), null, message, invoice.get_Table_ID(), invoice.getC_Invoice_ID()); m_created++; } } diff --git a/org.adempiere.base.process/src/org/compiere/process/AllocationAuto.java b/org.adempiere.base.process/src/org/compiere/process/AllocationAuto.java index a6317bf9a5..a4d724a121 100644 --- a/org.adempiere.base.process/src/org/compiere/process/AllocationAuto.java +++ b/org.adempiere.base.process/src/org/compiere/process/AllocationAuto.java @@ -399,7 +399,7 @@ public class AllocationAuto extends SvrProcess if (payment.allocateIt()) { String message = Msg.parseTranslation(getCtx(), "@PaymentAllocated@ " + payment.getDocumentNo() + " [1]"); - addLog(0, payment.getDateAcct(), openAmt, message, payment.get_Table_ID(), payment.getC_Payment_ID()); + addBufferLog(0, payment.getDateAcct(), openAmt, message, payment.get_Table_ID(), payment.getC_Payment_ID()); count++; } break; @@ -444,7 +444,7 @@ public class AllocationAuto extends SvrProcess if (payment.allocateIt()) { String message = Msg.parseTranslation(getCtx(), "@PaymentAllocated@ " + payment.getDocumentNo() + " [n]"); - addLog(0, payment.getDateAcct(), availableAmt, message); + addBufferLog(0, payment.getDateAcct(), availableAmt, message, payment.get_Table_ID(), payment.getC_Payment_ID()); count++; } } diff --git a/org.adempiere.base.process/src/org/compiere/process/BOMFlagValidate.java b/org.adempiere.base.process/src/org/compiere/process/BOMFlagValidate.java index 79ead59e46..7a6fa478dd 100644 --- a/org.adempiere.base.process/src/org/compiere/process/BOMFlagValidate.java +++ b/org.adempiere.base.process/src/org/compiere/process/BOMFlagValidate.java @@ -64,7 +64,7 @@ public class BOMFlagValidate extends SvrProcess { while (rs.next()) { StringBuilder msglog=new StringBuilder().append(rs.getString(1)).append(" BOM without BOM lines"); - addLog(0, null, null, msglog.toString(), MProduct.Table_ID, rs.getInt(2)); + addBufferLog(0, null, null, msglog.toString(), MProduct.Table_ID, rs.getInt(2)); } } catch (SQLException e) { throw e; @@ -120,7 +120,7 @@ public class BOMFlagValidate extends SvrProcess { while (rs.next()) { StringBuilder msglog = new StringBuilder().append(rs.getString(1)).append(" not BOM with BOM lines"); - addLog(0, null, null, msglog.toString(), MProduct.Table_ID, rs.getInt(2)); + addBufferLog(0, null, null, msglog.toString(), MProduct.Table_ID, rs.getInt(2)); } } catch (SQLException e) { throw e; diff --git a/org.adempiere.base.process/src/org/compiere/process/BOMValidate.java b/org.adempiere.base.process/src/org/compiere/process/BOMValidate.java index 7d6cbfac4b..4f7bbeb245 100644 --- a/org.adempiere.base.process/src/org/compiere/process/BOMValidate.java +++ b/org.adempiere.base.process/src/org/compiere/process/BOMValidate.java @@ -108,7 +108,7 @@ public class BOMValidate extends SvrProcess while (rs.next ()) { String info = validateProduct(new MProduct(getCtx(), rs.getInt("M_Product_ID"), get_TrxName())); - addLog(0, null, null, info, MProduct.Table_ID, rs.getInt("M_Product_ID")); + addBufferLog(0, null, null, info, MProduct.Table_ID, rs.getInt("M_Product_ID")); counter++; } } diff --git a/org.adempiere.base.process/src/org/compiere/process/BOMVerify.java b/org.adempiere.base.process/src/org/compiere/process/BOMVerify.java index 230ce83d69..b2850eb093 100644 --- a/org.adempiere.base.process/src/org/compiere/process/BOMVerify.java +++ b/org.adempiere.base.process/src/org/compiere/process/BOMVerify.java @@ -182,7 +182,7 @@ public class BOMVerify extends SvrProcess if (p_fromButton) addLog(0, null, null, product.getValue() + " recursively contains " + pp.getValue()); else - addLog(0, null, null, product.getValue() + " recursively contains " + pp.getValue(), MProduct.Table_ID, product.getM_Product_ID()); + addBufferLog(0, null, null, product.getValue() + " recursively contains " + pp.getValue(), MProduct.Table_ID, product.getM_Product_ID()); } else { @@ -200,7 +200,7 @@ public class BOMVerify extends SvrProcess if (p_fromButton) addLog(0, null, null, product.getValue() + " does not have lines"); else - addLog(0, null, null, product.getValue() + " does not have lines", MProduct.Table_ID, product.getM_Product_ID()); + addBufferLog(0, null, null, product.getValue() + " does not have lines", MProduct.Table_ID, product.getM_Product_ID()); } checkedproducts.add(product); diff --git a/org.adempiere.base.process/src/org/compiere/process/ConvertLead.java b/org.adempiere.base.process/src/org/compiere/process/ConvertLead.java index 7937b63165..c55bdff124 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ConvertLead.java +++ b/org.adempiere.base.process/src/org/compiere/process/ConvertLead.java @@ -68,7 +68,7 @@ public class ConvertLead extends SvrProcess { bp.setName(lead.getName()); bp.saveEx(); - addLog(bp.getC_BPartner_ID(), null, null, "@C_BPartner_ID@ @Created@", MBPartner.Table_ID, bp.getC_BPartner_ID()); + addBufferLog(bp.getC_BPartner_ID(), null, null, "@C_BPartner_ID@ @Created@", MBPartner.Table_ID, bp.getC_BPartner_ID()); lead.setC_BPartner_ID(bp.getC_BPartner_ID()); @@ -139,7 +139,7 @@ public class ConvertLead extends SvrProcess { op.saveEx(); - addLog(op.getC_Opportunity_ID(), null, null, "@C_Opportunity_ID@ @Created@", MOpportunity.Table_ID, op.getC_Opportunity_ID()); + addBufferLog(op.getC_Opportunity_ID(), null, null, "@C_Opportunity_ID@ @Created@", MOpportunity.Table_ID, op.getC_Opportunity_ID()); } lead.setIsSalesLead(false); diff --git a/org.adempiere.base.process/src/org/compiere/process/CostUpdate.java b/org.adempiere.base.process/src/org/compiere/process/CostUpdate.java index c11a2428e9..91a2832a2f 100644 --- a/org.adempiere.base.process/src/org/compiere/process/CostUpdate.java +++ b/org.adempiere.base.process/src/org/compiere/process/CostUpdate.java @@ -338,7 +338,7 @@ public class CostUpdate extends SvrProcess msg.append(m_docType.getName()).append(" ").append(inventoryDoc.getDocumentNo()); else msg.append(m_docType.get_Translation(I_C_DocType.COLUMNNAME_Name)).append(" ").append(inventoryDoc.getDocumentNo()); - addLog(getAD_PInstance_ID(), null, null, msg.toString(), I_M_Inventory.Table_ID, inventoryDoc.getM_Inventory_ID()); + addBufferLog(getAD_PInstance_ID(), null, null, msg.toString(), I_M_Inventory.Table_ID, inventoryDoc.getM_Inventory_ID()); } } } diff --git a/org.adempiere.base.process/src/org/compiere/process/ExpenseAPInvoice.java b/org.adempiere.base.process/src/org/compiere/process/ExpenseAPInvoice.java index 6744e3824f..cd2e528ba4 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ExpenseAPInvoice.java +++ b/org.adempiere.base.process/src/org/compiere/process/ExpenseAPInvoice.java @@ -224,7 +224,7 @@ public class ExpenseAPInvoice extends SvrProcess throw new IllegalStateException("Cannot save Invoice"); // m_noInvoices++; - addLog(invoice.get_ID(), invoice.getDateInvoiced(), + addBufferLog(invoice.get_ID(), invoice.getDateInvoiced(), invoice.getGrandTotal(), invoice.getDocumentNo(), invoice.get_Table_ID(), invoice.getC_Invoice_ID()); } // completeInvoice diff --git a/org.adempiere.base.process/src/org/compiere/process/ExpenseSOrder.java b/org.adempiere.base.process/src/org/compiere/process/ExpenseSOrder.java index 9ddd45dea0..b1bdcd3f82 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ExpenseSOrder.java +++ b/org.adempiere.base.process/src/org/compiere/process/ExpenseSOrder.java @@ -282,7 +282,7 @@ public class ExpenseSOrder extends SvrProcess if (!m_order.save()) throw new IllegalStateException("Cannot save Order"); m_noOrders++; - addLog (m_order.get_ID(), m_order.getDateOrdered(), m_order.getGrandTotal(), m_order.getDocumentNo(), m_order.get_Table_ID(), m_order.getC_Order_ID()); + addBufferLog (m_order.get_ID(), m_order.getDateOrdered(), m_order.getGrandTotal(), m_order.getDocumentNo(), m_order.get_Table_ID(), m_order.getC_Order_ID()); m_order = null; } // completeOrder diff --git a/org.adempiere.base.process/src/org/compiere/process/InOutGenerate.java b/org.adempiere.base.process/src/org/compiere/process/InOutGenerate.java index 31d592a971..c3d70940e4 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InOutGenerate.java +++ b/org.adempiere.base.process/src/org/compiere/process/InOutGenerate.java @@ -582,7 +582,7 @@ public class InOutGenerate extends SvrProcess } m_shipment.saveEx(); String message = Msg.parseTranslation(getCtx(), "@ShipmentProcessed@ " + m_shipment.getDocumentNo()); - addLog(m_shipment.getM_InOut_ID(), m_shipment.getMovementDate(), null, message, m_shipment.get_Table_ID(),m_shipment.getM_InOut_ID()); + addBufferLog(m_shipment.getM_InOut_ID(), m_shipment.getMovementDate(), null, message, m_shipment.get_Table_ID(),m_shipment.getM_InOut_ID()); m_created++; //reset storage cache as MInOut.completeIt will update m_storage diff --git a/org.adempiere.base.process/src/org/compiere/process/InvoiceBatchProcess.java b/org.adempiere.base.process/src/org/compiere/process/InvoiceBatchProcess.java index aa4ebfad9d..133edf025e 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InvoiceBatchProcess.java +++ b/org.adempiere.base.process/src/org/compiere/process/InvoiceBatchProcess.java @@ -167,7 +167,7 @@ public class InvoiceBatchProcess extends SvrProcess m_invoice.saveEx(); String message = Msg.parseTranslation(getCtx(), "@InvoiceProcessed@ " + m_invoice.getDocumentNo()); - addLog(0, m_invoice.getDateInvoiced(), m_invoice.getGrandTotal(), message, m_invoice.get_Table_ID(), m_invoice.getC_Invoice_ID()); + addBufferLog(0, m_invoice.getDateInvoiced(), m_invoice.getGrandTotal(), message, m_invoice.get_Table_ID(), m_invoice.getC_Invoice_ID()); m_count++; m_invoice = null; diff --git a/org.adempiere.base.process/src/org/compiere/process/InvoiceGenerate.java b/org.adempiere.base.process/src/org/compiere/process/InvoiceGenerate.java index 199d272343..f2b7a7f38b 100644 --- a/org.adempiere.base.process/src/org/compiere/process/InvoiceGenerate.java +++ b/org.adempiere.base.process/src/org/compiere/process/InvoiceGenerate.java @@ -271,7 +271,7 @@ public class InvoiceGenerate extends SvrProcess if (completeOrder && !fullyDelivered) { if (log.isLoggable(Level.FINE)) log.fine("Failed CompleteOrder - " + oLine); - addLog(0, null, null,"Failed CompleteOrder - " + oLine,oLine.get_Table_ID(),oLine.getC_OrderLine_ID()); // Elaine 2008/11/25 + addBufferLog(0, null, null,"Failed CompleteOrder - " + oLine,oLine.get_Table_ID(),oLine.getC_OrderLine_ID()); // Elaine 2008/11/25 completeOrder = false; break; } @@ -291,7 +291,7 @@ public class InvoiceGenerate extends SvrProcess { if (log.isLoggable(Level.FINE)) log.fine("Failed: " + order.getInvoiceRule() + " - ToInvoice=" + toInvoice + " - " + oLine); - addLog(0, null, null,"Failed: " + order.getInvoiceRule() + addBufferLog(0, null, null,"Failed: " + order.getInvoiceRule() + " - ToInvoice=" + toInvoice + " - " + oLine,oLine.get_Table_ID(),oLine.getC_OrderLine_ID()); } } // for all order lines @@ -489,14 +489,14 @@ public class InvoiceGenerate extends SvrProcess if (!m_invoice.processIt(p_docAction)) { log.warning("completeInvoice - failed: " + m_invoice); - addLog(0, null, null,"completeInvoice - failed: " + m_invoice,m_invoice.get_Table_ID(),m_invoice.getC_Invoice_ID()); // Elaine 2008/11/25 + addBufferLog(0, null, null,"completeInvoice - failed: " + m_invoice,m_invoice.get_Table_ID(),m_invoice.getC_Invoice_ID()); // Elaine 2008/11/25 throw new IllegalStateException("Invoice Process Failed: " + m_invoice + " - " + m_invoice.getProcessMsg()); } m_invoice.saveEx(); String message = Msg.parseTranslation(getCtx(), "@InvoiceProcessed@ " + m_invoice.getDocumentNo()); - addLog(m_invoice.getC_Invoice_ID(), m_invoice.getDateInvoiced(), null, message, m_invoice.get_Table_ID(), m_invoice.getC_Invoice_ID()); + addBufferLog(m_invoice.getC_Invoice_ID(), m_invoice.getDateInvoiced(), null, message, m_invoice.get_Table_ID(), m_invoice.getC_Invoice_ID()); m_created++; } m_invoice = null; diff --git a/org.adempiere.base.process/src/org/compiere/process/OrderPOCreate.java b/org.adempiere.base.process/src/org/compiere/process/OrderPOCreate.java index 3b7e321040..1d8f4943de 100644 --- a/org.adempiere.base.process/src/org/compiere/process/OrderPOCreate.java +++ b/org.adempiere.base.process/src/org/compiere/process/OrderPOCreate.java @@ -210,7 +210,7 @@ public class OrderPOCreate extends SvrProcess { po = createPOForVendor(rs.getInt(1), so); String message = Msg.parseTranslation(getCtx(), "@OrderCreated@ " + po.getDocumentNo()); - addLog(0, null, null, message, po.get_Table_ID(), po.getC_Order_ID()); + addBufferLog (0, null, null, message, po.get_Table_ID(), po.getC_Order_ID()); counter++; } diff --git a/org.adempiere.base.process/src/org/compiere/process/RequestInvoice.java b/org.adempiere.base.process/src/org/compiere/process/RequestInvoice.java index a9ffa56052..aec3c99ab9 100644 --- a/org.adempiere.base.process/src/org/compiere/process/RequestInvoice.java +++ b/org.adempiere.base.process/src/org/compiere/process/RequestInvoice.java @@ -150,6 +150,7 @@ public class RequestInvoice extends SvrProcess catch (Exception e) { log.log (Level.SEVERE, sql.toString(), e); + throw e; } finally { @@ -180,7 +181,7 @@ public class RequestInvoice extends SvrProcess } m_invoice.saveEx(); String message = Msg.parseTranslation(getCtx(), "@InvoiceProcessed@ " + m_invoice.getDocumentNo()); - addLog(0, null, m_invoice.getGrandTotal(), message, m_invoice.get_Table_ID(), m_invoice.getC_Invoice_ID()); + addBufferLog(0, null, m_invoice.getGrandTotal(), message, m_invoice.get_Table_ID(), m_invoice.getC_Invoice_ID()); } } m_invoice = null; diff --git a/org.adempiere.base.process/src/org/compiere/process/RequisitionPOCreate.java b/org.adempiere.base.process/src/org/compiere/process/RequisitionPOCreate.java index 8e2e26bf5a..0337437a95 100644 --- a/org.adempiere.base.process/src/org/compiere/process/RequisitionPOCreate.java +++ b/org.adempiere.base.process/src/org/compiere/process/RequisitionPOCreate.java @@ -382,7 +382,7 @@ public class RequisitionPOCreate extends SvrProcess { m_order.load(get_TrxName()); String message = Msg.parseTranslation(getCtx(), "@GeneratedPO@ " + m_order.getDocumentNo()); - addLog(0, null, m_order.getGrandTotal(), message, m_order.get_Table_ID(), m_order.getC_Order_ID()); + addBufferLog(0, null, m_order.getGrandTotal(), message, m_order.get_Table_ID(), m_order.getC_Order_ID()); } m_order = null; m_orderLine = null; diff --git a/org.adempiere.base.process/src/org/compiere/process/RfQCreatePO.java b/org.adempiere.base.process/src/org/compiere/process/RfQCreatePO.java index 25a85b86dd..5e18a5b3b7 100644 --- a/org.adempiere.base.process/src/org/compiere/process/RfQCreatePO.java +++ b/org.adempiere.base.process/src/org/compiere/process/RfQCreatePO.java @@ -175,7 +175,7 @@ public class RfQCreatePO extends SvrProcess order.setSalesRep_ID(rfq.getSalesRep_ID()); order.saveEx(); noOrders++; - addLog(0, null, null, order.getDocumentNo(), order.get_Table_ID(), order.getC_Order_ID()); + addBufferLog(0, null, null, order.getDocumentNo(), order.get_Table_ID(), order.getC_Order_ID()); } // For all Qtys MRfQResponseLineQty[] qtys = line.getQtys(false); diff --git a/org.adempiere.base/src/org/compiere/process/SvrProcess.java b/org.adempiere.base/src/org/compiere/process/SvrProcess.java index 76cf343fb4..040c7fec7e 100644 --- a/org.adempiere.base/src/org/compiere/process/SvrProcess.java +++ b/org.adempiere.base/src/org/compiere/process/SvrProcess.java @@ -22,6 +22,8 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; import java.util.logging.Level; @@ -54,6 +56,26 @@ public abstract class SvrProcess implements ProcessCall public static final String PROCESS_INFO_CTX_KEY = "ProcessInfo"; public static final String PROCESS_UI_CTX_KEY = "ProcessUI"; + private List listEntryLog; + + /** + * Add log to buffer, only process total success, flush buffer + * @param id + * @param date + * @param number + * @param msg + * @param tableId + * @param recordId + */ + public void addBufferLog(int id, Timestamp date, BigDecimal number, String msg, int tableId ,int recordId) { + ProcessInfoLog entryLog = new ProcessInfoLog(id, date, number, msg, tableId, recordId); + + if (listEntryLog == null) + listEntryLog = new ArrayList(); + + listEntryLog.add(entryLog); + } + /** * Server Process. * Note that the class is initiated by startProcess. @@ -191,7 +213,10 @@ public abstract class SvrProcess implements ProcessCall //transaction should rollback if there are error in process if ("@Error@".equals(msg)) success = false; - + + if (success) + flushBufferLog(); + // Parse Variables msg = Msg.parseTranslation(m_ctx, msg); m_pi.setSummary (msg, !success); @@ -449,7 +474,7 @@ public abstract class SvrProcess implements ProcessCall if (m_pi != null) m_pi.addLog(id, date, number, msg,tableId,recordId); - if (log.isLoggable(Level.INFO)) log.info(id + " - " + date + " - " + number + " - " + msg +" - "+tableId); + if (log.isLoggable(Level.INFO)) log.info(id + " - " + date + " - " + number + " - " + msg + " - " + tableId + " - " + recordId); } // addLog /************************************************************************** @@ -476,6 +501,17 @@ public abstract class SvrProcess implements ProcessCall addLog (0, null, null, msg); } // addLog + private void flushBufferLog () { + if (listEntryLog == null) + return; + + for (ProcessInfoLog entryLog : listEntryLog) { + if (m_pi != null) + m_pi.addLog(entryLog); + if (log.isLoggable(Level.INFO)) log.info(entryLog.getP_ID() + " - " + entryLog.getP_Date() + " - " + entryLog.getP_Number() + " - " + entryLog.getP_Msg() + " - " + entryLog.getAD_Table_ID() + " - " + entryLog.getRecord_ID()); + } + } + /************************************************************************** * Execute function * @param className class diff --git a/org.adempiere.base/src/org/eevolution/process/BankTransfer.java b/org.adempiere.base/src/org/eevolution/process/BankTransfer.java index 0703b6de0b..15a7c416ba 100644 --- a/org.adempiere.base/src/org/eevolution/process/BankTransfer.java +++ b/org.adempiere.base/src/org/eevolution/process/BankTransfer.java @@ -164,7 +164,7 @@ public class BankTransfer extends SvrProcess throw new IllegalStateException("Payment Process Failed: " + paymentBankFrom + " - " + paymentBankFrom.getProcessMsg()); } paymentBankFrom.saveEx(); - addLog(paymentBankFrom.getC_Payment_ID(), paymentBankFrom.getDateTrx(), + addBufferLog(paymentBankFrom.getC_Payment_ID(), paymentBankFrom.getDateTrx(), null, paymentBankFrom.getC_DocType().getName() + " " + paymentBankFrom.getDocumentNo(), MPayment.Table_ID, paymentBankFrom.getC_Payment_ID()); m_created++; @@ -190,7 +190,7 @@ public class BankTransfer extends SvrProcess throw new IllegalStateException("Payment Process Failed: " + paymentBankTo + " - " + paymentBankTo.getProcessMsg()); } paymentBankTo.saveEx(); - addLog(paymentBankTo.getC_Payment_ID(), paymentBankTo.getDateTrx(), + addBufferLog(paymentBankTo.getC_Payment_ID(), paymentBankTo.getDateTrx(), null, paymentBankTo.getC_DocType().getName() + " " + paymentBankTo.getDocumentNo(), MPayment.Table_ID, paymentBankTo.getC_Payment_ID()); m_created++;