IDEMPIERE-308 Performance: Replace with StringBuilder / Thanks to Richard Morales and David Peñuela

This commit is contained in:
Carlos Ruiz 2012-10-01 20:33:05 -05:00
parent b65f9deeb9
commit bd96df6367
120 changed files with 1512 additions and 1355 deletions

View File

@ -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"))

View File

@ -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);
}

View File

@ -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<Object> params = new ArrayList<Object>();
// 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!

View File

@ -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;

View File

@ -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

View File

@ -105,17 +105,17 @@ public class MAcctSchema extends X_C_AcctSchema
list.add(as);
ArrayList<Object> params = new ArrayList<Object>();
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 <MAcctSchema> ass = new Query(ctx, I_C_AcctSchema.Table_Name,whereClause,trxName)
List <MAcctSchema> 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();

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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<MaxImpression AND CM_Ad_Cat_ID=" + CM_Ad_Cat_ID, trxName);
StringBuilder msgids = new StringBuilder("ActualImpression+StartImpression<MaxImpression AND CM_Ad_Cat_ID=").append(CM_Ad_Cat_ID);
int [] thisAds = MAd.getAllIDs("CM_Ad",msgids.toString(), trxName);
if (thisAds!=null) {
for (int i=0;i<thisAds.length;i++) {
MAd tempAd = new MAd(ctx, thisAds[i], trxName);

View File

@ -273,7 +273,7 @@ public class MAging extends X_T_Aging
*/
public String toString()
{
StringBuffer sb = new StringBuffer("MAging[");
StringBuilder sb = new StringBuilder("MAging[");
sb.append("AD_PInstance_ID=").append(getAD_PInstance_ID())
.append(",C_BPartner_ID=").append(getC_BPartner_ID())
.append(",C_Currency_ID=").append(getC_Currency_ID())

View File

@ -209,7 +209,7 @@ public class MAlert extends X_AD_Alert
*/
public String toString ()
{
StringBuffer sb = new StringBuffer ("MAlert[");
StringBuilder sb = new StringBuilder ("MAlert[");
sb.append(get_ID())
.append("-").append(getName())
.append(",Valid=").append(isValid());

View File

@ -88,7 +88,7 @@ public class MAlertRecipient extends X_AD_AlertRecipient
*/
public String toString ()
{
StringBuffer sb = new StringBuffer ("MAlertRecipient[");
StringBuilder sb = new StringBuilder ("MAlertRecipient[");
sb.append(get_ID())
.append(",AD_User_ID=").append(getAD_User_ID())
.append(",AD_Role_ID=").append(getAD_Role_ID())

View File

@ -99,12 +99,12 @@ public class MAlertRule extends X_AD_AlertRule
*/
public String getSql(boolean applySecurity)
{
StringBuffer sql = new StringBuffer();
StringBuilder sql = new StringBuilder();
sql.append("SELECT ").append(getSelectClause())
.append(" FROM ").append(getFromClause());
if (getWhereClause() != null && getWhereClause().length() > 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())

View File

@ -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(": ")

View File

@ -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);

View File

@ -79,13 +79,13 @@ public class MArchive extends X_AD_Archive {
public static MArchive[] get(Properties ctx, String whereClause) {
ArrayList<MArchive> list = new ArrayList<MArchive>();
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();
}
/**

View File

@ -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 ("]");

View File

@ -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())

View File

@ -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(")");

View File

@ -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();
}
/**

View File

@ -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)

View File

@ -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);
List<MAttribute>list = new Query(ctx,I_M_Attribute.Table_Name,whereClause,null)
List<MAttribute>list = 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;

View File

@ -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--)
{

View File

@ -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");

View File

@ -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);

View File

@ -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");

View File

@ -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 <MBOM> list = new Query(ctx, I_M_BOM.Table_Name, where, trxName)
where.append(" AND ").append(whereClause);
List <MBOM> 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()))
;

View File

@ -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 ("]");

View File

@ -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

View File

@ -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 ?");

View File

@ -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

View File

@ -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

View File

@ -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
/**

View File

@ -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
/**

View File

@ -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;

View File

@ -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 ();

View File

@ -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<tableKeys.length;i++) {
X_CM_TemplateTable thisTemplateTable = new X_CM_TemplateTable(getCtx(), tableKeys[i], get_TrxName());
int [] existingKeys = X_CM_CStageTTable.getAllIDs("CM_CStageTTable", "CM_TemplateTable_ID=" + thisTemplateTable.get_ID(), get_TrxName());
msgx = new StringBuilder("CM_TemplateTable_ID=").append(thisTemplateTable.get_ID());
int [] existingKeys = X_CM_CStageTTable.getAllIDs("CM_CStageTTable", msgx.toString(), get_TrxName());
if (existingKeys==null || existingKeys.length==0) {
X_CM_CStageTTable newCStageTTable = new X_CM_CStageTTable(getCtx(), 0, get_TrxName());
newCStageTTable.setAD_Client_ID(getAD_Client_ID());

View File

@ -113,7 +113,8 @@ public class MCalendar extends X_C_Calendar
{
super(client.getCtx(), 0, client.get_TrxName());
setClientOrg(client);
setName(client.getName() + " " + Msg.translate(client.getCtx(), "C_Calendar_ID"));
StringBuilder msgset = new StringBuilder(client.getName()).append(" ").append(Msg.translate(client.getCtx(), "C_Calendar_ID"));
setName(msgset.toString());
} // MCalendar
/**

View File

@ -159,9 +159,9 @@ public class MCash extends X_C_Cash implements DocAction
Timestamp today = TimeUtil.getDay(System.currentTimeMillis());
setStatementDate (today); // @#Date@
setDateAcct (today); // @#Date@
String name = DisplayType.getDateFormat(DisplayType.Date).format(today)
+ " " + MOrg.get(ctx, getAD_Org_ID()).getValue();
setName (name);
StringBuilder name = new StringBuilder(DisplayType.getDateFormat(DisplayType.Date).format(today))
.append(" ").append(MOrg.get(ctx, getAD_Org_ID()).getValue());
setName (name.toString());
setIsApproved(false);
setPosted (false); // N
setProcessed (false);
@ -193,9 +193,9 @@ public class MCash extends X_C_Cash implements DocAction
{
setStatementDate (today);
setDateAcct (today);
String name = DisplayType.getDateFormat(DisplayType.Date).format(today)
+ " " + cb.getName();
setName (name);
StringBuilder name = new StringBuilder(DisplayType.getDateFormat(DisplayType.Date).format(today))
.append(" ").append(cb.getName());
setName (name.toString());
}
m_book = cb;
} // MCash
@ -254,7 +254,8 @@ public class MCash extends X_C_Cash implements DocAction
*/
public String getDocumentInfo()
{
return Msg.getElement(getCtx(), "C_Cash_ID") + " " + getDocumentNo();
StringBuilder msgreturn = new StringBuilder(Msg.getElement(getCtx(), "C_Cash_ID")).append(" ").append(getDocumentNo());
return msgreturn.toString();
} // getDocumentInfo
/**
@ -265,7 +266,8 @@ public class MCash extends X_C_Cash 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)
@ -320,7 +322,7 @@ public class MCash extends X_C_Cash implements DocAction
} // process
/** Process Message */
private String m_processMsg = null;
private StringBuffer m_processMsg = null;
/** Just Prepared Flag */
private boolean m_justPrepared = false;
@ -353,20 +355,20 @@ public class MCash extends X_C_Cash 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;
// Std Period open?
if (!MPeriod.isOpen(getCtx(), getDateAcct(), MDocType.DOCBASETYPE_CashJournal, getAD_Org_ID()))
{
m_processMsg = "@PeriodClosed@";
m_processMsg = new StringBuffer("@PeriodClosed@");
return DocAction.STATUS_Invalid;
}
MCashLine[] lines = getLines(false);
if (lines.length == 0)
{
m_processMsg = "@NoLines@";
m_processMsg = new StringBuffer("@NoLines@");
return DocAction.STATUS_Invalid;
}
// Add up Amounts
@ -386,7 +388,7 @@ public class MCash extends X_C_Cash implements DocAction
getAD_Client_ID(), getAD_Org_ID());
if (amt == null)
{
m_processMsg = "No Conversion Rate found - @C_CashLine_ID@= " + line.getLine();
m_processMsg = new StringBuffer("No Conversion Rate found - @C_CashLine_ID@= ").append(line.getLine());
return DocAction.STATUS_Invalid;
}
difference = difference.add(amt);
@ -395,7 +397,7 @@ public class MCash extends X_C_Cash implements DocAction
setStatementDifference(difference);
// setEndingBalance(getBeginningBalance().add(getStatementDifference()));
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;
@ -441,7 +443,7 @@ public class MCash extends X_C_Cash 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;
@ -466,19 +468,19 @@ public class MCash extends X_C_Cash implements DocAction
&& !MInvoice.DOCSTATUS_Voided.equals(invoice.getDocStatus())
)
{
m_processMsg = "@Line@ "+line.getLine()+": @InvoiceCreateDocNotCompleted@";
m_processMsg = new StringBuffer("@Line@ ").append(line.getLine()).append(": @InvoiceCreateDocNotCompleted@");
return DocAction.STATUS_Invalid;
}
//
String name = Msg.translate(getCtx(), "C_Cash_ID") + ": " + getName()
+ " - " + Msg.translate(getCtx(), "Line") + " " + line.getLine();
StringBuilder name = new StringBuilder(Msg.translate(getCtx(), "C_Cash_ID")).append(": ").append(getName())
.append(" - ").append(Msg.translate(getCtx(), "Line")).append(" ").append(line.getLine());
MAllocationHdr hdr = new MAllocationHdr(getCtx(), false,
getDateAcct(), line.getC_Currency_ID(),
name, get_TrxName());
name.toString(), get_TrxName());
hdr.setAD_Org_ID(getAD_Org_ID());
if (!hdr.save())
{
m_processMsg = CLogger.retrieveErrorString("Could not create Allocation Hdr");
m_processMsg = new StringBuffer(CLogger.retrieveErrorString("Could not create Allocation Hdr"));
return DocAction.STATUS_Invalid;
}
// Allocation Line
@ -488,16 +490,16 @@ public class MCash extends X_C_Cash implements DocAction
aLine.setC_CashLine_ID(line.getC_CashLine_ID());
if (!aLine.save())
{
m_processMsg = CLogger.retrieveErrorString("Could not create Allocation Line");
m_processMsg = new StringBuffer(CLogger.retrieveErrorString("Could not create Allocation Line"));
return DocAction.STATUS_Invalid;
}
// Should start WF
if(!hdr.processIt(DocAction.ACTION_Complete)) {
m_processMsg = CLogger.retrieveErrorString("Could not process Allocation");
m_processMsg = new StringBuffer(CLogger.retrieveErrorString("Could not process Allocation"));
return DocAction.STATUS_Invalid;
}
if (!hdr.save()) {
m_processMsg = CLogger.retrieveErrorString("Could not save Allocation");
m_processMsg = new StringBuffer(CLogger.retrieveErrorString("Could not save Allocation"));
return DocAction.STATUS_Invalid;
}
}
@ -529,14 +531,14 @@ public class MCash extends X_C_Cash implements DocAction
pay.setProcessed(true);
if (!pay.save())
{
m_processMsg = CLogger.retrieveErrorString("Could not create Payment");
m_processMsg = new StringBuffer(CLogger.retrieveErrorString("Could not create Payment"));
return DocAction.STATUS_Invalid;
}
line.setC_Payment_ID(pay.getC_Payment_ID());
if (!line.save())
{
m_processMsg = "Could not update Cash Line";
m_processMsg = new StringBuffer("Could not update Cash Line");
return DocAction.STATUS_Invalid;
}
}
@ -546,7 +548,7 @@ public class MCash extends X_C_Cash 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;
}
//
@ -564,7 +566,7 @@ public class MCash extends X_C_Cash 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;
@ -573,7 +575,7 @@ public class MCash extends X_C_Cash implements DocAction
if (retValue) {
// 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;
setDocAction(DOCACTION_None);
@ -594,7 +596,7 @@ public class MCash extends X_C_Cash 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;
}
@ -621,9 +623,10 @@ public class MCash extends X_C_Cash implements DocAction
cashline.setAmount(Env.ZERO);
cashline.setDiscountAmt(Env.ZERO);
cashline.setWriteOffAmt(Env.ZERO);
cashline.addDescription(Msg.getMsg(getCtx(), "Voided")
+ " (Amount=" + oldAmount + ", Discount=" + oldDiscount
+ ", WriteOff=" + oldWriteOff + ", )");
StringBuilder msgadd = new StringBuilder(Msg.getMsg(getCtx(), "Voided"))
.append(" (Amount=").append(oldAmount).append(", Discount=").append(oldDiscount)
.append(", WriteOff=").append(oldWriteOff).append(", )");
cashline.addDescription(msgadd.toString());
if (MCashLine.CASHTYPE_BankAccountTransfer.equals(cashline.getCashType()))
{
if (cashline.getC_Payment_ID() == 0)
@ -659,8 +662,10 @@ public class MCash extends X_C_Cash 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
/**
@ -672,14 +677,14 @@ public class MCash extends X_C_Cash 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;
return true;
@ -693,7 +698,7 @@ public class MCash extends X_C_Cash 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;
@ -702,7 +707,7 @@ public class MCash extends X_C_Cash implements DocAction
if (retValue) {
// 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;
}
@ -718,12 +723,12 @@ public class MCash extends X_C_Cash 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;
@ -738,7 +743,7 @@ public class MCash extends X_C_Cash 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;
@ -747,7 +752,7 @@ public class MCash extends X_C_Cash implements DocAction
return true;
// 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;
@ -760,10 +765,10 @@ public class MCash extends X_C_Cash implements DocAction
public void setProcessed (boolean processed)
{
super.setProcessed (processed);
String sql = "UPDATE C_CashLine SET Processed='"
+ (processed ? "Y" : "N")
+ "' WHERE C_Cash_ID=" + getC_Cash_ID();
int noLine = DB.executeUpdate (sql, get_TrxName());
StringBuilder sql = new StringBuilder("UPDATE C_CashLine SET Processed='")
.append((processed ? "Y" : "N"))
.append("' WHERE C_Cash_ID=").append(getC_Cash_ID());
int noLine = DB.executeUpdate (sql.toString(), get_TrxName());
m_lines = null;
log.fine(processed + " - Lines=" + noLine);
} // setProcessed
@ -774,7 +779,7 @@ public class MCash extends X_C_Cash implements DocAction
*/
public String toString ()
{
StringBuffer sb = new StringBuffer ("MCash[");
StringBuilder sb = new StringBuilder ("MCash[");
sb.append (get_ID ())
.append ("-").append (getName())
.append(", Balance=").append(getBeginningBalance())
@ -789,7 +794,7 @@ public class MCash extends X_C_Cash implements DocAction
*/
public String getSummary()
{
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append(getName());
// : Total Lines = 123.00 (#1)
sb.append(": ")
@ -809,7 +814,7 @@ public class MCash extends X_C_Cash implements DocAction
*/
public String getProcessMsg()
{
return m_processMsg;
return m_processMsg.toString();
} // getProcessMsg
/**

View File

@ -112,11 +112,11 @@ public class MCashPlanLine extends X_C_CashPlanLine
private boolean updateHeader()
{
// Update Cash Plan Header
String sql = "UPDATE C_CashPlan "
+ " SET GrandTotal="
+ "(SELECT COALESCE(SUM(LineTotalAmt),0) FROM C_CashPlanLine WHERE C_CashPlan.C_CashPlan_ID=C_CashPlanLine.C_CashPlan_ID) "
+ "WHERE C_CashPlan_ID=" + getC_CashPlan_ID();
int no = DB.executeUpdate(sql, get_TrxName());
StringBuilder sql = new StringBuilder("UPDATE C_CashPlan ")
.append(" SET GrandTotal=")
.append("(SELECT COALESCE(SUM(LineTotalAmt),0) FROM C_CashPlanLine WHERE C_CashPlan.C_CashPlan_ID=C_CashPlanLine.C_CashPlan_ID) ")
.append("WHERE C_CashPlan_ID=").append(getC_CashPlan_ID());
int no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 1)
log.warning("(1) #" + no);

View File

@ -61,7 +61,8 @@ public class MChangeRequest extends X_M_ChangeRequest
{
this (request.getCtx(), 0, request.get_TrxName());
setClientOrg(request);
setName(Msg.getElement(getCtx(), "R_Request_ID") + ": " + request.getDocumentNo());
StringBuilder msgset = new StringBuilder(Msg.getElement(getCtx(), "R_Request_ID")).append(": ").append(request.getDocumentNo());
setName(msgset.toString());
setHelp(request.getSummary());
//
setPP_Product_BOM_ID(group.getPP_Product_BOM_ID());

View File

@ -195,8 +195,10 @@ public class MChat extends X_CM_Chat
{
if (Description != null && Description.length() > 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
/**

View File

@ -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

View File

@ -108,15 +108,15 @@ public class MClickCount extends X_W_ClickCount
protected ValueNamePair[] getCount (String DateFormat)
{
ArrayList<ValueNamePair> list = new ArrayList<ValueNamePair>();
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
{

View File

@ -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<Integer>(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
{

View File

@ -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'"

View File

@ -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
/**

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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())

View File

@ -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);
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);
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);
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 ());

View File

@ -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())

View File

@ -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<QtyCost> fifo = new ArrayList<QtyCost>();
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<QtyCost> lifo = new ArrayList<QtyCost>();
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());

View File

@ -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(),

View File

@ -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())

View File

@ -115,21 +115,21 @@ public class MCostQueue extends X_M_CostQueue
MAcctSchema as, int Org_ID, MCostElement ce, String trxName)
{
ArrayList<MCostQueue> list = new ArrayList<MCostQueue>();
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
{

View File

@ -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

View File

@ -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

View File

@ -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<Object> parameters = new ArrayList<Object>();
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<Object> parameters = new ArrayList<Object>();
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)

View File

@ -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<Object> parameters = new ArrayList<Object>();
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<Object> parameters = new ArrayList<Object>();
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)

View File

@ -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)

View File

@ -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();
}
/**************************************************************************

View File

@ -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());

View File

@ -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

View File

@ -52,15 +52,15 @@ public class MDistributionRunDetail extends X_T_DistributionRunDetail
boolean orderBP, String trxName)
{
ArrayList<MDistributionRunDetail> list = new ArrayList<MDistributionRunDetail>();
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())

View File

@ -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())

View File

@ -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'");

View File

@ -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())

View File

@ -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();

View File

@ -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<MDunningRunLine> list = new ArrayList<MDunningRunLine>();
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
{

View File

@ -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

View File

@ -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();
}

View File

@ -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 = ?")

View File

@ -78,7 +78,7 @@ public class MEXPProcessor extends X_EXP_Processor {
List<X_EXP_ProcessorParameter> resultList = new ArrayList<X_EXP_ProcessorParameter>();
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

View File

@ -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 ();

View File

@ -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];
}

View File

@ -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())

View File

@ -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

View File

@ -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())

View File

@ -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

View File

@ -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<X_IMP_ProcessorParameter> resultList = new ArrayList<X_IMP_ProcessorParameter>();
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

View File

@ -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

View File

@ -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
/**

View File

@ -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
/**

View File

@ -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())

View File

@ -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())

View File

@ -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<toBeIndexed.length;i++) {
MIndex.runIndex(toBeIndexed[i], ctx, trxName, AD_Table_ID, Record_ID,
MIndex.runIndex(toBeIndexed[i], ctx, trxName.toString(), AD_Table_ID, Record_ID,
CM_WebProject_ID, lastUpdated);
}
DB.commit (true, trxName);
DB.commit (true, trxName.toString());
} catch (SQLException sqlE) {
try {
DB.rollback (true, trxName);
DB.rollback (true, trxName.toString());
} catch (SQLException sqlE2) {
}
}
@ -260,7 +260,7 @@ public class MIndex extends X_K_Index
return null;
//
keyword = keyword.toUpperCase(); // default locale
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
char[] chars = keyword.toCharArray();
for (int i = 0; i < chars.length; i++)
{

View File

@ -159,7 +159,7 @@ public class MInterestArea extends X_R_InterestArea
*/
public String toString ()
{
StringBuffer sb = new StringBuffer ("MInterestArea[")
StringBuilder sb = new StringBuilder ("MInterestArea[")
.append (get_ID()).append(" - ").append(getName())
.append ("]");
return sb.toString ();

View File

@ -162,8 +162,10 @@ public class MInventory extends X_M_Inventory implements DocAction
String desc = getDescription();
if (desc == null)
setDescription(description);
else
setDescription(desc + " | " + description);
else{
StringBuilder msgreturn = new StringBuilder(desc).append(" | ").append(description);
setDescription(msgreturn.toString());
}
} // addDescription
/**
@ -182,7 +184,7 @@ public class MInventory extends X_M_Inventory implements DocAction
*/
public String toString ()
{
StringBuffer sb = new StringBuffer ("MInventory[");
StringBuilder sb = new StringBuilder ("MInventory[");
sb.append (get_ID())
.append ("-").append (getDocumentNo())
.append (",M_Warehouse_ID=").append(getM_Warehouse_ID())
@ -197,7 +199,8 @@ public class MInventory extends X_M_Inventory 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
/**
@ -208,7 +211,8 @@ public class MInventory extends X_M_Inventory 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)
@ -285,7 +289,7 @@ public class MInventory extends X_M_Inventory implements DocAction
} // processIt
/** Process Message */
private String m_processMsg = null;
private StringBuffer m_processMsg = null;
/** Just Prepared Flag */
private boolean m_justPrepared = false;
@ -318,7 +322,7 @@ public class MInventory extends X_M_Inventory 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;
@ -327,14 +331,14 @@ public class MInventory extends X_M_Inventory implements DocAction
MInventoryLine[] lines = getLines(false);
if (lines.length == 0)
{
m_processMsg = "@NoLines@";
m_processMsg = new StringBuffer("@NoLines@");
return DocAction.STATUS_Invalid;
}
// TODO: Add up Amounts
// setApprovalAmt();
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;
@ -380,7 +384,7 @@ public class MInventory extends X_M_Inventory 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;
@ -440,7 +444,7 @@ public class MInventory extends X_M_Inventory implements DocAction
QtyMA.negate(), Env.ZERO, Env.ZERO, 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;
}
@ -452,7 +456,7 @@ public class MInventory extends X_M_Inventory implements DocAction
storage.setDateLastInventory(getMovementDate());
if (!storage.save(get_TrxName()))
{
m_processMsg = "Storage not updated(2)";
m_processMsg = new StringBuffer("Storage not updated(2)");
return DocAction.STATUS_Invalid;
}
}
@ -470,7 +474,7 @@ public class MInventory extends X_M_Inventory implements DocAction
mtrx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
if (!mtrx.save())
{
m_processMsg = "Transaction not inserted(2)";
m_processMsg = new StringBuffer("Transaction not inserted(2)");
return DocAction.STATUS_Invalid;
}
@ -490,7 +494,7 @@ public class MInventory extends X_M_Inventory implements DocAction
line.getM_AttributeSetInstance_ID(), 0,
qtyDiff, Env.ZERO, Env.ZERO, get_TrxName()))
{
m_processMsg = "Cannot correct Inventory (MA)";
m_processMsg = new StringBuffer("Cannot correct Inventory (MA)");
return DocAction.STATUS_Invalid;
}
@ -503,7 +507,7 @@ public class MInventory extends X_M_Inventory implements DocAction
storage.setDateLastInventory(getMovementDate());
if (!storage.save(get_TrxName()))
{
m_processMsg = "Storage not updated(2)";
m_processMsg = new StringBuffer("Storage not updated(2)");
return DocAction.STATUS_Invalid;
}
}
@ -520,7 +524,7 @@ public class MInventory extends X_M_Inventory implements DocAction
mtrx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
if (!mtrx.save())
{
m_processMsg = "Transaction not inserted(2)";
m_processMsg = new StringBuffer("Transaction not inserted(2)");
return DocAction.STATUS_Invalid;
}
} // Fallback
@ -532,7 +536,7 @@ public class MInventory extends X_M_Inventory 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;
}
@ -657,7 +661,7 @@ public class MInventory extends X_M_Inventory 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;
@ -665,7 +669,7 @@ public class MInventory extends X_M_Inventory 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;
}
@ -688,7 +692,8 @@ public class MInventory extends X_M_Inventory implements DocAction
{
line.setQtyInternalUse(Env.ZERO);
line.setQtyCount(line.getQtyBook());
line.addDescription("Void (" + oldCount + "/" + oldInternal + ")");
StringBuilder msgd = new StringBuilder("Void (").append(oldCount).append("/").append(oldInternal).append(")");
line.addDescription(msgd.toString());
line.saveEx(get_TrxName());
}
}
@ -699,7 +704,7 @@ public class MInventory extends X_M_Inventory 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;
setProcessed(true);
@ -715,13 +720,13 @@ public class MInventory extends X_M_Inventory 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;
return true;
@ -735,7 +740,7 @@ public class MInventory extends X_M_Inventory 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;
@ -750,7 +755,8 @@ public class MInventory extends X_M_Inventory implements DocAction
reversal.setIsApproved (false);
reversal.setPosted(false);
reversal.setProcessed(false);
reversal.addDescription("{->" + 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
/**

View File

@ -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())

View File

@ -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())

View File

@ -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
/**

View File

@ -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);

View File

@ -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

View File

@ -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{
msgreturn = new StringBuilder("No Reference for ").append(lc);
return msgreturn.toString();
}
else
return "No Reference for " + lc;
}
// *** 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++;
}

View File

@ -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<MInvoicePaySchedule> list = new ArrayList<MInvoicePaySchedule>();
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

View File

@ -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())

View File

@ -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())

Some files were not shown because too many files have changed in this diff Show More