diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutAssignment.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutAssignment.java index 943f3ee846..071743bc89 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutAssignment.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutAssignment.java @@ -57,7 +57,7 @@ public class CalloutAssignment extends CalloutEngine return ""; int M_Product_ID = 0; - String Name = null; + StringBuilder Name = null; String Description = null; BigDecimal Qty = null; String sql = "SELECT p.M_Product_ID, ra.Name, ra.Description, ra.Qty " @@ -74,7 +74,7 @@ public class CalloutAssignment extends CalloutEngine if (rs.next()) { M_Product_ID = rs.getInt (1); - Name = rs.getString(2); + Name = new StringBuilder(rs.getString(2)); Description = rs.getString(3); Qty = rs.getBigDecimal(4); } @@ -94,9 +94,9 @@ public class CalloutAssignment extends CalloutEngine { mTab.setValue ("M_Product_ID", new Integer (M_Product_ID)); if (Description != null) - Name += " (" + Description + ")"; - if (!".".equals(Name)) - mTab.setValue("Description", Name); + Name.append(" (").append(Description).append(")"); + if (!".".equals(Name.toString())) + mTab.setValue("Description", Name.toString()); // String variable = "Qty"; // TimeExpenseLine if (mTab.getTableName().startsWith("C_Order")) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java index 12771ba6ba..21b96bc58b 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutOrder.java @@ -1317,8 +1317,9 @@ public class CalloutOrder extends CalloutEngine BigDecimal total = available.subtract(notReserved); if (total.compareTo(QtyOrdered) < 0) { - String info = Msg.parseTranslation(ctx, "@QtyAvailable@=" + available - + " - @QtyNotReserved@=" + notReserved + " = " + total); + StringBuilder msgpts = new StringBuilder("@QtyAvailable@=").append(available) + .append(" - @QtyNotReserved@=").append(notReserved).append(" = ").append(total); + String info = Msg.parseTranslation(ctx, msgpts.toString()); mTab.fireDataStatusEEvent ("InsufficientQtyAvailable", info, false); } diff --git a/org.adempiere.base/src/org/compiere/model/MAccount.java b/org.adempiere.base/src/org/compiere/model/MAccount.java index 173adc77ec..7739a61a1b 100644 --- a/org.adempiere.base/src/org/compiere/model/MAccount.java +++ b/org.adempiere.base/src/org/compiere/model/MAccount.java @@ -74,7 +74,7 @@ public class MAccount extends X_C_ValidCombination int C_Project_ID, int C_Campaign_ID, int C_Activity_ID, int User1_ID, int User2_ID, int UserElement1_ID, int UserElement2_ID) { - StringBuffer info = new StringBuffer(); + StringBuilder info = new StringBuilder(); info.append("AD_Client_ID=").append(AD_Client_ID).append(",AD_Org_ID=").append(AD_Org_ID); // Schema info.append(",C_AcctSchema_ID=").append(C_AcctSchema_ID); @@ -83,7 +83,7 @@ public class MAccount extends X_C_ValidCombination ArrayList params = new ArrayList(); // Mandatory fields - StringBuffer whereClause = new StringBuffer("AD_Client_ID=?" // #1 + StringBuilder whereClause = new StringBuilder("AD_Client_ID=?" // #1 + " AND AD_Org_ID=?" + " AND C_AcctSchema_ID=?" + " AND Account_ID=?"); // #4 @@ -422,7 +422,7 @@ public class MAccount extends X_C_ValidCombination */ public String toString() { - StringBuffer sb = new StringBuffer("MAccount=["); + StringBuilder sb = new StringBuilder("MAccount=["); sb.append(getC_ValidCombination_ID()); if (getCombination() != null) sb.append(",") @@ -545,8 +545,8 @@ public class MAccount extends X_C_ValidCombination */ public void setValueDescription() { - StringBuffer combi = new StringBuffer(); - StringBuffer descr = new StringBuffer(); + StringBuilder combi = new StringBuilder(); + StringBuilder descr = new StringBuilder(); boolean fullyQualified = true; // MAcctSchema as = new MAcctSchema(getCtx(), getC_AcctSchema_ID(), get_TrxName()); // In Trx! diff --git a/org.adempiere.base/src/org/compiere/model/MAccountLookup.java b/org.adempiere.base/src/org/compiere/model/MAccountLookup.java index af7169b88e..cee7604a5f 100644 --- a/org.adempiere.base/src/org/compiere/model/MAccountLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MAccountLookup.java @@ -66,8 +66,10 @@ public final class MAccountLookup extends Lookup implements Serializable */ public String getDisplay (Object value) { - if (!containsKey (value)) - return "<" + value.toString() + ">"; + if (!containsKey (value)){ + StringBuilder msgreturn = new StringBuilder("<").append(value.toString()).append(">"); + return msgreturn.toString(); + } return toString(); } // getDisplay @@ -189,9 +191,9 @@ public final class MAccountLookup extends Lookup implements Serializable for(MAccount account :accounts) { - list.add (new KeyNamePair(account.getC_ValidCombination_ID(), - account.getCombination() + " - " + - account.getDescription())); + StringBuilder msglist = new StringBuilder(account.getCombination()).append(" - ") + .append(account.getDescription()); + list.add (new KeyNamePair(account.getC_ValidCombination_ID(), msglist.toString())); } // Sort & return return list; diff --git a/org.adempiere.base/src/org/compiere/model/MAcctProcessor.java b/org.adempiere.base/src/org/compiere/model/MAcctProcessor.java index d57a359468..ba6d4d9131 100644 --- a/org.adempiere.base/src/org/compiere/model/MAcctProcessor.java +++ b/org.adempiere.base/src/org/compiere/model/MAcctProcessor.java @@ -94,8 +94,9 @@ public class MAcctProcessor extends X_C_AcctProcessor { this (client.getCtx(), 0, client.get_TrxName()); setClientOrg(client); - setName (client.getName() + " - " - + Msg.translate(getCtx(), "C_AcctProcessor_ID")); + StringBuilder msgset = new StringBuilder(client.getName()).append(" - ") + .append(Msg.translate(getCtx(), "C_AcctProcessor_ID")); + setName (msgset.toString()); setSupervisor_ID (Supervisor_ID); } // MAcctProcessor @@ -107,7 +108,8 @@ public class MAcctProcessor extends X_C_AcctProcessor */ public String getServerID () { - return "AcctProcessor" + get_ID(); + StringBuilder msgreturn = new StringBuilder("AcctProcessor").append(get_ID()); + return msgreturn.toString(); } // getServerID /** @@ -144,10 +146,10 @@ public class MAcctProcessor extends X_C_AcctProcessor { if (getKeepLogDays() < 1) return 0; - String sql = "DELETE C_AcctProcessorLog " - + "WHERE C_AcctProcessor_ID=" + getC_AcctProcessor_ID() - + " AND (Created+" + getKeepLogDays() + ") < SysDate"; - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("DELETE C_AcctProcessorLog ") + .append("WHERE C_AcctProcessor_ID=").append(getC_AcctProcessor_ID()) + .append(" AND (Created+").append(getKeepLogDays()).append(") < SysDate"); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); return no; } // deleteLog diff --git a/org.adempiere.base/src/org/compiere/model/MAcctSchema.java b/org.adempiere.base/src/org/compiere/model/MAcctSchema.java index dca3bd7ba1..2d06d2f56b 100644 --- a/org.adempiere.base/src/org/compiere/model/MAcctSchema.java +++ b/org.adempiere.base/src/org/compiere/model/MAcctSchema.java @@ -105,17 +105,17 @@ public class MAcctSchema extends X_C_AcctSchema list.add(as); ArrayList params = new ArrayList(); - String whereClause = "IsActive=? " - + " AND EXISTS (SELECT * FROM C_AcctSchema_GL gl WHERE C_AcctSchema.C_AcctSchema_ID=gl.C_AcctSchema_ID)" - + " AND EXISTS (SELECT * FROM C_AcctSchema_Default d WHERE C_AcctSchema.C_AcctSchema_ID=d.C_AcctSchema_ID)"; + StringBuilder whereClause = new StringBuilder("IsActive=? ") + .append(" AND EXISTS (SELECT * FROM C_AcctSchema_GL gl WHERE C_AcctSchema.C_AcctSchema_ID=gl.C_AcctSchema_ID)") + .append(" AND EXISTS (SELECT * FROM C_AcctSchema_Default d WHERE C_AcctSchema.C_AcctSchema_ID=d.C_AcctSchema_ID)"); params.add("Y"); if (AD_Client_ID != 0) { - whereClause += " AND AD_Client_ID=?"; + whereClause.append(" AND AD_Client_ID=?"); params.add(AD_Client_ID); } - List ass = new Query(ctx, I_C_AcctSchema.Table_Name,whereClause,trxName) + List ass = new Query(ctx, I_C_AcctSchema.Table_Name,whereClause.toString(),trxName) .setParameters(params) .setOrderBy(MAcctSchema.COLUMNNAME_C_AcctSchema_ID) .list(); @@ -195,7 +195,8 @@ public class MAcctSchema extends X_C_AcctSchema this (client.getCtx(), 0, client.get_TrxName()); setClientOrg(client); setC_Currency_ID (currency.getKey()); - setName (client.getName() + " " + getGAAP() + "/" + get_ColumnCount() + " " + currency.getName()); + StringBuilder msgset = new StringBuilder(client.getName()).append(" ").append(getGAAP()).append("/").append(get_ColumnCount()).append(" ").append(currency.getName()); + setName (msgset.toString()); } // MAcctSchema @@ -291,7 +292,7 @@ public class MAcctSchema extends X_C_AcctSchema */ public String toString() { - StringBuffer sb = new StringBuffer("AcctSchema["); + StringBuilder sb = new StringBuilder("AcctSchema["); sb.append(get_ID()).append("-").append(getName()) .append("]"); return sb.toString(); diff --git a/org.adempiere.base/src/org/compiere/model/MAcctSchemaElement.java b/org.adempiere.base/src/org/compiere/model/MAcctSchemaElement.java index 0a76f3eaaa..9c55b8f8f0 100644 --- a/org.adempiere.base/src/org/compiere/model/MAcctSchemaElement.java +++ b/org.adempiere.base/src/org/compiere/model/MAcctSchemaElement.java @@ -388,10 +388,11 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element */ public String toString() { - return "AcctSchemaElement[" + get_ID() - + "-" + getName() - + "(" + getElementType() + ")=" + getDefaultValue() - + ",Pos=" + getSeqNo() + "]"; + StringBuilder msgreturn = new StringBuilder("AcctSchemaElement[").append(get_ID()) + .append("-").append(getName()) + .append("(").append(getElementType()).append(")=").append(getDefaultValue()) + .append(",Pos=").append(getSeqNo()).append("]"); + return msgreturn.toString(); } // toString @@ -486,10 +487,10 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element s_cache.clear(); // Resequence - if (newRecord || is_ValueChanged(COLUMNNAME_SeqNo)) - MAccount.updateValueDescription(getCtx(), - "AD_Client_ID=" + getAD_Client_ID(), get_TrxName()); - + if (newRecord || is_ValueChanged(COLUMNNAME_SeqNo)){ + StringBuilder msguvd = new StringBuilder("AD_Client_ID=").append(getAD_Client_ID()); + MAccount.updateValueDescription(getCtx(), msguvd.toString(), get_TrxName()); + } return success; } // afterSave @@ -500,16 +501,16 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element */ private void updateData (String element, int id) { - MAccount.updateValueDescription(getCtx(), - element + "=" + id, get_TrxName()); + StringBuilder msguvd = new StringBuilder(element).append("=").append(id); + MAccount.updateValueDescription(getCtx(),msguvd.toString(), get_TrxName()); // - String sql = "UPDATE C_ValidCombination SET " + element + "=" + id - + " WHERE " + element + " IS NULL AND AD_Client_ID=" + getAD_Client_ID(); - int noC = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE C_ValidCombination SET ").append(element).append("=").append(id) + .append(" WHERE ").append(element).append(" IS NULL AND AD_Client_ID=").append(getAD_Client_ID()); + int noC = DB.executeUpdate(sql.toString(), get_TrxName()); // - sql = "UPDATE Fact_Acct SET " + element + "=" + id - + " WHERE " + element + " IS NULL AND C_AcctSchema_ID=" + getC_AcctSchema_ID(); - int noF = DB.executeUpdate(sql, get_TrxName()); + sql = new StringBuilder("UPDATE Fact_Acct SET ").append(element).append("=").append(id) + .append(" WHERE ").append(element).append(" IS NULL AND C_AcctSchema_ID=").append(getC_AcctSchema_ID()); + int noF = DB.executeUpdate(sql.toString(), get_TrxName()); // log.fine("ValidCombination=" + noC + ", Fact=" + noF); } // updateData @@ -535,8 +536,8 @@ public final class MAcctSchemaElement extends X_C_AcctSchema_Element protected boolean afterDelete (boolean success) { // Update Account Info - MAccount.updateValueDescription(getCtx(), - "AD_Client_ID=" + getAD_Client_ID(), get_TrxName()); + StringBuilder msguvd = new StringBuilder("AD_Client_ID=").append(getAD_Client_ID()); + MAccount.updateValueDescription(getCtx(),msguvd.toString(), get_TrxName()); // s_cache.clear(); return success; diff --git a/org.adempiere.base/src/org/compiere/model/MAchievement.java b/org.adempiere.base/src/org/compiere/model/MAchievement.java index 8c2a90d2da..b8b414dc45 100644 --- a/org.adempiere.base/src/org/compiere/model/MAchievement.java +++ b/org.adempiere.base/src/org/compiere/model/MAchievement.java @@ -98,7 +98,7 @@ public class MAchievement extends X_PA_Achievement */ public String toString () { - StringBuffer sb = new StringBuffer ("MAchievement["); + StringBuilder sb = new StringBuilder ("MAchievement["); sb.append (get_ID()).append ("-").append (getName()).append ("]"); return sb.toString (); } // toString diff --git a/org.adempiere.base/src/org/compiere/model/MActivity.java b/org.adempiere.base/src/org/compiere/model/MActivity.java index ea0e267c44..d7a87b6560 100644 --- a/org.adempiere.base/src/org/compiere/model/MActivity.java +++ b/org.adempiere.base/src/org/compiere/model/MActivity.java @@ -110,8 +110,10 @@ public class MActivity extends X_C_Activity if (newRecord) insert_Tree(MTree_Base.TREETYPE_Activity); // Value/Name change - if (!newRecord && (is_ValueChanged("Value") || is_ValueChanged("Name"))) - MAccount.updateValueDescription(getCtx(), "C_Activity_ID=" + getC_Activity_ID(), get_TrxName()); + if (!newRecord && (is_ValueChanged("Value") || is_ValueChanged("Name"))){ + StringBuilder msguvd = new StringBuilder("C_Activity_ID=").append(getC_Activity_ID()); + MAccount.updateValueDescription(getCtx(), msguvd.toString(), get_TrxName()); + } return true; } // afterSave diff --git a/org.adempiere.base/src/org/compiere/model/MAd.java b/org.adempiere.base/src/org/compiere/model/MAd.java index 3ba7ceabc0..76a2c8ee97 100644 --- a/org.adempiere.base/src/org/compiere/model/MAd.java +++ b/org.adempiere.base/src/org/compiere/model/MAd.java @@ -72,7 +72,8 @@ public class MAd extends X_CM_Ad */ public static MAd getNext(Properties ctx, int CM_Ad_Cat_ID, String trxName) { MAd thisAd = null; - int [] thisAds = MAd.getAllIDs("CM_Ad","ActualImpression+StartImpression 0) sql.append(" WHERE ").append(getWhereClause()); - String finalSQL = sql.toString(); + StringBuilder finalSQL = new StringBuilder(sql.toString()); // // Apply Security: if (applySecurity) { @@ -118,14 +118,14 @@ public class MAlertRule extends X_AD_AlertRule if (AD_Role_ID != -1) { MRole role = MRole.get(getCtx(), AD_Role_ID); - finalSQL = role.addAccessSQL(finalSQL, null, true, false); + finalSQL = new StringBuilder(role.addAccessSQL(finalSQL.toString(), null, true, false)); } } } // if (getOtherClause() != null && getOtherClause().length() > 0) - finalSQL += " " + getOtherClause(); - return finalSQL; + finalSQL.append(" ").append(getOtherClause()); + return finalSQL.toString(); } // getSql /** @@ -139,12 +139,14 @@ public class MAlertRule extends X_AD_AlertRule { throw new IllegalArgumentException("Parameter extension cannot be empty"); } - String name = new SimpleDateFormat("yyyyMMddhhmm").format(new Timestamp(System.currentTimeMillis())) - +"_"+Util.stripDiacritics(getName().trim()); + StringBuilder msgname = new StringBuilder(new SimpleDateFormat("yyyyMMddhhmm").format(new Timestamp(System.currentTimeMillis()))) + .append("_").append(Util.stripDiacritics(getName().trim())); + String name = msgname.toString(); File file = null; try { - file = new File(System.getProperty("java.io.tmpdir"), name+"."+extension); + StringBuilder msgp = new StringBuilder(name).append(".").append(extension); + file = new File(System.getProperty("java.io.tmpdir"), msgp.toString()); file.createNewFile(); return file; } @@ -156,7 +158,8 @@ public class MAlertRule extends X_AD_AlertRule String filePrefix = "Alert_"; // TODO: add AD_AlertRule.FileName (maybe) try { - file = File.createTempFile(filePrefix, "."+extension); + StringBuilder msgctf = new StringBuilder(".").append(extension); + file = File.createTempFile(filePrefix, msgctf.toString()); } catch (IOException e) { @@ -198,16 +201,14 @@ public class MAlertRule extends X_AD_AlertRule * @return true if success */ private boolean updateParent() { - final String sql_count = "SELECT COUNT(*) FROM "+Table_Name+" r" - +" WHERE r."+COLUMNNAME_AD_Alert_ID+"=a."+MAlert.COLUMNNAME_AD_Alert_ID - +" AND r."+COLUMNNAME_IsValid+"='N'" - +" AND r.IsActive='Y'" - ; - final String sql = "UPDATE "+MAlert.Table_Name+" a SET " - +" "+MAlert.COLUMNNAME_IsValid+"=(CASE WHEN ("+sql_count+") > 0 THEN 'N' ELSE 'Y' END)" - +" WHERE a."+MAlert.COLUMNNAME_AD_Alert_ID+"=?" - ; - int no = DB.executeUpdate(sql, getAD_Alert_ID(), get_TrxName()); + StringBuilder sql_count = new StringBuilder("SELECT COUNT(*) FROM ").append(Table_Name).append(" r") + .append(" WHERE r.").append(COLUMNNAME_AD_Alert_ID).append("=a.").append(MAlert.COLUMNNAME_AD_Alert_ID) + .append(" AND r.").append(COLUMNNAME_IsValid).append("='N'") + .append(" AND r.IsActive='Y'"); + StringBuilder sql = new StringBuilder("UPDATE ").append(MAlert.Table_Name).append(" a SET ") + .append(" ").append(MAlert.COLUMNNAME_IsValid).append("=(CASE WHEN (").append(sql_count).append(") > 0 THEN 'N' ELSE 'Y' END)") + .append(" WHERE a.").append(MAlert.COLUMNNAME_AD_Alert_ID).append("=?"); + int no = DB.executeUpdate(sql.toString(), getAD_Alert_ID(), get_TrxName()); return no == 1; } @@ -217,7 +218,7 @@ public class MAlertRule extends X_AD_AlertRule */ public String toString () { - StringBuffer sb = new StringBuffer ("MAlertRule["); + StringBuilder sb = new StringBuilder ("MAlertRule["); sb.append(get_ID()) .append("-").append(getName()) .append(",Valid=").append(isValid()) diff --git a/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java b/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java index a861aa9cec..0917529f45 100644 --- a/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java +++ b/org.adempiere.base/src/org/compiere/model/MAllocationHdr.java @@ -278,10 +278,10 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction super.setProcessed (processed); if (get_ID() == 0) return; - String sql = "UPDATE C_AllocationHdr SET Processed='" - + (processed ? "Y" : "N") - + "' WHERE C_AllocationHdr_ID=" + getC_AllocationHdr_ID(); - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE C_AllocationHdr SET Processed='") + .append((processed ? "Y" : "N")) + .append("' WHERE C_AllocationHdr_ID=").append(getC_AllocationHdr_ID()); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); m_lines = null; log.fine(processed + " - #" + no); } // setProcessed @@ -411,10 +411,10 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction { if (line.getC_Invoice_ID() != 0) { - final String whereClause = I_C_Invoice.COLUMNNAME_C_Invoice_ID + "=? AND " - + I_C_Invoice.COLUMNNAME_IsPaid + "=? AND " - + I_C_Invoice.COLUMNNAME_DocStatus + " NOT IN (?,?)"; - boolean InvoiceIsPaid = new Query(getCtx(), I_C_Invoice.Table_Name, whereClause, get_TrxName()) + StringBuilder whereClause = new StringBuilder(I_C_Invoice.COLUMNNAME_C_Invoice_ID).append("=? AND ") + .append(I_C_Invoice.COLUMNNAME_IsPaid).append("=? AND ") + .append(I_C_Invoice.COLUMNNAME_DocStatus).append(" NOT IN (?,?)"); + boolean InvoiceIsPaid = new Query(getCtx(), I_C_Invoice.Table_Name, whereClause.toString(), get_TrxName()) .setClient_ID() .setParameters(line.getC_Invoice_ID(), "Y", X_C_Invoice.DOCSTATUS_Voided, X_C_Invoice.DOCSTATUS_Reversed) .match(); @@ -638,7 +638,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction */ public String toString () { - StringBuffer sb = new StringBuffer ("MAllocationHdr["); + StringBuilder sb = new StringBuilder ("MAllocationHdr["); sb.append(get_ID()).append("-").append(getSummary()).append ("]"); return sb.toString (); } // toString @@ -649,7 +649,8 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction */ public String getDocumentInfo() { - return Msg.getElement(getCtx(), "C_AllocationHdr_ID") + " " + getDocumentNo(); + StringBuilder msgreturn = new StringBuilder(Msg.getElement(getCtx(), "C_AllocationHdr_ID")).append(" ").append(getDocumentNo()); + return msgreturn.toString(); } // getDocumentInfo /** @@ -660,7 +661,8 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction { try { - File temp = File.createTempFile(get_TableName()+get_ID()+"_", ".pdf"); + StringBuilder msgctf = new StringBuilder(get_TableName()).append(get_ID()).append("_"); + File temp = File.createTempFile(msgctf.toString(), ".pdf"); return createPDF (temp); } catch (Exception e) @@ -689,7 +691,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction */ public String getSummary() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getDocumentNo()); // : Total Lines = 123.00 (#1) sb.append(": ") diff --git a/org.adempiere.base/src/org/compiere/model/MAllocationLine.java b/org.adempiere.base/src/org/compiere/model/MAllocationLine.java index c4fee6740a..bfd739c63d 100644 --- a/org.adempiere.base/src/org/compiere/model/MAllocationLine.java +++ b/org.adempiere.base/src/org/compiere/model/MAllocationLine.java @@ -221,7 +221,7 @@ public class MAllocationLine extends X_C_AllocationLine */ public String toString () { - StringBuffer sb = new StringBuffer ("MAllocationLine["); + StringBuilder sb = new StringBuilder ("MAllocationLine["); sb.append(get_ID()); if (getC_Payment_ID() != 0) sb.append(",C_Payment_ID=").append(getC_Payment_ID()); @@ -296,12 +296,12 @@ public class MAllocationLine extends X_C_AllocationLine } // Link to Order - String update = "UPDATE C_Order o " - + "SET C_Payment_ID=" - + (reverse ? "NULL " : "(SELECT C_Payment_ID FROM C_Invoice WHERE C_Invoice_ID=" + C_Invoice_ID + ") ") - + "WHERE o.C_Order_ID = (SELECT i.C_Order_ID FROM C_Invoice i " - + "WHERE i.C_Invoice_ID=" + C_Invoice_ID + ")"; - if (DB.executeUpdate(update, get_TrxName()) > 0) + StringBuilder update = new StringBuilder("UPDATE C_Order o ") + .append("SET C_Payment_ID=") + .append((reverse ? "NULL " : "(SELECT C_Payment_ID FROM C_Invoice WHERE C_Invoice_ID=")).append(C_Invoice_ID).append(") ") + .append("WHERE o.C_Order_ID = (SELECT i.C_Order_ID FROM C_Invoice i ") + .append("WHERE i.C_Invoice_ID=").append(C_Invoice_ID).append(")"); + if (DB.executeUpdate(update.toString(), get_TrxName()) > 0) log.fine("C_Payment_ID=" + C_Payment_ID + (reverse ? " UnLinked from" : " Linked to") + " order of C_Invoice_ID=" + C_Invoice_ID); @@ -325,12 +325,12 @@ public class MAllocationLine extends X_C_AllocationLine } // Link to Order - String update = "UPDATE C_Order o " - + "SET C_CashLine_ID=" - + (reverse ? "NULL " : "(SELECT C_CashLine_ID FROM C_Invoice WHERE C_Invoice_ID=" + C_Invoice_ID + ") ") - + "WHERE o.C_Order_ID = (SELECT i.C_Order_ID FROM C_Invoice i " - + "WHERE i.C_Invoice_ID=" + C_Invoice_ID + ")"; - if (DB.executeUpdate(update, get_TrxName()) > 0) + StringBuilder update = new StringBuilder("UPDATE C_Order o ") + .append("SET C_CashLine_ID=") + .append((reverse ? "NULL " : "(SELECT C_CashLine_ID FROM C_Invoice WHERE C_Invoice_ID=")).append(C_Invoice_ID).append(") ") + .append("WHERE o.C_Order_ID = (SELECT i.C_Order_ID FROM C_Invoice i ") + .append("WHERE i.C_Invoice_ID=").append(C_Invoice_ID).append(")"); + if (DB.executeUpdate(update.toString(), get_TrxName()) > 0) log.fine("C_CashLine_ID=" + C_CashLine_ID + (reverse ? " UnLinked from" : " Linked to") + " order of C_Invoice_ID=" + C_Invoice_ID); diff --git a/org.adempiere.base/src/org/compiere/model/MArchive.java b/org.adempiere.base/src/org/compiere/model/MArchive.java index 2992e9a01c..cd843f2948 100644 --- a/org.adempiere.base/src/org/compiere/model/MArchive.java +++ b/org.adempiere.base/src/org/compiere/model/MArchive.java @@ -79,13 +79,13 @@ public class MArchive extends X_AD_Archive { public static MArchive[] get(Properties ctx, String whereClause) { ArrayList list = new ArrayList(); PreparedStatement pstmt = null; - String sql = "SELECT * FROM AD_Archive WHERE AD_Client_ID=?"; + StringBuilder sql = new StringBuilder("SELECT * FROM AD_Archive WHERE AD_Client_ID=?"); if (whereClause != null && whereClause.length() > 0) - sql += whereClause; - sql += " ORDER BY Created"; + sql.append(whereClause); + sql.append(" ORDER BY Created"); try { - pstmt = DB.prepareStatement(sql, null); + pstmt = DB.prepareStatement(sql.toString(), null); pstmt.setInt(1, Env.getAD_Client_ID(ctx)); ResultSet rs = pstmt.executeQuery(); while (rs.next()) @@ -94,7 +94,7 @@ public class MArchive extends X_AD_Archive { pstmt.close(); pstmt = null; } catch (Exception e) { - s_log.log(Level.SEVERE, sql, e); + s_log.log(Level.SEVERE, sql.toString(), e); } try { if (pstmt != null) @@ -104,9 +104,9 @@ public class MArchive extends X_AD_Archive { pstmt = null; } if (list.size() == 0) - s_log.fine(sql); + s_log.fine(sql.toString()); else - s_log.finer(sql); + s_log.finer(sql.toString()); // MArchive[] retValue = new MArchive[list.size()]; list.toArray(retValue); @@ -215,12 +215,12 @@ public class MArchive extends X_AD_Archive { * @return info */ public String toString() { - StringBuffer sb = new StringBuffer("MArchive["); + StringBuilder sb = new StringBuilder("MArchive["); sb.append(get_ID()).append(",Name=").append(getName()); if (m_inflated != null) - sb.append(",Inflated=" + m_inflated); + sb.append(",Inflated=").append(m_inflated); if (m_deflated != null) - sb.append(",Deflated=" + m_deflated); + sb.append(",Deflated=").append(m_deflated); sb.append("]"); return sb.toString(); } // toString @@ -419,8 +419,9 @@ public class MArchive extends X_AD_Archive { } } // write to pdf - final File destFile = new File(m_archivePathRoot + File.separator - + getArchivePathSnippet() + this.get_ID() + ".pdf"); + StringBuilder msgfile = new StringBuilder(m_archivePathRoot).append(File.separator) + .append(getArchivePathSnippet()).append(this.get_ID()).append(".pdf"); + final File destFile = new File(msgfile.toString()); out = new BufferedOutputStream(new FileOutputStream(destFile)); out.write(inflatedData); @@ -433,7 +434,8 @@ public class MArchive extends X_AD_Archive { document.appendChild(root); document.setXmlStandalone(true); final Element entry = document.createElement("entry"); - entry.setAttribute("file", ARCHIVE_FOLDER_PLACEHOLDER + getArchivePathSnippet() + this.get_ID() + ".pdf"); + StringBuilder msgsat = new StringBuilder(ARCHIVE_FOLDER_PLACEHOLDER).append(getArchivePathSnippet()).append(this.get_ID()).append(".pdf"); + entry.setAttribute("file", msgsat.toString()); root.appendChild(entry); final Source source = new DOMSource(document); final ByteArrayOutputStream bos = new ByteArrayOutputStream(); @@ -538,19 +540,19 @@ public class MArchive extends X_AD_Archive { * @return String */ private String getArchivePathSnippet() { - String path = this.getAD_Client_ID() + File.separator + this.getAD_Org_ID() - + File.separator; + StringBuilder path = new StringBuilder(this.getAD_Client_ID()).append(File.separator).append(this.getAD_Org_ID()) + .append(File.separator); if (this.getAD_Process_ID() > 0) { - path = path + this.getAD_Process_ID() + File.separator; + path.append(this.getAD_Process_ID()).append(File.separator); } if (this.getAD_Table_ID() > 0) { - path = path + this.getAD_Table_ID() + File.separator; + path.append(this.getAD_Table_ID()).append(File.separator); } if (this.getRecord_ID() > 0) { - path = path + this.getRecord_ID() + File.separator; + path.append(this.getRecord_ID()).append(File.separator); } // path = path + this.get_ID() + ".pdf"; - return path; + return path.toString(); } /** diff --git a/org.adempiere.base/src/org/compiere/model/MAsset.java b/org.adempiere.base/src/org/compiere/model/MAsset.java index 372bae8cda..faf94f2241 100644 --- a/org.adempiere.base/src/org/compiere/model/MAsset.java +++ b/org.adempiere.base/src/org/compiere/model/MAsset.java @@ -183,20 +183,21 @@ public class MAsset extends X_A_Asset public void setValueNameDescription (MInOut shipment, int deliveryCount, MProduct product, MBPartner partner) { - String documentNo = "_" + shipment.getDocumentNo(); + StringBuilder documentNo = new StringBuilder("_").append(shipment.getDocumentNo()); if (deliveryCount > 1) - documentNo += "_" + deliveryCount; + documentNo.append("_").append(deliveryCount); // Value - String value = partner.getValue() + "_" + product.getValue(); + StringBuilder value = new StringBuilder(partner.getValue()).append("_").append(product.getValue()); if (value.length() > 40-documentNo.length()) - value = value.substring(0,40-documentNo.length()) + documentNo; - setValue(value); + value.delete(40-documentNo.length(), value.length()).append(documentNo); + + setValue(value.toString()); // Name MProduct.afterSave - String name = partner.getName() + " - " + product.getName(); + StringBuilder name = new StringBuilder(partner.getName()).append(" - ").append(product.getName()); if (name.length() > 60) - name = name.substring(0,60); - setName(name); + name.delete(60,name.length()); + setName(name.toString()); // Description String description = product.getDescription(); setDescription(description); @@ -211,8 +212,10 @@ public class MAsset extends X_A_Asset String desc = getDescription(); if (desc == null) setDescription(description); - else - setDescription(desc + " | " + description); + else{ + StringBuilder msgsd= new StringBuilder(desc).append(" | ").append(description); + setDescription(msgsd.toString()); + } } // addDescription /** @@ -233,7 +236,7 @@ public class MAsset extends X_A_Asset */ public String toString () { - StringBuffer sb = new StringBuffer ("MAsset[") + StringBuilder sb = new StringBuilder ("MAsset[") .append (get_ID ()) .append("-").append(getValue()) .append ("]"); diff --git a/org.adempiere.base/src/org/compiere/model/MAssetDelivery.java b/org.adempiere.base/src/org/compiere/model/MAssetDelivery.java index 374f84be54..9a6d6c1b21 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssetDelivery.java +++ b/org.adempiere.base/src/org/compiere/model/MAssetDelivery.java @@ -124,7 +124,7 @@ public class MAssetDelivery extends X_A_Asset_Delivery */ public String toString () { - StringBuffer sb = new StringBuffer ("MAssetDelivery[") + StringBuilder sb = new StringBuilder ("MAssetDelivery[") .append (get_ID ()) .append(",A_Asset_ID=").append(getA_Asset_ID()) .append(",MovementDate=").append(getMovementDate()) diff --git a/org.adempiere.base/src/org/compiere/model/MAssignmentSlot.java b/org.adempiere.base/src/org/compiere/model/MAssignmentSlot.java index 22049c764e..133d40d41c 100644 --- a/org.adempiere.base/src/org/compiere/model/MAssignmentSlot.java +++ b/org.adempiere.base/src/org/compiere/model/MAssignmentSlot.java @@ -438,7 +438,7 @@ public class MAssignmentSlot implements Comparator return getInfo(); // DISPLAY_ALL - StringBuffer sb = new StringBuffer("MAssignmentSlot["); + StringBuilder sb = new StringBuilder("MAssignmentSlot["); sb.append(m_startTime).append("-").append(m_endTime) .append("-Status=").append(m_status).append(",Name=") .append(m_name).append(",").append(m_description).append("]"); @@ -460,7 +460,7 @@ public class MAssignmentSlot implements Comparator */ public String getInfoTimeFromTo() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(m_language.getTimeFormat().format(m_startTime)) .append(" - ") .append(m_language.getTimeFormat().format(m_endTime)); @@ -473,7 +473,7 @@ public class MAssignmentSlot implements Comparator */ public String getInfoDateTimeFromTo() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(m_language.getDateTimeFormat().format(m_startTime)) .append(" - "); if (TimeUtil.isSameDay(m_startTime, m_endTime)) @@ -489,7 +489,7 @@ public class MAssignmentSlot implements Comparator */ public String getInfoNameDescription() { - StringBuffer sb = new StringBuffer(m_name); + StringBuilder sb = new StringBuilder(m_name); if (m_description.length() > 0) sb.append(" (").append(m_description).append(")"); return sb.toString(); @@ -501,7 +501,7 @@ public class MAssignmentSlot implements Comparator */ public String getInfo() { - StringBuffer sb = new StringBuffer(getInfoDateTimeFromTo()); + StringBuilder sb = new StringBuilder(getInfoDateTimeFromTo()); sb.append(": ").append(m_name); if (m_description.length() > 0) sb.append(" (").append(m_description).append(")"); diff --git a/org.adempiere.base/src/org/compiere/model/MAttachment.java b/org.adempiere.base/src/org/compiere/model/MAttachment.java index 9e384c076a..772a72ebd2 100644 --- a/org.adempiere.base/src/org/compiere/model/MAttachment.java +++ b/org.adempiere.base/src/org/compiere/model/MAttachment.java @@ -222,7 +222,7 @@ public class MAttachment extends X_AD_Attachment */ public String toString() { - StringBuffer sb = new StringBuffer("MAttachment["); + StringBuilder sb = new StringBuilder("MAttachment["); sb.append(getAD_Attachment_ID()).append(",Title=").append(getTitle()) .append(",Entries=").append(getEntryCount()); for (int i = 0; i < getEntryCount(); i++) @@ -435,9 +435,12 @@ public class MAttachment extends X_AD_Attachment System.out.println("- no entries -"); return; } - System.out.println("- entries: " + m_items.size()); - for (int i = 0; i < m_items.size(); i++) - System.out.println(" - " + getEntryName(i)); + StringBuilder msgout = new StringBuilder("- entries: ").append(m_items.size()); + System.out.println(msgout.toString()); + for (int i = 0; i < m_items.size(); i++){ + msgout = new StringBuilder(" - ").append(getEntryName(i)); + System.out.println(msgout.toString()); + } } // dumpEntryNames /** @@ -576,14 +579,16 @@ public class MAttachment extends X_AD_Attachment FileChannel out = null; try { //create destination folder - final File destFolder = new File(m_attachmentPathRoot + File.separator + getAttachmentPathSnippet()); + StringBuilder msgfile = new StringBuilder(m_attachmentPathRoot).append(File.separator).append(getAttachmentPathSnippet()); + final File destFolder = new File(msgfile.toString()); if(!destFolder.exists()){ if(!destFolder.mkdirs()){ log.warning("unable to create folder: " + destFolder.getPath()); } } - final File destFile = new File(m_attachmentPathRoot + File.separator - + getAttachmentPathSnippet() + File.separator + entryFile.getName()); + msgfile = new StringBuilder(m_attachmentPathRoot).append(File.separator) + .append(getAttachmentPathSnippet()).append(File.separator).append(entryFile.getName()); + final File destFile = new File(msgfile.toString()); in = new FileInputStream(entryFile).getChannel(); out = new FileOutputStream(destFile).getChannel(); in.transferTo(0, in.size(), out); @@ -808,9 +813,11 @@ public class MAttachment extends X_AD_Attachment * @return String */ private String getAttachmentPathSnippet(){ - return this.getAD_Client_ID() + File.separator + - this.getAD_Org_ID() + File.separator + - this.getAD_Table_ID() + File.separator + this.getRecord_ID(); + + StringBuilder msgreturn = new StringBuilder(this.getAD_Client_ID()).append(File.separator) + .append(this.getAD_Org_ID()).append(File.separator) + .append(this.getAD_Table_ID()).append(File.separator).append(this.getRecord_ID()); + return msgreturn.toString(); } /** diff --git a/org.adempiere.base/src/org/compiere/model/MAttachmentEntry.java b/org.adempiere.base/src/org/compiere/model/MAttachmentEntry.java index 3e45c19424..c3dc3d371c 100644 --- a/org.adempiere.base/src/org/compiere/model/MAttachmentEntry.java +++ b/org.adempiere.base/src/org/compiere/model/MAttachmentEntry.java @@ -144,7 +144,7 @@ public class MAttachmentEntry */ public String toStringX () { - StringBuffer sb = new StringBuffer (m_name); + StringBuilder sb = new StringBuilder (m_name); if (m_data != null) { sb.append(" ("); @@ -176,8 +176,8 @@ public class MAttachmentEntry */ public void dump () { - String hdr = "----- " + getName() + " -----"; - System.out.println (hdr); + StringBuilder hdr = new StringBuilder("----- ").append(getName()).append(" -----"); + System.out.println (hdr.toString()); if (m_data == null) { System.out.println ("----- no data -----"); @@ -191,14 +191,15 @@ public class MAttachmentEntry } System.out.println (); - System.out.println (hdr); + System.out.println (hdr.toString()); // Count nulls at end int ii = m_data.length -1; int nullCount = 0; while (m_data[ii--] == 0) nullCount++; - System.out.println("----- Length=" + m_data.length + ", EndNulls=" + nullCount - + ", RealLength=" + (m_data.length-nullCount)); + StringBuilder msgout = new StringBuilder("----- Length=").append(m_data.length).append(", EndNulls=").append(nullCount) + .append(", RealLength=").append((m_data.length-nullCount)); + System.out.println(msgout.toString()); /** // Dump w/o nulls if (nullCount > 0) diff --git a/org.adempiere.base/src/org/compiere/model/MAttribute.java b/org.adempiere.base/src/org/compiere/model/MAttribute.java index ab2f9d0f2f..df0e71573a 100644 --- a/org.adempiere.base/src/org/compiere/model/MAttribute.java +++ b/org.adempiere.base/src/org/compiere/model/MAttribute.java @@ -64,9 +64,9 @@ public class MAttribute extends X_M_Attribute sql += " AND AttributeValueType=?"; params.add(MAttribute.ATTRIBUTEVALUETYPE_List); } - final String whereClause = "AD_Client_ID=?"+sql; + StringBuilder whereClause = new StringBuilder("AD_Client_ID=?").append(sql); - Listlist = new Query(ctx,I_M_Attribute.Table_Name,whereClause,null) + Listlist = new Query(ctx,I_M_Attribute.Table_Name,whereClause.toString(),null) .setParameters(params) .setOnlyActiveRecords(true) .setOrderBy("Name") @@ -224,7 +224,7 @@ public class MAttribute extends X_M_Attribute */ public String toString () { - StringBuffer sb = new StringBuffer ("MAttribute["); + StringBuilder sb = new StringBuilder ("MAttribute["); sb.append (get_ID()).append ("-").append (getName()) .append(",Type=").append(getAttributeValueType()) .append(",Instance=").append(isInstanceAttribute()) @@ -243,13 +243,13 @@ public class MAttribute extends X_M_Attribute // Changed to Instance Attribute if (!newRecord && is_ValueChanged("IsInstanceAttribute") && isInstanceAttribute()) { - String sql = "UPDATE M_AttributeSet mas " - + "SET IsInstanceAttribute='Y' " - + "WHERE IsInstanceAttribute='N'" - + " AND EXISTS (SELECT * FROM M_AttributeUse mau " - + "WHERE mas.M_AttributeSet_ID=mau.M_AttributeSet_ID" - + " AND mau.M_Attribute_ID=" + getM_Attribute_ID() + ")"; - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE M_AttributeSet mas ") + .append("SET IsInstanceAttribute='Y' ") + .append("WHERE IsInstanceAttribute='N'") + .append(" AND EXISTS (SELECT * FROM M_AttributeUse mau ") + .append("WHERE mas.M_AttributeSet_ID=mau.M_AttributeSet_ID") + .append(" AND mau.M_Attribute_ID=").append(getM_Attribute_ID()).append(")"); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("AttributeSet Instance set #" + no); } return success; diff --git a/org.adempiere.base/src/org/compiere/model/MAttributeInstance.java b/org.adempiere.base/src/org/compiere/model/MAttributeInstance.java index 8906abd43f..9b22be74ba 100644 --- a/org.adempiere.base/src/org/compiere/model/MAttributeInstance.java +++ b/org.adempiere.base/src/org/compiere/model/MAttributeInstance.java @@ -131,7 +131,7 @@ public class MAttributeInstance extends X_M_AttributeInstance } // Display number w/o decimal 0 char[] chars = ValueNumber.toString().toCharArray(); - StringBuffer display = new StringBuffer(); + StringBuilder display = new StringBuilder(); boolean add = false; for (int i = chars.length-1; i >= 0; i--) { diff --git a/org.adempiere.base/src/org/compiere/model/MAttributeSet.java b/org.adempiere.base/src/org/compiere/model/MAttributeSet.java index 556eaf3605..9deb0bef5e 100644 --- a/org.adempiere.base/src/org/compiere/model/MAttributeSet.java +++ b/org.adempiere.base/src/org/compiere/model/MAttributeSet.java @@ -385,18 +385,18 @@ public class MAttributeSet extends X_M_AttributeSet // Set Instance Attribute if (!isInstanceAttribute()) { - String sql = "UPDATE M_AttributeSet mas" - + " SET IsInstanceAttribute='Y' " - + "WHERE M_AttributeSet_ID=" + getM_AttributeSet_ID() - + " AND IsInstanceAttribute='N'" - + " AND (IsSerNo='Y' OR IsLot='Y' OR IsGuaranteeDate='Y'" - + " OR EXISTS (SELECT * FROM M_AttributeUse mau" - + " INNER JOIN M_Attribute ma ON (mau.M_Attribute_ID=ma.M_Attribute_ID) " - + "WHERE mau.M_AttributeSet_ID=mas.M_AttributeSet_ID" - + " AND mau.IsActive='Y' AND ma.IsActive='Y'" - + " AND ma.IsInstanceAttribute='Y')" - + ")"; - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE M_AttributeSet mas") + .append(" SET IsInstanceAttribute='Y' ") + .append("WHERE M_AttributeSet_ID=").append(getM_AttributeSet_ID()) + .append(" AND IsInstanceAttribute='N'") + .append(" AND (IsSerNo='Y' OR IsLot='Y' OR IsGuaranteeDate='Y'") + .append(" OR EXISTS (SELECT * FROM M_AttributeUse mau") + .append(" INNER JOIN M_Attribute ma ON (mau.M_Attribute_ID=ma.M_Attribute_ID) ") + .append("WHERE mau.M_AttributeSet_ID=mas.M_AttributeSet_ID") + .append(" AND mau.IsActive='Y' AND ma.IsActive='Y'") + .append(" AND ma.IsInstanceAttribute='Y')") + .append(")"); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 0) { log.warning("Set Instance Attribute"); @@ -406,17 +406,17 @@ public class MAttributeSet extends X_M_AttributeSet // Reset Instance Attribute if (isInstanceAttribute() && !isSerNo() && !isLot() && !isGuaranteeDate()) { - String sql = "UPDATE M_AttributeSet mas" - + " SET IsInstanceAttribute='N' " - + "WHERE M_AttributeSet_ID=" + getM_AttributeSet_ID() - + " AND IsInstanceAttribute='Y'" - + " AND IsSerNo='N' AND IsLot='N' AND IsGuaranteeDate='N'" - + " AND NOT EXISTS (SELECT * FROM M_AttributeUse mau" - + " INNER JOIN M_Attribute ma ON (mau.M_Attribute_ID=ma.M_Attribute_ID) " - + "WHERE mau.M_AttributeSet_ID=mas.M_AttributeSet_ID" - + " AND mau.IsActive='Y' AND ma.IsActive='Y'" - + " AND ma.IsInstanceAttribute='Y')"; - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE M_AttributeSet mas") + .append(" SET IsInstanceAttribute='N' ") + .append("WHERE M_AttributeSet_ID=").append(getM_AttributeSet_ID()) + .append(" AND IsInstanceAttribute='Y'") + .append(" AND IsSerNo='N' AND IsLot='N' AND IsGuaranteeDate='N'") + .append(" AND NOT EXISTS (SELECT * FROM M_AttributeUse mau") + .append(" INNER JOIN M_Attribute ma ON (mau.M_Attribute_ID=ma.M_Attribute_ID) ") + .append("WHERE mau.M_AttributeSet_ID=mas.M_AttributeSet_ID") + .append(" AND mau.IsActive='Y' AND ma.IsActive='Y'") + .append(" AND ma.IsInstanceAttribute='Y')"); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 0) { log.warning("Reset Instance Attribute"); diff --git a/org.adempiere.base/src/org/compiere/model/MAttributeSetInstance.java b/org.adempiere.base/src/org/compiere/model/MAttributeSetInstance.java index 91b936bfd6..f7bb33a670 100644 --- a/org.adempiere.base/src/org/compiere/model/MAttributeSetInstance.java +++ b/org.adempiere.base/src/org/compiere/model/MAttributeSetInstance.java @@ -186,7 +186,7 @@ public class MAttributeSetInstance extends X_M_AttributeSetInstance return; } - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); // Instance Attribute Values MAttribute[] attributes = m_mas.getMAttributes(true); diff --git a/org.adempiere.base/src/org/compiere/model/MAttributeUse.java b/org.adempiere.base/src/org/compiere/model/MAttributeUse.java index d98d0c4b61..ad99de46db 100644 --- a/org.adempiere.base/src/org/compiere/model/MAttributeUse.java +++ b/org.adempiere.base/src/org/compiere/model/MAttributeUse.java @@ -70,32 +70,32 @@ public class MAttributeUse extends X_M_AttributeUse protected boolean afterSave (boolean newRecord, boolean success) { // also used for afterDelete - String sql = "UPDATE M_AttributeSet mas" - + " SET IsInstanceAttribute='Y' " - + "WHERE M_AttributeSet_ID=" + getM_AttributeSet_ID() - + " AND IsInstanceAttribute='N'" - + " AND (IsSerNo='Y' OR IsLot='Y' OR IsGuaranteeDate='Y'" - + " OR EXISTS (SELECT * FROM M_AttributeUse mau" - + " INNER JOIN M_Attribute ma ON (mau.M_Attribute_ID=ma.M_Attribute_ID) " - + "WHERE mau.M_AttributeSet_ID=mas.M_AttributeSet_ID" - + " AND mau.IsActive='Y' AND ma.IsActive='Y'" - + " AND ma.IsInstanceAttribute='Y')" - + ")"; - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE M_AttributeSet mas") + .append(" SET IsInstanceAttribute='Y' ") + .append("WHERE M_AttributeSet_ID=").append(getM_AttributeSet_ID()) + .append(" AND IsInstanceAttribute='N'") + .append(" AND (IsSerNo='Y' OR IsLot='Y' OR IsGuaranteeDate='Y'") + .append(" OR EXISTS (SELECT * FROM M_AttributeUse mau") + .append(" INNER JOIN M_Attribute ma ON (mau.M_Attribute_ID=ma.M_Attribute_ID) ") + .append("WHERE mau.M_AttributeSet_ID=mas.M_AttributeSet_ID") + .append(" AND mau.IsActive='Y' AND ma.IsActive='Y'") + .append(" AND ma.IsInstanceAttribute='Y')") + .append(")"); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 0) log.fine("afterSave - Set Instance Attribute"); // - sql = "UPDATE M_AttributeSet mas" - + " SET IsInstanceAttribute='N' " - + "WHERE M_AttributeSet_ID=" + getM_AttributeSet_ID() - + " AND IsInstanceAttribute='Y'" - + " AND IsSerNo='N' AND IsLot='N' AND IsGuaranteeDate='N'" - + " AND NOT EXISTS (SELECT * FROM M_AttributeUse mau" - + " INNER JOIN M_Attribute ma ON (mau.M_Attribute_ID=ma.M_Attribute_ID) " - + "WHERE mau.M_AttributeSet_ID=mas.M_AttributeSet_ID" - + " AND mau.IsActive='Y' AND ma.IsActive='Y'" - + " AND ma.IsInstanceAttribute='Y')"; - no = DB.executeUpdate(sql, get_TrxName()); + sql = new StringBuilder("UPDATE M_AttributeSet mas") + .append(" SET IsInstanceAttribute='N' ") + .append("WHERE M_AttributeSet_ID=").append(getM_AttributeSet_ID()) + .append(" AND IsInstanceAttribute='Y'") + .append(" AND IsSerNo='N' AND IsLot='N' AND IsGuaranteeDate='N'") + .append(" AND NOT EXISTS (SELECT * FROM M_AttributeUse mau") + .append(" INNER JOIN M_Attribute ma ON (mau.M_Attribute_ID=ma.M_Attribute_ID) ") + .append("WHERE mau.M_AttributeSet_ID=mas.M_AttributeSet_ID") + .append(" AND mau.IsActive='Y' AND ma.IsActive='Y'") + .append(" AND ma.IsInstanceAttribute='Y')"); + no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 0) log.fine("afterSave - Reset Instance Attribute"); diff --git a/org.adempiere.base/src/org/compiere/model/MBOM.java b/org.adempiere.base/src/org/compiere/model/MBOM.java index b64698ee82..ca4ed82fda 100644 --- a/org.adempiere.base/src/org/compiere/model/MBOM.java +++ b/org.adempiere.base/src/org/compiere/model/MBOM.java @@ -67,10 +67,10 @@ public class MBOM extends X_M_BOM String trxName, String whereClause) { //FR: [ 2214883 ] Remove SQL code and Replace for Query - red1 - String where = "M_Product_ID=?"; + StringBuilder where = new StringBuilder("M_Product_ID=?"); if (whereClause != null && whereClause.length() > 0) - where += " AND " + whereClause; - List list = new Query(ctx, I_M_BOM.Table_Name, where, trxName) + where.append(" AND ").append(whereClause); + List list = new Query(ctx, I_M_BOM.Table_Name, where.toString(), trxName) .setParameters(M_Product_ID) .list(); @@ -128,8 +128,8 @@ public class MBOM extends X_M_BOM // Only one Current Active if (getBOMType().equals(BOMTYPE_CurrentActive)) { - MBOM[] boms = getOfProduct(getCtx(), getM_Product_ID(), get_TrxName(), - "BOMType='A' AND BOMUse='" + getBOMUse() + "' AND IsActive='Y'"); + StringBuilder msgofp = new StringBuilder("BOMType='A' AND BOMUse='").append(getBOMUse()).append("' AND IsActive='Y'"); + MBOM[] boms = getOfProduct(getCtx(), getM_Product_ID(), get_TrxName(),msgofp.toString()); if (boms.length == 0 // only one = this || (boms.length == 1 && boms[0].getM_BOM_ID() == getM_BOM_ID())) ; diff --git a/org.adempiere.base/src/org/compiere/model/MBPBankAccount.java b/org.adempiere.base/src/org/compiere/model/MBPBankAccount.java index c233231438..e55146f3f2 100644 --- a/org.adempiere.base/src/org/compiere/model/MBPBankAccount.java +++ b/org.adempiere.base/src/org/compiere/model/MBPBankAccount.java @@ -188,7 +188,7 @@ public class MBPBankAccount extends X_C_BP_BankAccount */ public String toString () { - StringBuffer sb = new StringBuffer ("MBP_BankAccount[") + StringBuilder sb = new StringBuilder ("MBP_BankAccount[") .append (get_ID ()) .append(", Name=").append(getA_Name()) .append ("]"); diff --git a/org.adempiere.base/src/org/compiere/model/MBPartner.java b/org.adempiere.base/src/org/compiere/model/MBPartner.java index 40f5d32ca5..aef09a051a 100644 --- a/org.adempiere.base/src/org/compiere/model/MBPartner.java +++ b/org.adempiere.base/src/org/compiere/model/MBPartner.java @@ -531,7 +531,7 @@ public class MBPartner extends X_C_BPartner */ public String toString () { - StringBuffer sb = new StringBuffer ("MBPartner[ID=") + StringBuilder sb = new StringBuilder ("MBPartner[ID=") .append(get_ID()) .append(",Value=").append(getValue()) .append(",Name=").append(getName()) @@ -988,18 +988,18 @@ public class MBPartner extends X_C_BPartner // Trees insert_Tree(MTree_Base.TREETYPE_BPartner); // Accounting - insert_Accounting("C_BP_Customer_Acct", "C_BP_Group_Acct", - "p.C_BP_Group_ID=" + getC_BP_Group_ID()); - insert_Accounting("C_BP_Vendor_Acct", "C_BP_Group_Acct", - "p.C_BP_Group_ID=" + getC_BP_Group_ID()); + StringBuilder msgacc = new StringBuilder("p.C_BP_Group_ID=").append(getC_BP_Group_ID()); + insert_Accounting("C_BP_Customer_Acct", "C_BP_Group_Acct", msgacc.toString()); + insert_Accounting("C_BP_Vendor_Acct", "C_BP_Group_Acct",msgacc.toString()); insert_Accounting("C_BP_Employee_Acct", "C_AcctSchema_Default", null); } // Value/Name change if (success && !newRecord - && (is_ValueChanged("Value") || is_ValueChanged("Name"))) - MAccount.updateValueDescription(getCtx(), "C_BPartner_ID=" + getC_BPartner_ID(), get_TrxName()); - + && (is_ValueChanged("Value") || is_ValueChanged("Name"))){ + StringBuilder msgacc = new StringBuilder("C_BPartner_ID=").append(getC_BPartner_ID()); + MAccount.updateValueDescription(getCtx(), msgacc.toString(), get_TrxName()); + } return success; } // afterSave diff --git a/org.adempiere.base/src/org/compiere/model/MBPartnerInfo.java b/org.adempiere.base/src/org/compiere/model/MBPartnerInfo.java index 78f6404062..e4990afcab 100644 --- a/org.adempiere.base/src/org/compiere/model/MBPartnerInfo.java +++ b/org.adempiere.base/src/org/compiere/model/MBPartnerInfo.java @@ -52,8 +52,8 @@ public class MBPartnerInfo extends X_RV_BPartner public static MBPartnerInfo[] find (Properties ctx, String Value, String Name, String Contact, String EMail, String Phone, String City) { - StringBuffer sql = new StringBuffer ("SELECT * FROM RV_BPartner WHERE IsActive='Y'"); - StringBuffer sb = new StringBuffer(); + StringBuilder sql = new StringBuilder ("SELECT * FROM RV_BPartner WHERE IsActive='Y'"); + StringBuilder sb = new StringBuilder(); Value = getFindParameter (Value); if (Value != null) sb.append("UPPER(Value) LIKE ?"); diff --git a/org.adempiere.base/src/org/compiere/model/MBPartnerLocation.java b/org.adempiere.base/src/org/compiere/model/MBPartnerLocation.java index e4e5b48c20..6e733f2f06 100644 --- a/org.adempiere.base/src/org/compiere/model/MBPartnerLocation.java +++ b/org.adempiere.base/src/org/compiere/model/MBPartnerLocation.java @@ -125,7 +125,7 @@ public class MBPartnerLocation extends X_C_BPartner_Location { /** Cached Location */ private MLocation m_location = null; /** Unique Name */ - private String m_uniqueName = null; + private StringBuffer m_uniqueName = null; private int m_unique = 0; /** @@ -148,7 +148,7 @@ public class MBPartnerLocation extends X_C_BPartner_Location { * @return info */ public String toString() { - StringBuffer sb = new StringBuffer("MBPartner_Location[ID=") + StringBuilder sb = new StringBuilder("MBPartner_Location[ID=") .append(get_ID()).append(",C_Location_ID=") .append(getC_Location_ID()).append(",Name=").append(getName()) .append("]"); @@ -181,21 +181,21 @@ public class MBPartnerLocation extends X_C_BPartner_Location { * address */ private void makeUnique(MLocation address) { - m_uniqueName = ""; + m_uniqueName = new StringBuffer(); // 0 - City if (m_unique >= 0 || m_uniqueName.length() == 0) { String xx = address.getCity(); if (xx != null && xx.length() > 0) - m_uniqueName = xx; + m_uniqueName = new StringBuffer(xx); } // 1 + Address1 if (m_unique >= 1 || m_uniqueName.length() == 0) { String xx = address.getAddress1(); if (xx != null && xx.length() > 0) { if (m_uniqueName.length() > 0) - m_uniqueName += " "; - m_uniqueName += xx; + m_uniqueName.append(" "); + m_uniqueName.append(xx); } } // 2 + Address2 @@ -203,8 +203,8 @@ public class MBPartnerLocation extends X_C_BPartner_Location { String xx = address.getAddress2(); if (xx != null && xx.length() > 0) { if (m_uniqueName.length() > 0) - m_uniqueName += " "; - m_uniqueName += xx; + m_uniqueName.append(" "); + m_uniqueName.append(xx); } } // 3 - Region @@ -212,8 +212,8 @@ public class MBPartnerLocation extends X_C_BPartner_Location { String xx = address.getRegionName(true); if (xx != null && xx.length() > 0) { if (m_uniqueName.length() > 0) - m_uniqueName += " "; - m_uniqueName += xx; + m_uniqueName.append(" "); + m_uniqueName.append(xx); } } // 4 - ID @@ -221,12 +221,12 @@ public class MBPartnerLocation extends X_C_BPartner_Location { int id = get_ID(); if (id == 0) id = address.get_ID(); - m_uniqueName += "#" + id; + m_uniqueName.append("#").append(id); } } // makeUnique public String getBPLocName(MLocation address) { - m_uniqueName = getName(); + m_uniqueName = new StringBuffer(getName()); m_unique = MSysConfig.getIntValue("START_VALUE_BPLOCATION_NAME", 0, getAD_Client_ID(), getAD_Org_ID()); if (m_unique < 0 || m_unique > 4) @@ -256,7 +256,7 @@ public class MBPartnerLocation extends X_C_BPartner_Location { } } } - return m_uniqueName; + return m_uniqueName.toString(); } } // MBPartnerLocation diff --git a/org.adempiere.base/src/org/compiere/model/MBank.java b/org.adempiere.base/src/org/compiere/model/MBank.java index 710efab0bb..a01b066634 100644 --- a/org.adempiere.base/src/org/compiere/model/MBank.java +++ b/org.adempiere.base/src/org/compiere/model/MBank.java @@ -86,7 +86,7 @@ public class MBank extends X_C_Bank */ public String toString () { - StringBuffer sb = new StringBuffer ("MBank["); + StringBuilder sb = new StringBuilder ("MBank["); sb.append (get_ID ()).append ("-").append(getName ()).append ("]"); return sb.toString (); } // toString diff --git a/org.adempiere.base/src/org/compiere/model/MBankAccount.java b/org.adempiere.base/src/org/compiere/model/MBankAccount.java index f6d2af0246..ce681e4f54 100644 --- a/org.adempiere.base/src/org/compiere/model/MBankAccount.java +++ b/org.adempiere.base/src/org/compiere/model/MBankAccount.java @@ -95,7 +95,7 @@ public class MBankAccount extends X_C_BankAccount */ public String toString () { - StringBuffer sb = new StringBuffer ("MBankAccount[") + StringBuilder sb = new StringBuilder ("MBankAccount[") .append (get_ID()) .append("-").append(getAccountNo()) .append ("]"); @@ -117,7 +117,8 @@ public class MBankAccount extends X_C_BankAccount */ public String getName() { - return getBank().getName() + " " + getAccountNo(); + StringBuilder msgreturn = new StringBuilder(getBank().getName()).append(" ").append(getAccountNo()); + return msgreturn.toString(); } // getName /** diff --git a/org.adempiere.base/src/org/compiere/model/MBankStatement.java b/org.adempiere.base/src/org/compiere/model/MBankStatement.java index 56806857ef..4f38fa577b 100644 --- a/org.adempiere.base/src/org/compiere/model/MBankStatement.java +++ b/org.adempiere.base/src/org/compiere/model/MBankStatement.java @@ -148,8 +148,10 @@ public class MBankStatement extends X_C_BankStatement implements DocAction String desc = getDescription(); if (desc == null) setDescription(description); - else - setDescription(desc + " | " + description); + else{ + StringBuilder msgsd = new StringBuilder(desc).append(" | ").append(description); + setDescription(msgsd.toString()); + } } // addDescription /** @@ -162,10 +164,10 @@ public class MBankStatement extends X_C_BankStatement implements DocAction super.setProcessed (processed); if (get_ID() == 0) return; - String sql = "UPDATE C_BankStatementLine SET Processed='" - + (processed ? "Y" : "N") - + "' WHERE C_BankStatement_ID=" + getC_BankStatement_ID(); - int noLine = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE C_BankStatementLine SET Processed='") + .append((processed ? "Y" : "N")) + .append("' WHERE C_BankStatement_ID=").append(getC_BankStatement_ID()); + int noLine = DB.executeUpdate(sql.toString(), get_TrxName()); m_lines = null; log.fine("setProcessed - " + processed + " - Lines=" + noLine); } // setProcessed @@ -194,7 +196,8 @@ public class MBankStatement extends X_C_BankStatement implements DocAction */ public String getDocumentInfo() { - return getBankAccount().getName() + " " + getDocumentNo(); + StringBuilder msgreturn = new StringBuilder(getBankAccount().getName()).append(" ").append(getDocumentNo()); + return msgreturn.toString(); } // getDocumentInfo /** @@ -205,7 +208,8 @@ public class MBankStatement extends X_C_BankStatement implements DocAction { try { - File temp = File.createTempFile(get_TableName()+get_ID()+"_", ".pdf"); + StringBuilder msgfile = new StringBuilder(get_TableName()).append(get_ID()).append("_"); + File temp = File.createTempFile(msgfile.toString(), ".pdf"); return createPDF (temp); } catch (Exception e) @@ -259,7 +263,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction } // processIt /** Process Message */ - private String m_processMsg = null; + private StringBuffer m_processMsg = null; /** Just Prepared Flag */ private boolean m_justPrepared = false; @@ -292,7 +296,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction public String prepareIt() { log.info(toString()); - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE); + m_processMsg = new StringBuffer( ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -301,7 +305,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction MBankStatementLine[] lines = getLines(true); if (lines.length == 0) { - m_processMsg = "@NoLines@"; + m_processMsg = new StringBuffer("@NoLines@"); return DocAction.STATUS_Invalid; } // Lines @@ -322,7 +326,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction MPeriod.testPeriodOpen(getCtx(), minDate, MDocType.DOCBASETYPE_BankStatement, 0); MPeriod.testPeriodOpen(getCtx(), maxDate, MDocType.DOCBASETYPE_BankStatement, 0); - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -369,7 +373,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction return status; } - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -401,7 +405,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE); if (valid != null) { - m_processMsg = valid; + m_processMsg = new StringBuffer(valid); return DocAction.STATUS_Invalid; } // @@ -418,7 +422,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction { log.info(toString()); // Before Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID)); if (m_processMsg != null) return false; @@ -426,7 +430,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction || DOCSTATUS_Reversed.equals(getDocStatus()) || DOCSTATUS_Voided.equals(getDocStatus())) { - m_processMsg = "Document Closed: " + getDocStatus(); + m_processMsg = new StringBuffer("Document Closed: ").append(getDocStatus()); setDocAction(DOCACTION_None); return false; } @@ -460,16 +464,16 @@ public class MBankStatement extends X_C_BankStatement implements DocAction MBankStatementLine line = lines[i]; if (line.getStmtAmt().compareTo(Env.ZERO) != 0) { - String description = Msg.getMsg(getCtx(), "Voided") + " (" - + Msg.translate(getCtx(), "StmtAmt") + "=" + line.getStmtAmt(); + StringBuilder description = new StringBuilder(Msg.getMsg(getCtx(), "Voided")).append(" (") + .append(Msg.translate(getCtx(), "StmtAmt")).append("=").append(line.getStmtAmt()); if (line.getTrxAmt().compareTo(Env.ZERO) != 0) - description += ", " + Msg.translate(getCtx(), "TrxAmt") + "=" + line.getTrxAmt(); + description.append(", ").append(Msg.translate(getCtx(), "TrxAmt")).append("=").append(line.getTrxAmt()); if (line.getChargeAmt().compareTo(Env.ZERO) != 0) - description += ", " + Msg.translate(getCtx(), "ChargeAmt") + "=" + line.getChargeAmt(); + description.append(", ").append(Msg.translate(getCtx(), "ChargeAmt")).append("=").append(line.getChargeAmt()); if (line.getInterestAmt().compareTo(Env.ZERO) != 0) - description += ", " + Msg.translate(getCtx(), "InterestAmt") + "=" + line.getInterestAmt(); - description += ")"; - line.addDescription(description); + description.append(", ").append(Msg.translate(getCtx(), "InterestAmt")).append("=").append(line.getInterestAmt()); + description.append(")"); + line.addDescription(description.toString()); // line.setStmtAmt(Env.ZERO); line.setTrxAmt(Env.ZERO); @@ -489,7 +493,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction setStatementDifference(Env.ZERO); // After Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID)); if (m_processMsg != null) return false; @@ -506,14 +510,14 @@ public class MBankStatement extends X_C_BankStatement implements DocAction { log.info("closeIt - " + toString()); // Before Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE)); if (m_processMsg != null) return false; setDocAction(DOCACTION_None); // After Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE)); if (m_processMsg != null) return false; return true; @@ -527,12 +531,12 @@ public class MBankStatement extends X_C_BankStatement implements DocAction { log.info("reverseCorrectIt - " + toString()); // Before reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT)); if (m_processMsg != null) return false; // After reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT)); if (m_processMsg != null) return false; @@ -547,12 +551,12 @@ public class MBankStatement extends X_C_BankStatement implements DocAction { log.info("reverseAccrualIt - " + toString()); // Before reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL)); if (m_processMsg != null) return false; // After reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL)); if (m_processMsg != null) return false; @@ -567,12 +571,12 @@ public class MBankStatement extends X_C_BankStatement implements DocAction { log.info("reActivateIt - " + toString()); // Before reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE)); if (m_processMsg != null) return false; // After reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE)); if (m_processMsg != null) return false; return false; @@ -585,7 +589,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction */ public String getSummary() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getName()); // : Total Lines = 123.00 (#1) sb.append(": ") @@ -603,7 +607,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction */ public String getProcessMsg() { - return m_processMsg; + return m_processMsg.toString(); } // getProcessMsg /** diff --git a/org.adempiere.base/src/org/compiere/model/MBankStatementLine.java b/org.adempiere.base/src/org/compiere/model/MBankStatementLine.java index a365ba88ce..16ddc6f419 100644 --- a/org.adempiere.base/src/org/compiere/model/MBankStatementLine.java +++ b/org.adempiere.base/src/org/compiere/model/MBankStatementLine.java @@ -148,8 +148,10 @@ import org.compiere.util.Msg; String desc = getDescription(); if (desc == null) setDescription(description); - else - setDescription(desc + " | " + description); + else{ + StringBuilder msgsd = new StringBuilder(desc).append(" | ").append(description); + setDescription(msgsd.toString()); + } } // addDescription @@ -252,19 +254,19 @@ import org.compiere.util.Msg; */ private boolean updateHeader() { - String sql = "UPDATE C_BankStatement bs" - + " SET StatementDifference=(SELECT COALESCE(SUM(StmtAmt),0) FROM C_BankStatementLine bsl " - + "WHERE bsl.C_BankStatement_ID=bs.C_BankStatement_ID AND bsl.IsActive='Y') " - + "WHERE C_BankStatement_ID=" + getC_BankStatement_ID(); - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE C_BankStatement bs") + .append(" SET StatementDifference=(SELECT COALESCE(SUM(StmtAmt),0) FROM C_BankStatementLine bsl ") + .append("WHERE bsl.C_BankStatement_ID=bs.C_BankStatement_ID AND bsl.IsActive='Y') ") + .append("WHERE C_BankStatement_ID=").append(getC_BankStatement_ID()); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 1) { log.warning("StatementDifference #" + no); return false; } - sql = "UPDATE C_BankStatement bs" - + " SET EndingBalance=BeginningBalance+StatementDifference " - + "WHERE C_BankStatement_ID=" + getC_BankStatement_ID(); - no = DB.executeUpdate(sql, get_TrxName()); + sql = new StringBuilder("UPDATE C_BankStatement bs") + .append(" SET EndingBalance=BeginningBalance+StatementDifference ") + .append("WHERE C_BankStatement_ID=").append(getC_BankStatement_ID()); + no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 1) { log.warning("Balance #" + no); return false; diff --git a/org.adempiere.base/src/org/compiere/model/MBankStatementLoader.java b/org.adempiere.base/src/org/compiere/model/MBankStatementLoader.java index a248b0d5d9..ab938339b1 100644 --- a/org.adempiere.base/src/org/compiere/model/MBankStatementLoader.java +++ b/org.adempiere.base/src/org/compiere/model/MBankStatementLoader.java @@ -133,7 +133,7 @@ import org.compiere.impexp.BankStatementLoaderInterface; */ public String toString () { - StringBuffer sb = new StringBuffer ("MBankStatementLoader[") + StringBuilder sb = new StringBuilder ("MBankStatementLoader[") .append(get_ID ()).append("-").append(getName()) .append ("]"); return sb.toString (); diff --git a/org.adempiere.base/src/org/compiere/model/MCStage.java b/org.adempiere.base/src/org/compiere/model/MCStage.java index 4d1b7ccdbc..fce725208e 100644 --- a/org.adempiere.base/src/org/compiere/model/MCStage.java +++ b/org.adempiere.base/src/org/compiere/model/MCStage.java @@ -163,7 +163,7 @@ public class MCStage extends X_CM_CStage */ public String toString () { - StringBuffer sb = new StringBuffer ("MCStage[") + StringBuilder sb = new StringBuilder ("MCStage[") .append (get_ID()).append ("-").append (getName()).append ("]"); return sb.toString (); } // toString @@ -208,10 +208,10 @@ public class MCStage extends X_CM_CStage } if (newRecord) { - StringBuffer sb = new StringBuffer ("INSERT INTO AD_TreeNodeCMS " - + "(AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, " - + "AD_Tree_ID, Node_ID, Parent_ID, SeqNo) " - + "VALUES (") + StringBuilder sb = new StringBuilder ("INSERT INTO AD_TreeNodeCMS ") + .append("(AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, ") + .append("AD_Tree_ID, Node_ID, Parent_ID, SeqNo) ") + .append("VALUES (") .append(getAD_Client_ID()).append(",0, 'Y', SysDate, 0, SysDate, 0,") .append(getAD_Tree_ID()).append(",").append(get_ID()) .append(", 0, 999)"); @@ -237,7 +237,7 @@ public class MCStage extends X_CM_CStage if (!success) return success; // - StringBuffer sb = new StringBuffer ("DELETE FROM AD_TreeNodeCMS ") + StringBuilder sb = new StringBuilder ("DELETE FROM AD_TreeNodeCMS ") .append(" WHERE Node_ID=").append(get_IDOld()) .append(" AND AD_Tree_ID=").append(getAD_Tree_ID()); int no = DB.executeUpdate(sb.toString(), get_TrxName()); @@ -263,7 +263,7 @@ public class MCStage extends X_CM_CStage */ protected boolean checkElements () { X_CM_Template thisTemplate = new X_CM_Template(getCtx(), this.getCM_Template_ID(), get_TrxName()); - StringBuffer thisElementList = new StringBuffer(thisTemplate.getElements()); + StringBuilder thisElementList = new StringBuilder(thisTemplate.getElements()); while (thisElementList.indexOf("\n")>=0) { String thisElement = thisElementList.substring(0,thisElementList.indexOf("\n")); thisElementList.delete(0,thisElementList.indexOf("\n")+1); @@ -279,7 +279,8 @@ public class MCStage extends X_CM_CStage * @param elementName */ protected void checkElement(String elementName) { - int [] tableKeys = X_CM_CStage_Element.getAllIDs("CM_CStage_Element", "CM_CStage_ID=" + this.get_ID() + " AND Name like '" + elementName + "'", get_TrxName()); + StringBuilder msgx = new StringBuilder("CM_CStage_ID=").append(this.get_ID()).append(" AND Name like '").append(elementName).append("'"); + int [] tableKeys = X_CM_CStage_Element.getAllIDs("CM_CStage_Element", msgx.toString(), get_TrxName()); if (tableKeys==null || tableKeys.length==0) { X_CM_CStage_Element thisElement = new X_CM_CStage_Element(getCtx(), 0, get_TrxName()); thisElement.setAD_Client_ID(getAD_Client_ID()); @@ -296,11 +297,13 @@ public class MCStage extends X_CM_CStage * @return true if updated */ protected boolean checkTemplateTable () { - int [] tableKeys = X_CM_TemplateTable.getAllIDs("CM_TemplateTable", "CM_Template_ID=" + this.getCM_Template_ID(), get_TrxName()); + StringBuilder msgx = new StringBuilder("CM_Template_ID=").append(this.getCM_Template_ID()); + int [] tableKeys = X_CM_TemplateTable.getAllIDs("CM_TemplateTable", msgx.toString(), get_TrxName()); if (tableKeys!=null) { for (int i=0;i 0) super.setDescription (Description); - else - super.setDescription (getAD_Table_ID() + "#" + getRecord_ID()); + else{ + StringBuilder msgsd = new StringBuilder(getAD_Table_ID()).append("#").append(getRecord_ID()); + super.setDescription (msgsd.toString()); + } } // setDescription /** diff --git a/org.adempiere.base/src/org/compiere/model/MClick.java b/org.adempiere.base/src/org/compiere/model/MClick.java index 8c43271fb3..b696762bd4 100644 --- a/org.adempiere.base/src/org/compiere/model/MClick.java +++ b/org.adempiere.base/src/org/compiere/model/MClick.java @@ -202,7 +202,8 @@ public class MClick extends X_W_Click try { pstmt = DB.prepareStatement(sql, null); - pstmt.setString(1, "%" + url + "%"); + StringBuilder msgstr = new StringBuilder("%").append(url).append("%"); + pstmt.setString(1, msgstr.toString()); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { @@ -271,6 +272,7 @@ public class MClick extends X_W_Click } } } + System.out.println("#" + counter); } // main diff --git a/org.adempiere.base/src/org/compiere/model/MClickCount.java b/org.adempiere.base/src/org/compiere/model/MClickCount.java index 463b0582e1..4b9dcec07c 100644 --- a/org.adempiere.base/src/org/compiere/model/MClickCount.java +++ b/org.adempiere.base/src/org/compiere/model/MClickCount.java @@ -108,15 +108,15 @@ public class MClickCount extends X_W_ClickCount protected ValueNamePair[] getCount (String DateFormat) { ArrayList list = new ArrayList(); - String sql = "SELECT TRUNC(Created, '" + DateFormat + "'), Count(*) " - + "FROM W_Click " - + "WHERE W_ClickCount_ID=? " - + "GROUP BY TRUNC(Created, '" + DateFormat + "')"; + StringBuilder sql = new StringBuilder("SELECT TRUNC(Created, '").append(DateFormat).append("'), Count(*) ") + .append("FROM W_Click ") + .append("WHERE W_ClickCount_ID=? ") + .append("GROUP BY TRUNC(Created, '").append(DateFormat).append("')"); // PreparedStatement pstmt = null; try { - pstmt = DB.prepareStatement(sql, null); + pstmt = DB.prepareStatement(sql.toString(), null); pstmt.setInt(1, getW_ClickCount_ID()); ResultSet rs = pstmt.executeQuery(); while (rs.next()) @@ -132,7 +132,7 @@ public class MClickCount extends X_W_ClickCount } catch (SQLException ex) { - log.log(Level.SEVERE, sql, ex); + log.log(Level.SEVERE, sql.toString(), ex); } try { diff --git a/org.adempiere.base/src/org/compiere/model/MClient.java b/org.adempiere.base/src/org/compiere/model/MClient.java index 938ac32fb5..6702df7328 100644 --- a/org.adempiere.base/src/org/compiere/model/MClient.java +++ b/org.adempiere.base/src/org/compiere/model/MClient.java @@ -212,7 +212,7 @@ public class MClient extends X_AD_Client */ public String toString() { - StringBuffer sb = new StringBuffer ("MClient[") + StringBuilder sb = new StringBuilder ("MClient[") .append(get_ID()).append("-").append(getValue()) .append("]"); return sb.toString(); @@ -289,13 +289,13 @@ public class MClient extends X_AD_Client public boolean setupClientInfo (String language) { // Create Trees - String sql = null; + StringBuilder sql = null; if (Env.isBaseLanguage (language, "AD_Ref_List")) // Get TreeTypes & Name - sql = "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=120 AND IsActive='Y'"; + sql = new StringBuilder("SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=120 AND IsActive='Y'"); else - sql = "SELECT l.Value, t.Name FROM AD_Ref_List l, AD_Ref_List_Trl t " - + "WHERE l.AD_Reference_ID=120 AND l.AD_Ref_List_ID=t.AD_Ref_List_ID AND l.IsActive='Y'" - + " AND t.AD_Language=" + DB.TO_STRING(language); + sql = new StringBuilder("SELECT l.Value, t.Name FROM AD_Ref_List l, AD_Ref_List_Trl t ") + .append("WHERE l.AD_Reference_ID=120 AND l.AD_Ref_List_ID=t.AD_Ref_List_ID AND l.IsActive='Y'") + .append(" AND t.AD_Language=").append(DB.TO_STRING(language)); // Tree IDs int AD_Tree_Org_ID=0, AD_Tree_BPartner_ID=0, AD_Tree_Project_ID=0, @@ -305,59 +305,59 @@ public class MClient extends X_AD_Client boolean success = false; try { - PreparedStatement stmt = DB.prepareStatement(sql, get_TrxName()); + PreparedStatement stmt = DB.prepareStatement(sql.toString(), get_TrxName()); ResultSet rs = stmt.executeQuery(); MTree_Base tree = null; while (rs.next()) { String value = rs.getString(1); - String name = getName() + " " + rs.getString(2); + StringBuilder name = new StringBuilder(getName()).append(" ").append(rs.getString(2)); // if (value.equals(X_AD_Tree.TREETYPE_Organization)) { - tree = new MTree_Base (this, name, value); + tree = new MTree_Base (this, name.toString(), value); success = tree.save(); AD_Tree_Org_ID = tree.getAD_Tree_ID(); } else if (value.equals(X_AD_Tree.TREETYPE_BPartner)) { - tree = new MTree_Base (this, name, value); + tree = new MTree_Base (this, name.toString(), value); success = tree.save(); AD_Tree_BPartner_ID = tree.getAD_Tree_ID(); } else if (value.equals(X_AD_Tree.TREETYPE_Project)) { - tree = new MTree_Base (this, name, value); + tree = new MTree_Base (this, name.toString(), value); success = tree.save(); AD_Tree_Project_ID = tree.getAD_Tree_ID(); } else if (value.equals(X_AD_Tree.TREETYPE_SalesRegion)) { - tree = new MTree_Base (this, name, value); + tree = new MTree_Base (this, name.toString(), value); success = tree.save(); AD_Tree_SalesRegion_ID = tree.getAD_Tree_ID(); } else if (value.equals(X_AD_Tree.TREETYPE_Product)) { - tree = new MTree_Base (this, name, value); + tree = new MTree_Base (this, name.toString(), value); success = tree.save(); AD_Tree_Product_ID = tree.getAD_Tree_ID(); } else if (value.equals(X_AD_Tree.TREETYPE_ElementValue)) { - tree = new MTree_Base (this, name, value); + tree = new MTree_Base (this, name.toString(), value); success = tree.save(); m_AD_Tree_Account_ID = tree.getAD_Tree_ID(); } else if (value.equals(X_AD_Tree.TREETYPE_Campaign)) { - tree = new MTree_Base (this, name, value); + tree = new MTree_Base (this, name.toString(), value); success = tree.save(); AD_Tree_Campaign_ID = tree.getAD_Tree_ID(); } else if (value.equals(X_AD_Tree.TREETYPE_Activity)) { - tree = new MTree_Base (this, name, value); + tree = new MTree_Base (this, name.toString(), value); success = tree.save(); AD_Tree_Activity_ID = tree.getAD_Tree_ID(); } @@ -365,7 +365,7 @@ public class MClient extends X_AD_Client success = true; else // PC (Product Category), BB (BOM) { - tree = new MTree_Base (this, name, value); + tree = new MTree_Base (this, name.toString(), value); success = tree.save(); } if (!success) @@ -467,14 +467,18 @@ public class MClient extends X_AD_Client */ public String testEMail() { - if (getRequestEMail() == null || getRequestEMail().length() == 0) - return "No Request EMail for " + getName(); + if (getRequestEMail() == null || getRequestEMail().length() == 0){ + StringBuilder msgreturn = new StringBuilder("No Request EMail for ").append(getName()); + return msgreturn.toString(); + } // + StringBuilder msgce = new StringBuilder("Adempiere EMail Test: ").append(toString()); EMail email = createEMail (getRequestEMail(), - "Adempiere EMail Test", - "Adempiere EMail Test: " + toString()); - if (email == null) - return "Could not create EMail: " + getName(); + "Adempiere EMail Test",msgce.toString()); + if (email == null){ + StringBuilder msgreturn = new StringBuilder("Could not create EMail: ").append(getName()); + return msgreturn.toString(); + } try { String msg = null; @@ -920,52 +924,52 @@ public class MClient extends X_AD_Client if (m_fieldAccess == null) { m_fieldAccess = new ArrayList(11000); - String sqlvalidate = - "SELECT AD_Field_ID " - + " FROM AD_Field " - + " WHERE ( AD_Field_ID NOT IN ( " - // ASP subscribed fields for client - + " SELECT f.AD_Field_ID " - + " FROM ASP_Field f, ASP_Tab t, ASP_Window w, ASP_Level l, ASP_ClientLevel cl " - + " WHERE w.ASP_Level_ID = l.ASP_Level_ID " - + " AND cl.AD_Client_ID = " + getAD_Client_ID() - + " AND cl.ASP_Level_ID = l.ASP_Level_ID " - + " AND f.ASP_Tab_ID = t.ASP_Tab_ID " - + " AND t.ASP_Window_ID = w.ASP_Window_ID " - + " AND f.IsActive = 'Y' " - + " AND t.IsActive = 'Y' " - + " AND w.IsActive = 'Y' " - + " AND l.IsActive = 'Y' " - + " AND cl.IsActive = 'Y' " - + " AND f.ASP_Status = 'H' " - +" AND f.AD_Field_ID NOT IN (" - +" SELECT AD_Field_ID" - +" FROM ASP_ClientException ce" - +" WHERE ce.AD_Client_ID ="+getAD_Client_ID() - +" AND ce.IsActive = 'Y'" - +" AND ce.AD_Field_ID IS NOT NULL" - +" AND ce.ASP_Status <> 'H')" - + " UNION ALL " + StringBuilder sqlvalidate = new StringBuilder( + "SELECT AD_Field_ID ") + .append(" FROM AD_Field ") + .append(" WHERE ( AD_Field_ID NOT IN ( ") + // ASP subscribed fields for client) + .append(" SELECT f.AD_Field_ID ") + .append(" FROM ASP_Field f, ASP_Tab t, ASP_Window w, ASP_Level l, ASP_ClientLevel cl ") + .append(" WHERE w.ASP_Level_ID = l.ASP_Level_ID ") + .append(" AND cl.AD_Client_ID = ").append(getAD_Client_ID()) + .append(" AND cl.ASP_Level_ID = l.ASP_Level_ID ") + .append(" AND f.ASP_Tab_ID = t.ASP_Tab_ID ") + .append(" AND t.ASP_Window_ID = w.ASP_Window_ID ") + .append(" AND f.IsActive = 'Y' ") + .append(" AND t.IsActive = 'Y' ") + .append(" AND w.IsActive = 'Y' ") + .append(" AND l.IsActive = 'Y' ") + .append(" AND cl.IsActive = 'Y' ") + .append(" AND f.ASP_Status = 'H' ") + .append(" AND f.AD_Field_ID NOT IN (") + .append(" SELECT AD_Field_ID") + .append(" FROM ASP_ClientException ce") + .append(" WHERE ce.AD_Client_ID =").append(getAD_Client_ID()) + .append(" AND ce.IsActive = 'Y'") + .append(" AND ce.AD_Field_ID IS NOT NULL") + .append(" AND ce.ASP_Status <> 'H')") + .append(" UNION ALL ") // minus ASP hide exceptions for client - + " SELECT AD_Field_ID " - + " FROM ASP_ClientException ce " - + " WHERE ce.AD_Client_ID = " + getAD_Client_ID() - + " AND ce.IsActive = 'Y' " - + " AND ce.AD_Field_ID IS NOT NULL " - + " AND ce.ASP_Status = 'H'))" - + " ORDER BY AD_Field_ID"; + .append(" SELECT AD_Field_ID ") + .append(" FROM ASP_ClientException ce ") + .append(" WHERE ce.AD_Client_ID = ").append(getAD_Client_ID()) + .append(" AND ce.IsActive = 'Y' ") + .append(" AND ce.AD_Field_ID IS NOT NULL ") + .append(" AND ce.ASP_Status = 'H'))") + .append(" ORDER BY AD_Field_ID"); PreparedStatement pstmt = null; ResultSet rs = null; try { - pstmt = DB.prepareStatement(sqlvalidate, get_TrxName()); + pstmt = DB.prepareStatement(sqlvalidate.toString(), get_TrxName()); rs = pstmt.executeQuery(); while (rs.next()) m_fieldAccess.add(rs.getInt(1)); } catch (Exception e) { - log.log(Level.SEVERE, sqlvalidate, e); + log.log(Level.SEVERE, sqlvalidate.toString(), e); } finally { diff --git a/org.adempiere.base/src/org/compiere/model/MClientShare.java b/org.adempiere.base/src/org/compiere/model/MClientShare.java index ab378e2bd2..f0f45898f2 100644 --- a/org.adempiere.base/src/org/compiere/model/MClientShare.java +++ b/org.adempiere.base/src/org/compiere/model/MClientShare.java @@ -88,12 +88,12 @@ public class MClientShare extends X_AD_ClientShare { int Client_ID = rs.getInt(1); int table_ID = rs.getInt(2); - String key = Client_ID + "_" + table_ID; + StringBuilder key = new StringBuilder(Client_ID).append("_").append(table_ID); String ShareType = rs.getString(3); if (ShareType.equals(SHARETYPE_ClientAllShared)) - s_shares.put(key, Boolean.TRUE); + s_shares.put(key.toString(), Boolean.TRUE); else if (ShareType.equals(SHARETYPE_OrgNotShared)) - s_shares.put(key, Boolean.FALSE); + s_shares.put(key.toString(), Boolean.FALSE); } rs.close (); pstmt.close (); @@ -116,7 +116,7 @@ public class MClientShare extends X_AD_ClientShare if (s_shares.isEmpty()) // put in something s_shares.put("0_0", Boolean.TRUE); } // load - String key = AD_Client_ID + "_" + AD_Table_ID; + StringBuilder key = new StringBuilder(AD_Client_ID).append("_").append(AD_Table_ID); return s_shares.get(key); } // load @@ -211,26 +211,26 @@ public class MClientShare extends X_AD_ClientShare */ public String setDataToLevel() { - String info = "-"; + StringBuilder info = new StringBuilder("-"); if (isClientLevelOnly()) { - StringBuffer sql = new StringBuffer("UPDATE ") + StringBuilder sql = new StringBuilder("UPDATE ") .append(getTableName()) .append(" SET AD_Org_ID=0 WHERE AD_Org_ID<>0 AND AD_Client_ID=?"); int no = DB.executeUpdate(sql.toString(), getAD_Client_ID(), get_TrxName()); - info = getTableName() + " set to Shared #" + no; - log.info(info); + info = new StringBuilder(getTableName()).append(" set to Shared #").append(no); + log.info(info.toString()); } else if (isOrgLevelOnly()) { - StringBuffer sql = new StringBuffer("SELECT COUNT(*) FROM ") + StringBuilder sql = new StringBuilder("SELECT COUNT(*) FROM ") .append(getTableName()) .append(" WHERE AD_Org_ID=0 AND AD_Client_ID=?"); int no = DB.getSQLValue(get_TrxName(), sql.toString(), getAD_Client_ID()); - info = getTableName() + " Shared records #" + no; - log.info(info); + info = new StringBuilder(getTableName()).append(" Shared records #").append(no); + log.info(info.toString()); } - return info; + return info.toString(); } // setDataToLevel /** @@ -239,7 +239,7 @@ public class MClientShare extends X_AD_ClientShare */ public String listChildRecords() { - StringBuffer info = new StringBuffer(); + StringBuilder info = new StringBuilder(); String sql = "SELECT AD_Table_ID, TableName " + "FROM AD_Table t " + "WHERE AccessLevel='3' AND IsView='N'" diff --git a/org.adempiere.base/src/org/compiere/model/MColor.java b/org.adempiere.base/src/org/compiere/model/MColor.java index 6c191a7f43..d10da418e2 100644 --- a/org.adempiere.base/src/org/compiere/model/MColor.java +++ b/org.adempiere.base/src/org/compiere/model/MColor.java @@ -54,7 +54,8 @@ public class MColor extends X_AD_Color */ public String toString() { - return "MColor[ID=" + get_ID() + " - " + getName() + "]"; + StringBuilder msgreturn = new StringBuilder("MColor[ID=").append(get_ID()).append(" - ").append(getName()).append("]"); + return msgreturn.toString(); } // toString /** diff --git a/org.adempiere.base/src/org/compiere/model/MColorSchema.java b/org.adempiere.base/src/org/compiere/model/MColorSchema.java index 3672f497c2..12ce4b5301 100644 --- a/org.adempiere.base/src/org/compiere/model/MColorSchema.java +++ b/org.adempiere.base/src/org/compiere/model/MColorSchema.java @@ -204,7 +204,7 @@ public class MColorSchema extends X_PA_ColorSchema */ public String toString () { - StringBuffer sb = new StringBuffer ("MColorSchema["); + StringBuilder sb = new StringBuilder ("MColorSchema["); sb.append (get_ID()).append ("-").append (getName()).append ("]"); return sb.toString (); } // toString diff --git a/org.adempiere.base/src/org/compiere/model/MColumn.java b/org.adempiere.base/src/org/compiere/model/MColumn.java index 17afe81858..60704a241e 100644 --- a/org.adempiere.base/src/org/compiere/model/MColumn.java +++ b/org.adempiere.base/src/org/compiere/model/MColumn.java @@ -304,7 +304,7 @@ public class MColumn extends X_AD_Column || is_ValueChanged(MColumn.COLUMNNAME_Description) || is_ValueChanged(MColumn.COLUMNNAME_Help) ) { - StringBuffer sql = new StringBuffer("UPDATE AD_Field SET Name=") + StringBuilder sql = new StringBuilder("UPDATE AD_Field SET Name=") .append(DB.TO_STRING(getName())) .append(", Description=").append(DB.TO_STRING(getDescription())) .append(", Help=").append(DB.TO_STRING(getHelp())) @@ -324,7 +324,7 @@ public class MColumn extends X_AD_Column */ public String getSQLAdd (MTable table) { - StringBuffer sql = new StringBuffer ("ALTER TABLE ") + StringBuilder sql = new StringBuilder ("ALTER TABLE ") .append(table.getTableName()) .append(" ADD ").append(getSQLDDL()); String constraint = getConstraint(table.getTableName()); @@ -345,7 +345,7 @@ public class MColumn extends X_AD_Column if (isVirtualColumn()) return null; - StringBuffer sql = new StringBuffer (getColumnName()) + StringBuilder sql = new StringBuilder (getColumnName()) .append(" ").append(getSQLDataType()); // Default @@ -393,13 +393,13 @@ public class MColumn extends X_AD_Column */ public String getSQLModify (MTable table, boolean setNullOption) { - StringBuffer sql = new StringBuffer(); - StringBuffer sqlBase = new StringBuffer ("ALTER TABLE ") + StringBuilder sql = new StringBuilder(); + StringBuilder sqlBase = new StringBuilder ("ALTER TABLE ") .append(table.getTableName()) .append(" MODIFY ").append(getColumnName()); // Default - StringBuffer sqlDefault = new StringBuffer(sqlBase) + StringBuilder sqlDefault = new StringBuilder(sqlBase) .append(" ").append(getSQLDataType()); String defaultValue = getDefaultValue(); if (defaultValue != null @@ -433,7 +433,7 @@ public class MColumn extends X_AD_Column // Null Values if (isMandatory() && defaultValue != null && defaultValue.length() > 0) { - StringBuffer sqlSet = new StringBuffer("UPDATE ") + StringBuilder sqlSet = new StringBuilder("UPDATE ") .append(table.getTableName()) .append(" SET ").append(getColumnName()) .append("=").append(defaultValue) @@ -444,7 +444,7 @@ public class MColumn extends X_AD_Column // Null if (setNullOption) { - StringBuffer sqlNull = new StringBuffer(sqlBase); + StringBuilder sqlNull = new StringBuilder(sqlBase); if (isMandatory()) sqlNull.append(" NOT NULL"); else @@ -505,13 +505,14 @@ public class MColumn extends X_AD_Column public String getConstraint(String tableName) { if (isKey()) { - String constraintName; + StringBuilder constraintName; if (tableName.length() > 26) // Oracle restricts object names to 30 characters - constraintName = tableName.substring(0, 26) + "_Key"; + constraintName = new StringBuilder(tableName.substring(0, 26)).append("_Key"); else - constraintName = tableName + "_Key"; - return "CONSTRAINT " + constraintName + " PRIMARY KEY (" + getColumnName() + ")"; + constraintName = new StringBuilder(tableName).append("_Key"); + StringBuilder msgreturn = new StringBuilder("CONSTRAINT ").append(constraintName).append(" PRIMARY KEY (").append(getColumnName()).append(")"); + return msgreturn.toString(); } /** if (getAD_Reference_ID() == DisplayType.TableDir @@ -530,7 +531,7 @@ public class MColumn extends X_AD_Column */ public String toString() { - StringBuffer sb = new StringBuffer ("MColumn["); + StringBuilder sb = new StringBuilder ("MColumn["); sb.append (get_ID()).append ("-").append (getColumnName()).append ("]"); return sb.toString (); } // toString diff --git a/org.adempiere.base/src/org/compiere/model/MColumnAccess.java b/org.adempiere.base/src/org/compiere/model/MColumnAccess.java index d2e429845e..c5ce061657 100644 --- a/org.adempiere.base/src/org/compiere/model/MColumnAccess.java +++ b/org.adempiere.base/src/org/compiere/model/MColumnAccess.java @@ -68,7 +68,7 @@ public class MColumnAccess extends X_AD_Column_Access */ public String toString() { - StringBuffer sb = new StringBuffer("MColumnAccess["); + StringBuilder sb = new StringBuilder("MColumnAccess["); sb.append("AD_Role_ID=").append(getAD_Role_ID()) .append(",AD_Table_ID=").append(getAD_Table_ID()) .append(",AD_Column_ID=").append(getAD_Column_ID()) @@ -86,7 +86,7 @@ public class MColumnAccess extends X_AD_Column_Access { String in = Msg.getMsg(ctx, "Include"); String ex = Msg.getMsg(ctx, "Exclude"); - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(Msg.translate(ctx, "AD_Table_ID")) .append("=").append(getTableName(ctx)).append(", ") .append(Msg.translate(ctx, "AD_Column_ID")) @@ -157,8 +157,9 @@ public class MColumnAccess extends X_AD_Column_Access pstmt = null; } // Get Clear Text - String realName = Msg.translate(ctx, m_tableName + "_ID"); - if (!realName.equals(m_tableName + "_ID")) + StringBuilder msgrn = new StringBuilder(m_tableName).append("_ID"); + String realName = Msg.translate(ctx, msgrn.toString()); + if (!realName.equals(msgrn.toString())) m_tableName = realName; m_columnName = Msg.translate(ctx, m_columnName); } diff --git a/org.adempiere.base/src/org/compiere/model/MContactInterest.java b/org.adempiere.base/src/org/compiere/model/MContactInterest.java index 677cc4101b..78abb650d7 100644 --- a/org.adempiere.base/src/org/compiere/model/MContactInterest.java +++ b/org.adempiere.base/src/org/compiere/model/MContactInterest.java @@ -204,7 +204,7 @@ public class MContactInterest extends X_R_ContactInterest */ public String toString () { - StringBuffer sb = new StringBuffer ("MContactInterest[") + StringBuilder sb = new StringBuilder ("MContactInterest[") .append("R_InterestArea_ID=").append(getR_InterestArea_ID()) .append(",AD_User_ID=").append(getAD_User_ID()) .append(",Subscribed=").append(isSubscribed()) diff --git a/org.adempiere.base/src/org/compiere/model/MContainer.java b/org.adempiere.base/src/org/compiere/model/MContainer.java index ac22bf2d05..6f1b0735aa 100644 --- a/org.adempiere.base/src/org/compiere/model/MContainer.java +++ b/org.adempiere.base/src/org/compiere/model/MContainer.java @@ -274,18 +274,20 @@ public class MContainer extends X_CM_Container .getProperty ("java.naming.provider.url")), log, getCtx (), get_TrxName ()); // First update the new ones... + StringBuilder msgx = new StringBuilder("CM_CStage_ID=").append(stage.get_ID ()); int[] tableKeys = X_CM_CStage_Element.getAllIDs ("CM_CStage_Element", - "CM_CStage_ID=" + stage.get_ID (), trxName); + msgx.toString(), trxName); if (tableKeys != null && tableKeys.length > 0) { for (int i = 0; i < tableKeys.length; i++) { X_CM_CStage_Element thisStageElement = new X_CM_CStage_Element ( - project.getCtx (), tableKeys[i], trxName); + project.getCtx (), tableKeys[i], trxName); + msgx = new StringBuilder("CM_Container_ID=") + .append(stage.get_ID ()).append(" AND Name LIKE '") + .append(thisStageElement.getName ()).append("'"); int[] thisContainerElementKeys = X_CM_Container_Element - .getAllIDs ("CM_Container_Element", "CM_Container_ID=" - + stage.get_ID () + " AND Name LIKE '" - + thisStageElement.getName () + "'", trxName); + .getAllIDs ("CM_Container_Element", msgx.toString(), trxName); X_CM_Container_Element thisContainerElement; if (thisContainerElementKeys != null && thisContainerElementKeys.length > 0) @@ -318,18 +320,20 @@ public class MContainer extends X_CM_Container } } // Now we are checking the existing ones to delete the unneeded ones... + msgx = new StringBuilder("CM_Container_ID=").append(stage.get_ID ()); tableKeys = X_CM_Container_Element.getAllIDs ("CM_Container_Element", - "CM_Container_ID=" + stage.get_ID (), trxName); + msgx.toString(), trxName); if (tableKeys != null && tableKeys.length > 0) { for (int i = 0; i < tableKeys.length; i++) { X_CM_Container_Element thisContainerElement = new X_CM_Container_Element ( - project.getCtx (), tableKeys[i], trxName); + project.getCtx (), tableKeys[i], trxName); + msgx = new StringBuilder("CM_CStage_ID=") + .append(stage.get_ID ()).append(" AND Name LIKE '") + .append(thisContainerElement.getName ()).append("'"); int[] thisCStageElementKeys = X_CM_CStage_Element - .getAllIDs ("CM_CStage_Element", "CM_CStage_ID=" - + stage.get_ID () + " AND Name LIKE '" - + thisContainerElement.getName () + "'", trxName); + .getAllIDs ("CM_CStage_Element", msgx.toString(), trxName); // If we cannot find a representative in the Stage we will delete from production if (thisCStageElementKeys == null || thisCStageElementKeys.length < 1) @@ -356,18 +360,20 @@ public class MContainer extends X_CM_Container protected void updateTTables (MWebProject project, MCStage stage, String trxName) { + StringBuilder msgx = new StringBuilder("CM_CStage_ID=").append(stage.get_ID ()); int[] tableKeys = X_CM_CStageTTable.getAllIDs (I_CM_CStageTTable.Table_Name, - "CM_CStage_ID=" + stage.get_ID (), trxName); + msgx.toString(), trxName); if (tableKeys != null && tableKeys.length > 0) { for (int i = 0; i < tableKeys.length; i++) { X_CM_CStageTTable thisStageTTable = new X_CM_CStageTTable ( - project.getCtx (), tableKeys[i], trxName); + project.getCtx (), tableKeys[i], trxName); + msgx = new StringBuilder("CM_Container_ID=").append(stage.get_ID ()) + .append(" AND CM_TemplateTable_ID=") + .append(thisStageTTable.getCM_TemplateTable_ID ()); int[] thisContainerTTableKeys = X_CM_ContainerTTable.getAllIDs ( - I_CM_ContainerTTable.Table_Name, "CM_Container_ID=" + stage.get_ID () - + " AND CM_TemplateTable_ID=" - + thisStageTTable.getCM_TemplateTable_ID (), trxName); + I_CM_ContainerTTable.Table_Name, msgx.toString(), trxName); X_CM_ContainerTTable thisContainerTTable; if (thisContainerTTableKeys != null && thisContainerTTableKeys.length > 0) @@ -407,7 +413,7 @@ public class MContainer extends X_CM_Container */ public String toString () { - StringBuffer sb = new StringBuffer ("MContainer[").append (get_ID ()) + StringBuilder sb = new StringBuilder ("MContainer[").append (get_ID ()) .append ("-").append (getName ()).append ("]"); return sb.toString (); } // toString @@ -427,10 +433,10 @@ public class MContainer extends X_CM_Container return success; if (newRecord) { - StringBuffer sb = new StringBuffer ( - "INSERT INTO AD_TreeNodeCMC " - + "(AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, " - + "AD_Tree_ID, Node_ID, Parent_ID, SeqNo) " + "VALUES (") + StringBuilder sb = new StringBuilder ( + "INSERT INTO AD_TreeNodeCMC ") + .append("(AD_Client_ID,AD_Org_ID, IsActive,Created,CreatedBy,Updated,UpdatedBy, ") + .append("AD_Tree_ID, Node_ID, Parent_ID, SeqNo) ").append("VALUES (") .append (getAD_Client_ID ()).append ( ",0, 'Y', SysDate, 0, SysDate, 0,").append ( getAD_Tree_ID ()).append (",").append (get_ID ()).append ( @@ -447,7 +453,8 @@ public class MContainer extends X_CM_Container protected MContainerElement[] getAllElements() { - int elements[] = MContainerElement.getAllIDs("CM_Container_Element", "CM_Container_ID=" + get_ID(), get_TrxName()); + StringBuilder msgmc = new StringBuilder("CM_Container_ID=").append(get_ID()); + int elements[] = MContainerElement.getAllIDs("CM_Container_Element", msgmc.toString(), get_TrxName()); if (elements.length>0) { MContainerElement[] containerElements = new MContainerElement[elements.length]; @@ -475,7 +482,7 @@ public class MContainer extends X_CM_Container } } // - StringBuffer sb = new StringBuffer ("DELETE FROM AD_TreeNodeCMC ") + StringBuilder sb = new StringBuilder ("DELETE FROM AD_TreeNodeCMC ") .append (" WHERE Node_ID=").append (get_ID ()).append ( " AND AD_Tree_ID=").append (getAD_Tree_ID ()); int no = DB.executeUpdate (sb.toString (), get_TrxName ()); @@ -497,7 +504,7 @@ public class MContainer extends X_CM_Container if (!success) return success; // - StringBuffer sb = new StringBuffer ("DELETE FROM AD_TreeNodeCMC ") + StringBuilder sb = new StringBuilder ("DELETE FROM AD_TreeNodeCMC ") .append (" WHERE Node_ID=").append (get_IDOld ()).append ( " AND AD_Tree_ID=").append (getAD_Tree_ID ()); int no = DB.executeUpdate (sb.toString (), get_TrxName ()); diff --git a/org.adempiere.base/src/org/compiere/model/MConversionRate.java b/org.adempiere.base/src/org/compiere/model/MConversionRate.java index 225dadb3f2..14e3daf0b2 100644 --- a/org.adempiere.base/src/org/compiere/model/MConversionRate.java +++ b/org.adempiere.base/src/org/compiere/model/MConversionRate.java @@ -372,7 +372,7 @@ public class MConversionRate extends X_C_Conversion_Rate */ public String toString() { - StringBuffer sb = new StringBuffer("MConversionRate["); + StringBuilder sb = new StringBuilder("MConversionRate["); sb.append(get_ID()) .append(",Currency=").append(getC_Currency_ID()) .append(",To=").append(getC_Currency_ID_To()) diff --git a/org.adempiere.base/src/org/compiere/model/MCost.java b/org.adempiere.base/src/org/compiere/model/MCost.java index 831ae108c9..ea84d9e3d7 100644 --- a/org.adempiere.base/src/org/compiere/model/MCost.java +++ b/org.adempiere.base/src/org/compiere/model/MCost.java @@ -463,22 +463,22 @@ public class MCost extends X_M_Cost int M_ASI_ID, int AD_Org_ID, int C_Currency_ID) { BigDecimal retValue = null; - String sql = "SELECT currencyConvert(il.PriceActual, i.C_Currency_ID, ?, i.DateAcct, i.C_ConversionType_ID, il.AD_Client_ID, il.AD_Org_ID) " + StringBuilder sql = new StringBuilder("SELECT currencyConvert(il.PriceActual, i.C_Currency_ID, ?, i.DateAcct, i.C_ConversionType_ID, il.AD_Client_ID, il.AD_Org_ID) ") // ,il.PriceActual, il.QtyInvoiced, i.DateInvoiced, il.Line - + "FROM C_InvoiceLine il " - + " INNER JOIN C_Invoice i ON (il.C_Invoice_ID=i.C_Invoice_ID) " - + "WHERE il.M_Product_ID=?" - + " AND i.IsSOTrx='N'"; + .append("FROM C_InvoiceLine il ") + .append(" INNER JOIN C_Invoice i ON (il.C_Invoice_ID=i.C_Invoice_ID) ") + .append("WHERE il.M_Product_ID=?") + .append(" AND i.IsSOTrx='N'"); if (AD_Org_ID != 0) - sql += " AND il.AD_Org_ID=?"; + sql.append(" AND il.AD_Org_ID=?"); else if (M_ASI_ID != 0) - sql += " AND il.M_AttributeSetInstance_ID=?"; - sql += " ORDER BY i.DateInvoiced DESC, il.Line DESC"; + sql.append(" AND il.M_AttributeSetInstance_ID=?"); + sql.append(" ORDER BY i.DateInvoiced DESC, il.Line DESC"); // PreparedStatement pstmt = null; try { - pstmt = DB.prepareStatement (sql, product.get_TrxName()); + pstmt = DB.prepareStatement (sql.toString(), product.get_TrxName()); pstmt.setInt (1, C_Currency_ID); pstmt.setInt (2, product.getM_Product_ID()); if (AD_Org_ID != 0) @@ -494,7 +494,7 @@ public class MCost extends X_M_Cost } catch (Exception e) { - s_log.log (Level.SEVERE, sql, e); + s_log.log (Level.SEVERE, sql.toString(), e); } try { @@ -527,24 +527,24 @@ public class MCost extends X_M_Cost int M_ASI_ID, int AD_Org_ID, int C_Currency_ID) { BigDecimal retValue = null; - String sql = "SELECT currencyConvert(ol.PriceCost, o.C_Currency_ID, ?, o.DateAcct, o.C_ConversionType_ID, ol.AD_Client_ID, ol.AD_Org_ID)," - + " currencyConvert(ol.PriceActual, o.C_Currency_ID, ?, o.DateAcct, o.C_ConversionType_ID, ol.AD_Client_ID, ol.AD_Org_ID) " + StringBuilder sql = new StringBuilder("SELECT currencyConvert(ol.PriceCost, o.C_Currency_ID, ?, o.DateAcct, o.C_ConversionType_ID, ol.AD_Client_ID, ol.AD_Org_ID),") + .append(" currencyConvert(ol.PriceActual, o.C_Currency_ID, ?, o.DateAcct, o.C_ConversionType_ID, ol.AD_Client_ID, ol.AD_Org_ID) ") // ,ol.PriceCost,ol.PriceActual, ol.QtyOrdered, o.DateOrdered, ol.Line - + "FROM C_OrderLine ol" - + " INNER JOIN C_Order o ON (ol.C_Order_ID=o.C_Order_ID) " - + "WHERE ol.M_Product_ID=?" - + " AND o.IsSOTrx='N'"; + .append("FROM C_OrderLine ol") + .append(" INNER JOIN C_Order o ON (ol.C_Order_ID=o.C_Order_ID) ") + .append("WHERE ol.M_Product_ID=?") + .append(" AND o.IsSOTrx='N'"); if (AD_Org_ID != 0) - sql += " AND ol.AD_Org_ID=?"; + sql.append(" AND ol.AD_Org_ID=?"); else if (M_ASI_ID != 0) - sql += " AND ol.M_AttributeSetInstance_ID=?"; - sql += " ORDER BY o.DateOrdered DESC, ol.Line DESC"; + sql.append(" AND ol.M_AttributeSetInstance_ID=?"); + sql.append(" ORDER BY o.DateOrdered DESC, ol.Line DESC"); // PreparedStatement pstmt = null; ResultSet rs = null; try { - pstmt = DB.prepareStatement (sql, product.get_TrxName()); + pstmt = DB.prepareStatement (sql.toString(), product.get_TrxName()); pstmt.setInt (1, C_Currency_ID); pstmt.setInt (2, C_Currency_ID); pstmt.setInt (3, product.getM_Product_ID()); @@ -562,7 +562,7 @@ public class MCost extends X_M_Cost } catch (SQLException e) { - throw new DBException(e, sql); + throw new DBException(e, sql.toString()); } finally { @@ -838,18 +838,18 @@ public class MCost extends X_M_Cost public static BigDecimal calculateAverageInv (MProduct product, int M_AttributeSetInstance_ID, MAcctSchema as, int AD_Org_ID) { - String sql = "SELECT t.MovementQty, mi.Qty, il.QtyInvoiced, il.PriceActual," - + " i.C_Currency_ID, i.DateAcct, i.C_ConversionType_ID, i.AD_Client_ID, i.AD_Org_ID, t.M_Transaction_ID " - + "FROM M_Transaction t" - + " INNER JOIN M_MatchInv mi ON (t.M_InOutLine_ID=mi.M_InOutLine_ID)" - + " INNER JOIN C_InvoiceLine il ON (mi.C_InvoiceLine_ID=il.C_InvoiceLine_ID)" - + " INNER JOIN C_Invoice i ON (il.C_Invoice_ID=i.C_Invoice_ID) " - + "WHERE t.M_Product_ID=?"; + StringBuilder sql = new StringBuilder("SELECT t.MovementQty, mi.Qty, il.QtyInvoiced, il.PriceActual,") + .append(" i.C_Currency_ID, i.DateAcct, i.C_ConversionType_ID, i.AD_Client_ID, i.AD_Org_ID, t.M_Transaction_ID ") + .append("FROM M_Transaction t") + .append(" INNER JOIN M_MatchInv mi ON (t.M_InOutLine_ID=mi.M_InOutLine_ID)") + .append(" INNER JOIN C_InvoiceLine il ON (mi.C_InvoiceLine_ID=il.C_InvoiceLine_ID)") + .append(" INNER JOIN C_Invoice i ON (il.C_Invoice_ID=i.C_Invoice_ID) ") + .append("WHERE t.M_Product_ID=?"); if (AD_Org_ID != 0) - sql += " AND t.AD_Org_ID=?"; + sql.append(" AND t.AD_Org_ID=?"); else if (M_AttributeSetInstance_ID != 0) - sql += " AND t.M_AttributeSetInstance_ID=?"; - sql += " ORDER BY t.M_Transaction_ID"; + sql.append(" AND t.M_AttributeSetInstance_ID=?"); + sql.append(" ORDER BY t.M_Transaction_ID"); PreparedStatement pstmt = null; ResultSet rs = null; @@ -859,7 +859,7 @@ public class MCost extends X_M_Cost int oldTransaction_ID = 0; try { - pstmt = DB.prepareStatement (sql, null); + pstmt = DB.prepareStatement (sql.toString(), null); pstmt.setInt (1, product.getM_Product_ID()); if (AD_Org_ID != 0) pstmt.setInt (2, AD_Org_ID); @@ -904,7 +904,7 @@ public class MCost extends X_M_Cost } catch (SQLException e) { - throw new DBException(e, sql); + throw new DBException(e, sql.toString()); } finally { @@ -931,19 +931,19 @@ public class MCost extends X_M_Cost public static BigDecimal calculateAveragePO (MProduct product, int M_AttributeSetInstance_ID, MAcctSchema as, int AD_Org_ID) { - String sql = "SELECT t.MovementQty, mp.Qty, ol.QtyOrdered, ol.PriceCost, ol.PriceActual," // 1..5 - + " o.C_Currency_ID, o.DateAcct, o.C_ConversionType_ID," // 6..8 - + " o.AD_Client_ID, o.AD_Org_ID, t.M_Transaction_ID " // 9..11 - + "FROM M_Transaction t" - + " INNER JOIN M_MatchPO mp ON (t.M_InOutLine_ID=mp.M_InOutLine_ID)" - + " INNER JOIN C_OrderLine ol ON (mp.C_OrderLine_ID=ol.C_OrderLine_ID)" - + " INNER JOIN C_Order o ON (ol.C_Order_ID=o.C_Order_ID) " - + "WHERE t.M_Product_ID=?"; + StringBuilder sql = new StringBuilder("SELECT t.MovementQty, mp.Qty, ol.QtyOrdered, ol.PriceCost, ol.PriceActual,") // 1..5 + .append(" o.C_Currency_ID, o.DateAcct, o.C_ConversionType_ID,") // 6..8 + .append(" o.AD_Client_ID, o.AD_Org_ID, t.M_Transaction_ID ") // 9..11 + .append("FROM M_Transaction t") + .append(" INNER JOIN M_MatchPO mp ON (t.M_InOutLine_ID=mp.M_InOutLine_ID)") + .append(" INNER JOIN C_OrderLine ol ON (mp.C_OrderLine_ID=ol.C_OrderLine_ID)") + .append(" INNER JOIN C_Order o ON (ol.C_Order_ID=o.C_Order_ID) ") + .append("WHERE t.M_Product_ID=?"); if (AD_Org_ID != 0) - sql += " AND t.AD_Org_ID=?"; + sql.append(" AND t.AD_Org_ID=?"); else if (M_AttributeSetInstance_ID != 0) - sql += " AND t.M_AttributeSetInstance_ID=?"; - sql += " ORDER BY t.M_Transaction_ID"; + sql.append(" AND t.M_AttributeSetInstance_ID=?"); + sql.append(" ORDER BY t.M_Transaction_ID"); PreparedStatement pstmt = null; ResultSet rs = null; @@ -953,7 +953,7 @@ public class MCost extends X_M_Cost int oldTransaction_ID = 0; try { - pstmt = DB.prepareStatement (sql, null); + pstmt = DB.prepareStatement (sql.toString(), null); pstmt.setInt (1, product.getM_Product_ID()); if (AD_Org_ID != 0) pstmt.setInt (2, AD_Org_ID); @@ -1000,7 +1000,7 @@ public class MCost extends X_M_Cost } catch (SQLException e) { - throw new DBException(e, sql); + throw new DBException(e, sql.toString()); } finally { @@ -1027,18 +1027,18 @@ public class MCost extends X_M_Cost public static BigDecimal calculateFiFo (MProduct product, int M_AttributeSetInstance_ID, MAcctSchema as, int AD_Org_ID) { - String sql = "SELECT t.MovementQty, mi.Qty, il.QtyInvoiced, il.PriceActual," - + " i.C_Currency_ID, i.DateAcct, i.C_ConversionType_ID, i.AD_Client_ID, i.AD_Org_ID, t.M_Transaction_ID " - + "FROM M_Transaction t" - + " INNER JOIN M_MatchInv mi ON (t.M_InOutLine_ID=mi.M_InOutLine_ID)" - + " INNER JOIN C_InvoiceLine il ON (mi.C_InvoiceLine_ID=il.C_InvoiceLine_ID)" - + " INNER JOIN C_Invoice i ON (il.C_Invoice_ID=i.C_Invoice_ID) " - + "WHERE t.M_Product_ID=?"; + StringBuilder sql = new StringBuilder("SELECT t.MovementQty, mi.Qty, il.QtyInvoiced, il.PriceActual,") + .append(" i.C_Currency_ID, i.DateAcct, i.C_ConversionType_ID, i.AD_Client_ID, i.AD_Org_ID, t.M_Transaction_ID ") + .append("FROM M_Transaction t") + .append(" INNER JOIN M_MatchInv mi ON (t.M_InOutLine_ID=mi.M_InOutLine_ID)") + .append(" INNER JOIN C_InvoiceLine il ON (mi.C_InvoiceLine_ID=il.C_InvoiceLine_ID)") + .append(" INNER JOIN C_Invoice i ON (il.C_Invoice_ID=i.C_Invoice_ID) ") + .append("WHERE t.M_Product_ID=?"); if (AD_Org_ID != 0) - sql += " AND t.AD_Org_ID=?"; + sql.append(" AND t.AD_Org_ID=?"); else if (M_AttributeSetInstance_ID != 0) - sql += " AND t.M_AttributeSetInstance_ID=?"; - sql += " ORDER BY t.M_Transaction_ID"; + sql.append(" AND t.M_AttributeSetInstance_ID=?"); + sql.append(" ORDER BY t.M_Transaction_ID"); PreparedStatement pstmt = null; ResultSet rs = null; @@ -1047,7 +1047,7 @@ public class MCost extends X_M_Cost ArrayList fifo = new ArrayList(); try { - pstmt = DB.prepareStatement (sql, null); + pstmt = DB.prepareStatement (sql.toString(), null); pstmt.setInt (1, product.getM_Product_ID()); if (AD_Org_ID != 0) pstmt.setInt (2, AD_Org_ID); @@ -1136,7 +1136,7 @@ public class MCost extends X_M_Cost } catch (SQLException e) { - throw new DBException(e, sql); + throw new DBException(e, sql.toString()); } finally { @@ -1164,19 +1164,19 @@ public class MCost extends X_M_Cost public static BigDecimal calculateLiFo (MProduct product, int M_AttributeSetInstance_ID, MAcctSchema as, int AD_Org_ID) { - String sql = "SELECT t.MovementQty, mi.Qty, il.QtyInvoiced, il.PriceActual," - + " i.C_Currency_ID, i.DateAcct, i.C_ConversionType_ID, i.AD_Client_ID, i.AD_Org_ID, t.M_Transaction_ID " - + "FROM M_Transaction t" - + " INNER JOIN M_MatchInv mi ON (t.M_InOutLine_ID=mi.M_InOutLine_ID)" - + " INNER JOIN C_InvoiceLine il ON (mi.C_InvoiceLine_ID=il.C_InvoiceLine_ID)" - + " INNER JOIN C_Invoice i ON (il.C_Invoice_ID=i.C_Invoice_ID) " - + "WHERE t.M_Product_ID=?"; + StringBuilder sql = new StringBuilder("SELECT t.MovementQty, mi.Qty, il.QtyInvoiced, il.PriceActual,") + .append(" i.C_Currency_ID, i.DateAcct, i.C_ConversionType_ID, i.AD_Client_ID, i.AD_Org_ID, t.M_Transaction_ID ") + .append("FROM M_Transaction t") + .append(" INNER JOIN M_MatchInv mi ON (t.M_InOutLine_ID=mi.M_InOutLine_ID)") + .append(" INNER JOIN C_InvoiceLine il ON (mi.C_InvoiceLine_ID=il.C_InvoiceLine_ID)") + .append(" INNER JOIN C_Invoice i ON (il.C_Invoice_ID=i.C_Invoice_ID) ") + .append("WHERE t.M_Product_ID=?"); if (AD_Org_ID != 0) - sql += " AND t.AD_Org_ID=?"; + sql.append(" AND t.AD_Org_ID=?"); else if (M_AttributeSetInstance_ID != 0) - sql += " AND t.M_AttributeSetInstance_ID=?"; + sql.append(" AND t.M_AttributeSetInstance_ID=?"); // Starting point? - sql += " ORDER BY t.M_Transaction_ID DESC"; + sql.append(" ORDER BY t.M_Transaction_ID DESC"); PreparedStatement pstmt = null; ResultSet rs = null; @@ -1185,7 +1185,7 @@ public class MCost extends X_M_Cost ArrayList lifo = new ArrayList(); try { - pstmt = DB.prepareStatement (sql, null); + pstmt = DB.prepareStatement (sql.toString(), null); pstmt.setInt (1, product.getM_Product_ID()); if (AD_Org_ID != 0) pstmt.setInt (2, AD_Org_ID); @@ -1255,7 +1255,7 @@ public class MCost extends X_M_Cost } catch (SQLException e) { - throw new DBException(e, sql); + throw new DBException(e, sql.toString()); } finally { @@ -1299,7 +1299,7 @@ public class MCost extends X_M_Cost */ public String toString () { - StringBuffer sb = new StringBuffer ("Qty=").append(Qty) + StringBuilder sb = new StringBuilder ("Qty=").append(Qty) .append (",Cost=").append (Cost); return sb.toString (); } // toString @@ -1562,7 +1562,7 @@ public class MCost extends X_M_Cost */ public String toString () { - StringBuffer sb = new StringBuffer ("MCost["); + StringBuilder sb = new StringBuilder ("MCost["); sb.append ("AD_Client_ID=").append (getAD_Client_ID()); if (getAD_Org_ID() != 0) sb.append (",AD_Org_ID=").append (getAD_Org_ID()); diff --git a/org.adempiere.base/src/org/compiere/model/MCostDetail.java b/org.adempiere.base/src/org/compiere/model/MCostDetail.java index 85cfef48d7..6141fc9a9c 100644 --- a/org.adempiere.base/src/org/compiere/model/MCostDetail.java +++ b/org.adempiere.base/src/org/compiere/model/MCostDetail.java @@ -73,12 +73,12 @@ public class MCostDetail extends X_M_CostDetail String Description, String trxName) { // Delete Unprocessed zero Differences - String sql = "DELETE M_CostDetail " - + "WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0" - + " AND C_OrderLine_ID=" + C_OrderLine_ID - + " AND C_AcctSchema_ID =" + as.getC_AcctSchema_ID() - + " AND M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID; - int no = DB.executeUpdate(sql, trxName); + StringBuilder sql = new StringBuilder("DELETE M_CostDetail ") + .append("WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0") + .append(" AND C_OrderLine_ID=").append(C_OrderLine_ID) + .append(" AND C_AcctSchema_ID =").append(as.getC_AcctSchema_ID()) + .append(" AND M_AttributeSetInstance_ID=").append(M_AttributeSetInstance_ID); + int no = DB.executeUpdate(sql.toString(), trxName); if (no != 0) s_log.config("Deleted #" + no); MCostDetail cd = get (as.getCtx(), "C_OrderLine_ID=?", @@ -140,12 +140,12 @@ public class MCostDetail extends X_M_CostDetail String Description, String trxName) { // Delete Unprocessed zero Differences - String sql = "DELETE M_CostDetail " - + "WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0" - + " AND C_InvoiceLine_ID=" + C_InvoiceLine_ID - + " AND C_AcctSchema_ID =" + as.getC_AcctSchema_ID() - + " AND M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID; - int no = DB.executeUpdate(sql, trxName); + StringBuilder sql = new StringBuilder("DELETE M_CostDetail ") + .append("WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0") + .append(" AND C_InvoiceLine_ID=").append(C_InvoiceLine_ID) + .append(" AND C_AcctSchema_ID =").append(as.getC_AcctSchema_ID()) + .append(" AND M_AttributeSetInstance_ID=").append(M_AttributeSetInstance_ID); + int no = DB.executeUpdate(sql.toString(), trxName); if (no != 0) s_log.config("Deleted #" + no); MCostDetail cd = get (as.getCtx(), "C_InvoiceLine_ID=?", @@ -207,12 +207,12 @@ public class MCostDetail extends X_M_CostDetail String Description, boolean IsSOTrx, String trxName) { // Delete Unprocessed zero Differences - String sql = "DELETE M_CostDetail " - + "WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0" - + " AND M_InOutLine_ID=" + M_InOutLine_ID - + " AND C_AcctSchema_ID =" + as.getC_AcctSchema_ID() - + " AND M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID; - int no = DB.executeUpdate(sql, trxName); + StringBuilder sql = new StringBuilder("DELETE M_CostDetail ") + .append("WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0") + .append(" AND M_InOutLine_ID=").append(M_InOutLine_ID) + .append(" AND C_AcctSchema_ID =").append(as.getC_AcctSchema_ID()) + .append(" AND M_AttributeSetInstance_ID=").append(M_AttributeSetInstance_ID); + int no = DB.executeUpdate(sql.toString(), trxName); if (no != 0) s_log.config("Deleted #" + no); MCostDetail cd = get (as.getCtx(), "M_InOutLine_ID=?", @@ -274,12 +274,12 @@ public class MCostDetail extends X_M_CostDetail String Description, String trxName) { // Delete Unprocessed zero Differences - String sql = "DELETE M_CostDetail " - + "WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0" - + " AND M_InventoryLine_ID=" + M_InventoryLine_ID - + " AND C_AcctSchema_ID =" + as.getC_AcctSchema_ID() - + " AND M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID; - int no = DB.executeUpdate(sql, trxName); + StringBuilder sql = new StringBuilder("DELETE M_CostDetail ") + .append("WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0") + .append(" AND M_InventoryLine_ID=").append(M_InventoryLine_ID) + .append(" AND C_AcctSchema_ID =").append(as.getC_AcctSchema_ID()) + .append(" AND M_AttributeSetInstance_ID=").append(M_AttributeSetInstance_ID); + int no = DB.executeUpdate(sql.toString(), trxName); if (no != 0) s_log.config("Deleted #" + no); MCostDetail cd = get (as.getCtx(), "M_InventoryLine_ID=?", @@ -341,17 +341,18 @@ public class MCostDetail extends X_M_CostDetail String Description, String trxName) { // Delete Unprocessed zero Differences - String sql = "DELETE M_CostDetail " - + "WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0" - + " AND M_MovementLine_ID=" + M_MovementLine_ID - + " AND IsSOTrx=" + (from ? "'Y'" : "'N'") - + " AND C_AcctSchema_ID =" + as.getC_AcctSchema_ID() - + " AND M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID; - int no = DB.executeUpdate(sql, trxName); + StringBuilder sql = new StringBuilder("DELETE M_CostDetail ") + .append("WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0") + .append(" AND M_MovementLine_ID=").append(M_MovementLine_ID) + .append(" AND IsSOTrx=").append((from ? "'Y'" : "'N'")) + .append(" AND C_AcctSchema_ID =").append(as.getC_AcctSchema_ID()) + .append(" AND M_AttributeSetInstance_ID=").append(M_AttributeSetInstance_ID); + int no = DB.executeUpdate(sql.toString(), trxName); if (no != 0) s_log.config("Deleted #" + no); - MCostDetail cd = get (as.getCtx(), "M_MovementLine_ID=? AND IsSOTrx=" - + (from ? "'Y'" : "'N'"), + StringBuilder msget = new StringBuilder( "M_MovementLine_ID=? AND IsSOTrx=") + .append((from ? "'Y'" : "'N'")); + MCostDetail cd = get (as.getCtx(),msget.toString(), M_MovementLine_ID, M_AttributeSetInstance_ID, as.getC_AcctSchema_ID(), trxName); // if (cd == null) // createNew @@ -410,12 +411,12 @@ public class MCostDetail extends X_M_CostDetail String Description, String trxName) { // Delete Unprocessed zero Differences - String sql = "DELETE M_CostDetail " - + "WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0" - + " AND M_ProductionLine_ID=" + M_ProductionLine_ID - + " AND C_AcctSchema_ID =" + as.getC_AcctSchema_ID() - + " AND M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID; - int no = DB.executeUpdate(sql, trxName); + StringBuilder sql = new StringBuilder("DELETE M_CostDetail ") + .append("WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0") + .append(" AND M_ProductionLine_ID=").append(M_ProductionLine_ID) + .append(" AND C_AcctSchema_ID =").append(as.getC_AcctSchema_ID()) + .append(" AND M_AttributeSetInstance_ID=").append(M_AttributeSetInstance_ID); + int no = DB.executeUpdate(sql.toString(), trxName); if (no != 0) s_log.config("Deleted #" + no); MCostDetail cd = get (as.getCtx(), "M_ProductionLine_ID=?", @@ -467,21 +468,21 @@ public class MCostDetail extends X_M_CostDetail public static MCostDetail get (Properties ctx, String whereClause, int ID, int M_AttributeSetInstance_ID, String trxName) { - String sql = "SELECT * FROM M_CostDetail WHERE " + whereClause; + StringBuilder sql = new StringBuilder("SELECT * FROM M_CostDetail WHERE ").append(whereClause); MClientInfo clientInfo = MClientInfo.get(ctx); MAcctSchema primary = clientInfo.getMAcctSchema1(); int C_AcctSchema_ID = primary != null ? primary.getC_AcctSchema_ID() : 0; if (C_AcctSchema_ID > 0) { - sql = sql + " AND C_AcctSchema_ID=?"; + sql.append(" AND C_AcctSchema_ID=?"); } MCostDetail retValue = null; PreparedStatement pstmt = null; ResultSet rs = null; try { - pstmt = DB.prepareStatement (sql, null); + pstmt = DB.prepareStatement (sql.toString(), null); pstmt.setInt (1, ID); pstmt.setInt (2, M_AttributeSetInstance_ID); if (C_AcctSchema_ID > 0) @@ -515,10 +516,10 @@ public class MCostDetail extends X_M_CostDetail public static MCostDetail get (Properties ctx, String whereClause, int ID, int M_AttributeSetInstance_ID, int C_AcctSchema_ID, String trxName) { - final String localWhereClause = whereClause - + " AND M_AttributeSetInstance_ID=?" - + " AND C_AcctSchema_ID=?"; - MCostDetail retValue = new Query(ctx,I_M_CostDetail.Table_Name,localWhereClause,trxName) + StringBuilder localWhereClause = new StringBuilder(whereClause) + .append(" AND M_AttributeSetInstance_ID=?") + .append(" AND C_AcctSchema_ID=?"); + MCostDetail retValue = new Query(ctx,I_M_CostDetail.Table_Name,localWhereClause.toString(),trxName) .setParameters(ID,M_AttributeSetInstance_ID,C_AcctSchema_ID) .first(); return retValue; @@ -714,7 +715,7 @@ public class MCostDetail extends X_M_CostDetail */ public String toString () { - StringBuffer sb = new StringBuffer ("MCostDetail["); + StringBuilder sb = new StringBuilder ("MCostDetail["); sb.append (get_ID()); if (getC_OrderLine_ID() != 0) sb.append (",C_OrderLine_ID=").append (getC_OrderLine_ID()); @@ -1001,17 +1002,17 @@ public class MCostDetail extends X_M_CostDetail * Solution: * Make sure the current qty is reflecting the actual qty in storage */ - String sql = "SELECT COALESCE(SUM(QtyOnHand),0) FROM M_Storage" - + " WHERE AD_Client_ID=" + cost.getAD_Client_ID() - + " AND M_Product_ID=" + cost.getM_Product_ID(); + StringBuilder sql = new StringBuilder("SELECT COALESCE(SUM(QtyOnHand),0) FROM M_Storage") + .append(" WHERE AD_Client_ID=").append(cost.getAD_Client_ID()) + .append(" AND M_Product_ID=").append(cost.getM_Product_ID()); //Costing Level String CostingLevel = product.getCostingLevel(as); if (MAcctSchema.COSTINGLEVEL_Organization.equals(CostingLevel)) - sql += " AND AD_Org_ID=" + cost.getAD_Org_ID(); + sql.append(" AND AD_Org_ID=").append(cost.getAD_Org_ID()); else if (MAcctSchema.COSTINGLEVEL_BatchLot.equals(CostingLevel)) - sql += " AND M_AttributeSetInstance_ID=" + M_ASI_ID; + sql.append(" AND M_AttributeSetInstance_ID=").append(M_ASI_ID); // - BigDecimal qtyOnhand = DB.getSQLValueBD(get_TrxName(), sql); + BigDecimal qtyOnhand = DB.getSQLValueBD(get_TrxName(), sql.toString()); if (qtyOnhand.signum() != 0) { BigDecimal oldSum = cost.getCurrentCostPrice().multiply(cost.getCurrentQty()); @@ -1158,17 +1159,17 @@ public class MCostDetail extends X_M_CostDetail MCostElement[] lce = MCostElement.getNonCostingMethods(this); if (lce.length > 0) { - String sql = "SELECT COALESCE(SUM(QtyOnHand),0) FROM M_Storage" - + " WHERE AD_Client_ID=" + cost.getAD_Client_ID() - + " AND M_Product_ID=" + cost.getM_Product_ID(); + StringBuilder sql = new StringBuilder("SELECT COALESCE(SUM(QtyOnHand),0) FROM M_Storage") + .append(" WHERE AD_Client_ID=").append(cost.getAD_Client_ID()) + .append(" AND M_Product_ID=").append(cost.getM_Product_ID()); //Costing Level String CostingLevel = product.getCostingLevel(as); if (MAcctSchema.COSTINGLEVEL_Organization.equals(CostingLevel)) - sql += " AND AD_Org_ID=" + cost.getAD_Org_ID(); + sql.append(" AND AD_Org_ID=").append(cost.getAD_Org_ID()); else if (MAcctSchema.COSTINGLEVEL_BatchLot.equals(CostingLevel)) - sql += " AND M_AttributeSetInstance_ID=" + M_ASI_ID; + sql.append(" AND M_AttributeSetInstance_ID=").append(M_ASI_ID); // - BigDecimal qtyOnhand = DB.getSQLValueBD(get_TrxName(), sql); + BigDecimal qtyOnhand = DB.getSQLValueBD(get_TrxName(), sql.toString()); for (int i = 0 ; i < lce.length ; i++) { MCost lCost = MCost.get(getCtx(), cost.getAD_Client_ID(), cost.getAD_Org_ID(), diff --git a/org.adempiere.base/src/org/compiere/model/MCostElement.java b/org.adempiere.base/src/org/compiere/model/MCostElement.java index a2b4769707..29b4158fb2 100644 --- a/org.adempiere.base/src/org/compiere/model/MCostElement.java +++ b/org.adempiere.base/src/org/compiere/model/MCostElement.java @@ -441,7 +441,7 @@ public class MCostElement extends X_M_CostElement */ public String toString () { - StringBuffer sb = new StringBuffer ("MCostElement["); + StringBuilder sb = new StringBuilder ("MCostElement["); sb.append (get_ID ()) .append ("-").append (getName()) .append(",Type=").append(getCostElementType()) diff --git a/org.adempiere.base/src/org/compiere/model/MCostQueue.java b/org.adempiere.base/src/org/compiere/model/MCostQueue.java index 4157861c1e..b0e72ef9cf 100644 --- a/org.adempiere.base/src/org/compiere/model/MCostQueue.java +++ b/org.adempiere.base/src/org/compiere/model/MCostQueue.java @@ -115,21 +115,21 @@ public class MCostQueue extends X_M_CostQueue MAcctSchema as, int Org_ID, MCostElement ce, String trxName) { ArrayList list = new ArrayList(); - String sql = "SELECT * FROM M_CostQueue " - + "WHERE AD_Client_ID=? AND AD_Org_ID=?" - + " AND M_Product_ID=?" - + " AND M_CostType_ID=? AND C_AcctSchema_ID=?" - + " AND M_CostElement_ID=?"; + StringBuilder sql = new StringBuilder("SELECT * FROM M_CostQueue ") + .append("WHERE AD_Client_ID=? AND AD_Org_ID=?") + .append(" AND M_Product_ID=?") + .append(" AND M_CostType_ID=? AND C_AcctSchema_ID=?") + .append(" AND M_CostElement_ID=?"); if (M_ASI_ID != 0) - sql += " AND M_AttributeSetInstance_ID=?"; - sql += " AND CurrentQty<>0 " - + "ORDER BY M_AttributeSetInstance_ID "; + sql.append(" AND M_AttributeSetInstance_ID=?"); + sql.append(" AND CurrentQty<>0 ") + .append("ORDER BY M_AttributeSetInstance_ID "); if (!ce.isFifo()) - sql += "DESC"; + sql.append("DESC"); PreparedStatement pstmt = null; try { - pstmt = DB.prepareStatement (sql, trxName); + pstmt = DB.prepareStatement (sql.toString(), trxName); pstmt.setInt (1, product.getAD_Client_ID()); pstmt.setInt (2, Org_ID); pstmt.setInt (3, product.getM_Product_ID()); @@ -147,7 +147,7 @@ public class MCostQueue extends X_M_CostQueue } catch (Exception e) { - s_log.log (Level.SEVERE, sql, e); + s_log.log (Level.SEVERE, sql.toString(), e); } try { diff --git a/org.adempiere.base/src/org/compiere/model/MCostType.java b/org.adempiere.base/src/org/compiere/model/MCostType.java index 3d055b9c45..57efe558b7 100644 --- a/org.adempiere.base/src/org/compiere/model/MCostType.java +++ b/org.adempiere.base/src/org/compiere/model/MCostType.java @@ -61,7 +61,7 @@ public class MCostType extends X_M_CostType */ public String toString () { - StringBuffer sb = new StringBuffer ("MCostType["); + StringBuilder sb = new StringBuilder ("MCostType["); sb.append (get_ID()).append ("-").append (getName ()).append ("]"); return sb.toString (); } // toString diff --git a/org.adempiere.base/src/org/compiere/model/MCurrency.java b/org.adempiere.base/src/org/compiere/model/MCurrency.java index d4021884d0..c15e923241 100644 --- a/org.adempiere.base/src/org/compiere/model/MCurrency.java +++ b/org.adempiere.base/src/org/compiere/model/MCurrency.java @@ -146,15 +146,15 @@ public class MCurrency extends X_C_Currency */ public static String getISO_Code (Properties ctx, int C_Currency_ID) { - String contextKey = "C_Currency_" + C_Currency_ID; - String retValue = ctx.getProperty(contextKey); + StringBuilder contextKey = new StringBuilder("C_Currency_").append(C_Currency_ID); + String retValue = ctx.getProperty(contextKey.toString()); if (retValue != null) return retValue; // Create it MCurrency c = get(ctx, C_Currency_ID); retValue = c.getISO_Code(); - ctx.setProperty(contextKey, retValue); + ctx.setProperty(contextKey.toString(), retValue); return retValue; } // getISO @@ -176,10 +176,11 @@ public class MCurrency extends X_C_Currency */ public String toString() { - return "MCurrency[" + getC_Currency_ID() - + "-" + getISO_Code() + "-" + getCurSymbol() - + "," + getDescription() - + ",Precision=" + getStdPrecision() + "/" + getCostingPrecision(); + StringBuilder msgreturn = new StringBuilder("MCurrency[").append(getC_Currency_ID()) + .append("-").append(getISO_Code()).append("-").append(getCurSymbol()) + .append(",").append(getDescription()) + .append(",Precision=").append(getStdPrecision()).append("/").append(getCostingPrecision()); + return msgreturn.toString(); } // toString diff --git a/org.adempiere.base/src/org/compiere/model/MDashboardContent.java b/org.adempiere.base/src/org/compiere/model/MDashboardContent.java index d015ec0350..bd4bbd61c1 100644 --- a/org.adempiere.base/src/org/compiere/model/MDashboardContent.java +++ b/org.adempiere.base/src/org/compiere/model/MDashboardContent.java @@ -37,24 +37,24 @@ public class MDashboardContent extends X_PA_DashboardContent { Properties ctx = Env.getCtx(); - String whereClause = COLUMNNAME_IsShowInDashboard+"=?"; + StringBuilder whereClause = new StringBuilder(COLUMNNAME_IsShowInDashboard).append("=?"); if (AD_Role_ID == 0) - whereClause += " AND ("+COLUMNNAME_AD_Role_ID+" IS NULL OR "+COLUMNNAME_AD_Role_ID+"=?)"; + whereClause.append(" AND (").append(COLUMNNAME_AD_Role_ID).append(" IS NULL OR ").append(COLUMNNAME_AD_Role_ID).append("=?)"); else - whereClause += " AND "+COLUMNNAME_AD_Role_ID+"=?"; + whereClause.append(" AND ").append(COLUMNNAME_AD_Role_ID).append("=?"); if (AD_User_ID == 0) - whereClause += " AND ("+COLUMNNAME_AD_User_ID+" IS NULL OR "+COLUMNNAME_AD_User_ID+"=?)"; + whereClause.append(" AND (").append(COLUMNNAME_AD_User_ID).append(" IS NULL OR ").append(COLUMNNAME_AD_User_ID).append("=?)"); else - whereClause += " AND "+COLUMNNAME_AD_User_ID+"=?"; + whereClause.append(" AND ").append(COLUMNNAME_AD_User_ID).append("=?"); List parameters = new ArrayList(); parameters.add(isShowInDashboard); parameters.add(AD_Role_ID); parameters.add(AD_User_ID); - return new Query(ctx, Table_Name, whereClause, null) + return new Query(ctx, Table_Name, whereClause.toString(), null) .setParameters(parameters) .setOnlyActiveRecords(true) .setApplyAccessFilter(true, false) @@ -71,23 +71,23 @@ public class MDashboardContent extends X_PA_DashboardContent { Properties ctx = Env.getCtx(); - String whereClause = ""; + StringBuilder whereClause = new StringBuilder(); if (AD_Role_ID == 0) - whereClause += "("+COLUMNNAME_AD_Role_ID+" IS NULL OR "+COLUMNNAME_AD_Role_ID+"=?)"; + whereClause.append("(").append(COLUMNNAME_AD_Role_ID).append(" IS NULL OR ").append(COLUMNNAME_AD_Role_ID).append("=?)"); else - whereClause += COLUMNNAME_AD_Role_ID+"=?"; + whereClause.append(COLUMNNAME_AD_Role_ID).append("=?"); if (AD_User_ID == 0) - whereClause += " AND ("+COLUMNNAME_AD_User_ID+" IS NULL OR "+COLUMNNAME_AD_User_ID+"=?)"; + whereClause.append(" AND (").append(COLUMNNAME_AD_User_ID).append(" IS NULL OR ").append(COLUMNNAME_AD_User_ID).append("=?)"); else - whereClause += " AND "+COLUMNNAME_AD_User_ID+"=?"; + whereClause.append(" AND ").append(COLUMNNAME_AD_User_ID).append("=?"); List parameters = new ArrayList(); parameters.add(AD_Role_ID); parameters.add(AD_User_ID); - return new Query(ctx, Table_Name, whereClause, null) + return new Query(ctx, Table_Name, whereClause.toString(), null) .setParameters(parameters) .setOnlyActiveRecords(true) .setApplyAccessFilter(true, false) diff --git a/org.adempiere.base/src/org/compiere/model/MDashboardPreference.java b/org.adempiere.base/src/org/compiere/model/MDashboardPreference.java index b30ec34909..43bf3725b6 100644 --- a/org.adempiere.base/src/org/compiere/model/MDashboardPreference.java +++ b/org.adempiere.base/src/org/compiere/model/MDashboardPreference.java @@ -49,24 +49,24 @@ public class MDashboardPreference extends X_PA_DashboardPreference { Properties ctx = Env.getCtx(); - String whereClause = COLUMNNAME_IsShowInDashboard+"=?"; + StringBuilder whereClause = new StringBuilder(COLUMNNAME_IsShowInDashboard).append("=?"); if (AD_Role_ID == 0) - whereClause += " AND ("+COLUMNNAME_AD_Role_ID+" IS NULL OR "+COLUMNNAME_AD_Role_ID+"=?)"; + whereClause.append(" AND (").append(COLUMNNAME_AD_Role_ID).append(" IS NULL OR ").append(COLUMNNAME_AD_Role_ID).append("=?)"); else - whereClause += " AND "+COLUMNNAME_AD_Role_ID+"=?"; + whereClause.append(" AND ").append(COLUMNNAME_AD_Role_ID).append("=?"); if (AD_User_ID == 0) - whereClause += " AND ("+COLUMNNAME_AD_User_ID+" IS NULL OR "+COLUMNNAME_AD_User_ID+"=?)"; + whereClause.append(" AND (").append(COLUMNNAME_AD_User_ID).append(" IS NULL OR ").append(COLUMNNAME_AD_User_ID).append("=?)"); else - whereClause += " AND "+COLUMNNAME_AD_User_ID+"=?"; + whereClause.append(" AND ").append(COLUMNNAME_AD_User_ID).append("=?"); List parameters = new ArrayList(); parameters.add(isShowInDashboard); parameters.add(AD_Role_ID); parameters.add(AD_User_ID); - return new Query(ctx, Table_Name, whereClause, null) + return new Query(ctx, Table_Name, whereClause.toString(), null) .setParameters(parameters) .setOnlyActiveRecords(true) .setApplyAccessFilter(true, false) @@ -83,23 +83,23 @@ public class MDashboardPreference extends X_PA_DashboardPreference { Properties ctx = Env.getCtx(); - String whereClause = ""; + StringBuilder whereClause = new StringBuilder(); if (AD_Role_ID == 0) - whereClause += "("+COLUMNNAME_AD_Role_ID+" IS NULL OR "+COLUMNNAME_AD_Role_ID+"=?)"; + whereClause.append("(").append(COLUMNNAME_AD_Role_ID).append(" IS NULL OR ").append(COLUMNNAME_AD_Role_ID).append("=?)"); else - whereClause += COLUMNNAME_AD_Role_ID+"=?"; + whereClause.append(COLUMNNAME_AD_Role_ID).append("=?"); if (AD_User_ID == 0) - whereClause += " AND ("+COLUMNNAME_AD_User_ID+" IS NULL OR "+COLUMNNAME_AD_User_ID+"=?)"; + whereClause.append(" AND (").append(COLUMNNAME_AD_User_ID).append(" IS NULL OR ").append(COLUMNNAME_AD_User_ID).append("=?)"); else - whereClause += " AND "+COLUMNNAME_AD_User_ID+"=?"; + whereClause.append(" AND ").append(COLUMNNAME_AD_User_ID).append("=?"); List parameters = new ArrayList(); parameters.add(AD_Role_ID); parameters.add(AD_User_ID); - return new Query(ctx, Table_Name, whereClause, null) + return new Query(ctx, Table_Name, whereClause.toString(), null) .setParameters(parameters) .setOnlyActiveRecords(true) .setApplyAccessFilter(true, false) diff --git a/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java b/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java index 8fd509f314..774e032ecc 100644 --- a/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java +++ b/org.adempiere.base/src/org/compiere/model/MDepreciationWorkfile.java @@ -63,9 +63,9 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile int p_wkasset_ID = 0; //p_A_Asset_ID = getA_Asset_ID(); p_wkasset_ID = getA_Depreciation_Workfile_ID(); - StringBuffer sqlB = new StringBuffer ("UPDATE A_Depreciation_Workfile " - + "SET Processing = 'Y'" - + " WHERE A_Depreciation_Workfile_ID = " + p_wkasset_ID ); + StringBuilder sqlB = new StringBuilder ("UPDATE A_Depreciation_Workfile ") + .append("SET Processing = 'Y'") + .append(" WHERE A_Depreciation_Workfile_ID = " ).append(p_wkasset_ID ); int no = DB.executeUpdate (sqlB.toString(),null); if (no == -1) diff --git a/org.adempiere.base/src/org/compiere/model/MDesktop.java b/org.adempiere.base/src/org/compiere/model/MDesktop.java index 9482f2e44c..6af38950ad 100644 --- a/org.adempiere.base/src/org/compiere/model/MDesktop.java +++ b/org.adempiere.base/src/org/compiere/model/MDesktop.java @@ -72,22 +72,22 @@ public class MDesktop { AD_Desktop_ID = ad_Desktop_ID; // Get WB info - String sql = null; + StringBuilder sql = null; if (Env.isBaseLanguage(m_ctx, "AD_Desktop")) - sql = "SELECT Name,Description,Help," // 1..3 - + " AD_Column_ID,AD_Image_ID,AD_Color_ID,PA_Goal_ID " // 4..7 - + "FROM AD_Desktop " - + "WHERE AD_Desktop_ID=? AND IsActive='Y'"; + sql = new StringBuilder("SELECT Name,Description,Help,") // 1..3 + .append(" AD_Column_ID,AD_Image_ID,AD_Color_ID,PA_Goal_ID ") // 4..7 + .append("FROM AD_Desktop ") + .append("WHERE AD_Desktop_ID=? AND IsActive='Y'"); else - sql = "SELECT t.Name,t.Description,t.Help," - + " w.AD_Column_ID,w.AD_Image_ID,w.AD_Color_ID,w.PA_Goal_ID " - + "FROM AD_Desktop w, AD_Desktop_Trl t " - + "WHERE w.AD_Desktop_ID=? AND w.IsActive='Y'" - + " AND w.AD_Desktop_ID=t.AD_Desktop_ID" - + " AND t.AD_Language='" + Env.getAD_Language(m_ctx) + "'"; + sql = new StringBuilder("SELECT t.Name,t.Description,t.Help,") + .append(" w.AD_Column_ID,w.AD_Image_ID,w.AD_Color_ID,w.PA_Goal_ID ") + .append("FROM AD_Desktop w, AD_Desktop_Trl t ") + .append("WHERE w.AD_Desktop_ID=? AND w.IsActive='Y'") + .append(" AND w.AD_Desktop_ID=t.AD_Desktop_ID") + .append(" AND t.AD_Language='").append(Env.getAD_Language(m_ctx)).append("'"); try { - PreparedStatement pstmt = DB.prepareStatement(sql, null); + PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); pstmt.setInt(1, AD_Desktop_ID); ResultSet rs = pstmt.executeQuery(); if (rs.next()) @@ -112,7 +112,7 @@ public class MDesktop } catch (SQLException e) { - log.log(Level.SEVERE, sql, e); + log.log(Level.SEVERE, sql.toString(), e); } if (AD_Desktop_ID == 0) @@ -126,7 +126,8 @@ public class MDesktop */ public String toString() { - return "MDesktop ID=" + AD_Desktop_ID + " " + Name; + StringBuilder msgreturn = new StringBuilder("MDesktop ID=").append(AD_Desktop_ID).append(" ").append(Name); + return msgreturn.toString(); } /************************************************************************** diff --git a/org.adempiere.base/src/org/compiere/model/MDiscountSchemaBreak.java b/org.adempiere.base/src/org/compiere/model/MDiscountSchemaBreak.java index f96e666b2b..de31f034be 100644 --- a/org.adempiere.base/src/org/compiere/model/MDiscountSchemaBreak.java +++ b/org.adempiere.base/src/org/compiere/model/MDiscountSchemaBreak.java @@ -109,7 +109,7 @@ public class MDiscountSchemaBreak extends X_M_DiscountSchemaBreak */ public String toString () { - StringBuffer sb = new StringBuffer ("MDiscountSchemaBreak["); + StringBuilder sb = new StringBuilder ("MDiscountSchemaBreak["); sb.append(get_ID()).append("-Seq=").append(getSeqNo()); if (getM_Product_Category_ID() != 0) sb.append(",M_Product_Category_ID=").append(getM_Product_Category_ID()); diff --git a/org.adempiere.base/src/org/compiere/model/MDistribution.java b/org.adempiere.base/src/org/compiere/model/MDistribution.java index bdd49e0b08..a63fd5c622 100644 --- a/org.adempiere.base/src/org/compiere/model/MDistribution.java +++ b/org.adempiere.base/src/org/compiere/model/MDistribution.java @@ -270,12 +270,12 @@ public class MDistribution extends X_GL_Distribution */ public String validate() { - String retValue = null; + StringBuilder retValue = null; getLines(true); if (m_lines.length == 0) - retValue = "@NoLines@"; + retValue = new StringBuilder("@NoLines@"); else if (getPercentTotal().compareTo(Env.ONEHUNDRED) != 0) - retValue = "@PercentTotal@ <> 100"; + retValue = new StringBuilder("@PercentTotal@ <> 100"); else { // More then one line with 0 @@ -286,8 +286,8 @@ public class MDistribution extends X_GL_Distribution { if (lineFound >= 0 && m_lines[i].getPercent().compareTo(Env.ZERO) == 0) { - retValue = "@Line@ " + lineFound - + " + " + m_lines[i].getLine() + ": == 0"; + retValue = new StringBuilder("@Line@ ").append(lineFound) + .append(" + ").append(m_lines[i].getLine()).append(": == 0"); break; } lineFound = m_lines[i].getLine(); @@ -296,7 +296,7 @@ public class MDistribution extends X_GL_Distribution } setIsValid (retValue == null); - return retValue; + return retValue.toString(); } // validate diff --git a/org.adempiere.base/src/org/compiere/model/MDistributionRunDetail.java b/org.adempiere.base/src/org/compiere/model/MDistributionRunDetail.java index 7c5e684681..d730ddcb8a 100644 --- a/org.adempiere.base/src/org/compiere/model/MDistributionRunDetail.java +++ b/org.adempiere.base/src/org/compiere/model/MDistributionRunDetail.java @@ -52,15 +52,15 @@ public class MDistributionRunDetail extends X_T_DistributionRunDetail boolean orderBP, String trxName) { ArrayList list = new ArrayList(); - String sql = "SELECT * FROM T_DistributionRunDetail WHERE M_DistributionRun_ID=? "; + StringBuilder sql = new StringBuilder("SELECT * FROM T_DistributionRunDetail WHERE M_DistributionRun_ID=? "); if (orderBP) - sql += "ORDER BY C_BPartner_ID, C_BPartner_Location_ID"; + sql.append("ORDER BY C_BPartner_ID, C_BPartner_Location_ID"); else - sql += "ORDER BY M_DistributionRunLine_ID"; + sql.append("ORDER BY M_DistributionRunLine_ID"); PreparedStatement pstmt = null; try { - pstmt = DB.prepareStatement (sql, trxName); + pstmt = DB.prepareStatement (sql.toString(), trxName); pstmt.setInt (1, M_DistributionRun_ID); ResultSet rs = pstmt.executeQuery (); while (rs.next ()) @@ -71,7 +71,7 @@ public class MDistributionRunDetail extends X_T_DistributionRunDetail } catch (Exception e) { - s_log.log(Level.SEVERE, sql, e); + s_log.log(Level.SEVERE, sql.toString(), e); } try { @@ -191,7 +191,7 @@ public class MDistributionRunDetail extends X_T_DistributionRunDetail */ public String toString () { - StringBuffer sb = new StringBuffer ("MDistributionRunDetail[") + StringBuilder sb = new StringBuilder ("MDistributionRunDetail[") .append (get_ID ()) .append (";M_DistributionListLine_ID=").append (getM_DistributionListLine_ID()) .append(";Qty=").append(getQty()) diff --git a/org.adempiere.base/src/org/compiere/model/MDistributionRunLine.java b/org.adempiere.base/src/org/compiere/model/MDistributionRunLine.java index 48f0fb94e0..e5baa1c3da 100644 --- a/org.adempiere.base/src/org/compiere/model/MDistributionRunLine.java +++ b/org.adempiere.base/src/org/compiere/model/MDistributionRunLine.java @@ -235,7 +235,7 @@ public class MDistributionRunLine extends X_M_DistributionRunLine */ public String toString () { - StringBuffer sb = new StringBuffer ("MDistributionRunLine[") + StringBuilder sb = new StringBuilder ("MDistributionRunLine[") .append(get_ID()).append("-") .append(getInfo()) .append ("]"); @@ -248,7 +248,7 @@ public class MDistributionRunLine extends X_M_DistributionRunLine */ public String getInfo() { - StringBuffer sb = new StringBuffer (); + StringBuilder sb = new StringBuilder (); sb.append("Line=").append(getLine()) .append (",TotalQty=").append(getTotalQty()) .append(",SumMin=").append(getActualMin()) diff --git a/org.adempiere.base/src/org/compiere/model/MDocType.java b/org.adempiere.base/src/org/compiere/model/MDocType.java index b6ce65abbb..ff2185b82d 100644 --- a/org.adempiere.base/src/org/compiere/model/MDocType.java +++ b/org.adempiere.base/src/org/compiere/model/MDocType.java @@ -192,7 +192,7 @@ public class MDocType extends X_C_DocType */ public String toString() { - StringBuffer sb = new StringBuffer("MDocType["); + StringBuilder sb = new StringBuilder("MDocType["); sb.append(get_ID()).append("-").append(getName()) .append(",DocNoSequence_ID=").append(getDocNoSequence_ID()) .append("]"); @@ -266,23 +266,23 @@ public class MDocType extends X_C_DocType if (newRecord && success) { // Add doctype/docaction access to all roles of client - String sqlDocAction = "INSERT INTO AD_Document_Action_Access " - + "(AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy," - + "C_DocType_ID , AD_Ref_List_ID, AD_Role_ID) " - + "(SELECT " - + getAD_Client_ID() + ",0,'Y', SysDate," - + getUpdatedBy() + ", SysDate," + getUpdatedBy() - + ", doctype.C_DocType_ID, action.AD_Ref_List_ID, rol.AD_Role_ID " - + "FROM AD_Client client " - + "INNER JOIN C_DocType doctype ON (doctype.AD_Client_ID=client.AD_Client_ID) " - + "INNER JOIN AD_Ref_List action ON (action.AD_Reference_ID=135) " - + "INNER JOIN AD_Role rol ON (rol.AD_Client_ID=client.AD_Client_ID) " - + "WHERE client.AD_Client_ID=" + getAD_Client_ID() - + " AND doctype.C_DocType_ID=" + get_ID() - + " AND rol.IsManual='N'" - + ")"; + StringBuilder sqlDocAction = new StringBuilder("INSERT INTO AD_Document_Action_Access ") + .append("(AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,") + .append("C_DocType_ID , AD_Ref_List_ID, AD_Role_ID) ") + .append("(SELECT ") + .append(getAD_Client_ID()).append(",0,'Y', SysDate,") + .append(getUpdatedBy()).append(", SysDate,").append(getUpdatedBy()) + .append(", doctype.C_DocType_ID, action.AD_Ref_List_ID, rol.AD_Role_ID ") + .append("FROM AD_Client client ") + .append("INNER JOIN C_DocType doctype ON (doctype.AD_Client_ID=client.AD_Client_ID) ") + .append("INNER JOIN AD_Ref_List action ON (action.AD_Reference_ID=135) ") + .append("INNER JOIN AD_Role rol ON (rol.AD_Client_ID=client.AD_Client_ID) ") + .append("WHERE client.AD_Client_ID=").append(getAD_Client_ID()) + .append(" AND doctype.C_DocType_ID=").append(get_ID()) + .append(" AND rol.IsManual='N'") + .append(")"); - int docact = DB.executeUpdate(sqlDocAction, get_TrxName()); + int docact = DB.executeUpdate(sqlDocAction.toString(), get_TrxName()); log.fine("AD_Document_Action_Access=" + docact); } return success; @@ -296,7 +296,8 @@ public class MDocType extends X_C_DocType protected boolean beforeDelete () { // delete access records - int docactDel = DB.executeUpdate("DELETE FROM AD_Document_Action_Access WHERE C_DocType_ID=" + get_ID(), get_TrxName()); + StringBuilder msgdb = new StringBuilder("DELETE FROM AD_Document_Action_Access WHERE C_DocType_ID=").append(get_ID()); + int docactDel = DB.executeUpdate(msgdb.toString(), get_TrxName()); log.fine("Delete AD_Document_Action_Access=" + docactDel + " for C_DocType_ID: " + get_ID()); return docactDel >= 0; } // beforeDelete @@ -334,7 +335,7 @@ public class MDocType extends X_C_DocType if (relatedDocTypeName != null) { - StringBuffer whereClause = new StringBuffer(30); + StringBuilder whereClause = new StringBuilder(30); whereClause.append("Name='").append(relatedDocTypeName).append("' "); whereClause.append("and AD_Client_ID=").append(Env.getAD_Client_ID(Env.getCtx())); whereClause.append(" AND IsActive='Y'"); diff --git a/org.adempiere.base/src/org/compiere/model/MDocTypeCounter.java b/org.adempiere.base/src/org/compiere/model/MDocTypeCounter.java index 0a283bcf0e..623760cdc2 100644 --- a/org.adempiere.base/src/org/compiere/model/MDocTypeCounter.java +++ b/org.adempiere.base/src/org/compiere/model/MDocTypeCounter.java @@ -354,7 +354,7 @@ public class MDocTypeCounter extends X_C_DocTypeCounter */ public String toString () { - StringBuffer sb = new StringBuffer ("MDocTypeCounter["); + StringBuilder sb = new StringBuilder ("MDocTypeCounter["); sb.append(get_ID()).append(",").append(getName()) .append(",C_DocType_ID=").append(getC_DocType_ID()) .append(",Counter=").append(getCounter_C_DocType_ID()) diff --git a/org.adempiere.base/src/org/compiere/model/MDunning.java b/org.adempiere.base/src/org/compiere/model/MDunning.java index 41c580fcb0..848550765b 100644 --- a/org.adempiere.base/src/org/compiere/model/MDunning.java +++ b/org.adempiere.base/src/org/compiere/model/MDunning.java @@ -63,7 +63,7 @@ public class MDunning extends X_C_Dunning @Override public String toString() { - StringBuffer sb = new StringBuffer("MDunning[").append(get_ID()) + StringBuilder sb = new StringBuilder("MDunning[").append(get_ID()) .append("-").append(getName()); sb.append("]"); return sb.toString(); diff --git a/org.adempiere.base/src/org/compiere/model/MDunningRunEntry.java b/org.adempiere.base/src/org/compiere/model/MDunningRunEntry.java index 8346b873e9..b531d61321 100644 --- a/org.adempiere.base/src/org/compiere/model/MDunningRunEntry.java +++ b/org.adempiere.base/src/org/compiere/model/MDunningRunEntry.java @@ -145,13 +145,13 @@ public class MDunningRunEntry extends X_C_DunningRunEntry } else if (firstActive != null) { - String msg = "@C_BPartner_ID@ " + bp.getName(); + StringBuilder msg = new StringBuilder("@C_BPartner_ID@ ").append(bp.getName()); if (isSOTrx) - msg += " @No@ @IsPayFrom@"; + msg.append(" @No@ @IsPayFrom@"); else - msg += " @No@ @IsRemitTo@"; - msg += " & @IsBillTo@"; - log.info(msg); + msg.append(" @No@ @IsRemitTo@"); + msg.append(" & @IsBillTo@"); + log.info(msg.toString()); setC_BPartner_Location_ID (firstActive.getC_BPartner_Location_ID()); } } @@ -199,13 +199,13 @@ public class MDunningRunEntry extends X_C_DunningRunEntry public MDunningRunLine[] getLines (boolean onlyInvoices) { ArrayList list = new ArrayList(); - String sql = "SELECT * FROM C_DunningRunLine WHERE C_DunningRunEntry_ID=?"; + StringBuilder sql = new StringBuilder("SELECT * FROM C_DunningRunLine WHERE C_DunningRunEntry_ID=?"); if (onlyInvoices) - sql += " AND C_Invoice_ID IS NOT NULL"; + sql.append(" AND C_Invoice_ID IS NOT NULL"); PreparedStatement pstmt = null; try { - pstmt = DB.prepareStatement(sql, get_TrxName()); + pstmt = DB.prepareStatement(sql.toString(), get_TrxName()); pstmt.setInt(1, get_ID ()); ResultSet rs = pstmt.executeQuery(); while (rs.next()) @@ -216,7 +216,7 @@ public class MDunningRunEntry extends X_C_DunningRunEntry } catch (Exception e) { - s_log.log(Level.SEVERE, sql, e); + s_log.log(Level.SEVERE, sql.toString(), e); } try { diff --git a/org.adempiere.base/src/org/compiere/model/MDunningRunLine.java b/org.adempiere.base/src/org/compiere/model/MDunningRunLine.java index d274e9c838..756fbfbf1a 100644 --- a/org.adempiere.base/src/org/compiere/model/MDunningRunLine.java +++ b/org.adempiere.base/src/org/compiere/model/MDunningRunLine.java @@ -340,17 +340,17 @@ public class MDunningRunLine extends X_C_DunningRunLine private void updateEntry() { // we do not count the fee line as an item, but it sum it up. - String sql = "UPDATE C_DunningRunEntry e " - + "SET Amt=NVL((SELECT SUM(ConvertedAmt)+SUM(FeeAmt)+SUM(InterestAmt)" - + " FROM C_DunningRunLine l " - + "WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID), 0), " - + "QTY=(SELECT COUNT(*)" - + " FROM C_DunningRunLine l " - + "WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID " - + " AND (NOT C_Invoice_ID IS NULL OR NOT C_Payment_ID IS NULL))" - + " WHERE C_DunningRunEntry_ID=" + getC_DunningRunEntry_ID(); + StringBuilder sql = new StringBuilder("UPDATE C_DunningRunEntry e ") + .append("SET Amt=NVL((SELECT SUM(ConvertedAmt)+SUM(FeeAmt)+SUM(InterestAmt)") + .append(" FROM C_DunningRunLine l ") + .append("WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID), 0), ") + .append("QTY=(SELECT COUNT(*)") + .append(" FROM C_DunningRunLine l ") + .append("WHERE e.C_DunningRunEntry_ID=l.C_DunningRunEntry_ID ") + .append(" AND (NOT C_Invoice_ID IS NULL OR NOT C_Payment_ID IS NULL))") + .append(" WHERE C_DunningRunEntry_ID=").append(getC_DunningRunEntry_ID()); - DB.executeUpdate(sql, get_TrxName()); + DB.executeUpdate(sql.toString(), get_TrxName()); } // updateEntry } // MDunningRunLine diff --git a/org.adempiere.base/src/org/compiere/model/MEXPFormat.java b/org.adempiere.base/src/org/compiere/model/MEXPFormat.java index aa0e3b2d1d..9c19dbc9d7 100644 --- a/org.adempiere.base/src/org/compiere/model/MEXPFormat.java +++ b/org.adempiere.base/src/org/compiere/model/MEXPFormat.java @@ -131,7 +131,7 @@ public class MEXPFormat extends X_EXP_Format { if(retValue!=null) return retValue; - StringBuffer whereClause = new StringBuffer(X_EXP_Format.COLUMNNAME_Value).append("=?") + StringBuilder whereClause = new StringBuilder(X_EXP_Format.COLUMNNAME_Value).append("=?") .append(" AND AD_Client_ID = ?") .append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?"); @@ -157,7 +157,7 @@ public class MEXPFormat extends X_EXP_Format { if(retValue!=null) return retValue; - StringBuffer whereClause = new StringBuffer(" AD_Client_ID = ? ") + StringBuilder whereClause = new StringBuilder(" AD_Client_ID = ? ") .append(" AND ").append(X_EXP_Format.COLUMNNAME_AD_Table_ID).append(" = ? ") .append(" AND ").append(X_EXP_Format.COLUMNNAME_Version).append(" = ?"); @@ -176,7 +176,7 @@ public class MEXPFormat extends X_EXP_Format { @Override public String toString() { - StringBuffer sb = new StringBuffer ("X_EXP_Format[ID=").append(get_ID()).append("; Value = "+getValue()+"]"); + StringBuilder sb = new StringBuilder ("X_EXP_Format[ID=").append(get_ID()).append("; Value = ").append(getValue()).append("]"); return sb.toString(); } diff --git a/org.adempiere.base/src/org/compiere/model/MEXPFormatLine.java b/org.adempiere.base/src/org/compiere/model/MEXPFormatLine.java index 6b1115675e..2ceb8632ce 100644 --- a/org.adempiere.base/src/org/compiere/model/MEXPFormatLine.java +++ b/org.adempiere.base/src/org/compiere/model/MEXPFormatLine.java @@ -61,7 +61,7 @@ public class MEXPFormatLine extends X_EXP_FormatLine { @Override public String toString() { - StringBuffer sb = new StringBuffer ("X_EXP_FormatLine[ID=").append(get_ID()).append("; Value="+getValue()+"; Type="+getType()+"]"); + StringBuilder sb = new StringBuilder ("X_EXP_FormatLine[ID=").append(get_ID()).append("; Value=").append(getValue()).append("; Type=").append(getType()).append("]"); return sb.toString(); } @@ -70,7 +70,7 @@ public class MEXPFormatLine extends X_EXP_FormatLine { { MEXPFormatLine result = null; - StringBuffer sql = new StringBuffer("SELECT * ") + StringBuilder sql = new StringBuilder("SELECT * ") .append(" FROM ").append(X_EXP_FormatLine.Table_Name) .append(" WHERE ").append(X_EXP_Format.COLUMNNAME_Value).append("=?") //.append(" AND IsActive = ?") diff --git a/org.adempiere.base/src/org/compiere/model/MEXPProcessor.java b/org.adempiere.base/src/org/compiere/model/MEXPProcessor.java index f1aea22235..b2d69b69c2 100644 --- a/org.adempiere.base/src/org/compiere/model/MEXPProcessor.java +++ b/org.adempiere.base/src/org/compiere/model/MEXPProcessor.java @@ -78,7 +78,7 @@ public class MEXPProcessor extends X_EXP_Processor { List resultList = new ArrayList(); - StringBuffer sql = new StringBuffer("SELECT * ") + StringBuilder sql = new StringBuilder("SELECT * ") .append(" FROM ").append(X_EXP_ProcessorParameter.Table_Name) .append(" WHERE ").append(X_EXP_ProcessorParameter.COLUMNNAME_EXP_Processor_ID).append("=?") // # 1 .append(" AND IsActive = ?") // # 2 diff --git a/org.adempiere.base/src/org/compiere/model/MElementValue.java b/org.adempiere.base/src/org/compiere/model/MElementValue.java index 767f86bb3f..1ad8f7b486 100644 --- a/org.adempiere.base/src/org/compiere/model/MElementValue.java +++ b/org.adempiere.base/src/org/compiere/model/MElementValue.java @@ -183,7 +183,7 @@ public class MElementValue extends X_C_ElementValue */ public String toString () { - StringBuffer sb = new StringBuffer (); + StringBuilder sb = new StringBuilder(); sb.append(getValue()).append(" - ").append(getName()); return sb.toString (); } // toString @@ -194,7 +194,7 @@ public class MElementValue extends X_C_ElementValue */ public String toStringX () { - StringBuffer sb = new StringBuffer ("MElementValue["); + StringBuilder sb = new StringBuilder ("MElementValue["); sb.append(get_ID()).append(",").append(getValue()).append(" - ").append(getName()) .append ("]"); return sb.toString (); diff --git a/org.adempiere.base/src/org/compiere/model/MExpenseType.java b/org.adempiere.base/src/org/compiere/model/MExpenseType.java index 5d915e03d3..f774dd1be6 100644 --- a/org.adempiere.base/src/org/compiere/model/MExpenseType.java +++ b/org.adempiere.base/src/org/compiere/model/MExpenseType.java @@ -67,7 +67,8 @@ public class MExpenseType extends X_S_ExpenseType { if (m_product == null) { - MProduct[] products = MProduct.get(getCtx(), "S_ExpenseType_ID=" + getS_ExpenseType_ID(), get_TrxName()); + StringBuilder msgmp = new StringBuilder("S_ExpenseType_ID=").append(getS_ExpenseType_ID()); + MProduct[] products = MProduct.get(getCtx(), msgmp.toString(), get_TrxName()); if (products.length > 0) m_product = products[0]; } diff --git a/org.adempiere.base/src/org/compiere/model/MFactAcct.java b/org.adempiere.base/src/org/compiere/model/MFactAcct.java index 91629d3ba3..9fa427a221 100644 --- a/org.adempiere.base/src/org/compiere/model/MFactAcct.java +++ b/org.adempiere.base/src/org/compiere/model/MFactAcct.java @@ -110,7 +110,7 @@ public class MFactAcct extends X_Fact_Acct */ public String toString () { - StringBuffer sb = new StringBuffer ("MFactAcct["); + StringBuilder sb = new StringBuilder ("MFactAcct["); sb.append(get_ID()).append("-Acct=").append(getAccount_ID()) .append(",Dr=").append(getAmtSourceDr()).append("|").append(getAmtAcctDr()) .append(",Cr=").append(getAmtSourceCr()).append("|").append(getAmtAcctCr()) diff --git a/org.adempiere.base/src/org/compiere/model/MGLCategory.java b/org.adempiere.base/src/org/compiere/model/MGLCategory.java index 351ff5a2d1..87cf2bbc93 100644 --- a/org.adempiere.base/src/org/compiere/model/MGLCategory.java +++ b/org.adempiere.base/src/org/compiere/model/MGLCategory.java @@ -167,11 +167,12 @@ public class MGLCategory extends X_GL_Category @Override public String toString() { - return getClass().getSimpleName()+"["+get_ID() - +", Name="+getName() - +", IsDefault="+isDefault() - +", IsActive="+isActive() - +", CategoryType="+getCategoryType() - +"]"; + StringBuilder msgreturn = new StringBuilder(getClass().getSimpleName()).append("[").append(get_ID()) + .append(", Name=").append(getName()) + .append(", IsDefault=").append(isDefault()) + .append(", IsActive=").append(isActive()) + .append(", CategoryType=").append(getCategoryType()) + .append("]"); + return msgreturn.toString(); } } // MGLCategory diff --git a/org.adempiere.base/src/org/compiere/model/MGoal.java b/org.adempiere.base/src/org/compiere/model/MGoal.java index 6778d211a5..db6abad1b0 100644 --- a/org.adempiere.base/src/org/compiere/model/MGoal.java +++ b/org.adempiere.base/src/org/compiere/model/MGoal.java @@ -511,7 +511,7 @@ public class MGoal extends X_PA_Goal */ public String toString () { - StringBuffer sb = new StringBuffer ("MGoal["); + StringBuilder sb = new StringBuilder ("MGoal["); sb.append (get_ID ()) .append ("-").append (getName()) .append(",").append(getGoalPerformance()) diff --git a/org.adempiere.base/src/org/compiere/model/MGoalRestriction.java b/org.adempiere.base/src/org/compiere/model/MGoalRestriction.java index 4ed7c9725d..a3a7ef9618 100644 --- a/org.adempiere.base/src/org/compiere/model/MGoalRestriction.java +++ b/org.adempiere.base/src/org/compiere/model/MGoalRestriction.java @@ -63,7 +63,7 @@ public class MGoalRestriction extends X_PA_GoalRestriction */ public String toString () { - StringBuffer sb = new StringBuffer ("MGoalRestriction["); + StringBuilder sb = new StringBuilder ("MGoalRestriction["); sb.append (get_ID()).append ("-").append (getName()).append ("]"); return sb.toString (); } // toString diff --git a/org.adempiere.base/src/org/compiere/model/MIMPProcessor.java b/org.adempiere.base/src/org/compiere/model/MIMPProcessor.java index 8e84d4842d..7e33c21f5e 100644 --- a/org.adempiere.base/src/org/compiere/model/MIMPProcessor.java +++ b/org.adempiere.base/src/org/compiere/model/MIMPProcessor.java @@ -134,21 +134,22 @@ public class MIMPProcessor { if (getKeepLogDays() < 1) return 0; - String sql = "DELETE " + X_IMP_ProcessorLog.Table_Name + " " - + "WHERE "+X_IMP_ProcessorLog.COLUMNNAME_IMP_Processor_ID+"=" + getIMP_Processor_ID() - + " AND (Created+" + getKeepLogDays() + ") < SysDate"; - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("DELETE ").append(X_IMP_ProcessorLog.Table_Name).append(" ") + .append("WHERE ").append(X_IMP_ProcessorLog.COLUMNNAME_IMP_Processor_ID).append("=").append(getIMP_Processor_ID()) + .append(" AND (Created+").append(getKeepLogDays()).append(") < SysDate"); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); return no; } public String getServerID() { - return "ReplicationProcessor" + get_ID(); + StringBuilder msgreturn = new StringBuilder("ReplicationProcessor").append(get_ID()); + return msgreturn.toString(); } public X_IMP_ProcessorParameter[] getIMP_ProcessorParameters(String trxName) { List resultList = new ArrayList(); - StringBuffer sql = new StringBuffer("SELECT * ") + StringBuilder sql = new StringBuilder("SELECT * ") .append(" FROM ").append(X_IMP_ProcessorParameter.Table_Name) .append(" WHERE ").append(X_IMP_ProcessorParameter.COLUMNNAME_IMP_Processor_ID).append("=?") // # 1 .append(" AND IsActive = ?") // # 2 diff --git a/org.adempiere.base/src/org/compiere/model/MImage.java b/org.adempiere.base/src/org/compiere/model/MImage.java index 56970a2d8c..918e92a8d5 100644 --- a/org.adempiere.base/src/org/compiere/model/MImage.java +++ b/org.adempiere.base/src/org/compiere/model/MImage.java @@ -290,7 +290,8 @@ public class MImage extends X_AD_Image */ public String toString() { - return "MImage[ID=" + get_ID() + ",Name=" + getName() + "]"; + StringBuilder msgreturn = new StringBuilder("MImage[ID=").append(get_ID()).append(",Name=").append(getName()).append("]"); + return msgreturn.toString(); } // toString diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index 6d28cfe442..77c39ee3fe 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -564,8 +564,10 @@ public class MInOut extends X_M_InOut implements DocAction String desc = getDescription(); if (desc == null) setDescription(description); - else - setDescription(desc + " | " + description); + else{ + StringBuilder msgsd = new StringBuilder(desc).append(" | ").append(description); + setDescription(msgsd.toString()); + } } // addDescription /** @@ -574,7 +576,7 @@ public class MInOut extends X_M_InOut implements DocAction */ public String toString () { - StringBuffer sb = new StringBuffer ("MInOut[") + StringBuilder sb = new StringBuilder ("MInOut[") .append (get_ID()).append("-").append(getDocumentNo()) .append(",DocStatus=").append(getDocStatus()) .append ("]"); @@ -588,7 +590,8 @@ public class MInOut extends X_M_InOut implements DocAction public String getDocumentInfo() { MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); - return dt.getName() + " " + getDocumentNo(); + StringBuilder msgreturn = new StringBuilder(dt.getName()).append(" ").append(getDocumentNo()); + return msgreturn.toString(); } // getDocumentInfo /** @@ -599,7 +602,8 @@ public class MInOut extends X_M_InOut implements DocAction { try { - File temp = File.createTempFile(get_TableName()+get_ID()+"_", ".pdf"); + StringBuilder msgfile = new StringBuilder(get_TableName()).append(get_ID()).append("_"); + File temp = File.createTempFile(msgfile.toString(), ".pdf"); return createPDF (temp); } catch (Exception e) @@ -801,10 +805,10 @@ public class MInOut extends X_M_InOut implements DocAction super.setProcessed (processed); if (get_ID() == 0) return; - String sql = "UPDATE M_InOutLine SET Processed='" - + (processed ? "Y" : "N") - + "' WHERE M_InOut_ID=" + getM_InOut_ID(); - int noLine = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE M_InOutLine SET Processed='") + .append((processed ? "Y" : "N")) + .append("' WHERE M_InOut_ID=").append(getM_InOut_ID()); + int noLine = DB.executeUpdate(sql.toString(), get_TrxName()); m_lines = null; log.fine(processed + " - Lines=" + noLine); } // setProcessed @@ -1045,12 +1049,12 @@ public class MInOut extends X_M_InOut implements DocAction if (is_ValueChanged("AD_Org_ID")) { - String sql = "UPDATE M_InOutLine ol" - + " SET AD_Org_ID =" - + "(SELECT AD_Org_ID" - + " FROM M_InOut o WHERE ol.M_InOut_ID=o.M_InOut_ID) " - + "WHERE M_InOut_ID=" + getC_Order_ID(); - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE M_InOutLine ol") + .append(" SET AD_Org_ID =") + .append("(SELECT AD_Org_ID") + .append(" FROM M_InOut o WHERE ol.M_InOut_ID=o.M_InOut_ID) ") + .append("WHERE M_InOut_ID=").append(getC_Order_ID()); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Lines -> #" + no); } return true; @@ -1070,7 +1074,7 @@ public class MInOut extends X_M_InOut implements DocAction } // process /** Process Message */ - private String m_processMsg = null; + private StringBuffer m_processMsg = null; /** Just Prepared Flag */ private boolean m_justPrepared = false; @@ -1103,7 +1107,7 @@ public class MInOut extends X_M_InOut implements DocAction public String prepareIt() { log.info(toString()); - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -1112,13 +1116,13 @@ public class MInOut extends X_M_InOut implements DocAction // Order OR RMA can be processed on a shipment/receipt if (getC_Order_ID() != 0 && getM_RMA_ID() != 0) { - m_processMsg = "@OrderOrRMA@"; + m_processMsg = new StringBuffer("@OrderOrRMA@"); return DocAction.STATUS_Invalid; } // Std Period open? if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID())) { - m_processMsg = "@PeriodClosed@"; + m_processMsg = new StringBuffer("@PeriodClosed@"); return DocAction.STATUS_Invalid; } @@ -1133,24 +1137,24 @@ public class MInOut extends X_M_InOut implements DocAction MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), get_TrxName()); if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus())) { - m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@=" - + bp.getTotalOpenBalance() - + ", @SO_CreditLimit@=" + bp.getSO_CreditLimit(); + m_processMsg = new StringBuffer("@BPartnerCreditStop@ - @TotalOpenBalance@=") + .append(bp.getTotalOpenBalance()) + .append(", @SO_CreditLimit@=").append(bp.getSO_CreditLimit()); return DocAction.STATUS_Invalid; } if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus())) { - m_processMsg = "@BPartnerCreditHold@ - @TotalOpenBalance@=" - + bp.getTotalOpenBalance() - + ", @SO_CreditLimit@=" + bp.getSO_CreditLimit(); + m_processMsg = new StringBuffer("@BPartnerCreditHold@ - @TotalOpenBalance@=") + .append(bp.getTotalOpenBalance()) + .append(", @SO_CreditLimit@=").append(bp.getSO_CreditLimit()); return DocAction.STATUS_Invalid; } BigDecimal notInvoicedAmt = MBPartner.getNotInvoicedAmt(getC_BPartner_ID()); if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus(notInvoicedAmt))) { - m_processMsg = "@BPartnerOverSCreditHold@ - @TotalOpenBalance@=" - + bp.getTotalOpenBalance() + ", @NotInvoicedAmt@=" + notInvoicedAmt - + ", @SO_CreditLimit@=" + bp.getSO_CreditLimit(); + m_processMsg = new StringBuffer("@BPartnerOverSCreditHold@ - @TotalOpenBalance@=") + .append(bp.getTotalOpenBalance()).append(", @NotInvoicedAmt@=").append(notInvoicedAmt) + .append(", @SO_CreditLimit@=").append(bp.getSO_CreditLimit()); return DocAction.STATUS_Invalid; } } @@ -1160,7 +1164,7 @@ public class MInOut extends X_M_InOut implements DocAction MInOutLine[] lines = getLines(true); if (lines == null || lines.length == 0) { - m_processMsg = "@NoLines@"; + m_processMsg = new StringBuffer("@NoLines@"); return DocAction.STATUS_Invalid; } BigDecimal Volume = Env.ZERO; @@ -1181,8 +1185,8 @@ public class MInOut extends X_M_InOut implements DocAction continue; if (product != null && product.isASIMandatory(isSOTrx())) { - m_processMsg = "@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #" + lines[i].getLine() + - ", @M_Product_ID@=" + product.getValue() + ")"; + m_processMsg = new StringBuffer("@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #").append(lines[i].getLine()) + .append(", @M_Product_ID@=").append(product.getValue()).append(")"); return DocAction.STATUS_Invalid; } } @@ -1194,7 +1198,7 @@ public class MInOut extends X_M_InOut implements DocAction createConfirmation(); } - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -1240,7 +1244,7 @@ public class MInOut extends X_M_InOut implements DocAction return status; } - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -1254,8 +1258,8 @@ public class MInOut extends X_M_InOut implements DocAction if (MInOutConfirm.CONFIRMTYPE_CustomerConfirmation.equals(confirm.getConfirmType())) continue; // - m_processMsg = "Open @M_InOutConfirm_ID@: " + - confirm.getConfirmTypeName() + " - " + confirm.getDocumentNo(); + m_processMsg = new StringBuffer("Open @M_InOutConfirm_ID@: ") + .append(confirm.getConfirmTypeName()).append(" - ").append(confirm.getDocumentNo()); return DocAction.STATUS_InProgress; } } @@ -1265,7 +1269,7 @@ public class MInOut extends X_M_InOut implements DocAction if (!isApproved()) approveIt(); log.info(toString()); - StringBuffer info = new StringBuffer(); + StringBuilder info = new StringBuilder(); // For all lines MInOutLine[] lines = getLines(false); @@ -1359,7 +1363,7 @@ public class MInOut extends X_M_InOut implements DocAction get_TrxName())) { String lastError = CLogger.retrieveErrorString(""); - m_processMsg = "Cannot correct Inventory (MA) - " + lastError; + m_processMsg = new StringBuffer("Cannot correct Inventory (MA) - ").append(lastError); return DocAction.STATUS_Invalid; } if (!sameWarehouse) { @@ -1371,7 +1375,7 @@ public class MInOut extends X_M_InOut implements DocAction ma.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID, Env.ZERO, reservedDiff, orderedDiff, get_TrxName())) { - m_processMsg = "Cannot correct Inventory (MA) in order warehouse"; + m_processMsg = new StringBuffer("Cannot correct Inventory (MA) in order warehouse"); return DocAction.STATUS_Invalid; } } @@ -1383,7 +1387,7 @@ public class MInOut extends X_M_InOut implements DocAction mtrx.setM_InOutLine_ID(sLine.getM_InOutLine_ID()); if (!mtrx.save()) { - m_processMsg = "Could not create Material Transaction (MA)"; + m_processMsg = new StringBuffer("Could not create Material Transaction (MA)"); return DocAction.STATUS_Invalid; } } @@ -1401,7 +1405,7 @@ public class MInOut extends X_M_InOut implements DocAction sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID, Qty, reservedDiff, orderedDiff, get_TrxName())) { - m_processMsg = "Cannot correct Inventory"; + m_processMsg = new StringBuffer("Cannot correct Inventory"); return DocAction.STATUS_Invalid; } if (!sameWarehouse) { @@ -1413,7 +1417,7 @@ public class MInOut extends X_M_InOut implements DocAction sLine.getM_AttributeSetInstance_ID(), reservationAttributeSetInstance_ID, Env.ZERO, QtySO.negate(), QtyPO.negate(), get_TrxName())) { - m_processMsg = "Cannot correct Inventory"; + m_processMsg = new StringBuffer("Cannot correct Inventory"); return DocAction.STATUS_Invalid; } } @@ -1425,7 +1429,7 @@ public class MInOut extends X_M_InOut implements DocAction mtrx.setM_InOutLine_ID(sLine.getM_InOutLine_ID()); if (!mtrx.save()) { - m_processMsg = CLogger.retrieveErrorString("Could not create Material Transaction"); + m_processMsg = new StringBuffer(CLogger.retrieveErrorString("Could not create Material Transaction")); return DocAction.STATUS_Invalid; } } @@ -1449,7 +1453,7 @@ public class MInOut extends X_M_InOut implements DocAction } if (!oLine.save()) { - m_processMsg = "Could not update Order Line"; + m_processMsg = new StringBuffer("Could not update Order Line"); return DocAction.STATUS_Invalid; } else @@ -1469,7 +1473,7 @@ public class MInOut extends X_M_InOut implements DocAction } if (!rmaLine.save()) { - m_processMsg = "Could not update RMA Line"; + m_processMsg = new StringBuffer("Could not update RMA Line"); return DocAction.STATUS_Invalid; } } @@ -1496,7 +1500,7 @@ public class MInOut extends X_M_InOut implements DocAction MAsset asset = new MAsset (this, sLine, deliveryCount); if (!asset.save(get_TrxName())) { - m_processMsg = "Could not create Asset"; + m_processMsg = new StringBuffer("Could not create Asset"); return DocAction.STATUS_Invalid; } info.append(asset.getValue()); @@ -1533,7 +1537,7 @@ public class MInOut extends X_M_InOut implements DocAction isNewMatchInv = true; if (!inv.save(get_TrxName())) { - m_processMsg = CLogger.retrieveErrorString("Could not create Inv Matching"); + m_processMsg = new StringBuffer(CLogger.retrieveErrorString("Could not create Inv Matching")); return DocAction.STATUS_Invalid; } if (isNewMatchInv) @@ -1552,7 +1556,7 @@ public class MInOut extends X_M_InOut implements DocAction isNewMatchPO = true; if (!po.save(get_TrxName())) { - m_processMsg = "Could not create PO Matching"; + m_processMsg = new StringBuffer("Could not create PO Matching"); return DocAction.STATUS_Invalid; } if (isNewMatchPO) @@ -1580,7 +1584,7 @@ public class MInOut extends X_M_InOut implements DocAction isNewMatchPO = true; if (!po.save(get_TrxName())) { - m_processMsg = "Could not create PO(Inv) Matching"; + m_processMsg = new StringBuffer("Could not create PO(Inv) Matching"); return DocAction.STATUS_Invalid; } if (isNewMatchPO) @@ -1612,14 +1616,14 @@ public class MInOut extends X_M_InOut implements DocAction String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE); if (valid != null) { - m_processMsg = valid; + m_processMsg = new StringBuffer(valid); return DocAction.STATUS_Invalid; } // Set the definite document number after completed (if needed) setDefiniteDocumentNo(); - m_processMsg = info.toString(); + m_processMsg = new StringBuffer(info.toString()); setProcessed(true); setDocAction(DOCACTION_Close); return DocAction.STATUS_Completed; @@ -1942,7 +1946,7 @@ public class MInOut extends X_M_InOut implements DocAction { log.info(toString()); // Before Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID)); if (m_processMsg != null) return false; @@ -1950,7 +1954,7 @@ public class MInOut extends X_M_InOut implements DocAction || DOCSTATUS_Reversed.equals(getDocStatus()) || DOCSTATUS_Voided.equals(getDocStatus())) { - m_processMsg = "Document Closed: " + getDocStatus(); + m_processMsg = new StringBuffer("Document Closed: ").append(getDocStatus()); return false; } @@ -1970,7 +1974,8 @@ public class MInOut extends X_M_InOut implements DocAction if (old.signum() != 0) { line.setQty(Env.ZERO); - line.addDescription("Void (" + old + ")"); + StringBuilder msgd = new StringBuilder("Void (").append(old).append(")"); + line.addDescription(msgd.toString()); line.saveEx(get_TrxName()); } } @@ -1986,7 +1991,7 @@ public class MInOut extends X_M_InOut implements DocAction } // After Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID)); if (m_processMsg != null) return false; @@ -2003,7 +2008,7 @@ public class MInOut extends X_M_InOut implements DocAction { log.info(toString()); // Before Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE)); if (m_processMsg != null) return false; @@ -2011,7 +2016,7 @@ public class MInOut extends X_M_InOut implements DocAction setDocAction(DOCACTION_None); // After Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE)); if (m_processMsg != null) return false; return true; @@ -2025,14 +2030,14 @@ public class MInOut extends X_M_InOut implements DocAction { log.info(toString()); // Before reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT)); if (m_processMsg != null) return false; MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID())) { - m_processMsg = "@PeriodClosed@"; + m_processMsg = new StringBuffer("@PeriodClosed@"); return false; } @@ -2061,7 +2066,7 @@ public class MInOut extends X_M_InOut implements DocAction getC_DocType_ID(), isSOTrx(), false, get_TrxName(), true); if (reversal == null) { - m_processMsg = "Could not create Ship Reversal"; + m_processMsg = new StringBuffer("Could not create Ship Reversal"); return false; } reversal.setReversal(true); @@ -2079,7 +2084,7 @@ public class MInOut extends X_M_InOut implements DocAction rLine.setReversalLine_ID(sLines[i].getM_InOutLine_ID()); if (!rLine.save(get_TrxName())) { - m_processMsg = "Could not correct Ship Reversal Line"; + m_processMsg = new StringBuffer("Could not correct Ship Reversal Line"); return false; } // We need to copy MA @@ -2100,14 +2105,17 @@ public class MInOut extends X_M_InOut implements DocAction if (asset != null) { asset.setIsActive(false); - asset.addDescription("(" + reversal.getDocumentNo() + " #" + rLine.getLine() + "<-)"); + StringBuilder msgd = new StringBuilder( + "(").append(reversal.getDocumentNo()).append(" #").append(rLine.getLine()).append("<-)"); + asset.addDescription(msgd.toString()); asset.saveEx(); } } reversal.setC_Order_ID(getC_Order_ID()); // Set M_RMA_ID reversal.setM_RMA_ID(getM_RMA_ID()); - reversal.addDescription("{->" + getDocumentNo() + ")"); + StringBuilder msgd = new StringBuilder("{->").append(getDocumentNo()).append(")"); + reversal.addDescription(msgd.toString()); //FR1948157 reversal.setReversal_ID(getM_InOut_ID()); reversal.saveEx(get_TrxName()); @@ -2115,7 +2123,7 @@ public class MInOut extends X_M_InOut implements DocAction if (!reversal.processIt(DocAction.ACTION_Complete) || !reversal.getDocStatus().equals(DocAction.STATUS_Completed)) { - m_processMsg = "Reversal ERROR: " + reversal.getProcessMsg(); + m_processMsg = new StringBuffer("Reversal ERROR: ").append(reversal.getProcessMsg()); return false; } reversal.closeIt(); @@ -2124,7 +2132,8 @@ public class MInOut extends X_M_InOut implements DocAction reversal.setDocAction(DOCACTION_None); reversal.saveEx(get_TrxName()); // - addDescription("(" + reversal.getDocumentNo() + "<-)"); + msgd = new StringBuilder("(").append(reversal.getDocumentNo()).append("<-)"); + addDescription(msgd.toString()); // // Void Confirmations @@ -2135,11 +2144,11 @@ public class MInOut extends X_M_InOut implements DocAction voidConfirmations(); // After reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT)); if (m_processMsg != null) return false; - m_processMsg = reversal.getDocumentNo(); + m_processMsg = new StringBuffer(reversal.getDocumentNo()); setProcessed(true); setDocStatus(DOCSTATUS_Reversed); // may come from void setDocAction(DOCACTION_None); @@ -2154,12 +2163,12 @@ public class MInOut extends X_M_InOut implements DocAction { log.info(toString()); // Before reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL)); if (m_processMsg != null) return false; // After reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL)); if (m_processMsg != null) return false; @@ -2174,12 +2183,12 @@ public class MInOut extends X_M_InOut implements DocAction { log.info(toString()); // Before reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE)); if (m_processMsg != null) return false; // After reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE)); if (m_processMsg != null) return false; @@ -2193,7 +2202,7 @@ public class MInOut extends X_M_InOut implements DocAction */ public String getSummary() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getDocumentNo()); // : Total Lines = 123.00 (#1) sb.append(":") @@ -2211,7 +2220,7 @@ public class MInOut extends X_M_InOut implements DocAction */ public String getProcessMsg() { - return m_processMsg; + return m_processMsg.toString(); } // getProcessMsg /** diff --git a/org.adempiere.base/src/org/compiere/model/MInOutConfirm.java b/org.adempiere.base/src/org/compiere/model/MInOutConfirm.java index 03d6dfdad4..aefea48bf7 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutConfirm.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutConfirm.java @@ -174,8 +174,10 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction String desc = getDescription(); if (desc == null) setDescription(description); - else - setDescription(desc + " | " + description); + else{ + StringBuilder msgd = new StringBuilder(desc).append(" | ").append(description); + setDescription(msgd.toString()); + } } // addDescription /** @@ -193,7 +195,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction */ public String toString () { - StringBuffer sb = new StringBuffer ("MInOutConfirm["); + StringBuilder sb = new StringBuilder ("MInOutConfirm["); sb.append(get_ID()).append("-").append(getSummary()) .append ("]"); return sb.toString (); @@ -205,7 +207,8 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction */ public String getDocumentInfo() { - return Msg.getElement(getCtx(), "M_InOutConfirm_ID") + " " + getDocumentNo(); + StringBuilder msgreturn = new StringBuilder(Msg.getElement(getCtx(), "M_InOutConfirm_ID")).append(" ").append(getDocumentNo()); + return msgreturn.toString(); } // getDocumentInfo /** @@ -216,7 +219,8 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction { try { - File temp = File.createTempFile(get_TableName()+get_ID()+"_", ".pdf"); + StringBuilder msgfile = new StringBuilder(get_TableName()).append(get_ID()).append("_"); + File temp = File.createTempFile(msgfile.toString(), ".pdf"); return createPDF (temp); } catch (Exception e) @@ -249,11 +253,11 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction { int AD_User_ID = Env.getAD_User_ID(getCtx()); MUser user = MUser.get(getCtx(), AD_User_ID); - String info = user.getName() - + ": " - + Msg.translate(getCtx(), "IsApproved") - + " - " + new Timestamp(System.currentTimeMillis()); - addDescription(info); + StringBuilder info = new StringBuilder(user.getName()) + .append(": ") + .append(Msg.translate(getCtx(), "IsApproved")) + .append(" - ").append(new Timestamp(System.currentTimeMillis())); + addDescription(info.toString()); } super.setIsApproved (IsApproved); } // setIsApproved @@ -272,7 +276,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction } // processIt /** Process Message */ - private String m_processMsg = null; + private StringBuffer m_processMsg = null; /** Just Prepared Flag */ private boolean m_justPrepared = false; @@ -305,7 +309,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction public String prepareIt() { log.info(toString()); - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -323,7 +327,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction MInOutLineConfirm[] lines = getLines(true); if (lines.length == 0) { - m_processMsg = "@NoLines@"; + m_processMsg = new StringBuffer("@NoLines@"); return DocAction.STATUS_Invalid; } // Set dispute if not fully confirmed @@ -338,7 +342,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction } setIsInDispute(difference); - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; // @@ -384,7 +388,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction return status; } - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -404,7 +408,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction { if (dt.getC_DocTypeDifference_ID() == 0) { - m_processMsg = "No Split Document Type defined for: " + dt.getName(); + m_processMsg = new StringBuffer("No Split Document Type defined for: ").append(dt.getName()); return DocAction.STATUS_Invalid; } splitInOut (inout, dt.getC_DocTypeDifference_ID(), lines); @@ -419,7 +423,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction confirmLine.set_TrxName(get_TrxName()); if (!confirmLine.processLine (inout.isSOTrx(), getConfirmType())) { - m_processMsg = "ShipLine not saved - " + confirmLine; + m_processMsg = new StringBuffer("ShipLine not saved - ").append(confirmLine); return DocAction.STATUS_Invalid; } if (confirmLine.isFullyConfirmed()) @@ -444,9 +448,9 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction } // for all lines if (m_creditMemo != null) - m_processMsg += " @C_Invoice_ID@=" + m_creditMemo.getDocumentNo(); + m_processMsg.append(" @C_Invoice_ID@=").append(m_creditMemo.getDocumentNo()); if (m_inventory != null) - m_processMsg += " @M_Inventory_ID@=" + m_inventory.getDocumentNo(); + m_processMsg.append(" @M_Inventory_ID@=").append(m_inventory.getDocumentNo()); // Try to complete Shipment @@ -457,7 +461,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE); if (valid != null) { - m_processMsg = valid; + m_processMsg = new StringBuffer(valid); return DocAction.STATUS_Invalid; } @@ -490,10 +494,12 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction if (split == null) { split = new MInOut (original, C_DocType_ID, original.getMovementDate()); - split.addDescription("Splitted from " + original.getDocumentNo()); + StringBuilder msgd = new StringBuilder("Splitted from ").append(original.getDocumentNo()); + split.addDescription(msgd.toString()); split.setIsInDispute(true); split.saveEx(); - original.addDescription("Split: " + split.getDocumentNo()); + msgd = new StringBuilder("Split: ").append(split.getDocumentNo()); + original.addDescription(msgd.toString()); original.saveEx(); } // @@ -508,12 +514,14 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction splitLine.setM_Product_ID(oldLine.getM_Product_ID()); splitLine.setM_Warehouse_ID(oldLine.getM_Warehouse_ID()); splitLine.setRef_InOutLine_ID(oldLine.getRef_InOutLine_ID()); - splitLine.addDescription("Split: from " + oldLine.getMovementQty()); + StringBuilder msgd = new StringBuilder("Split: from ").append(oldLine.getMovementQty()); + splitLine.addDescription(msgd.toString()); // Qtys splitLine.setQty(differenceQty); // Entered/Movement splitLine.saveEx(); // Old - oldLine.addDescription("Splitted: from " + oldLine.getMovementQty()); + msgd = new StringBuilder("Splitted: from ").append(oldLine.getMovementQty()); + oldLine.addDescription(msgd.toString()); oldLine.setQty(oldLine.getMovementQty().subtract(differenceQty)); oldLine.saveEx(); // Update Confirmation Line @@ -528,8 +536,8 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction return ; } - m_processMsg = "Split @M_InOut_ID@=" + split.getDocumentNo() - + " - @M_InOutConfirm_ID@="; + m_processMsg = new StringBuffer("Split @M_InOut_ID@=").append(split.getDocumentNo()) + .append(" - @M_InOutConfirm_ID@="); MDocType dt = MDocType.get(getCtx(), original.getC_DocType_ID()); if (!dt.isPrepareSplitDocument()) @@ -552,13 +560,13 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction index++; // try just next if (splitConfirms[index].isProcessed()) { - m_processMsg += splitConfirms[index].getDocumentNo() + " processed??"; + m_processMsg.append(splitConfirms[index].getDocumentNo()).append(" processed??"); return; } } splitConfirms[index].setIsInDispute(true); splitConfirms[index].saveEx(); - m_processMsg += splitConfirms[index].getDocumentNo(); + m_processMsg.append(splitConfirms[index].getDocumentNo()); // Set Lines to unconfirmed MInOutLineConfirm[] splitConfirmLines = splitConfirms[index].getLines(false); for (int i = 0; i < splitConfirmLines.length; i++) @@ -570,7 +578,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction } } else - m_processMsg += "??"; + m_processMsg.append("??"); } // splitInOut @@ -584,9 +592,9 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction private boolean createDifferenceDoc (MInOut inout, MInOutLineConfirm confirm) { if (m_processMsg == null) - m_processMsg = ""; + m_processMsg = new StringBuffer(); else if (m_processMsg.length() > 0) - m_processMsg += "; "; + m_processMsg.append("; "); // Credit Memo if linked Document if (confirm.getDifferenceQty().signum() != 0 && !inout.isSOTrx() && inout.getRef_InOut_ID() != 0) @@ -595,7 +603,8 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction if (m_creditMemo == null) { m_creditMemo = new MInvoice (inout, null); - m_creditMemo.setDescription(Msg.translate(getCtx(), "M_InOutConfirm_ID") + " " + getDocumentNo()); + StringBuilder msgd = new StringBuilder(Msg.translate(getCtx(), "M_InOutConfirm_ID")).append(" ").append(getDocumentNo()); + m_creditMemo.setDescription(msgd.toString()); m_creditMemo.setC_DocTypeTarget_ID(MDocType.DOCBASETYPE_APCreditMemo); m_creditMemo.saveEx(); setC_Invoice_ID(m_creditMemo.getC_Invoice_ID()); @@ -620,7 +629,8 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction { MWarehouse wh = MWarehouse.get(getCtx(), inout.getM_Warehouse_ID()); m_inventory = new MInventory (wh, get_TrxName()); - m_inventory.setDescription(Msg.translate(getCtx(), "M_InOutConfirm_ID") + " " + getDocumentNo()); + StringBuilder msgd = new StringBuilder(Msg.translate(getCtx(), "M_InOutConfirm_ID")).append(" ").append(getDocumentNo()); + m_inventory.setDescription(msgd.toString()); m_inventory.saveEx(); setM_Inventory_ID(m_inventory.getM_Inventory_ID()); } @@ -630,7 +640,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction confirm.getScrappedQty(), Env.ZERO); if (!line.save(get_TrxName())) { - m_processMsg += "Inventory Line not created"; + m_processMsg.append("Inventory Line not created"); return false; } confirm.setM_InventoryLine_ID(line.getM_InventoryLine_ID()); @@ -639,7 +649,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction // if (!confirm.save(get_TrxName())) { - m_processMsg += "Confirmation Line not saved"; + m_processMsg.append("Confirmation Line not saved"); return false; } return true; @@ -653,7 +663,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction { log.info(toString()); // Before Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID)); if (m_processMsg != null) return false; @@ -661,7 +671,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction || DOCSTATUS_Reversed.equals(getDocStatus()) || DOCSTATUS_Voided.equals(getDocStatus())) { - m_processMsg = "Document Closed: " + getDocStatus(); + m_processMsg = new StringBuffer("Document Closed: ").append(getDocStatus()); return false; } @@ -695,7 +705,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction } // After Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID)); if (m_processMsg != null) return false; @@ -713,14 +723,14 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction { log.info(toString()); // Before Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE)); if (m_processMsg != null) return false; setDocAction(DOCACTION_None); // After Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE)); if (m_processMsg != null) return false; @@ -735,12 +745,12 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction { log.info(toString()); // Before reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT)); if (m_processMsg != null) return false; // After reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT)); if (m_processMsg != null) return false; @@ -755,12 +765,12 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction { log.info(toString()); // Before reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL)); if (m_processMsg != null) return false; // After reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL)); if (m_processMsg != null) return false; @@ -775,12 +785,12 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction { log.info(toString()); // Before reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE)); if (m_processMsg != null) return false; // After reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE)); if (m_processMsg != null) return false; @@ -794,7 +804,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction */ public String getSummary() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getDocumentNo()); // : Total Lines = 123.00 (#1) sb.append(": ") @@ -812,7 +822,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction */ public String getProcessMsg() { - return m_processMsg; + return m_processMsg.toString(); } // getProcessMsg /** diff --git a/org.adempiere.base/src/org/compiere/model/MInOutLine.java b/org.adempiere.base/src/org/compiere/model/MInOutLine.java index 8641f14542..da12869f2d 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutLine.java @@ -423,8 +423,10 @@ public class MInOutLine extends X_M_InOutLine String desc = getDescription(); if (desc == null) setDescription(description); - else - setDescription(desc + " | " + description); + else{ + StringBuilder msgd = new StringBuilder(desc).append(" | ").append(description); + setDescription(msgd.toString()); + } } // addDescription /** @@ -628,7 +630,7 @@ public class MInOutLine extends X_M_InOutLine */ public String toString () { - StringBuffer sb = new StringBuffer ("MInOutLine[").append (get_ID()) + StringBuilder sb = new StringBuilder ("MInOutLine[").append (get_ID()) .append(",M_Product_ID=").append(getM_Product_ID()) .append(",QtyEntered=").append(getQtyEntered()) .append(",MovementQty=").append(getMovementQty()) diff --git a/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java b/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java index c1d422aa61..cf28a56c55 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java +++ b/org.adempiere.base/src/org/compiere/model/MInOutLineMA.java @@ -62,10 +62,10 @@ public class MInOutLineMA extends X_M_InOutLineMA */ public static int deleteInOutMA (int M_InOut_ID, String trxName) { - String sql = "DELETE FROM M_InOutLineMA ma WHERE EXISTS " - + "(SELECT * FROM M_InOutLine l WHERE l.M_InOutLine_ID=ma.M_InOutLine_ID" - + " AND M_InOut_ID=" + M_InOut_ID + ")"; - return DB.executeUpdate(sql, trxName); + StringBuilder sql = new StringBuilder("DELETE FROM M_InOutLineMA ma WHERE EXISTS ") + .append("(SELECT * FROM M_InOutLine l WHERE l.M_InOutLine_ID=ma.M_InOutLine_ID") + .append(" AND M_InOut_ID=").append(M_InOut_ID).append(")"); + return DB.executeUpdate(sql.toString(), trxName); } // deleteInOutMA /** @@ -130,7 +130,7 @@ public class MInOutLineMA extends X_M_InOutLineMA */ public String toString () { - StringBuffer sb = new StringBuffer ("MInOutLineMA["); + StringBuilder sb = new StringBuilder ("MInOutLineMA["); sb.append("M_InOutLine_ID=").append(getM_InOutLine_ID()) .append(",M_AttributeSetInstance_ID=").append(getM_AttributeSetInstance_ID()) .append(", Qty=").append(getMovementQty()) diff --git a/org.adempiere.base/src/org/compiere/model/MIndex.java b/org.adempiere.base/src/org/compiere/model/MIndex.java index a6778f068e..9bb05d9363 100644 --- a/org.adempiere.base/src/org/compiere/model/MIndex.java +++ b/org.adempiere.base/src/org/compiere/model/MIndex.java @@ -72,10 +72,10 @@ public class MIndex extends X_K_Index */ public static int cleanUp (String trxName, int AD_Client_ID, int AD_Table_ID, int Record_ID) { - StringBuffer sb = new StringBuffer ("DELETE FROM K_Index " - + "WHERE AD_Client_ID=" + AD_Client_ID + " AND " - + "AD_Table_ID=" + AD_Table_ID + " AND " - + "Record_ID=" + Record_ID); + StringBuilder sb = new StringBuilder ("DELETE FROM K_Index ") + .append("WHERE AD_Client_ID=").append(AD_Client_ID).append( " AND ") + .append("AD_Table_ID=").append(AD_Table_ID).append( " AND ") + .append("Record_ID=").append(Record_ID); int no = DB.executeUpdate(sb.toString(), trxName); return no; } @@ -214,20 +214,20 @@ public class MIndex extends X_K_Index public static void reIndex(boolean runCleanUp, String[] toBeIndexed, Properties ctx, int AD_Client_ID, int AD_Table_ID, int Record_ID, int CM_WebProject_ID, Timestamp lastUpdated) { - String trxName = "ReIndex_" + AD_Table_ID + "_" + Record_ID; + StringBuilder trxName = new StringBuilder("ReIndex_").append(AD_Table_ID).append("_").append(Record_ID); try { if (!runCleanUp) { - MIndex.cleanUp(trxName, AD_Client_ID, AD_Table_ID, Record_ID); + MIndex.cleanUp(trxName.toString(), AD_Client_ID, AD_Table_ID, Record_ID); } for (int i=0;i" + getDocumentNo() + ")"); + StringBuilder msgd = new StringBuilder("{->").append(getDocumentNo()).append(")"); + reversal.addDescription(msgd.toString()); //FR1948157 reversal.setReversal_ID(getM_Inventory_ID()); reversal.saveEx(); @@ -792,19 +798,20 @@ public class MInventory extends X_M_Inventory implements DocAction // if (!reversal.processIt(DocAction.ACTION_Complete)) { - m_processMsg = "Reversal ERROR: " + reversal.getProcessMsg(); + m_processMsg = new StringBuffer("Reversal ERROR: ").append(reversal.getProcessMsg()); return false; } reversal.closeIt(); reversal.setDocStatus(DOCSTATUS_Reversed); reversal.setDocAction(DOCACTION_None); reversal.saveEx(); - m_processMsg = reversal.getDocumentNo(); + m_processMsg = new StringBuffer(reversal.getDocumentNo()); // Update Reversed (this) - addDescription("(" + reversal.getDocumentNo() + "<-)"); + msgd = new StringBuilder("(").append(reversal.getDocumentNo()).append("<-)"); + addDescription(msgd.toString()); // After reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT)); if (m_processMsg != null) return false; setProcessed(true); @@ -824,12 +831,12 @@ public class MInventory extends X_M_Inventory implements DocAction { log.info(toString()); // Before reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL)); if (m_processMsg != null) return false; // After reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL)); if (m_processMsg != null) return false; @@ -844,12 +851,12 @@ public class MInventory extends X_M_Inventory implements DocAction { log.info(toString()); // Before reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE)); if (m_processMsg != null) return false; // After reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE)); if (m_processMsg != null) return false; @@ -863,7 +870,7 @@ public class MInventory extends X_M_Inventory implements DocAction */ public String getSummary() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getDocumentNo()); // : Total Lines = 123.00 (#1) sb.append(": ") @@ -881,7 +888,7 @@ public class MInventory extends X_M_Inventory implements DocAction */ public String getProcessMsg() { - return m_processMsg; + return m_processMsg.toString(); } // getProcessMsg /** diff --git a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java index f1287d296d..6e6b7f1970 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java @@ -206,8 +206,10 @@ public class MInventoryLine extends X_M_InventoryLine String desc = getDescription(); if (desc == null) setDescription(description); - else - setDescription(desc + " | " + description); + else{ + StringBuilder msgd = new StringBuilder(desc).append(" | ").append(description); + setDescription(msgd.toString()); + } } // addDescription /** @@ -236,7 +238,7 @@ public class MInventoryLine extends X_M_InventoryLine */ public String toString () { - StringBuffer sb = new StringBuffer ("MInventoryLine["); + StringBuilder sb = new StringBuilder ("MInventoryLine["); sb.append (get_ID()) .append("-M_Product_ID=").append (getM_Product_ID()) .append(",QtyCount=").append(getQtyCount()) diff --git a/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java b/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java index 4a133c6391..12123e75a1 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java +++ b/org.adempiere.base/src/org/compiere/model/MInventoryLineMA.java @@ -85,10 +85,10 @@ public class MInventoryLineMA extends X_M_InventoryLineMA */ public static int deleteInventoryMA (int M_Inventory_ID, String trxName) { - String sql = "DELETE FROM M_InventoryLineMA ma WHERE EXISTS " - + "(SELECT * FROM M_InventoryLine l WHERE l.M_InventoryLine_ID=ma.M_InventoryLine_ID" - + " AND M_Inventory_ID=" + M_Inventory_ID + ")"; - return DB.executeUpdate(sql, trxName); + StringBuilder sql = new StringBuilder("DELETE FROM M_InventoryLineMA ma WHERE EXISTS ") + .append("(SELECT * FROM M_InventoryLine l WHERE l.M_InventoryLine_ID=ma.M_InventoryLine_ID") + .append(" AND M_Inventory_ID=").append(M_Inventory_ID).append(")"); + return DB.executeUpdate(sql.toString(), trxName); } // deleteInventoryMA /** @@ -99,10 +99,10 @@ public class MInventoryLineMA extends X_M_InventoryLineMA */ public static int deleteInventoryLineMA (int M_InventoryLine_ID, String trxName) { - String sql = "DELETE FROM M_InventoryLineMA ma WHERE EXISTS " - + "(SELECT * FROM M_InventoryLine l WHERE l.M_InventoryLine_ID=ma.M_InventoryLine_ID" - + " AND M_InventoryLine_ID=" + M_InventoryLine_ID + ")"; - return DB.executeUpdate(sql, trxName); + StringBuilder sql = new StringBuilder("DELETE FROM M_InventoryLineMA ma WHERE EXISTS ") + .append("(SELECT * FROM M_InventoryLine l WHERE l.M_InventoryLine_ID=ma.M_InventoryLine_ID") + .append(" AND M_InventoryLine_ID=").append(M_InventoryLine_ID).append(")"); + return DB.executeUpdate(sql.toString(), trxName); } // deleteInventoryMA /** Logger */ @@ -155,7 +155,7 @@ public class MInventoryLineMA extends X_M_InventoryLineMA */ public String toString () { - StringBuffer sb = new StringBuffer ("MInventoryLineMA["); + StringBuilder sb = new StringBuilder ("MInventoryLineMA["); sb.append("M_InventoryLine_ID=").append(getM_InventoryLine_ID()) .append(",M_AttributeSetInstance_ID=").append(getM_AttributeSetInstance_ID()) .append(", Qty=").append(getMovementQty()) diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index b9f4f4ae2c..8faedb10fb 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -219,7 +219,7 @@ public class MInvoice extends X_C_Invoice implements DocAction */ public static String getPDFFileName (String documentDir, int C_Invoice_ID) { - StringBuffer sb = new StringBuffer (documentDir); + StringBuilder sb = new StringBuilder (documentDir); if (sb.length() == 0) sb.append("."); if (!sb.toString().endsWith(File.separator)) @@ -825,8 +825,10 @@ public class MInvoice extends X_C_Invoice implements DocAction String desc = getDescription(); if (desc == null) setDescription(description); - else - setDescription(desc + " | " + description); + else{ + StringBuilder msgd = new StringBuilder(desc).append(" | ").append(description); + setDescription(msgd.toString()); + } } // addDescription /** @@ -851,9 +853,9 @@ public class MInvoice extends X_C_Invoice implements DocAction super.setProcessed (processed); if (get_ID() == 0) return; - String set = "SET Processed='" - + (processed ? "Y" : "N") - + "' WHERE C_Invoice_ID=" + getC_Invoice_ID(); + StringBuilder set = new StringBuilder("SET Processed='") + .append((processed ? "Y" : "N")) + .append("' WHERE C_Invoice_ID=").append(getC_Invoice_ID()); int noLine = DB.executeUpdate("UPDATE C_InvoiceLine " + set, get_TrxName()); int noTax = DB.executeUpdate("UPDATE C_InvoiceTax " + set, get_TrxName()); m_lines = null; @@ -1021,7 +1023,7 @@ public class MInvoice extends X_C_Invoice implements DocAction */ public String toString () { - StringBuffer sb = new StringBuffer ("MInvoice[") + StringBuilder sb = new StringBuilder ("MInvoice[") .append(get_ID()).append("-").append(getDocumentNo()) .append(",GrandTotal=").append(getGrandTotal()); if (m_lines != null) @@ -1037,7 +1039,8 @@ public class MInvoice extends X_C_Invoice implements DocAction public String getDocumentInfo() { MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); - return dt.getName() + " " + getDocumentNo(); + StringBuilder msgreturn = new StringBuilder(dt.getName()).append(" ").append(getDocumentNo()); + return msgreturn.toString(); } // getDocumentInfo @@ -1054,12 +1057,12 @@ public class MInvoice extends X_C_Invoice implements DocAction if (is_ValueChanged("AD_Org_ID")) { - String sql = "UPDATE C_InvoiceLine ol" - + " SET AD_Org_ID =" - + "(SELECT AD_Org_ID" - + " FROM C_Invoice o WHERE ol.C_Invoice_ID=o.C_Invoice_ID) " - + "WHERE C_Invoice_ID=" + getC_Invoice_ID(); - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE C_InvoiceLine ol") + .append(" SET AD_Org_ID =") + .append("(SELECT AD_Org_ID") + .append(" FROM C_Invoice o WHERE ol.C_Invoice_ID=o.C_Invoice_ID) ") + .append("WHERE C_Invoice_ID=").append(getC_Invoice_ID()); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine("Lines -> #" + no); } return true; @@ -1255,7 +1258,8 @@ public class MInvoice extends X_C_Invoice implements DocAction { try { - File temp = File.createTempFile(get_TableName()+get_ID()+"_", ".pdf"); + StringBuilder msgfile = new StringBuilder(get_TableName()).append(get_ID()).append("_"); + File temp = File.createTempFile(msgfile.toString(), ".pdf"); return createPDF (temp); } catch (Exception e) @@ -1335,7 +1339,7 @@ public class MInvoice extends X_C_Invoice implements DocAction } // process /** Process Message */ - private String m_processMsg = null; + private StringBuffer m_processMsg = null; /** Just Prepared Flag */ private boolean m_justPrepared = false; @@ -1368,7 +1372,7 @@ public class MInvoice extends X_C_Invoice implements DocAction public String prepareIt() { log.info(toString()); - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -1378,14 +1382,14 @@ public class MInvoice extends X_C_Invoice implements DocAction MInvoiceLine[] lines = getLines(true); if (lines.length == 0) { - m_processMsg = "@NoLines@"; + m_processMsg = new StringBuffer("@NoLines@"); return DocAction.STATUS_Invalid; } // No Cash Book if (PAYMENTRULE_Cash.equals(getPaymentRule()) && MCashBook.get(getCtx(), getAD_Org_ID(), getC_Currency_ID()) == null) { - m_processMsg = "@NoCashBook@"; + m_processMsg = new StringBuffer("@NoCashBook@"); return DocAction.STATUS_Invalid; } @@ -1394,14 +1398,14 @@ public class MInvoice extends X_C_Invoice implements DocAction setC_DocType_ID(getC_DocTypeTarget_ID()); if (getC_DocType_ID() == 0) { - m_processMsg = "No Document Type"; + m_processMsg = new StringBuffer("No Document Type"); return DocAction.STATUS_Invalid; } explodeBOM(); if (!calculateTaxTotal()) // setTotals { - m_processMsg = "Error calculating Tax"; + m_processMsg = new StringBuffer("Error calculating Tax"); return DocAction.STATUS_Invalid; } @@ -1410,13 +1414,13 @@ public class MInvoice extends X_C_Invoice implements DocAction { if (!createPaySchedule()) { - m_processMsg = "@ErrorPaymentSchedule@"; + m_processMsg = new StringBuffer("@ErrorPaymentSchedule@"); return DocAction.STATUS_Invalid; } } else { if (MInvoicePaySchedule.getInvoicePaySchedule(getCtx(), getC_Invoice_ID(), 0, get_TrxName()).length > 0) { - m_processMsg = "@ErrorPaymentSchedule@"; + m_processMsg = new StringBuffer("@ErrorPaymentSchedule@"); return DocAction.STATUS_Invalid; } } @@ -1433,9 +1437,9 @@ public class MInvoice extends X_C_Invoice implements DocAction MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null); if ( MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()) ) { - m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@=" - + bp.getTotalOpenBalance() - + ", @SO_CreditLimit@=" + bp.getSO_CreditLimit(); + m_processMsg = new StringBuffer("@BPartnerCreditStop@ - @TotalOpenBalance@=") + .append(bp.getTotalOpenBalance()) + .append(", @SO_CreditLimit@=").append(bp.getSO_CreditLimit()); return DocAction.STATUS_Invalid; } } @@ -1450,13 +1454,13 @@ public class MInvoice extends X_C_Invoice implements DocAction String error = line.allocateLandedCosts(); if (error != null && error.length() > 0) { - m_processMsg = error; + m_processMsg = new StringBuffer(error); return DocAction.STATUS_Invalid; } } } - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -1541,12 +1545,12 @@ public class MInvoice extends X_C_Invoice implements DocAction line.setPriceList (Env.ZERO); line.setLineNetAmt (Env.ZERO); // - String description = product.getName (); + StringBuilder description = new StringBuilder(product.getName ()); if (product.getDescription () != null) - description += " " + product.getDescription (); + description.append(" ").append(product.getDescription ()); if (line.getDescription () != null) - description += " " + line.getDescription (); - line.setDescription (description); + description.append(" ").append(line.getDescription ()); + line.setDescription (description.toString()); line.saveEx (get_TrxName()); } // for all lines with BOM @@ -1564,7 +1568,8 @@ public class MInvoice extends X_C_Invoice implements DocAction { log.fine(""); // Delete Taxes - DB.executeUpdateEx("DELETE C_InvoiceTax WHERE C_Invoice_ID=" + getC_Invoice_ID(), get_TrxName()); + StringBuilder msgdb = new StringBuilder("DELETE C_InvoiceTax WHERE C_Invoice_ID=").append(getC_Invoice_ID()); + DB.executeUpdateEx(msgdb.toString(), get_TrxName()); m_taxes = null; // Lines @@ -1698,7 +1703,7 @@ public class MInvoice extends X_C_Invoice implements DocAction return status; } - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -1706,7 +1711,7 @@ public class MInvoice extends X_C_Invoice implements DocAction if (!isApproved()) approveIt(); log.info(toString()); - StringBuffer info = new StringBuffer(); + StringBuilder info = new StringBuilder(); // POS supports multiple payments boolean fromPOS = false; @@ -1743,17 +1748,17 @@ public class MInvoice extends X_C_Invoice implements DocAction if (cash == null || cash.get_ID() == 0) { - m_processMsg = "@NoCashBook@"; + m_processMsg = new StringBuffer("@NoCashBook@"); return DocAction.STATUS_Invalid; } MCashLine cl = new MCashLine (cash); cl.setInvoice(this); if (!cl.save(get_TrxName())) { - m_processMsg = "Could not save Cash Journal Line"; + m_processMsg = new StringBuffer("Could not save Cash Journal Line"); return DocAction.STATUS_Invalid; } - info.append("@C_Cash_ID@: " + cash.getName() + " #" + cl.getLine()); + info.append("@C_Cash_ID@: ").append(cash.getName()).append(" #").append(cl.getLine()); setC_CashLine_ID(cl.getC_CashLine_ID()); } // CashBook @@ -1777,7 +1782,7 @@ public class MInvoice extends X_C_Invoice implements DocAction ol.setQtyInvoiced(ol.getQtyInvoiced().add(line.getQtyInvoiced())); if (!ol.save(get_TrxName())) { - m_processMsg = "Could not update Order Line"; + m_processMsg = new StringBuffer("Could not update Order Line"); return DocAction.STATUS_Invalid; } } @@ -1795,7 +1800,7 @@ public class MInvoice extends X_C_Invoice implements DocAction isNewMatchPO = true; if (!po.save(get_TrxName())) { - m_processMsg = "Could not create PO Matching"; + m_processMsg = new StringBuffer("Could not create PO Matching"); return DocAction.STATUS_Invalid; } matchPO++; @@ -1814,7 +1819,7 @@ public class MInvoice extends X_C_Invoice implements DocAction rmaLine.setQtyInvoiced(line.getQtyInvoiced()); if (!rmaLine.save(get_TrxName())) { - m_processMsg = "Could not update RMA Line"; + m_processMsg = new StringBuffer("Could not update RMA Line"); return DocAction.STATUS_Invalid; } } @@ -1838,7 +1843,7 @@ public class MInvoice extends X_C_Invoice implements DocAction isNewMatchInv = true; if (!inv.save(get_TrxName())) { - m_processMsg = CLogger.retrieveErrorString("Could not create Invoice Matching"); + m_processMsg = new StringBuffer(CLogger.retrieveErrorString("Could not create Invoice Matching")); return DocAction.STATUS_Invalid; } matchInv++; @@ -1860,8 +1865,8 @@ public class MInvoice extends X_C_Invoice implements DocAction getC_Currency_ID(), getDateAcct(), getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID()); if (invAmt == null) { - m_processMsg = "Could not convert C_Currency_ID=" + getC_Currency_ID() - + " to base C_Currency_ID=" + MClient.get(Env.getCtx()).getC_Currency_ID(); + m_processMsg = new StringBuffer("Could not convert C_Currency_ID=").append(getC_Currency_ID()) + .append(" to base C_Currency_ID=").append(MClient.get(Env.getCtx()).getC_Currency_ID()); return DocAction.STATUS_Invalid; } // Total Balance @@ -1902,7 +1907,7 @@ public class MInvoice extends X_C_Invoice implements DocAction bp.setSOCreditStatus(); if (!bp.save(get_TrxName())) { - m_processMsg = "Could not update Business Partner"; + m_processMsg = new StringBuffer("Could not update Business Partner"); return DocAction.STATUS_Invalid; } @@ -1911,10 +1916,11 @@ public class MInvoice extends X_C_Invoice implements DocAction { MUser user = new MUser (getCtx(), getAD_User_ID(), get_TrxName()); user.setLastContact(new Timestamp(System.currentTimeMillis())); - user.setLastResult(Msg.translate(getCtx(), "C_Invoice_ID") + ": " + getDocumentNo()); + StringBuilder msgr = new StringBuilder(Msg.translate(getCtx(), "C_Invoice_ID")).append(": ").append(getDocumentNo()); + user.setLastResult(msgr.toString()); if (!user.save(get_TrxName())) { - m_processMsg = "Could not update Business Partner User"; + m_processMsg = new StringBuffer("Could not update Business Partner User"); return DocAction.STATUS_Invalid; } } // user @@ -1930,8 +1936,8 @@ public class MInvoice extends X_C_Invoice implements DocAction getDateAcct(), 0, getAD_Client_ID(), getAD_Org_ID()); if (amt == null) { - m_processMsg = "Could not convert C_Currency_ID=" + getC_Currency_ID() - + " to Project C_Currency_ID=" + C_CurrencyTo_ID; + m_processMsg = new StringBuffer("Could not convert C_Currency_ID=").append(getC_Currency_ID()) + .append(" to Project C_Currency_ID=").append(C_CurrencyTo_ID); return DocAction.STATUS_Invalid; } BigDecimal newAmt = project.getInvoicedAmt(); @@ -1945,7 +1951,7 @@ public class MInvoice extends X_C_Invoice implements DocAction project.setInvoicedAmt(newAmt); if (!project.save(get_TrxName())) { - m_processMsg = "Could not update Project"; + m_processMsg = new StringBuffer("Could not update Project"); return DocAction.STATUS_Invalid; } } // project @@ -1954,7 +1960,7 @@ public class MInvoice extends X_C_Invoice implements DocAction String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE); if (valid != null) { - m_processMsg = valid; + m_processMsg = new StringBuffer(valid); return DocAction.STATUS_Invalid; } @@ -1966,7 +1972,7 @@ public class MInvoice extends X_C_Invoice implements DocAction if (counter != null) info.append(" - @CounterDoc@: @C_Invoice_ID@=").append(counter.getDocumentNo()); - m_processMsg = info.toString().trim(); + m_processMsg = new StringBuffer(info.toString().trim()); setProcessed(true); setDocAction(DOCACTION_Close); return DocAction.STATUS_Completed; @@ -2092,7 +2098,7 @@ public class MInvoice extends X_C_Invoice implements DocAction { log.info(toString()); // Before Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID)); if (m_processMsg != null) return false; @@ -2100,7 +2106,7 @@ public class MInvoice extends X_C_Invoice implements DocAction || DOCSTATUS_Reversed.equals(getDocStatus()) || DOCSTATUS_Voided.equals(getDocStatus())) { - m_processMsg = "Document Closed: " + getDocStatus(); + m_processMsg = new StringBuffer("Document Closed: ").append(getDocStatus()); setDocAction(DOCACTION_None); return false; } @@ -2124,7 +2130,8 @@ public class MInvoice extends X_C_Invoice implements DocAction line.setTaxAmt(Env.ZERO); line.setLineNetAmt(Env.ZERO); line.setLineTotalAmt(Env.ZERO); - line.addDescription(Msg.getMsg(getCtx(), "Voided") + " (" + old + ")"); + StringBuilder msgd = new StringBuilder(Msg.getMsg(getCtx(), "Voided")).append(" (").append(old).append(")"); + line.addDescription(msgd.toString()); // Unlink Shipment if (line.getM_InOutLine_ID() != 0) { @@ -2146,7 +2153,7 @@ public class MInvoice extends X_C_Invoice implements DocAction } // After Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID)); if (m_processMsg != null) return false; @@ -2163,7 +2170,7 @@ public class MInvoice extends X_C_Invoice implements DocAction { log.info(toString()); // Before Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE)); if (m_processMsg != null) return false; @@ -2171,7 +2178,7 @@ public class MInvoice extends X_C_Invoice implements DocAction setDocAction(DOCACTION_None); // After Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE)); if (m_processMsg != null) return false; return true; @@ -2185,7 +2192,7 @@ public class MInvoice extends X_C_Invoice implements DocAction { log.info(toString()); // Before reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT)); if (m_processMsg != null) return false; @@ -2228,7 +2235,7 @@ public class MInvoice extends X_C_Invoice implements DocAction reversal = copyFrom (this, getDateInvoiced(), getDateAcct(), getC_DocType_ID(), isSOTrx(), false, get_TrxName(), true, getDocumentNo()+"^"); if (reversal == null) { - m_processMsg = "Could not create Invoice Reversal"; + m_processMsg = new StringBuffer("Could not create Invoice Reversal"); return false; } reversal.setReversal(true); @@ -2247,7 +2254,7 @@ public class MInvoice extends X_C_Invoice implements DocAction rLine.setLineTotalAmt(rLine.getLineTotalAmt().negate()); if (!rLine.save(get_TrxName())) { - m_processMsg = "Could not correct Invoice Reversal Line"; + m_processMsg = new StringBuffer("Could not correct Invoice Reversal Line"); return false; } } @@ -2259,7 +2266,7 @@ public class MInvoice extends X_C_Invoice implements DocAction // if (!reversal.processIt(DocAction.ACTION_Complete)) { - m_processMsg = "Reversal ERROR: " + reversal.getProcessMsg(); + m_processMsg = new StringBuffer("Reversal ERROR: ").append(reversal.getProcessMsg()); return false; } reversal.setC_Payment_ID(0); @@ -2269,9 +2276,10 @@ public class MInvoice extends X_C_Invoice implements DocAction reversal.setDocStatus(DOCSTATUS_Reversed); reversal.setDocAction(DOCACTION_None); reversal.saveEx(get_TrxName()); - m_processMsg = reversal.getDocumentNo(); + m_processMsg = new StringBuffer(reversal.getDocumentNo()); // - addDescription("(" + reversal.getDocumentNo() + "<-)"); + StringBuilder msgd = new StringBuilder("(").append(reversal.getDocumentNo()).append("<-)"); + addDescription(msgd.toString()); // Clean up Reversed (this) MInvoiceLine[] iLines = getLines(false); @@ -2297,10 +2305,10 @@ public class MInvoice extends X_C_Invoice implements DocAction setIsPaid(true); // Create Allocation + msgd = new StringBuilder( + Msg.translate(getCtx(), "C_Invoice_ID")).append(": ").append(getDocumentNo()).append("/").append(reversal.getDocumentNo()); MAllocationHdr alloc = new MAllocationHdr(getCtx(), false, getDateAcct(), - getC_Currency_ID(), - Msg.translate(getCtx(), "C_Invoice_ID") + ": " + getDocumentNo() + "/" + reversal.getDocumentNo(), - get_TrxName()); + getC_Currency_ID(),msgd.toString(),get_TrxName()); alloc.setAD_Org_ID(getAD_Org_ID()); if (alloc.save()) { @@ -2326,7 +2334,7 @@ public class MInvoice extends X_C_Invoice implements DocAction } // After reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT)); if (m_processMsg != null) return false; @@ -2341,12 +2349,12 @@ public class MInvoice extends X_C_Invoice implements DocAction { log.info(toString()); // Before reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL)); if (m_processMsg != null) return false; // After reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL)); if (m_processMsg != null) return false; @@ -2361,12 +2369,12 @@ public class MInvoice extends X_C_Invoice implements DocAction { log.info(toString()); // Before reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE)); if (m_processMsg != null) return false; // After reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE)); if (m_processMsg != null) return false; @@ -2381,7 +2389,7 @@ public class MInvoice extends X_C_Invoice implements DocAction */ public String getSummary() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getDocumentNo()); // : Grand Total = 123.00 (#1) sb.append(": "). @@ -2399,7 +2407,7 @@ public class MInvoice extends X_C_Invoice implements DocAction */ public String getProcessMsg() { - return m_processMsg; + return m_processMsg.toString(); } // getProcessMsg /** diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceBatch.java b/org.adempiere.base/src/org/compiere/model/MInvoiceBatch.java index 10c6e8ac92..8f734e8205 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceBatch.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceBatch.java @@ -136,9 +136,9 @@ public class MInvoiceBatch extends X_C_InvoiceBatch super.setProcessed (processed); if (get_ID() == 0) return; - String set = "SET Processed='" - + (processed ? "Y" : "N") - + "' WHERE C_InvoiceBatch_ID=" + getC_InvoiceBatch_ID(); + StringBuilder set = new StringBuilder("SET Processed='") + .append((processed ? "Y" : "N")) + .append("' WHERE C_InvoiceBatch_ID=").append(getC_InvoiceBatch_ID()); int noLine = DB.executeUpdate("UPDATE C_InvoiceBatchLine " + set, get_TrxName()); m_lines = null; log.fine(processed + " - Lines=" + noLine); diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java b/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java index 784bd956c6..76fb56d569 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java @@ -111,11 +111,11 @@ public class MInvoiceBatchLine extends X_C_InvoiceBatchLine { if (success) { - String sql = "UPDATE C_InvoiceBatch h " - + "SET DocumentAmt = NVL((SELECT SUM(LineTotalAmt) FROM C_InvoiceBatchLine l " - + "WHERE h.C_InvoiceBatch_ID=l.C_InvoiceBatch_ID AND l.IsActive='Y'),0) " - + "WHERE C_InvoiceBatch_ID=" + getC_InvoiceBatch_ID(); - DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE C_InvoiceBatch h ") + .append("SET DocumentAmt = NVL((SELECT SUM(LineTotalAmt) FROM C_InvoiceBatchLine l ") + .append("WHERE h.C_InvoiceBatch_ID=l.C_InvoiceBatch_ID AND l.IsActive='Y'),0) ") + .append("WHERE C_InvoiceBatch_ID=").append(getC_InvoiceBatch_ID()); + DB.executeUpdate(sql.toString(), get_TrxName()); } return success; } // afterSave diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java index 00a6226ebe..726245d2bb 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java @@ -308,8 +308,10 @@ public class MInvoiceLine extends X_C_InvoiceLine String desc = getDescription(); if (desc == null) setDescription(description); - else - setDescription(desc + " | " + description); + else{ + StringBuilder msgd = new StringBuilder(desc).append(" | ").append(description); + setDescription(msgd.toString()); + } } // addDescription /** @@ -702,7 +704,7 @@ public class MInvoiceLine extends X_C_InvoiceLine */ public String toString () { - StringBuffer sb = new StringBuffer ("MInvoiceLine[") + StringBuilder sb = new StringBuilder ("MInvoiceLine[") .append(get_ID()).append(",").append(getLine()) .append(",QtyInvoiced=").append(getQtyInvoiced()) .append(",LineNetAmt=").append(getLineNetAmt()) @@ -1005,13 +1007,14 @@ public class MInvoiceLine extends X_C_InvoiceLine MLandedCost[] lcs = MLandedCost.getLandedCosts(this); if (lcs.length == 0) return ""; - String sql = "DELETE C_LandedCostAllocation WHERE C_InvoiceLine_ID=" + getC_InvoiceLine_ID(); - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("DELETE C_LandedCostAllocation WHERE C_InvoiceLine_ID=").append(getC_InvoiceLine_ID()); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 0) log.info("Deleted #" + no); int inserted = 0; // *** Single Criteria *** + StringBuilder msgreturn; if (lcs.length == 1) { MLandedCost lc = lcs[0]; @@ -1038,8 +1041,10 @@ public class MInvoiceLine extends X_C_InvoiceLine MInOutLine iol = (MInOutLine)list.get(i); total = total.add(iol.getBase(lc.getLandedCostDistribution())); } - if (total.signum() == 0) - return "Total of Base values is 0 - " + lc.getLandedCostDistribution(); + if (total.signum() == 0){ + msgreturn = new StringBuilder("Total of Base values is 0 - ").append(lc.getLandedCostDistribution()); + return msgreturn.toString(); + } // Create Allocations for (int i = 0; i < list.size(); i++) { @@ -1059,8 +1064,10 @@ public class MInvoiceLine extends X_C_InvoiceLine result /= total.doubleValue(); lca.setAmt(result, getPrecision()); } - if (!lca.save()) - return "Cannot save line Allocation = " + lca; + if (!lca.save()){ + msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca); + return msgreturn.toString(); + } inserted++; } log.info("Inserted " + inserted); @@ -1071,8 +1078,10 @@ public class MInvoiceLine extends X_C_InvoiceLine else if (lc.getM_InOutLine_ID() != 0) { MInOutLine iol = new MInOutLine (getCtx(), lc.getM_InOutLine_ID(), get_TrxName()); - if (iol.isDescription() || iol.getM_Product_ID() == 0) - return "Invalid Receipt Line - " + iol; + if (iol.isDescription() || iol.getM_Product_ID() == 0){ + msgreturn = new StringBuilder("Invalid Receipt Line - ").append(iol); + return msgreturn.toString(); + } MLandedCostAllocation lca = new MLandedCostAllocation (this, lc.getM_CostElement_ID()); lca.setM_Product_ID(iol.getM_Product_ID()); lca.setM_AttributeSetInstance_ID(iol.getM_AttributeSetInstance_ID()); @@ -1085,7 +1094,8 @@ public class MInvoiceLine extends X_C_InvoiceLine // end MZ if (lca.save()) return ""; - return "Cannot save single line Allocation = " + lc; + msgreturn = new StringBuilder("Cannot save single line Allocation = ").append(lc); + return msgreturn.toString(); } // Single Product else if (lc.getM_Product_ID() != 0) @@ -1095,10 +1105,13 @@ public class MInvoiceLine extends X_C_InvoiceLine lca.setAmt(getLineNetAmt()); if (lca.save()) return ""; - return "Cannot save Product Allocation = " + lc; + msgreturn = new StringBuilder("Cannot save Product Allocation = ").append(lc); + return msgreturn.toString(); } - else - return "No Reference for " + lc; + else{ + msgreturn = new StringBuilder("No Reference for ").append(lc); + return msgreturn.toString(); + } } // *** Multiple Criteria *** @@ -1149,8 +1162,10 @@ public class MInvoiceLine extends X_C_InvoiceLine MInOutLine iol = (MInOutLine)list.get(i); total = total.add(iol.getBase(LandedCostDistribution)); } - if (total.signum() == 0) - return "Total of Base values is 0 - " + LandedCostDistribution; + if (total.signum() == 0){ + msgreturn = new StringBuilder("Total of Base values is 0 - ").append(LandedCostDistribution); + return msgreturn.toString(); + } // Create Allocations for (int i = 0; i < list.size(); i++) { @@ -1170,8 +1185,10 @@ public class MInvoiceLine extends X_C_InvoiceLine result /= total.doubleValue(); lca.setAmt(result, getPrecision()); } - if (!lca.save()) - return "Cannot save line Allocation = " + lca; + if (!lca.save()){ + msgreturn = new StringBuilder("Cannot save line Allocation = ").append(lca); + return msgreturn.toString(); + } inserted++; } diff --git a/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java b/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java index 9d21b55640..ce4e2a2a98 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java @@ -53,19 +53,19 @@ public class MInvoicePaySchedule extends X_C_InvoicePaySchedule public static MInvoicePaySchedule[] getInvoicePaySchedule(Properties ctx, int C_Invoice_ID, int C_InvoicePaySchedule_ID, String trxName) { - String sql = "SELECT * FROM C_InvoicePaySchedule ips WHERE IsActive='Y' "; + StringBuilder sql = new StringBuilder("SELECT * FROM C_InvoicePaySchedule ips WHERE IsActive='Y' "); if (C_Invoice_ID != 0) - sql += "AND C_Invoice_ID=? "; + sql.append("AND C_Invoice_ID=? "); else - sql += "AND EXISTS (SELECT * FROM C_InvoicePaySchedule x" - + " WHERE x.C_InvoicePaySchedule_ID=? AND ips.C_Invoice_ID=x.C_Invoice_ID) "; - sql += "ORDER BY DueDate"; + sql.append("AND EXISTS (SELECT * FROM C_InvoicePaySchedule x") + .append(" WHERE x.C_InvoicePaySchedule_ID=? AND ips.C_Invoice_ID=x.C_Invoice_ID) "); + sql.append("ORDER BY DueDate"); // ArrayList list = new ArrayList(); PreparedStatement pstmt = null; try { - pstmt = DB.prepareStatement(sql, trxName); + pstmt = DB.prepareStatement(sql.toString(), trxName); if (C_Invoice_ID != 0) pstmt.setInt(1, C_Invoice_ID); else @@ -205,9 +205,9 @@ public class MInvoicePaySchedule extends X_C_InvoicePaySchedule */ public String toString() { - StringBuffer sb = new StringBuffer("MInvoicePaySchedule["); - sb.append(get_ID()).append("-Due=" + getDueDate() + "/" + getDueAmt()) - .append(";Discount=").append(getDiscountDate() + "/" + getDiscountAmt()) + StringBuilder sb = new StringBuilder("MInvoicePaySchedule["); + sb.append(get_ID()).append("-Due=").append(getDueDate()).append("/").append(getDueAmt()) + .append(";Discount=").append(getDiscountDate()).append("/").append(getDiscountAmt()) .append("]"); return sb.toString(); } // toString diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceTax.java b/org.adempiere.base/src/org/compiere/model/MInvoiceTax.java index d1eee99490..d95309ef72 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceTax.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceTax.java @@ -248,7 +248,7 @@ public class MInvoiceTax extends X_C_InvoiceTax */ public String toString () { - StringBuffer sb = new StringBuffer ("MInvoiceTax["); + StringBuilder sb = new StringBuilder ("MInvoiceTax["); sb.append("C_Invoice_ID=").append(getC_Invoice_ID()) .append(",C_Tax_ID=").append(getC_Tax_ID()) .append(", Base=").append(getTaxBaseAmt()).append(",Tax=").append(getTaxAmt()) diff --git a/org.adempiere.base/src/org/compiere/model/MIssue.java b/org.adempiere.base/src/org/compiere/model/MIssue.java index fa51d35183..341128ff0b 100644 --- a/org.adempiere.base/src/org/compiere/model/MIssue.java +++ b/org.adempiere.base/src/org/compiere/model/MIssue.java @@ -155,7 +155,7 @@ public class MIssue extends X_AD_Issue public MIssue (LogRecord record) { this (Env.getCtx(), 0, null); - String summary = record.getMessage(); + StringBuilder summary = new StringBuilder(record.getMessage()); setSourceClassName(record.getSourceClassName()); setSourceMethodName(record.getSourceMethodName()); setLoggerName(record.getLoggerName()); @@ -163,11 +163,11 @@ public class MIssue extends X_AD_Issue if (t != null) { if (summary != null && summary.length() > 0) - summary = t.toString() + " " + summary; + summary = new StringBuilder(t.toString()).append(" ").append(summary); if (summary == null || summary.length() == 0) - summary = t.toString(); + summary = new StringBuilder(t.toString()); // - StringBuffer error = new StringBuffer(); + StringBuilder error = new StringBuilder(); StackTraceElement[] tes = t.getStackTrace(); int count = 0; for (int i = 0; i < tes.length; i++) @@ -179,9 +179,9 @@ public class MIssue extends X_AD_Issue error.append(s).append("\n"); if (count == 0) { - String source = element.getClassName() - + "." + element.getMethodName(); - setSourceClassName(source); + StringBuilder source = new StringBuilder(element.getClassName()) + .append(".").append(element.getMethodName()); + setSourceClassName(source.toString()); setLineNo(element.getLineNumber()); } count++; @@ -197,8 +197,8 @@ public class MIssue extends X_AD_Issue setStackTrace(cWriter.toString()); } if (summary == null || summary.length() == 0) - summary = "??"; - setIssueSummary(summary); + summary = new StringBuilder("??"); + setIssueSummary(summary.toString()); setRecord_ID(1); } // MIssue @@ -304,8 +304,10 @@ public class MIssue extends X_AD_Issue if (old == null || old.length() == 0) setComments (Comments); else if (!old.equals(Comments) - && old.indexOf(Comments) == -1) // something new - setComments (Comments + " | " + old); + && old.indexOf(Comments) == -1){ // something new + StringBuilder msgc = new StringBuilder(Comments).append(" | ").append(old); + setComments (msgc.toString()); + } } // addComments /** @@ -357,7 +359,7 @@ public class MIssue extends X_AD_Issue */ public String createAnswer() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); if (getA_Asset_ID() != 0) sb.append("Sign up for support at http://www.adempiere.org to receive answers."); else @@ -416,7 +418,7 @@ public class MIssue extends X_AD_Issue { if (true) return "-"; - StringBuffer parameter = new StringBuffer("?"); + StringBuilder parameter = new StringBuilder("?"); if (getRecord_ID() == 0) // don't report return "ID=0"; if (getRecord_ID() == 1) // new @@ -435,7 +437,8 @@ public class MIssue extends X_AD_Issue catch (Exception e) { log.severe(e.getLocalizedMessage()); - return "New-" + e.getLocalizedMessage(); + StringBuilder msgreturn = new StringBuilder("New-").append(e.getLocalizedMessage()); + return msgreturn.toString(); } } else // existing @@ -449,7 +452,8 @@ public class MIssue extends X_AD_Issue catch (Exception e) { log.severe(e.getLocalizedMessage()); - return "Update-" + e.getLocalizedMessage(); + StringBuilder msgreturn = new StringBuilder("Update-").append(e.getLocalizedMessage()); + return msgreturn.toString(); } } @@ -457,7 +461,7 @@ public class MIssue extends X_AD_Issue String target = "http://dev1/wstore/issueReportServlet"; try // Send GET Request { - StringBuffer urlString = new StringBuffer(target) + StringBuilder urlString = new StringBuilder(target) .append(parameter); URL url = new URL (urlString.toString()); URLConnection uc = url.openConnection(); @@ -465,15 +469,15 @@ public class MIssue extends X_AD_Issue } catch (Exception e) { - String msg = "Cannot connect to http://" + target; + StringBuilder msg = new StringBuilder("Cannot connect to http://").append(target); if (e instanceof FileNotFoundException || e instanceof ConnectException) - msg += "\nServer temporarily down - Please try again later"; + msg.append("\nServer temporarily down - Please try again later"); else { - msg += "\nCheck connection - " + e.getLocalizedMessage(); - log.log(Level.FINE, msg); + msg.append("\nCheck connection - ").append(e.getLocalizedMessage()); + log.log(Level.FINE, msg.toString()); } - return msg; + return msg.toString(); } return readResponse(in); } // report @@ -485,7 +489,7 @@ public class MIssue extends X_AD_Issue */ private String readResponse(InputStreamReader in) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); int Record_ID = 0; String ResponseText = null; String RequestDocumentNo = null; @@ -543,7 +547,7 @@ public class MIssue extends X_AD_Issue */ public String toString () { - StringBuffer sb = new StringBuffer ("MIssue["); + StringBuilder sb = new StringBuilder ("MIssue["); sb.append (get_ID()) .append ("-").append (getIssueSummary()) .append (",Record=").append (getRecord_ID()) diff --git a/org.adempiere.base/src/org/compiere/model/MIssueProject.java b/org.adempiere.base/src/org/compiere/model/MIssueProject.java index bd905b8804..b21ee35b2a 100644 --- a/org.adempiere.base/src/org/compiere/model/MIssueProject.java +++ b/org.adempiere.base/src/org/compiere/model/MIssueProject.java @@ -148,7 +148,7 @@ public class MIssueProject extends X_R_IssueProject */ public String toString () { - StringBuffer sb = new StringBuffer ("MIssueProject["); + StringBuilder sb = new StringBuilder ("MIssueProject["); sb.append (get_ID()) .append ("-").append (getName()) .append(",A_Asset_ID=").append(getA_Asset_ID()) diff --git a/org.adempiere.base/src/org/compiere/model/MIssueSystem.java b/org.adempiere.base/src/org/compiere/model/MIssueSystem.java index baa5ebf324..127d08030d 100644 --- a/org.adempiere.base/src/org/compiere/model/MIssueSystem.java +++ b/org.adempiere.base/src/org/compiere/model/MIssueSystem.java @@ -130,7 +130,7 @@ public class MIssueSystem extends X_R_IssueSystem */ public String toString () { - StringBuffer sb = new StringBuffer ("MIssueSystem["); + StringBuilder sb = new StringBuilder ("MIssueSystem["); sb.append(get_ID()) .append ("-").append (getDBAddress()) .append(",A_Asset_ID=").append(getA_Asset_ID()) diff --git a/org.adempiere.base/src/org/compiere/model/MIssueUser.java b/org.adempiere.base/src/org/compiere/model/MIssueUser.java index a621df91c6..a20b6370ca 100644 --- a/org.adempiere.base/src/org/compiere/model/MIssueUser.java +++ b/org.adempiere.base/src/org/compiere/model/MIssueUser.java @@ -133,7 +133,7 @@ public class MIssueUser extends X_R_IssueUser */ public String toString () { - StringBuffer sb = new StringBuffer ("MIssueUser["); + StringBuilder sb = new StringBuilder ("MIssueUser["); sb.append (get_ID()) .append ("-").append(getUserName()) .append(",AD_User_ID=").append(getAD_User_ID()) diff --git a/org.adempiere.base/src/org/compiere/model/MJournal.java b/org.adempiere.base/src/org/compiere/model/MJournal.java index 6dae4b1338..969c14e7fe 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournal.java +++ b/org.adempiere.base/src/org/compiere/model/MJournal.java @@ -203,8 +203,10 @@ public class MJournal extends X_GL_Journal implements DocAction String desc = getDescription(); if (desc == null) setDescription(description); - else - setDescription(desc + " | " + description); + else{ + StringBuilder msgd = new StringBuilder(desc).append(" | ").append(description); + setDescription(msgd.toString()); + } } /************************************************************************** @@ -279,10 +281,10 @@ public class MJournal extends X_GL_Journal implements DocAction super.setProcessed (processed); if (get_ID() == 0) return; - String sql = "UPDATE GL_JournalLine SET Processed='" - + (processed ? "Y" : "N") - + "' WHERE GL_Journal_ID=" + getGL_Journal_ID(); - int noLine = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE GL_JournalLine SET Processed='") + .append((processed ? "Y" : "N")) + .append("' WHERE GL_Journal_ID=").append(getGL_Journal_ID()); + int noLine = DB.executeUpdate(sql.toString(), get_TrxName()); log.fine(processed + " - Lines=" + noLine); } // setProcessed @@ -372,11 +374,11 @@ public class MJournal extends X_GL_Journal implements DocAction private boolean updateBatch() { if (getGL_JournalBatch_ID()!=0) { // idempiere 344 - nmicoud - String sql = "UPDATE GL_JournalBatch jb" - + " SET (TotalDr, TotalCr) = (SELECT COALESCE(SUM(TotalDr),0), COALESCE(SUM(TotalCr),0)" - + " FROM GL_Journal j WHERE j.IsActive='Y' AND jb.GL_JournalBatch_ID=j.GL_JournalBatch_ID) " - + "WHERE GL_JournalBatch_ID=" + getGL_JournalBatch_ID(); - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE GL_JournalBatch jb") + .append(" SET (TotalDr, TotalCr) = (SELECT COALESCE(SUM(TotalDr),0), COALESCE(SUM(TotalCr),0)") + .append(" FROM GL_Journal j WHERE j.IsActive='Y' AND jb.GL_JournalBatch_ID=j.GL_JournalBatch_ID) ") + .append("WHERE GL_JournalBatch_ID=").append(getGL_JournalBatch_ID()); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 1) log.warning("afterSave - Update Batch #" + no); return no == 1; @@ -398,7 +400,7 @@ public class MJournal extends X_GL_Journal implements DocAction } // process /** Process Message */ - private String m_processMsg = null; + private StringBuffer m_processMsg = null; /** Just Prepared Flag */ private boolean m_justPrepared = false; @@ -430,7 +432,7 @@ public class MJournal extends X_GL_Journal implements DocAction public String prepareIt() { log.info(toString()); - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); @@ -440,14 +442,14 @@ public class MJournal extends X_GL_Journal implements DocAction if (period == null) { log.warning("No Period for " + getDateAcct()); - m_processMsg = "@PeriodNotFound@"; + m_processMsg = new StringBuffer("@PeriodNotFound@"); return DocAction.STATUS_Invalid; } // Standard Period if (period.getC_Period_ID() != getC_Period_ID() && period.isStandardPeriod()) { - m_processMsg = "@PeriodNotValid@"; + m_processMsg = new StringBuffer("@PeriodNotValid@"); return DocAction.STATUS_Invalid; } boolean open = period.isOpen(dt.getDocBaseType(), getDateAcct()); @@ -455,7 +457,7 @@ public class MJournal extends X_GL_Journal implements DocAction { log.warning(period.getName() + ": Not open for " + dt.getDocBaseType() + " (" + getDateAcct() + ")"); - m_processMsg = "@PeriodClosed@"; + m_processMsg = new StringBuffer("@PeriodClosed@"); return DocAction.STATUS_Invalid; } @@ -463,7 +465,7 @@ public class MJournal extends X_GL_Journal implements DocAction MJournalLine[] lines = getLines(true); if (lines.length == 0) { - m_processMsg = "@NoLines@"; + m_processMsg = new StringBuffer("@NoLines@"); return DocAction.STATUS_Invalid; } @@ -479,8 +481,8 @@ public class MJournal extends X_GL_Journal implements DocAction // bcahya, BF [2789319] No check of Actual, Budget, Statistical attribute if (!line.getAccountElementValue().isActive()) { - m_processMsg = "@InActiveAccount@ - @Line@=" + line.getLine() - + " - " + line.getAccountElementValue(); + m_processMsg = new StringBuffer("@InActiveAccount@ - @Line@=").append(line.getLine()) + .append(" - ").append(line.getAccountElementValue()); return DocAction.STATUS_Invalid; } @@ -491,8 +493,8 @@ public class MJournal extends X_GL_Journal implements DocAction getPostingType().equals(POSTINGTYPE_Reservation) ) { - m_processMsg = "@DocControlledError@ - @Line@=" + line.getLine() - + " - " + line.getAccountElementValue(); + m_processMsg = new StringBuffer("@DocControlledError@ - @Line@=").append(line.getLine()) + .append(" - ").append(line.getAccountElementValue()); return DocAction.STATUS_Invalid; } // @@ -500,22 +502,22 @@ public class MJournal extends X_GL_Journal implements DocAction // bcahya, BF [2789319] No check of Actual, Budget, Statistical attribute if (getPostingType().equals(POSTINGTYPE_Actual) && !line.getAccountElementValue().isPostActual()) { - m_processMsg = "@PostingTypeActualError@ - @Line@=" + line.getLine() - + " - " + line.getAccountElementValue(); + m_processMsg = new StringBuffer("@PostingTypeActualError@ - @Line@=").append(line.getLine()) + .append(" - ").append(line.getAccountElementValue()); return DocAction.STATUS_Invalid; } if (getPostingType().equals(POSTINGTYPE_Budget) && !line.getAccountElementValue().isPostBudget()) { - m_processMsg = "@PostingTypeBudgetError@ - @Line@=" + line.getLine() - + " - " + line.getAccountElementValue(); + m_processMsg = new StringBuffer("@PostingTypeBudgetError@ - @Line@=").append(line.getLine()) + .append(" - ").append(line.getAccountElementValue()); return DocAction.STATUS_Invalid; } if (getPostingType().equals(POSTINGTYPE_Statistical) && !line.getAccountElementValue().isPostStatistical()) { - m_processMsg = "@PostingTypeStatisticalError@ - @Line@=" + line.getLine() - + " - " + line.getAccountElementValue(); + m_processMsg = new StringBuffer("@PostingTypeStatisticalError@ - @Line@=").append(line.getLine()) + .append(" - ").append(line.getAccountElementValue()); return DocAction.STATUS_Invalid; } // end BF [2789319] No check of Actual, Budget, Statistical attribute @@ -530,7 +532,7 @@ public class MJournal extends X_GL_Journal implements DocAction if (Env.ZERO.compareTo(getControlAmt()) != 0 && getControlAmt().compareTo(getTotalDr()) != 0) { - m_processMsg = "@ControlAmtError@"; + m_processMsg = new StringBuffer("@ControlAmtError@"); return DocAction.STATUS_Invalid; } @@ -540,7 +542,7 @@ public class MJournal extends X_GL_Journal implements DocAction MAcctSchemaGL gl = MAcctSchemaGL.get(getCtx(), getC_AcctSchema_ID()); if (gl == null || !gl.isUseSuspenseBalancing()) { - m_processMsg = "@UnbalancedJornal@"; + m_processMsg = new StringBuffer("@UnbalancedJornal@"); return DocAction.STATUS_Invalid; } } @@ -548,7 +550,7 @@ public class MJournal extends X_GL_Journal implements DocAction if (!DOCACTION_Complete.equals(getDocAction())) setDocAction(DOCACTION_Complete); - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -592,7 +594,7 @@ public class MJournal extends X_GL_Journal implements DocAction return status; } - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -604,7 +606,7 @@ public class MJournal extends X_GL_Journal implements DocAction String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE); if (valid != null) { - m_processMsg = valid; + m_processMsg = new StringBuffer(valid); return DocAction.STATUS_Invalid; } @@ -644,7 +646,7 @@ public class MJournal extends X_GL_Journal implements DocAction { log.info(toString()); // Before Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID)); if (m_processMsg != null) return false; @@ -660,7 +662,7 @@ public class MJournal extends X_GL_Journal implements DocAction } // After Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID)); if (m_processMsg != null) return false; @@ -676,7 +678,7 @@ public class MJournal extends X_GL_Journal implements DocAction { log.info(toString()); // Before Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE)); if (m_processMsg != null) return false; @@ -691,7 +693,7 @@ public class MJournal extends X_GL_Journal implements DocAction } // After Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE)); if (m_processMsg != null) return false; @@ -706,7 +708,7 @@ public class MJournal extends X_GL_Journal implements DocAction public boolean reverseCorrectIt() { // Before reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT)); if (m_processMsg != null) return false; @@ -716,7 +718,7 @@ public class MJournal extends X_GL_Journal implements DocAction return false; // After reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT)); if (m_processMsg != null) return false; @@ -739,12 +741,14 @@ public class MJournal extends X_GL_Journal implements DocAction reverse.setC_Period_ID(getC_Period_ID()); reverse.setDateAcct(getDateAcct()); // Reverse indicator - reverse.addDescription("(->" + getDocumentNo() + ")"); + StringBuilder msgd = new StringBuilder("(->").append(getDocumentNo()).append(")"); + reverse.addDescription(msgd.toString()); //FR [ 1948157 ] reverse.setReversal_ID(getGL_Journal_ID()); if (!reverse.save()) return null; - addDescription("(" + reverse.getDocumentNo() + "<-)"); + msgd = new StringBuilder("(").append(reverse.getDocumentNo()).append("<-)"); + addDescription(msgd.toString()); // Lines reverse.copyLinesFrom(this, null, 'C'); @@ -764,7 +768,7 @@ public class MJournal extends X_GL_Journal implements DocAction public boolean reverseAccrualIt() { // Before reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL)); if (m_processMsg != null) return false; @@ -774,7 +778,7 @@ public class MJournal extends X_GL_Journal implements DocAction return false; // After reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL)); if (m_processMsg != null) return false; @@ -797,12 +801,12 @@ public class MJournal extends X_GL_Journal implements DocAction reverse.set_ValueNoCheck ("C_Period_ID", null); // reset reverse.setDateAcct(reverse.getDateDoc()); // Reverse indicator - String description = reverse.getDescription(); - if (description == null) - description = "** " + getDocumentNo() + " **"; + StringBuilder description ; + if (reverse.getDescription() == null) + description = new StringBuilder("** ").append(getDocumentNo()).append(" **"); else - description += " ** " + getDocumentNo() + " **"; - reverse.setDescription(description); + description = new StringBuilder(reverse.getDescription()).append(" ** ").append(getDocumentNo()).append(" **"); + reverse.setDescription(description.toString()); if (!reverse.save()) return null; @@ -822,7 +826,7 @@ public class MJournal extends X_GL_Journal implements DocAction { log.info(toString()); // Before reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE)); if (m_processMsg != null) return false; @@ -834,7 +838,7 @@ public class MJournal extends X_GL_Journal implements DocAction setDocAction(DOCACTION_Complete); // After reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE)); if (m_processMsg != null) return false; @@ -848,7 +852,7 @@ public class MJournal extends X_GL_Journal implements DocAction */ public String getSummary() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getDocumentNo()); // : Total Lines = 123.00 (#1) sb.append(": ") @@ -868,7 +872,7 @@ public class MJournal extends X_GL_Journal implements DocAction */ public String toString () { - StringBuffer sb = new StringBuffer ("MJournal["); + StringBuilder sb = new StringBuilder ("MJournal["); sb.append(get_ID()).append(",").append(getDescription()) .append(",DR=").append(getTotalDr()) .append(",CR=").append(getTotalCr()) @@ -883,7 +887,8 @@ public class MJournal extends X_GL_Journal implements DocAction public String getDocumentInfo() { MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); - return dt.getName() + " " + getDocumentNo(); + StringBuilder msgreturn = new StringBuilder(dt.getName()).append(" ").append(getDocumentNo()); + return msgreturn.toString(); } // getDocumentInfo /** @@ -894,7 +899,8 @@ public class MJournal extends X_GL_Journal implements DocAction { try { - File temp = File.createTempFile(get_TableName()+get_ID()+"_", ".pdf"); + StringBuilder msgfile = new StringBuilder(get_TableName()).append(get_ID()).append("_"); + File temp = File.createTempFile(msgfile.toString(), ".pdf"); return createPDF (temp); } catch (Exception e) @@ -924,7 +930,7 @@ public class MJournal extends X_GL_Journal implements DocAction */ public String getProcessMsg() { - return m_processMsg; + return m_processMsg.toString(); } // getProcessMsg /** diff --git a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java index f9085c4a67..2d828d2835 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournalBatch.java +++ b/org.adempiere.base/src/org/compiere/model/MJournalBatch.java @@ -280,7 +280,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction } // process /** Process Message */ - private String m_processMsg = null; + private StringBuffer m_processMsg = null; /** Just Prepared Flag */ private boolean m_justPrepared = false; @@ -312,7 +312,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction public String prepareIt() { log.info(toString()); - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); @@ -320,7 +320,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction // Std Period open? if (!MPeriod.isOpen(getCtx(), getDateAcct(), dt.getDocBaseType(), getAD_Org_ID())) { - m_processMsg = "@PeriodClosed@"; + m_processMsg = new StringBuffer("@PeriodClosed@"); return DocAction.STATUS_Invalid; } @@ -328,7 +328,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction MJournal[] journals = getJournals(false); if (journals.length == 0) { - m_processMsg = "@NoLines@"; + m_processMsg = new StringBuffer("@NoLines@"); return DocAction.STATUS_Invalid; } @@ -352,7 +352,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction { journal.setDocStatus(status); journal.saveEx(); - m_processMsg = journal.getProcessMsg(); + m_processMsg = new StringBuffer(journal.getProcessMsg()); return status; } journal.setDocStatus(DOCSTATUS_InProgress); @@ -369,7 +369,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction if (Env.ZERO.compareTo(getControlAmt()) != 0 && getControlAmt().compareTo(getTotalDr()) != 0) { - m_processMsg = "@ControlAmtError@"; + m_processMsg = new StringBuffer("@ControlAmtError@"); return DocAction.STATUS_Invalid; } @@ -398,7 +398,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction } } - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -444,7 +444,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction return status; } - m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_BEFORE_COMPLETE)); if (m_processMsg != null) return DocAction.STATUS_Invalid; @@ -481,7 +481,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction journal.saveEx(); if (!DocAction.STATUS_Completed.equals(journal.getDocStatus())) { - m_processMsg = journal.getProcessMsg(); + m_processMsg = new StringBuffer(journal.getProcessMsg()); return journal.getDocStatus(); } } @@ -495,7 +495,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE); if (valid != null) { - m_processMsg = valid; + m_processMsg = new StringBuffer(valid); return DocAction.STATUS_Invalid; } @@ -531,11 +531,11 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction { log.info("voidIt - " + toString()); // Before Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_VOID)); if (m_processMsg != null) return false; // After Void - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_VOID)); if (m_processMsg != null) return false; @@ -550,7 +550,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction { log.info("closeIt - " + toString()); // Before Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_CLOSE)); if (m_processMsg != null) return false; @@ -570,7 +570,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction || DOCSTATUS_InProgress.equals(journal.getDocStatus()) || DOCSTATUS_Invalid.equals(journal.getDocStatus())) { - m_processMsg = "Journal not Completed: " + journal.getSummary(); + m_processMsg = new StringBuffer("Journal not Completed: ").append(journal.getSummary()); return false; } @@ -583,14 +583,14 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction { if (!journal.closeIt()) { - m_processMsg = "Cannot close: " + journal.getSummary(); + m_processMsg = new StringBuffer("Cannot close: ").append(journal.getSummary()); return false; } journal.saveEx(); } } // After Close - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_CLOSE)); if (m_processMsg != null) return false; @@ -606,7 +606,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction { log.info("reverseCorrectIt - " + toString()); // Before reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSECORRECT)); if (m_processMsg != null) return false; @@ -622,7 +622,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction ; else { - m_processMsg = "All Journals need to be Completed: " + journal.getSummary(); + m_processMsg = new StringBuffer("All Journals need to be Completed: ").append(journal.getSummary()); return false; } } @@ -633,12 +633,12 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction reverse.setC_Period_ID(getC_Period_ID()); reverse.setDateAcct(getDateAcct()); // Reverse indicator - String description = reverse.getDescription(); - if (description == null) - description = "** " + getDocumentNo() + " **"; + StringBuilder description ; + if (reverse.getDescription() == null) + description = new StringBuilder("** ").append(getDocumentNo()).append(" **"); else - description += " ** " + getDocumentNo() + " **"; - reverse.setDescription(description); + description = new StringBuilder(reverse.getDescription()).append(" ** ").append(getDocumentNo()).append(" **"); + reverse.setDescription(description.toString()); //[ 1948157 ] reverse.setReversal_ID(getGL_JournalBatch_ID()); reverse.saveEx(); @@ -652,7 +652,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction continue; if (journal.reverseCorrectIt(reverse.getGL_JournalBatch_ID()) == null) { - m_processMsg = "Could not reverse " + journal; + m_processMsg = new StringBuffer("Could not reverse ").append(journal); return false; } journal.saveEx(); @@ -662,7 +662,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction setReversal_ID(reverse.getGL_JournalBatch_ID()); saveEx(); // After reverseCorrect - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSECORRECT)); if (m_processMsg != null) return false; @@ -678,7 +678,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction { log.info("reverseAccrualIt - " + toString()); // Before reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REVERSEACCRUAL)); if (m_processMsg != null) return false; @@ -694,7 +694,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction ; else { - m_processMsg = "All Journals need to be Completed: " + journal.getSummary(); + m_processMsg = new StringBuffer("All Journals need to be Completed: ").append(journal.getSummary()); return false; } } @@ -704,12 +704,12 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction reverse.setDateDoc(new Timestamp(System.currentTimeMillis())); reverse.setDateAcct(reverse.getDateDoc()); // Reverse indicator - String description = reverse.getDescription(); - if (description == null) - description = "** " + getDocumentNo() + " **"; + StringBuilder description; + if (reverse.getDescription() == null) + description = new StringBuilder("** ").append(getDocumentNo()).append(" **"); else - description += " ** " + getDocumentNo() + " **"; - reverse.setDescription(description); + description = new StringBuilder(reverse.getDescription()).append(" ** ").append(getDocumentNo()).append(" **"); + reverse.setDescription(description.toString()); reverse.saveEx(); // Reverse Journals @@ -720,13 +720,13 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction continue; if (journal.reverseAccrualIt(reverse.getGL_JournalBatch_ID()) == null) { - m_processMsg = "Could not reverse " + journal; + m_processMsg = new StringBuffer("Could not reverse ").append(journal); return false; } journal.saveEx(); } // After reverseAccrual - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REVERSEACCRUAL)); if (m_processMsg != null) return false; @@ -742,7 +742,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction log.info("reActivateIt - " + toString()); // Before reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_BEFORE_REACTIVATE)); if (m_processMsg != null) return false; @@ -764,7 +764,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction setDocAction(DOCACTION_Complete); // After reActivate - m_processMsg = ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE); + m_processMsg = new StringBuffer(ModelValidationEngine.get().fireDocValidate(this,ModelValidator.TIMING_AFTER_REACTIVATE)); if (m_processMsg != null) return false; @@ -778,7 +778,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction */ public String getSummary() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(getDocumentNo()); // : Total Lines = 123.00 (#1) sb.append(": ") @@ -798,7 +798,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction */ public String toString () { - StringBuffer sb = new StringBuffer ("MJournalBatch["); + StringBuilder sb = new StringBuilder ("MJournalBatch["); sb.append(get_ID()).append(",").append(getDescription()) .append(",DR=").append(getTotalDr()) .append(",CR=").append(getTotalCr()) @@ -813,7 +813,8 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction public String getDocumentInfo() { MDocType dt = MDocType.get(getCtx(), getC_DocType_ID()); - return dt.getName() + " " + getDocumentNo(); + StringBuilder msgreturn = new StringBuilder(dt.getName()).append(" ").append(getDocumentNo()); + return msgreturn.toString(); } // getDocumentInfo /** @@ -824,7 +825,8 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction { try { - File temp = File.createTempFile(get_TableName()+get_ID()+"_", ".pdf"); + StringBuilder msgfile = new StringBuilder(get_TableName()).append(get_ID()).append("_"); + File temp = File.createTempFile(msgfile.toString(), ".pdf"); return createPDF (temp); } catch (Exception e) @@ -854,7 +856,7 @@ public class MJournalBatch extends X_GL_JournalBatch implements DocAction */ public String getProcessMsg() { - return m_processMsg; + return m_processMsg.toString(); } // getProcessMsg /** diff --git a/org.adempiere.base/src/org/compiere/model/MJournalLine.java b/org.adempiere.base/src/org/compiere/model/MJournalLine.java index 08d2af1aa4..4f05c677d3 100644 --- a/org.adempiere.base/src/org/compiere/model/MJournalLine.java +++ b/org.adempiere.base/src/org/compiere/model/MJournalLine.java @@ -357,24 +357,24 @@ public class MJournalLine extends X_GL_JournalLine private boolean updateJournalTotal() { // Update Journal Total - String sql = "UPDATE GL_Journal j" - + " SET (TotalDr, TotalCr) = (SELECT COALESCE(SUM(AmtAcctDr),0), COALESCE(SUM(AmtAcctCr),0)" // croo Bug# 1789935 - + " FROM GL_JournalLine jl WHERE jl.IsActive='Y' AND j.GL_Journal_ID=jl.GL_Journal_ID) " - + "WHERE GL_Journal_ID=" + getGL_Journal_ID(); - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("UPDATE GL_Journal j") + .append(" SET (TotalDr, TotalCr) = (SELECT COALESCE(SUM(AmtAcctDr),0), COALESCE(SUM(AmtAcctCr),0)") // croo Bug# 1789935 + .append(" FROM GL_JournalLine jl WHERE jl.IsActive='Y' AND j.GL_Journal_ID=jl.GL_Journal_ID) ") + .append("WHERE GL_Journal_ID=").append(getGL_Journal_ID()); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 1) log.warning("afterSave - Update Journal #" + no); // Update Batch Total int GL_JournalBatch_ID=DB.getSQLValue(get_TrxName(), "SELECT GL_JournalBatch_ID FROM GL_Journal WHERE GL_Journal_ID=?", getGL_Journal_ID()); if (GL_JournalBatch_ID!=0) { // idempiere 344 - nmicoud - sql = "UPDATE GL_JournalBatch jb" - + " SET (TotalDr, TotalCr) = (SELECT COALESCE(SUM(TotalDr),0), COALESCE(SUM(TotalCr),0)" - + " FROM GL_Journal j WHERE jb.GL_JournalBatch_ID=j.GL_JournalBatch_ID) " - + "WHERE GL_JournalBatch_ID=" - + "(SELECT DISTINCT GL_JournalBatch_ID FROM GL_Journal WHERE GL_Journal_ID=" - + getGL_Journal_ID() + ")"; - no = DB.executeUpdate(sql, get_TrxName()); + sql = new StringBuilder("UPDATE GL_JournalBatch jb") + .append(" SET (TotalDr, TotalCr) = (SELECT COALESCE(SUM(TotalDr),0), COALESCE(SUM(TotalCr),0)") + .append(" FROM GL_Journal j WHERE jb.GL_JournalBatch_ID=j.GL_JournalBatch_ID) ") + .append("WHERE GL_JournalBatch_ID=") + .append("(SELECT DISTINCT GL_JournalBatch_ID FROM GL_Journal WHERE GL_Journal_ID=") + .append(getGL_Journal_ID()).append(")"); + no = DB.executeUpdate(sql.toString(), get_TrxName()); if (no != 1) log.warning("Update Batch #" + no); } diff --git a/org.adempiere.base/src/org/compiere/model/MLandedCost.java b/org.adempiere.base/src/org/compiere/model/MLandedCost.java index 3e5c873df2..65025d78bb 100644 --- a/org.adempiere.base/src/org/compiere/model/MLandedCost.java +++ b/org.adempiere.base/src/org/compiere/model/MLandedCost.java @@ -155,7 +155,7 @@ public class MLandedCost extends X_C_LandedCost */ public String toString () { - StringBuffer sb = new StringBuffer ("MLandedCost["); + StringBuilder sb = new StringBuilder ("MLandedCost["); sb.append (get_ID ()) .append (",CostDistribution=").append (getLandedCostDistribution()) .append(",M_CostElement_ID=").append(getM_CostElement_ID()); diff --git a/org.adempiere.base/src/org/compiere/model/MLdapProcessor.java b/org.adempiere.base/src/org/compiere/model/MLdapProcessor.java index 188ed74263..ce5b5a8a71 100755 --- a/org.adempiere.base/src/org/compiere/model/MLdapProcessor.java +++ b/org.adempiere.base/src/org/compiere/model/MLdapProcessor.java @@ -121,8 +121,9 @@ public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProce */ public String getInfo() { - return "Auth=" + m_auth - + ", OK=" + m_ok + ", Error=" + m_error; + StringBuilder msgreturn = new StringBuilder("Auth=").append(m_auth) + .append(", OK=").append(m_ok).append(", Error=").append(m_error); + return msgreturn.toString(); } // getInfo /** @@ -180,10 +181,10 @@ public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProce { if (getKeepLogDays() < 1) return 0; - String sql = "DELETE AD_LdapProcessorLog " - + "WHERE AD_LdapProcessor_ID=" + getAD_LdapProcessor_ID() - + " AND (Created+" + getKeepLogDays() + ") < SysDate"; - int no = DB.executeUpdate(sql, get_TrxName()); + StringBuilder sql = new StringBuilder("DELETE AD_LdapProcessorLog ") + .append("WHERE AD_LdapProcessor_ID=").append(getAD_LdapProcessor_ID()) + .append(" AND (Created+").append(getKeepLogDays()).append(") < SysDate"); + int no = DB.executeUpdate(sql.toString(), get_TrxName()); return no; } // deleteLog @@ -211,7 +212,7 @@ public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProce */ public String toString() { - StringBuffer sb = new StringBuffer ("MLdapProcessor["); + StringBuilder sb = new StringBuilder ("MLdapProcessor["); sb.append (get_ID()).append ("-").append (getName()) .append (",Port=").append (getLdapPort()) .append ("]"); @@ -233,35 +234,35 @@ public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProce if (ldapUser == null) ldapUser = new MLdapUser(); - String error = null; - String info = null; + StringBuilder error = null; + StringBuilder info = null; // User if (usr == null || usr.trim().length () == 0) { - error = "@NotFound@ User"; - ldapUser.setErrorString(error); + error = new StringBuilder("@NotFound@ User"); + ldapUser.setErrorString(error.toString()); m_error++; - log.warning (error); + log.warning (error.toString()); return ldapUser; } usr = usr.trim(); // Client if (o == null || o.length () == 0) { - error = "@NotFound@ O"; - ldapUser.setErrorString(error); + error = new StringBuilder("@NotFound@ O"); + ldapUser.setErrorString(error.toString()); m_error++; - log.warning (error); + log.warning (error.toString()); return ldapUser; } int AD_Client_ID = findClient(o); if (AD_Client_ID == 0) { - error = "@NotFound@ O=" + o; - ldapUser.setErrorString(error); + error = new StringBuilder("@NotFound@ O=").append(o); + ldapUser.setErrorString(error.toString()); m_error++; - log.config (error); + log.config (error.toString()); return ldapUser; } // Optional Interest Area @@ -271,10 +272,10 @@ public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProce R_InterestArea_ID = findInterestArea (AD_Client_ID, ou); if (R_InterestArea_ID == 0) { - error = "@NotFound@ OU=" + ou; - ldapUser.setErrorString(error); + error = new StringBuilder("@NotFound@ OU=").append(ou); + ldapUser.setErrorString(error.toString()); m_error++; - log.config (error); + log.config (error.toString()); return ldapUser; } } @@ -322,7 +323,7 @@ public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProce catch (Exception e) { log.log (Level.SEVERE, sql, e); - error = "System Error"; + error = new StringBuilder("System Error"); } finally { @@ -332,51 +333,51 @@ public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProce if (error != null) { m_error++; - ldapUser.setErrorString(error); + ldapUser.setErrorString(error.toString()); return ldapUser; } // if (AD_User_ID == 0) { - error = "@NotFound@ User=" + usr; - info = "User not found - " + usr; + error = new StringBuilder("@NotFound@ User=").append(usr); + info = new StringBuilder("User not found - ").append(usr); } else if (!IsActive) { - error = "@NotFound@ User=" + usr; - info = "User not active - " + usr; + error = new StringBuilder("@NotFound@ User=").append(usr); + info = new StringBuilder("User not active - ").append(usr); } else if (EMailVerify == null) { - error = "@UserNotVerified@ User=" + usr; - info = "User EMail not verified - " + usr; + error = new StringBuilder("@UserNotVerified@ User=").append(usr); + info = new StringBuilder("User EMail not verified - ").append(usr); } else if (usr.equalsIgnoreCase(LdapUser)) - info = "User verified - Ldap=" + usr - + (isUnique ? "" : " - Not Unique"); + info = new StringBuilder("User verified - Ldap=").append(usr) + .append((isUnique ? "" : " - Not Unique")); else if (usr.equalsIgnoreCase(Value)) - info = "User verified - Value=" + usr - + (isUnique ? "" : " - Not Unique"); + info = new StringBuilder("User verified - Value=").append(usr) + .append((isUnique ? "" : " - Not Unique")); else if (usr.equalsIgnoreCase(EMail)) - info = "User verified - EMail=" + usr - + (isUnique ? "" : " - Not Unique"); + info = new StringBuilder("User verified - EMail=").append(usr) + .append((isUnique ? "" : " - Not Unique")); else - info = "User verified ?? " + usr - + " - Name=" + Name - + ", Ldap=" + LdapUser + ", Value=" + Value - + (isUnique ? "" : " - Not Unique"); + info = new StringBuilder("User verified ?? ").append(usr) + .append(" - Name=").append(Name) + .append(", Ldap=").append(LdapUser).append(", Value=").append(Value) + .append((isUnique ? "" : " - Not Unique")); // Error if (error != null) // should use Language of the User { - logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info, error); - ldapUser.setErrorString(Msg.translate (getCtx(), error)); + logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info.toString(), error.toString()); + ldapUser.setErrorString(Msg.translate (getCtx(), error.toString())); return ldapUser; } // Done if (R_InterestArea_ID == 0) { - logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info, null); + logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info.toString(), null); ldapUser.setOrg(o); ldapUser.setOrgUnit(ou); ldapUser.setUserId(usr); @@ -407,7 +408,7 @@ public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProce catch (Exception e) { log.log (Level.SEVERE, sql, e); - error = "System Error (2)"; + error = new StringBuilder("System Error (2)"); } finally { @@ -418,38 +419,38 @@ public class MLdapProcessor extends X_AD_LdapProcessor implements AdempiereProce if (error != null) { m_error++; - ldapUser.setErrorString(error); + ldapUser.setErrorString(error.toString()); return ldapUser; } if (!found) { - error = "@UserNotSubscribed@ User=" + usr; - info = "No User Interest - " + usr - + " - R_InterestArea_ID=" + R_InterestArea_ID; + error = new StringBuilder("@UserNotSubscribed@ User=").append(usr); + info = new StringBuilder("No User Interest - ").append(usr) + .append(" - R_InterestArea_ID=").append(R_InterestArea_ID); } else if (OptOutDate != null) { - error = "@UserNotSubscribed@ User=" + usr + " @OptOutDate@=" + OptOutDate; - info = "Opted out - " + usr + " - OptOutDate=" + OptOutDate; + error = new StringBuilder("@UserNotSubscribed@ User=").append(usr).append(" @OptOutDate@=").append(OptOutDate); + info = new StringBuilder("Opted out - ").append(usr).append(" - OptOutDate=").append(OptOutDate); } else if (!IsActive) { - error = "@UserNotSubscribed@ User=" + usr; - info = "User Interest Not Active - " + usr; + error = new StringBuilder("@UserNotSubscribed@ User=").append(usr); + info = new StringBuilder("User Interest Not Active - ").append(usr); } else - info = "User subscribed - " + usr; + info = new StringBuilder("User subscribed - ").append(usr); if (error != null) // should use Language of the User { - logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info, error); - ldapUser.setErrorString(Msg.translate (getCtx(), error)); + logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info.toString(), error.toString()); + ldapUser.setErrorString(Msg.translate (getCtx(), error.toString())); return ldapUser; } // Done - logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info, null); + logAccess (AD_Client_ID, AD_User_ID, R_InterestArea_ID, info.toString(), null); ldapUser.setOrg(o); ldapUser.setOrgUnit(ou); ldapUser.setUserId(usr); diff --git a/org.adempiere.base/src/org/compiere/model/MLocation.java b/org.adempiere.base/src/org/compiere/model/MLocation.java index d49e9d0c5d..5e12ed88dd 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocation.java +++ b/org.adempiere.base/src/org/compiere/model/MLocation.java @@ -453,7 +453,7 @@ public class MLocation extends X_C_Location implements Comparator boolean local = getC_Country_ID() == MCountry.getDefault(getCtx()).getC_Country_ID(); String inStr = local ? c.getDisplaySequenceLocal() : c.getDisplaySequence(); - StringBuffer outStr = new StringBuffer(); + StringBuilder outStr = new StringBuilder(); String token; int i = inStr.indexOf('@'); @@ -519,7 +519,7 @@ public class MLocation extends X_C_Location implements Comparator */ public String toString() { - StringBuffer retStr = new StringBuffer(); + StringBuilder retStr = new StringBuilder(); if (isAddressLinesReverse()) { // City, Region, Postal @@ -556,7 +556,7 @@ public class MLocation extends X_C_Location implements Comparator */ public String toStringCR() { - StringBuffer retStr = new StringBuffer(); + StringBuilder retStr = new StringBuilder(); if (isAddressLinesReverse()) { // City, Region, Postal @@ -593,7 +593,7 @@ public class MLocation extends X_C_Location implements Comparator */ public String toStringX() { - StringBuffer sb = new StringBuffer("MLocation=["); + StringBuilder sb = new StringBuilder("MLocation=["); sb.append(get_ID()) .append(",C_Country_ID=").append(getC_Country_ID()) .append(",C_Region_ID=").append(getC_Region_ID()) @@ -650,10 +650,12 @@ public class MLocation extends X_C_Location implements Comparator && ("Y".equals(Env.getContext(getCtx(), "$Element_LF")) || "Y".equals(Env.getContext(getCtx(), "$Element_LT"))) && (is_ValueChanged("Postal") || is_ValueChanged("City")) - ) - MAccount.updateValueDescription(getCtx(), - "(C_LocFrom_ID=" + getC_Location_ID() - + " OR C_LocTo_ID=" + getC_Location_ID() + ")", get_TrxName()); + ){ + StringBuilder msgup = new StringBuilder( + "(C_LocFrom_ID=").append(getC_Location_ID()) + .append(" OR C_LocTo_ID=").append(getC_Location_ID()).append(")"); + MAccount.updateValueDescription(getCtx(), msgup.toString(), get_TrxName()); + } //Update BP_Location name IDEMPIERE 417 if (get_TrxName().startsWith(PO.LOCAL_TRX_PREFIX)) { // saved without trx @@ -676,14 +678,14 @@ public class MLocation extends X_C_Location implements Comparator public String getMapsLocation() { MRegion region = new MRegion(Env.getCtx(), getC_Region_ID(), get_TrxName()); - String address = ""; - address = address + (getAddress1() != null ? getAddress1() + ", " : ""); - address = address + (getAddress2() != null ? getAddress2() + ", " : ""); - address = address + (getCity() != null ? getCity() + ", " : ""); - address = address + (region.getName() != null ? region.getName() + ", " : ""); - address = address + (getCountryName() != null ? getCountryName() : ""); + StringBuilder address = new StringBuilder(); + address.append((getAddress1() != null ? getAddress1() + ", " : "")); + address.append((getAddress2() != null ? getAddress2() + ", " : "")); + address.append((getCity() != null ? getCity() + ", " : "")); + address.append((region.getName() != null ? region.getName() + ", " : "")); + address.append((getCountryName() != null ? getCountryName() : "")); - return address.replace(" ", "+"); + return address.toString().replace(" ", "+"); } } // MLocation diff --git a/org.adempiere.base/src/org/compiere/model/MLocationLookup.java b/org.adempiere.base/src/org/compiere/model/MLocationLookup.java index 34fb33ac8d..85f3b3286d 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocationLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MLocationLookup.java @@ -63,8 +63,10 @@ public final class MLocationLookup extends Lookup if (value == null) return null; MLocation loc = getLocation (value, null); - if (loc == null) - return "<" + value.toString() + ">"; + if (loc == null){ + StringBuilder msgreturn = new StringBuilder("<").append(value.toString()).append(">"); + return msgreturn.toString(); + } return loc.toString(); } // getDisplay diff --git a/org.adempiere.base/src/org/compiere/model/MLocator.java b/org.adempiere.base/src/org/compiere/model/MLocator.java index c9c7d6ee7d..7337e70a91 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocator.java +++ b/org.adempiere.base/src/org/compiere/model/MLocator.java @@ -269,8 +269,10 @@ public class MLocator extends X_M_Locator public String getWarehouseName() { MWarehouse wh = MWarehouse.get(getCtx(), getM_Warehouse_ID()); - if (wh.get_ID() == 0) - return "<" + getM_Warehouse_ID() + ">"; + if (wh.get_ID() == 0){ + StringBuilder msgreturn = new StringBuilder("<").append(getM_Warehouse_ID()).append(">"); + return msgreturn.toString(); + } return wh.getName(); } // getWarehouseName diff --git a/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java b/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java index 9eaf2f47ee..608c046b78 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java @@ -191,8 +191,10 @@ public final class MLocatorLookup extends Lookup implements Serializable return ""; // NamePair display = get (value); - if (display == null) - return "<" + value.toString() + ">"; + if (display == null){ + StringBuilder msgreturn = new StringBuilder("<").append(value.toString()).append(">"); + return msgreturn.toString(); + } return display.toString(); } // getDisplay @@ -256,7 +258,8 @@ public final class MLocatorLookup extends Lookup implements Serializable */ public String toString() { - return "MLocatorLookup[Size=" + m_lookup.size() + "]"; + StringBuilder msgreturn = new StringBuilder("MLocatorLookup[Size=").append(m_lookup.size()).append("]"); + return msgreturn.toString(); } // toString @@ -320,7 +323,7 @@ public final class MLocatorLookup extends Lookup implements Serializable int local_only_warehouse_id = getOnly_Warehouse_ID(); // [ 1674891 ] MLocatorLookup - weird error int local_only_product_id = getOnly_Product_ID(); - StringBuffer sql = new StringBuffer("SELECT * FROM M_Locator ") + StringBuilder sql = new StringBuilder("SELECT * FROM M_Locator ") .append(" WHERE IsActive='Y'"); if (local_only_warehouse_id != 0) diff --git a/org.adempiere.base/src/org/compiere/model/MLookup.java b/org.adempiere.base/src/org/compiere/model/MLookup.java index b1b6fe7d2b..420002054f 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MLookup.java @@ -223,8 +223,10 @@ public final class MLookup extends Lookup implements Serializable return ""; // Object display = get (key); - if (display == null) - return "<" + key.toString() + ">"; + if (display == null){ + StringBuilder msgreturn = new StringBuilder("<").append(key.toString()).append(">"); + return msgreturn.toString(); + } return display.toString(); } // getDisplay @@ -251,10 +253,11 @@ public final class MLookup extends Lookup implements Serializable */ public String toString() { - return "MLookup[" + m_info.KeyColumn + ",Column_ID=" + m_info.Column_ID - + ",Size=" + m_lookup.size() + ",Validated=" + isValidated() - + "-" + getValidation() - + "]"; + StringBuilder msgreturn = new StringBuilder("MLookup[").append(m_info.KeyColumn).append(",Column_ID=").append(m_info.Column_ID) + .append(",Size=").append(m_lookup.size()).append(",Validated=").append(isValidated()) + .append("-").append(getValidation()) + .append("]"); + return msgreturn.toString(); } // toString /** @@ -665,7 +668,7 @@ public final class MLookup extends Lookup implements Serializable long startTime = System.currentTimeMillis(); if (Ini.isClient()) MLookupCache.loadStart (m_info); - String sql = m_info.Query; + StringBuilder sql = new StringBuilder(m_info.Query); // not validated if (!m_info.IsValidated) @@ -692,14 +695,13 @@ public final class MLookup extends Lookup implements Serializable // int posOrder = sql.lastIndexOf(" ORDER BY "); if (posOrder != -1) - sql = sql.substring(0, posOrder) - + (hasWhere ? " AND " : " WHERE ") - + validation - + sql.substring(posOrder); + sql = new StringBuilder(sql.substring(0, posOrder)) + .append((hasWhere ? " AND " : " WHERE ")) + .append(validation) + .append(sql.substring(posOrder)); else - sql += (hasWhere ? " AND " : " WHERE ") - - + validation; + sql.append((hasWhere ? " AND " : " WHERE ")) + .append(validation); if (CLogMgt.isLevelFinest()) log.fine(m_info.KeyColumn + ": Validation=" + validation); } @@ -712,7 +714,7 @@ public final class MLookup extends Lookup implements Serializable } // if (CLogMgt.isLevelFiner()) - Env.setContext(m_info.ctx, Env.WINDOW_MLOOKUP, m_info.Column_ID, m_info.KeyColumn, sql); + Env.setContext(m_info.ctx, Env.WINDOW_MLOOKUP, m_info.Column_ID, m_info.KeyColumn, sql.toString()); if (CLogMgt.isLevelFinest()) log.fine(m_info.KeyColumn + ": " + sql); @@ -726,7 +728,7 @@ public final class MLookup extends Lookup implements Serializable try { // SELECT Key, Value, Name, IsActive FROM ... - pstmt = DB.prepareStatement(sql, null); + pstmt = DB.prepareStatement(sql.toString(), null); rs = pstmt.executeQuery(); // Get first ... rows @@ -735,16 +737,16 @@ public final class MLookup extends Lookup implements Serializable { if (rows++ > MAX_ROWS) { - String s = m_info.KeyColumn + ": Loader - Too many records"; + StringBuilder s = new StringBuilder(m_info.KeyColumn).append(": Loader - Too many records"); if (m_info.Column_ID > 0) { MColumn mColumn = MColumn.get(m_info.ctx, m_info.Column_ID); String column = mColumn.getColumnName(); - s = s + ", Column="+column; + s.append(", Column=").append(column); String tableName = MTable.getTableName(m_info.ctx, mColumn.getAD_Table_ID()); - s = s + ", Table="+tableName; + s.append(", Table=").append(tableName); } - log.warning(s); + log.warning(s.toString()); break; } // check for interrupted every 10 rows @@ -752,23 +754,23 @@ public final class MLookup extends Lookup implements Serializable break; // load data - String name = rs.getString(3); + StringBuilder name = new StringBuilder(rs.getString(3)); boolean isActive = rs.getString(4).equals("Y"); if (!isActive) { - name = INACTIVE_S + name + INACTIVE_E; + name.append(INACTIVE_S).append(INACTIVE_E); m_hasInactive = true; } if (isNumber) { int key = rs.getInt(1); - KeyNamePair p = new KeyNamePair(key, name); + KeyNamePair p = new KeyNamePair(key, name.toString()); m_lookup.put(new Integer(key), p); } else { String value = rs.getString(2); - ValueNamePair p = new ValueNamePair(value, name); + ValueNamePair p = new ValueNamePair(value, name.toString()); m_lookup.put(value, p); } // log.fine( m_info.KeyColumn + ": " + name); diff --git a/org.adempiere.base/src/org/compiere/model/MLookupCache.java b/org.adempiere.base/src/org/compiere/model/MLookupCache.java index 9a62d94444..fc0e15fd98 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookupCache.java +++ b/org.adempiere.base/src/org/compiere/model/MLookupCache.java @@ -69,7 +69,7 @@ public class MLookupCache if (info == null) return String.valueOf(System.currentTimeMillis()); // - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(info.WindowNo).append(":") // .append(info.Column_ID) .append(info.KeyColumn) @@ -125,7 +125,7 @@ public class MLookupCache */ public static void cacheReset (int WindowNo) { - String key = String.valueOf(WindowNo) + ":"; + StringBuilder key = new StringBuilder(String.valueOf(WindowNo)).append(":"); int startNo = s_loadedLookups.size(); // find keys of Lookups to delete ArrayList toDelete = new ArrayList(); @@ -133,7 +133,7 @@ public class MLookupCache while (iterator.hasNext()) { String info = (String)iterator.next(); - if (info != null && info.startsWith(key)) + if (info != null && info.startsWith(key.toString())) toDelete.add(info); } diff --git a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java index f979518461..a60c7cb269 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookupFactory.java +++ b/org.adempiere.base/src/org/compiere/model/MLookupFactory.java @@ -290,31 +290,31 @@ public class MLookupFactory static public MLookupInfo getLookup_List(Language language, int AD_Reference_Value_ID) { String byValue = DB.getSQLValueString(null, "SELECT IsOrderByValue FROM AD_Reference WHERE AD_Reference_ID = ? ", AD_Reference_Value_ID); - StringBuffer realSQL = new StringBuffer ("SELECT NULL, AD_Ref_List.Value,"); + StringBuilder realSQL = new StringBuilder ("SELECT NULL, AD_Ref_List.Value,"); MClient client = MClient.get(Env.getCtx()); - String AspFilter=""; + StringBuilder AspFilter = new StringBuilder(); if ( client.isUseASP() ) { - AspFilter=" AND AD_Ref_List.AD_Ref_List_ID NOT IN ( " - +" SELECT li.AD_Ref_List_ID" - +" FROM ASP_Ref_List li" - +" INNER JOIN ASP_Level l ON ( li.ASP_Level_ID = l.ASP_Level_ID)" - +" INNER JOIN ASP_ClientLevel cl on (l.ASP_Level_ID = cl.ASP_Level_ID)" - +" INNER JOIN AD_Client c on (cl.AD_Client_ID = c.AD_Client_ID)" - +" WHERE li.AD_Reference_ID="+AD_Reference_Value_ID - +" AND li.IsActive='Y'" - +" AND c.AD_Client_ID="+client.getAD_Client_ID() - +" AND li.ASP_Status='H')"; + AspFilter.append(" AND AD_Ref_List.AD_Ref_List_ID NOT IN ( ") + .append(" SELECT li.AD_Ref_List_ID") + .append(" FROM ASP_Ref_List li") + .append(" INNER JOIN ASP_Level l ON ( li.ASP_Level_ID = l.ASP_Level_ID)") + .append(" INNER JOIN ASP_ClientLevel cl on (l.ASP_Level_ID = cl.ASP_Level_ID)") + .append(" INNER JOIN AD_Client c on (cl.AD_Client_ID = c.AD_Client_ID)") + .append(" WHERE li.AD_Reference_ID=").append(AD_Reference_Value_ID) + .append(" AND li.IsActive='Y'") + .append(" AND c.AD_Client_ID=").append(client.getAD_Client_ID()) + .append(" AND li.ASP_Status='H')"); } if (Env.isBaseLanguage(language, "AD_Ref_List")) realSQL.append("AD_Ref_List.Name,AD_Ref_List.IsActive FROM AD_Ref_List "); else - realSQL.append("trl.Name, AD_Ref_List.IsActive " - + "FROM AD_Ref_List INNER JOIN AD_Ref_List_Trl trl " - + " ON (AD_Ref_List.AD_Ref_List_ID=trl.AD_Ref_List_ID AND trl.AD_Language='") + realSQL.append("trl.Name, AD_Ref_List.IsActive ") + .append("FROM AD_Ref_List INNER JOIN AD_Ref_List_Trl trl ") + .append(" ON (AD_Ref_List.AD_Ref_List_ID=trl.AD_Ref_List_ID AND trl.AD_Language='") .append(language.getAD_Language()).append("')"); realSQL.append(" WHERE AD_Ref_List.AD_Reference_ID=").append(AD_Reference_Value_ID); - realSQL.append(AspFilter); + realSQL.append(AspFilter.toString()); if ("Y".equals(byValue)) realSQL.append(" ORDER BY 2"); else @@ -334,13 +334,13 @@ public class MLookupFactory static public String getLookup_ListEmbed(Language language, int AD_Reference_Value_ID, String linkColumnName) { - StringBuffer realSQL = new StringBuffer ("SELECT "); + StringBuilder realSQL = new StringBuilder ("SELECT "); if (Env.isBaseLanguage(language, "AD_Ref_List")) realSQL.append("AD_Ref_List.Name FROM AD_Ref_List "); else - realSQL.append("trl.Name " - + "FROM AD_Ref_List INNER JOIN AD_Ref_List_Trl trl " - + " ON (AD_Ref_List.AD_Ref_List_ID=trl.AD_Ref_List_ID AND trl.AD_Language='") + realSQL.append("trl.Name ") + .append("FROM AD_Ref_List INNER JOIN AD_Ref_List_Trl trl ") + .append(" ON (AD_Ref_List.AD_Ref_List_ID=trl.AD_Ref_List_ID AND trl.AD_Language='") .append(language.getAD_Language()).append("')"); realSQL.append(" WHERE AD_Ref_List.AD_Reference_ID=").append(AD_Reference_Value_ID) .append(" AND AD_Ref_List.Value=").append(linkColumnName); @@ -362,7 +362,7 @@ public class MLookupFactory int WindowNo, int AD_Reference_Value_ID) { // Try cache - assume no language change - String key = Env.getAD_Client_ID(ctx) + "|" + String.valueOf(AD_Reference_Value_ID); + StringBuilder key = new StringBuilder(Env.getAD_Client_ID(ctx)).append("|").append(String.valueOf(AD_Reference_Value_ID)); MLookupInfo retValue = (MLookupInfo)s_cacheRefTable.get(key); if (retValue != null) { @@ -434,7 +434,7 @@ public class MLookupFactory return null; } - StringBuffer realSQL = new StringBuffer("SELECT "); + StringBuilder realSQL = new StringBuilder("SELECT "); if (!KeyColumn.endsWith("_ID")) realSQL.append("NULL,"); @@ -513,9 +513,10 @@ public class MLookupFactory ZoomWindow = overrideZoomWindow; ZoomWindowPO = 0; } + StringBuilder msginf = new StringBuilder(TableName).append(".").append(KeyColumn); retValue = new MLookupInfo (realSQL.toString(), TableName, - TableName + "." + KeyColumn, ZoomWindow, ZoomWindowPO, zoomQuery); - s_cacheRefTable.put(key, retValue.cloneIt()); + msginf.toString(), ZoomWindow, ZoomWindowPO, zoomQuery); + s_cacheRefTable.put(key.toString(), retValue.cloneIt()); return retValue; } // getLookup_Table @@ -583,7 +584,7 @@ public class MLookupFactory TableNameAlias = TableName; } - StringBuffer embedSQL = new StringBuffer("SELECT "); + StringBuilder embedSQL = new StringBuilder("SELECT "); // Translated if (IsTranslated && !Env.isBaseLanguage(language, TableName)) @@ -649,7 +650,7 @@ public class MLookupFactory int ZoomWindowPO = 0; //try cache - String cacheKey = Env.getAD_Client_ID(ctx) + "|" + TableName + "." + KeyColumn; + StringBuilder cacheKey = new StringBuilder(Env.getAD_Client_ID(ctx)).append("|").append(TableName).append(".").append(KeyColumn); if (s_cacheRefTable.containsKey(cacheKey)) return s_cacheRefTable.get(cacheKey).cloneIt(); @@ -709,10 +710,10 @@ public class MLookupFactory list.add(new LookupDisplayColumn(KeyColumn, null, false, DisplayType.ID, 0)); } - StringBuffer realSQL = new StringBuffer("SELECT "); + StringBuilder realSQL = new StringBuilder("SELECT "); realSQL.append(TableName).append(".").append(KeyColumn).append(",NULL,"); - StringBuffer displayColumn = new StringBuffer(); + StringBuilder displayColumn = new StringBuilder(); int size = list.size(); // Get Display Column for (int i = 0; i < size; i++) @@ -720,7 +721,8 @@ public class MLookupFactory if (i > 0) displayColumn.append(" ||'_'|| " ); LookupDisplayColumn ldc = (LookupDisplayColumn)list.get(i); - String columnSQL = ldc.IsVirtual ? ldc.ColumnSQL : TableName + "." + ldc.ColumnName; + StringBuilder msg = new StringBuilder(TableName).append(".").append(ldc.ColumnName); + String columnSQL = ldc.IsVirtual ? ldc.ColumnSQL : msg.toString(); displayColumn.append("NVL("); @@ -795,9 +797,10 @@ public class MLookupFactory if (CLogMgt.isLevelFinest()) s_log.fine("ColumnName=" + ColumnName + " - " + realSQL); + StringBuilder msginf = new StringBuilder(TableName).append(".").append(KeyColumn); MLookupInfo lInfo = new MLookupInfo(realSQL.toString(), TableName, - TableName + "." + KeyColumn, ZoomWindow, ZoomWindowPO, zoomQuery); - s_cacheRefTable.put(cacheKey, lInfo.cloneIt()); + msginf.toString(), ZoomWindow, ZoomWindowPO, zoomQuery); + s_cacheRefTable.put(cacheKey.toString(), lInfo.cloneIt()); return lInfo; } // getLookup_TableDir @@ -881,7 +884,7 @@ public class MLookupFactory } // - StringBuffer embedSQL = new StringBuffer("SELECT "); + StringBuilder embedSQL = new StringBuilder("SELECT "); int size = list.size(); for (int i = 0; i < size; i++) @@ -889,7 +892,8 @@ public class MLookupFactory if (i > 0) embedSQL.append("||' - '||" ); LookupDisplayColumn ldc = (LookupDisplayColumn)list.get(i); - String columnSQL = ldc.IsVirtual ? ldc.ColumnSQL : TableName + "." + ldc.ColumnName; + StringBuilder msg = new StringBuilder(TableName).append(".").append(ldc.ColumnName); + String columnSQL = ldc.IsVirtual ? ldc.ColumnSQL : msg.toString(); // translated if (ldc.IsTranslated && !Env.isBaseLanguage(language, TableName) && !ldc.IsVirtual) diff --git a/org.adempiere.base/src/org/compiere/model/MLookupInfo.java b/org.adempiere.base/src/org/compiere/model/MLookupInfo.java index c857055bc6..650c27ac42 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookupInfo.java +++ b/org.adempiere.base/src/org/compiere/model/MLookupInfo.java @@ -65,7 +65,9 @@ public class MLookupInfo implements Serializable, Cloneable refName = rs.getString(2); validationType = rs.getString(3); isActive = rs.getString(4).equals("Y"); - CLogger.get().config("AD_Reference Name=" + refName + ", ID=" + id + ", Type=" + validationType + ", Active=" + isActive); + StringBuilder msgconf = new StringBuilder( + "AD_Reference Name=").append(refName).append(", ID=").append(id).append(", Type=").append(validationType).append(", Active=").append(isActive); + CLogger.get().config(msgconf.toString()); } rs.close(); pstmt.close(); @@ -107,7 +109,8 @@ public class MLookupInfo implements Serializable, Cloneable retValue = id; colName = rs.getString(2); tabName = rs.getString(3); - CLogger.get().config("Name=" + colName + ", ID=" + id + ", Table=" + tabName); + StringBuilder msgconf = new StringBuilder("Name=").append(colName).append(", ID=").append(id).append(", Table=").append(tabName); + CLogger.get().config(msgconf.toString()); } rs.close(); pstmt.close(); @@ -195,7 +198,7 @@ public class MLookupInfo implements Serializable, Cloneable */ public String toString() { - StringBuffer sb = new StringBuffer ("MLookupInfo[") + StringBuilder sb = new StringBuilder ("MLookupInfo[") .append(KeyColumn) .append("-Direct=").append(QueryDirect) .append("]"); diff --git a/org.adempiere.base/src/org/compiere/model/MMailText.java b/org.adempiere.base/src/org/compiere/model/MMailText.java index ac894d4199..3ecbb103fb 100644 --- a/org.adempiere.base/src/org/compiere/model/MMailText.java +++ b/org.adempiere.base/src/org/compiere/model/MMailText.java @@ -88,7 +88,7 @@ public class MMailText extends X_R_MailText if (!all) return parse(m_MailText); // - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append(m_MailText); String s = m_MailText2; if (s != null && s.length() > 0) @@ -176,7 +176,7 @@ public class MMailText extends X_R_MailText String inStr = text; String token; - StringBuffer outStr = new StringBuffer(); + StringBuilder outStr = new StringBuilder(); int i = inStr.indexOf('@'); while (i != -1) @@ -211,8 +211,10 @@ public class MMailText extends X_R_MailText private String parseVariable (String variable, PO po) { int index = po.get_ColumnIndex(variable); - if (index == -1) - return "@" + variable + "@"; // keep for next + if (index == -1){ + StringBuilder msgreturn = new StringBuilder("@").append(variable).append("@"); + return msgreturn.toString(); // keep for next + } // Object value = po.get_Value(index); if (value == null) @@ -305,13 +307,13 @@ public class MMailText extends X_R_MailText { if (m_bpartner != null && m_bpartner.getAD_Language() != null) { - String key = m_bpartner.getAD_Language() + get_ID(); + StringBuilder key = new StringBuilder(m_bpartner.getAD_Language()).append(get_ID()); MMailTextTrl trl = s_cacheTrl.get(key); if (trl == null) { trl = getTranslation(m_bpartner.getAD_Language()); if (trl != null) - s_cacheTrl.put(key, trl); + s_cacheTrl.put(key.toString(), trl); } if (trl != null) { diff --git a/org.adempiere.base/src/org/compiere/model/MMatchPO.java b/org.adempiere.base/src/org/compiere/model/MMatchPO.java index a7365f3c69..4f075b44cf 100644 --- a/org.adempiere.base/src/org/compiere/model/MMatchPO.java +++ b/org.adempiere.base/src/org/compiere/model/MMatchPO.java @@ -758,7 +758,7 @@ public class MMatchPO extends X_M_MatchPO */ public String toString () { - StringBuffer sb = new StringBuffer ("MMatchPO["); + StringBuilder sb = new StringBuilder ("MMatchPO["); sb.append (get_ID()) .append (",Qty=").append (getQty()) .append (",C_OrderLine_ID=").append (getC_OrderLine_ID()) @@ -800,10 +800,10 @@ public class MMatchPO extends X_M_MatchPO if (po1.getM_InOutLine_ID() != 0 && po1.getC_InvoiceLine_ID() == 0 && po2.getM_InOutLine_ID() == 0 && po2.getC_InvoiceLine_ID() != 0) { - String s1 = "UPDATE M_MatchPO SET C_InvoiceLine_ID=" - + po2.getC_InvoiceLine_ID() - + " WHERE M_MatchPO_ID=" + po1.getM_MatchPO_ID(); - int no1 = DB.executeUpdate(s1, null); + StringBuilder s1 = new StringBuilder("UPDATE M_MatchPO SET C_InvoiceLine_ID=") + .append(po2.getC_InvoiceLine_ID()) + .append(" WHERE M_MatchPO_ID=").append(po1.getM_MatchPO_ID()); + int no1 = DB.executeUpdate(s1.toString(), null); if (no1 != 1) { errors++; diff --git a/org.adempiere.base/src/org/compiere/model/MMeasure.java b/org.adempiere.base/src/org/compiere/model/MMeasure.java index f3065b4582..8df75f2c33 100644 --- a/org.adempiere.base/src/org/compiere/model/MMeasure.java +++ b/org.adempiere.base/src/org/compiere/model/MMeasure.java @@ -166,7 +166,7 @@ public class MMeasure extends X_PA_Measure // else if (MGoal.MEASUREDISPLAY_Day.equals(MeasureDisplay)) // trunc = "D"; trunc = "TRUNC(DateDoc,'" + trunc + "')"; - StringBuffer sql = new StringBuffer ("SELECT SUM(ManualActual), ") + StringBuilder sql = new StringBuilder ("SELECT SUM(ManualActual), ") .append(trunc).append(" FROM PA_Achievement WHERE PA_Measure_ID=? AND IsAchieved='Y' ") .append("GROUP BY ").append(trunc) .append(" ORDER BY ").append(trunc); @@ -283,7 +283,7 @@ public class MMeasure extends X_PA_Measure */ public String toString () { - StringBuffer sb = new StringBuffer ("MMeasure["); + StringBuilder sb = new StringBuilder ("MMeasure["); sb.append (get_ID()).append ("-").append (getName()).append ("]"); return sb.toString (); } // toString @@ -594,20 +594,20 @@ public class MMeasure extends X_PA_Measure while (st.hasMoreTokens()) // for each class { String cmd = st.nextToken().trim(); - String retValue = ""; + StringBuilder retValue = new StringBuilder(); if (cmd.toLowerCase().startsWith(MRule.SCRIPT_PREFIX)) { MRule rule = MRule.get(getCtx(), cmd.substring(MRule.SCRIPT_PREFIX.length())); if (rule == null) { - retValue = "Script " + cmd + " not found"; - log.log(Level.SEVERE, retValue); + retValue = new StringBuilder("Script ").append(cmd).append(" not found"); + log.log(Level.SEVERE, retValue.toString()); break; } if ( ! (rule.getEventType().equals(MRule.EVENTTYPE_MeasureForPerformanceAnalysis) && rule.getRuleType().equals(MRule.RULETYPE_JSR223ScriptingAPIs))) { - retValue = "Script " + cmd - + " must be of type JSR 223 and event measure"; - log.log(Level.SEVERE, retValue); + retValue = new StringBuilder("Script ").append(cmd) + .append(" must be of type JSR 223 and event measure"); + log.log(Level.SEVERE, retValue.toString()); break; } ScriptEngine engine = rule.getScriptEngine(); @@ -622,7 +622,7 @@ public class MMeasure extends X_PA_Measure catch (Exception e) { log.log(Level.SEVERE, "", e); - retValue = "Script Invalid: " + e.toString(); + retValue = new StringBuilder("Script Invalid: ").append(e.toString()); return false; } } @@ -652,9 +652,9 @@ public class MMeasure extends X_PA_Measure } } - if (!Util.isEmpty(retValue)) // interrupt on first error + if (!Util.isEmpty(retValue.toString())) // interrupt on first error { - log.severe (retValue); + log.severe (retValue.toString()); return false; } } diff --git a/org.adempiere.base/src/org/compiere/model/M_Element.java b/org.adempiere.base/src/org/compiere/model/M_Element.java index 033c2f3ccd..706a3fd31b 100644 --- a/org.adempiere.base/src/org/compiere/model/M_Element.java +++ b/org.adempiere.base/src/org/compiere/model/M_Element.java @@ -186,10 +186,10 @@ public class M_Element extends X_AD_Element if (getColumnName().length() != columnName.length()) setColumnName(columnName); - String sql = "select count(*) from AD_Element where UPPER(ColumnName)=?"; + StringBuilder sql = new StringBuilder("select count(*) from AD_Element where UPPER(ColumnName)=?"); if (!newRecord) - sql += " AND AD_Element_ID<>" + get_ID(); - int no = DB.getSQLValue(null, sql, columnName.toUpperCase()); + sql.append(" AND AD_Element_ID<>").append(get_ID()); + int no = DB.getSQLValue(null, sql.toString(), columnName.toUpperCase()); if (no > 0) { log.saveError("SaveErrorNotUnique", Msg.getElement(getCtx(), COLUMNNAME_ColumnName)); return false; @@ -210,7 +210,7 @@ public class M_Element extends X_AD_Element // Update Columns, Fields, Parameters, Print Info if (!newRecord) { - StringBuffer sql = new StringBuffer(); + StringBuilder sql = new StringBuilder(); int no = 0; if ( is_ValueChanged(M_Element.COLUMNNAME_Name) @@ -219,7 +219,7 @@ public class M_Element extends X_AD_Element || is_ValueChanged(M_Element.COLUMNNAME_ColumnName) ) { // Column - sql = new StringBuffer("UPDATE AD_Column SET ColumnName=") + sql = new StringBuilder("UPDATE AD_Column SET ColumnName=") .append(DB.TO_STRING(getColumnName())) .append(", Name=").append(DB.TO_STRING(getName())) .append(", Description=").append(DB.TO_STRING(getDescription())) @@ -229,7 +229,7 @@ public class M_Element extends X_AD_Element log.fine("afterSave - Columns updated #" + no); // Parameter - sql = new StringBuffer("UPDATE AD_Process_Para SET ColumnName=") + sql = new StringBuilder("UPDATE AD_Process_Para SET ColumnName=") .append(DB.TO_STRING(getColumnName())) .append(", Name=").append(DB.TO_STRING(getName())) .append(", Description=").append(DB.TO_STRING(getDescription())) @@ -240,7 +240,7 @@ public class M_Element extends X_AD_Element .append(" AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL"); no = DB.executeUpdate(sql.toString(), get_TrxName()); - sql = new StringBuffer("UPDATE AD_Process_Para SET ColumnName=") + sql = new StringBuilder("UPDATE AD_Process_Para SET ColumnName=") .append(DB.TO_STRING(getColumnName())) .append(", Name=").append(DB.TO_STRING(getName())) .append(", Description=").append(DB.TO_STRING(getDescription())) @@ -256,7 +256,7 @@ public class M_Element extends X_AD_Element || is_ValueChanged(M_Element.COLUMNNAME_Help) ) { // Field - sql = new StringBuffer("UPDATE AD_Field SET Name=") + sql = new StringBuilder("UPDATE AD_Field SET Name=") .append(DB.TO_STRING(getName())) .append(", Description=").append(DB.TO_STRING(getDescription())) .append(", Help=").append(DB.TO_STRING(getHelp())) @@ -275,7 +275,7 @@ public class M_Element extends X_AD_Element || is_ValueChanged(M_Element.COLUMNNAME_Name) ) { // Print Info - sql = new StringBuffer("UPDATE AD_PrintFormatItem pi SET PrintName=") + sql = new StringBuilder("UPDATE AD_PrintFormatItem pi SET PrintName=") .append(DB.TO_STRING(getPrintName())) .append(", Name=").append(DB.TO_STRING(getName())) .append(" WHERE IsCentrallyMaintained='Y'") @@ -296,7 +296,7 @@ public class M_Element extends X_AD_Element */ public String toString() { - StringBuffer sb = new StringBuffer ("M_Element["); + StringBuilder sb = new StringBuilder ("M_Element["); sb.append (get_ID()).append ("-").append (getColumnName()).append ("]"); return sb.toString (); } // toString