IDEMPIERE-308 Performance: Replace use of StringBuffer and String concatenation with StringBuilder / review classes on org.adempiere.base.process / thanks to Richard Morales and David Peñuela

This commit is contained in:
Carlos Ruiz 2012-09-21 19:27:59 -05:00
parent ae107dbb64
commit 502bd015c1
14 changed files with 210 additions and 186 deletions

View File

@ -89,9 +89,9 @@ public class ASPGenerateFields extends SvrProcess
*/ */
protected String doIt () throws Exception protected String doIt () throws Exception
{ {
log.info("ASP_Status=" + p_ASP_Status StringBuilder msglog = new StringBuilder("ASP_Status=").append(p_ASP_Status)
+ ", ASP_Tab_ID=" + p_ASP_Tab_ID .append(", ASP_Tab_ID=").append(p_ASP_Tab_ID);
); log.info(msglog.toString());
X_ASP_Tab asptab = new X_ASP_Tab(getCtx(), p_ASP_Tab_ID, get_TrxName()); X_ASP_Tab asptab = new X_ASP_Tab(getCtx(), p_ASP_Tab_ID, get_TrxName());
p_ASP_Level_ID = asptab.getASP_Window().getASP_Level_ID(); p_ASP_Level_ID = asptab.getASP_Window().getASP_Level_ID();

View File

@ -107,10 +107,10 @@ public class ASPGenerateLevel extends SvrProcess
*/ */
protected String doIt () throws Exception protected String doIt () throws Exception
{ {
log.info("ASP_Status=" + p_ASP_Status StringBuilder msglog = new StringBuilder("ASP_Status=").append(p_ASP_Status)
+ ", AD_Menu_ID=" + p_AD_Menu_ID .append(", AD_Menu_ID=").append(p_AD_Menu_ID)
+ ", IsGenerateFields=" + p_IsGenerateFields .append(", IsGenerateFields=").append(p_IsGenerateFields);
); log.info(msglog.toString());
MClientInfo clientInfo = MClientInfo.get(getCtx(), getAD_Client_ID(), get_TrxName()); MClientInfo clientInfo = MClientInfo.get(getCtx(), getAD_Client_ID(), get_TrxName());
int AD_Tree_ID = clientInfo.getAD_Tree_Menu_ID(); int AD_Tree_ID = clientInfo.getAD_Tree_Menu_ID();

View File

@ -51,16 +51,16 @@ public class ApplyMigrationScripts extends SvrProcess {
protected String doIt() throws Exception { protected String doIt() throws Exception {
// TODO Auto-generated method stub // TODO Auto-generated method stub
log.info("Applying migrations scripts"); log.info("Applying migrations scripts");
String sql = "select ad_migrationscript_id, script, name from ad_migrationscript where isApply = 'Y' and status = 'IP' order by name, created"; StringBuilder sql = new StringBuilder()
PreparedStatement pstmt = DB.prepareStatement(sql, this.get_TrxName()); .append("select ad_migrationscript_id, script, name from ad_migrationscript where isApply = 'Y' and status = 'IP' order by name, created");
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), this.get_TrxName());
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
while (rs.next()) { while (rs.next()) {
byte[] scriptArray = rs.getBytes(2); byte[] scriptArray = rs.getBytes(2);
int seqID = rs.getInt(1); int seqID = rs.getInt(1);
boolean execOk = true; boolean execOk = true;
try { try {
StringBuffer tmpSql = new StringBuffer(); StringBuilder tmpSql = new StringBuilder(new String(scriptArray));
tmpSql = new StringBuffer(new String(scriptArray));
if (tmpSql.length() > 0) { if (tmpSql.length() > 0) {
log.info("Executing script " + rs.getString(3)); log.info("Executing script " + rs.getString(3));
@ -70,12 +70,12 @@ public class ApplyMigrationScripts extends SvrProcess {
} catch (SQLException e) { } catch (SQLException e) {
execOk = false; execOk = false;
e.printStackTrace(); e.printStackTrace();
log.saveError("Error", "Script: " + rs.getString(3) + " - " StringBuilder msglog = new StringBuilder("Script: ").append(rs.getString(3)).append(" - ").append(e.getMessage());
+ e.getMessage()); log.saveError("Error", msglog.toString());
log.severe(e.getMessage()); log.severe(e.getMessage());
} finally { } finally {
sql = "UPDATE ad_migrationscript SET status = ? , isApply = 'N' WHERE ad_migrationscript_id = ? "; sql = new StringBuilder("UPDATE ad_migrationscript SET status = ? , isApply = 'N' WHERE ad_migrationscript_id = ? ");
pstmt = DB.prepareStatement(sql, this.get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), this.get_TrxName());
if (execOk) { if (execOk) {
pstmt.setString(1, "CO"); pstmt.setString(1, "CO");
pstmt.setInt(2, seqID); pstmt.setInt(2, seqID);
@ -91,8 +91,8 @@ public class ApplyMigrationScripts extends SvrProcess {
} }
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
log.saveError("Error", "Script: " + rs.getString(3) + " - " StringBuilder msglog = new StringBuilder("Script: ").append(rs.getString(3)).append(" - ").append(e.getMessage());
+ e.getMessage()); log.saveError("Error", msglog.toString());
log.severe(e.getMessage()); log.severe(e.getMessage());
} }
} }
@ -110,7 +110,7 @@ public class ApplyMigrationScripts extends SvrProcess {
public boolean executeScript(String sql, String fileName) { public boolean executeScript(String sql, String fileName) {
BufferedReader reader = new BufferedReader(new StringReader(sql)); BufferedReader reader = new BufferedReader(new StringReader(sql));
StringBuffer sqlBuf = new StringBuffer(); StringBuilder sqlBuf = new StringBuilder();
String line; String line;
boolean statementReady = false; boolean statementReady = false;
boolean execOk = true; boolean execOk = true;
@ -151,8 +151,9 @@ public class ApplyMigrationScripts extends SvrProcess {
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
execOk = false; execOk = false;
log.saveError("Error", "Script: " + fileName + " - " StringBuilder msglog = new StringBuilder("Script: ").append(fileName).append(" - ")
+ e.getMessage() + ". The line that caused the error is the following ==> " + sqlBuf); .append(e.getMessage()).append(". The line that caused the error is the following ==> ").append(sqlBuf);
log.saveError("Error", msglog.toString());
log.severe(e.getMessage()); log.severe(e.getMessage());
} finally { } finally {
stmt.close(); stmt.close();

View File

@ -96,7 +96,8 @@ public class ClientAcctProcessor extends SvrProcess
*/ */
protected String doIt () throws Exception protected String doIt () throws Exception
{ {
log.info("C_AcctSchema_ID=" + p_C_AcctSchema_ID + ", AD_Table_ID=" + p_AD_Table_ID); StringBuilder msglog = new StringBuilder("C_AcctSchema_ID=").append(p_C_AcctSchema_ID).append(", AD_Table_ID=").append(p_AD_Table_ID);
log.info(msglog.toString());
if (! MClient.isClientAccounting()) if (! MClient.isClientAccounting())
throw new AdempiereUserError(Msg.getMsg(getCtx(), "ClientAccountingNotEnabled")); throw new AdempiereUserError(Msg.getMsg(getCtx(), "ClientAccountingNotEnabled"));
@ -145,7 +146,7 @@ public class ClientAcctProcessor extends SvrProcess
&& p_AD_Table_ID != AD_Table_ID) && p_AD_Table_ID != AD_Table_ID)
continue; continue;
StringBuffer sql = new StringBuffer ("SELECT DISTINCT ProcessedOn FROM ").append(TableName) StringBuilder sql = new StringBuilder("SELECT DISTINCT ProcessedOn FROM ").append(TableName)
.append(" WHERE AD_Client_ID=? AND ProcessedOn<?") .append(" WHERE AD_Client_ID=? AND ProcessedOn<?")
.append(" AND Processed='Y' AND Posted='N' AND IsActive='Y'"); .append(" AND Processed='Y' AND Posted='N' AND IsActive='Y'");
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
@ -195,7 +196,7 @@ public class ClientAcctProcessor extends SvrProcess
&& p_AD_Table_ID != AD_Table_ID) && p_AD_Table_ID != AD_Table_ID)
continue; continue;
// SELECT * FROM table // SELECT * FROM table
StringBuffer sql = new StringBuffer ("SELECT * FROM ").append(TableName) StringBuilder sql = new StringBuilder("SELECT * FROM ").append(TableName)
.append(" WHERE AD_Client_ID=? AND (ProcessedOn"); .append(" WHERE AD_Client_ID=? AND (ProcessedOn");
if (processedOn.compareTo(Env.ZERO) != 0) if (processedOn.compareTo(Env.ZERO) != 0)
sql.append("=?"); sql.append("=?");
@ -263,10 +264,14 @@ public class ClientAcctProcessor extends SvrProcess
if (countError[i] > 0) if (countError[i] > 0)
m_summary.append("(Errors=").append(countError[i]).append(")"); m_summary.append("(Errors=").append(countError[i]).append(")");
m_summary.append(" - "); m_summary.append(" - ");
log.finer(getName() + ": " + m_summary.toString()); StringBuilder msglog = new StringBuilder(getName()).append(": ").append(m_summary.toString());
log.finer(msglog.toString());
} }
else else
log.finer(getName() + ": " + TableName + " - no work"); {
StringBuilder msglog = new StringBuilder(getName()).append(": ").append(TableName).append(" - no work");
log.finer(msglog.toString());
}
} }
} // postSession } // postSession

View File

@ -224,9 +224,9 @@ public class ExpenseTypesFromAccounts extends SvrProcess {
} }
} }
String returnStr = addCount + " products added."; StringBuilder returnStr = new StringBuilder(addCount).append(" products added.");
if (skipCount>0) returnStr += " " + skipCount + " products skipped."; if (skipCount>0) returnStr.append(" ").append(skipCount).append(" products skipped.");
return(returnStr); return(returnStr.toString());
} }

View File

@ -102,7 +102,7 @@ public class Export extends SvrProcess
AD_Table_ID = getTable_ID(); AD_Table_ID = getTable_ID();
// C_Invoice; AD_Table_ID = 318 // C_Invoice; AD_Table_ID = 318
StringBuffer sb = new StringBuffer ("AD_Table_ID=").append(AD_Table_ID); StringBuilder sb = new StringBuilder("AD_Table_ID=").append(AD_Table_ID);
sb.append("; Record_ID=").append(getRecord_ID()); sb.append("; Record_ID=").append(getRecord_ID());
// Parameter // Parameter
ProcessInfoParameter[] para = getParameter(); ProcessInfoParameter[] para = getParameter();
@ -154,7 +154,7 @@ public class Export extends SvrProcess
} }
MEXPFormat exportFormat = new MEXPFormat(getCtx(), EXP_Format_ID, get_TrxName()); MEXPFormat exportFormat = new MEXPFormat(getCtx(), EXP_Format_ID, get_TrxName());
StringBuffer sql = new StringBuffer("SELECT * ") StringBuilder sql = new StringBuilder("SELECT * ")
.append("FROM ").append(table.getTableName()).append(" ") .append("FROM ").append(table.getTableName()).append(" ")
.append("WHERE ").append(po.get_KeyColumns()[0]).append("=?") .append("WHERE ").append(po.get_KeyColumns()[0]).append("=?")
; ;
@ -270,7 +270,8 @@ public class Export extends SvrProcess
} }
} }
}*/ }*/
log.info("EXP Field - column=["+column.getColumnName()+"]; value=" + value); StringBuilder msglog = new StringBuilder("EXP Field - column=[").append(column.getColumnName()).append("]; value=").append(value);
log.info(msglog.toString());
if (valueString != null && !"".equals(valueString) && !"null".equals(valueString)) { if (valueString != null && !"".equals(valueString) && !"null".equals(valueString)) {
Text newText = outDocument.createTextNode(valueString); Text newText = outDocument.createTextNode(valueString);
newElement.appendChild(newText); newElement.appendChild(newText);
@ -331,7 +332,8 @@ public class Export extends SvrProcess
} }
} }
}*/ }*/
log.info("EXP Field - column=["+column.getColumnName()+"]; value=" + value); StringBuilder msglog = new StringBuilder("EXP Field - column=[").append(column.getColumnName()).append("]; value=").append(value);
log.info(msglog.toString());
if (valueString != null && !"".equals(valueString) && !"null".equals(valueString)) { if (valueString != null && !"".equals(valueString) && !"null".equals(valueString)) {
rootElement.setAttribute(formatLine.getValue(), valueString); rootElement.setAttribute(formatLine.getValue(), valueString);
elementHasValue = true; elementHasValue = true;
@ -348,7 +350,7 @@ public class Export extends SvrProcess
MTable tableEmbedded = MTable.get(getCtx(), embeddedFormat.getAD_Table_ID()); MTable tableEmbedded = MTable.get(getCtx(), embeddedFormat.getAD_Table_ID());
log.info("Table Embedded = " + tableEmbedded); log.info("Table Embedded = " + tableEmbedded);
StringBuffer sql = new StringBuffer("SELECT * ") StringBuilder sql = new StringBuilder("SELECT * ")
.append("FROM ").append(tableEmbedded.getTableName()).append(" ") .append("FROM ").append(tableEmbedded.getTableName()).append(" ")
.append("WHERE ").append(masterPO.get_KeyColumns()[0]).append("=?") .append("WHERE ").append(masterPO.get_KeyColumns()[0]).append("=?")
//+ "WHERE " + po.get_WhereClause(false) //+ "WHERE " + po.get_WhereClause(false)

View File

@ -83,10 +83,10 @@ public class HouseKeeping extends SvrProcess{
int nodel = 0; int nodel = 0;
if (houseKeeping.isSaveInHistoric()){ if (houseKeeping.isSaveInHistoric()){
String sql = "INSERT INTO hst_"+tableName + " SELECT * FROM " + tableName; StringBuilder sql = new StringBuilder("INSERT INTO hst_").append(tableName).append(" SELECT * FROM ").append(tableName);
if (whereClause != null && whereClause.length() > 0) if (whereClause != null && whereClause.length() > 0)
sql = sql + " WHERE " + whereClause; sql.append(" WHERE ").append(whereClause);
noins = DB.executeUpdate(sql, get_TrxName()); noins = DB.executeUpdate(sql.toString(), get_TrxName());
if (noins == -1) if (noins == -1)
throw new AdempiereSystemError("Cannot insert into hst_"+tableName); throw new AdempiereSystemError("Cannot insert into hst_"+tableName);
addLog("@Inserted@ " + noins); addLog("@Inserted@ " + noins);
@ -98,15 +98,15 @@ public class HouseKeeping extends SvrProcess{
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
String dateString = dateFormat.format(date); String dateString = dateFormat.format(date);
FileWriter file = new FileWriter(pathFile+File.separator+tableName+dateString+".xml"); FileWriter file = new FileWriter(pathFile+File.separator+tableName+dateString+".xml");
String sql = "SELECT * FROM " + tableName; StringBuilder sql = new StringBuilder("SELECT * FROM ").append(tableName);
if (whereClause != null && whereClause.length() > 0) if (whereClause != null && whereClause.length() > 0)
sql = sql + " WHERE " + whereClause; sql.append(" WHERE ").append(whereClause);
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
StringBuffer linexml = null; StringBuffer linexml = null;
try try
{ {
pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql.toString(), get_TrxName());
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) { while (rs.next()) {
GenericPO po = new GenericPO(tableName, getCtx(), rs, get_TrxName()); GenericPO po = new GenericPO(tableName, getCtx(), rs, get_TrxName());
@ -130,10 +130,10 @@ public class HouseKeeping extends SvrProcess{
addLog("@Exported@ " + noexp); addLog("@Exported@ " + noexp);
}//XmlExport }//XmlExport
String sql = "DELETE FROM " + tableName; StringBuilder sql = new StringBuilder("DELETE FROM ").append(tableName);
if (whereClause != null && whereClause.length() > 0) if (whereClause != null && whereClause.length() > 0)
sql = sql + " WHERE " + whereClause; sql.append(" WHERE ").append(whereClause);
nodel = DB.executeUpdate(sql, get_TrxName()); nodel = DB.executeUpdate(sql.toString(), get_TrxName());
if (nodel == -1) if (nodel == -1)
throw new AdempiereSystemError("Cannot delete from " + tableName); throw new AdempiereSystemError("Cannot delete from " + tableName);
Timestamp time = new Timestamp(date.getTime()); Timestamp time = new Timestamp(date.getTime());
@ -141,7 +141,7 @@ public class HouseKeeping extends SvrProcess{
houseKeeping.setLastDeleted(nodel); houseKeeping.setLastDeleted(nodel);
houseKeeping.saveEx(); houseKeeping.saveEx();
addLog("@Deleted@ " + nodel); addLog("@Deleted@ " + nodel);
String msg = Msg.getElement(getCtx(), tableName + "_ID") + " #" + nodel; StringBuilder msg = new StringBuilder(Msg.getElement(getCtx(), tableName + "_ID")).append(" #").append(nodel);
return msg; return msg.toString();
}//doIt }//doIt
} }

View File

@ -114,10 +114,11 @@ public class ImmediateBankTransfer extends SvrProcess
*/ */
protected String doIt() throws Exception protected String doIt() throws Exception
{ {
log.info("From Bank="+p_From_C_BankAccount_ID+" - To Bank="+p_To_C_BankAccount_ID StringBuilder msglog = new StringBuilder("From Bank=").append(p_From_C_BankAccount_ID).append(" - To Bank=").append(p_To_C_BankAccount_ID)
+ " - C_CashBook_ID="+p_C_CashBook_ID+" - Amount="+p_Amount+" - Name="+p_Name .append(" - C_CashBook_ID=").append(p_C_CashBook_ID).append(" - Amount=").append(p_Amount).append(" - Name=").append(p_Name)
+ " - Description="+p_Description+ " - Statement Date="+p_StatementDate+ .append(" - Description=").append(p_Description).append(" - Statement Date=").append(p_StatementDate)
" - Date Account="+p_DateAcct); .append(" - Date Account=").append(p_DateAcct);
log.info(msglog.toString());
if (p_To_C_BankAccount_ID == 0 || p_From_C_BankAccount_ID == 0) if (p_To_C_BankAccount_ID == 0 || p_From_C_BankAccount_ID == 0)
throw new IllegalArgumentException("Banks required"); throw new IllegalArgumentException("Banks required");
@ -248,17 +249,18 @@ public class ImmediateBankTransfer extends SvrProcess
MCash cash = createCash(); MCash cash = createCash();
MCashLine cashLines[]= createCashLines(cash); MCashLine cashLines[]= createCashLines(cash);
StringBuffer processMsg = new StringBuffer(cash.getDocumentNo()); StringBuilder processMsg = new StringBuilder(cash.getDocumentNo());
cash.setDocAction(p_docAction); cash.setDocAction(p_docAction);
if (!cash.processIt(p_docAction)) if (!cash.processIt(p_docAction))
{ {
processMsg.append(" (NOT Processed)"); processMsg.append(" (NOT Processed)");
log.warning("Cash Processing failed: " + cash + " - " + cash.getProcessMsg()); StringBuilder msglog = new StringBuilder("Cash Processing failed: ").append(cash).append(" - ").append(cash.getProcessMsg());
addLog(cash.getC_Cash_ID(), cash.getStatementDate(), null, log.warning(msglog.toString());
"Cash Processing failed: " + cash + " - " msglog = new StringBuilder("Cash Processing failed: ").append(cash).append(" - ")
+ cash.getProcessMsg() .append(cash.getProcessMsg())
+ " / please complete it manually"); .append(" / please complete it manually");
addLog(cash.getC_Cash_ID(), cash.getStatementDate(), null,msglog.toString());
throw new IllegalStateException("Cash Processing failed: " + cash + " - " + cash.getProcessMsg()); throw new IllegalStateException("Cash Processing failed: " + cash + " - " + cash.getProcessMsg());
} }
if (!cash.save()) if (!cash.save())

View File

@ -88,9 +88,9 @@ public class ImportPriceList extends SvrProcess
*/ */
protected String doIt() throws Exception protected String doIt() throws Exception
{ {
StringBuffer sql = null; StringBuilder sql = null;
int no = 0; int no = 0;
String clientCheck = " AND AD_Client_ID=" + m_AD_Client_ID; StringBuilder clientCheck = new StringBuilder(" AND AD_Client_ID=").append(m_AD_Client_ID);
int m_discountschema_id = DB.getSQLValue(get_TrxName(), int m_discountschema_id = DB.getSQLValue(get_TrxName(),
"SELECT MIN(M_DiscountSchema_ID) FROM M_DiscountSchema WHERE DiscountType='P' AND IsActive='Y' AND AD_Client_ID=?", "SELECT MIN(M_DiscountSchema_ID) FROM M_DiscountSchema WHERE DiscountType='P' AND IsActive='Y' AND AD_Client_ID=?",
@ -103,81 +103,81 @@ public class ImportPriceList extends SvrProcess
// Delete Old Imported // Delete Old Imported
if (m_deleteOldImported) if (m_deleteOldImported)
{ {
sql = new StringBuffer ("DELETE I_PriceList " sql = new StringBuilder("DELETE I_PriceList "
+ "WHERE I_IsImported='Y'").append(clientCheck); + "WHERE I_IsImported='Y'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
log.info("Delete Old Impored =" + no); log.info("Delete Old Impored =" + no);
} }
// Set Client, Org, IsActive, Created/Updated, EnforcePriceLimit, IsSOPriceList, IsTaxIncluded, PricePrecision // Set Client, Org, IsActive, Created/Updated, EnforcePriceLimit, IsSOPriceList, IsTaxIncluded, PricePrecision
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder("UPDATE I_PriceList ")
+ "SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append(")," .append("SET AD_Client_ID = COALESCE (AD_Client_ID, ").append(m_AD_Client_ID).append("),")
+ " AD_Org_ID = COALESCE (AD_Org_ID, 0)," .append(" AD_Org_ID = COALESCE (AD_Org_ID, 0),")
+ " IsActive = COALESCE (IsActive, 'Y')," .append(" IsActive = COALESCE (IsActive, 'Y'),")
+ " Created = COALESCE (Created, SysDate)," .append(" Created = COALESCE (Created, SysDate),")
+ " CreatedBy = COALESCE (CreatedBy, 0)," .append(" CreatedBy = COALESCE (CreatedBy, 0),")
+ " Updated = COALESCE (Updated, SysDate)," .append(" Updated = COALESCE (Updated, SysDate),")
+ " UpdatedBy = COALESCE (UpdatedBy, 0)," .append(" UpdatedBy = COALESCE (UpdatedBy, 0),")
+ " EnforcePriceLimit = COALESCE (EnforcePriceLimit, 'N')," .append(" EnforcePriceLimit = COALESCE (EnforcePriceLimit, 'N'),")
+ " IsSOPriceList = COALESCE (IsSOPriceList, 'N')," .append(" IsSOPriceList = COALESCE (IsSOPriceList, 'N'),")
+ " IsTaxIncluded = COALESCE (IsTaxIncluded, 'N')," .append(" IsTaxIncluded = COALESCE (IsTaxIncluded, 'N'),")
+ " PricePrecision = COALESCE (PricePrecision, 2)," .append(" PricePrecision = COALESCE (PricePrecision, 2),")
+ " I_ErrorMsg = ' '," .append(" I_ErrorMsg = ' ',")
+ " I_IsImported = 'N' " .append(" I_IsImported = 'N' ")
+ "WHERE I_IsImported<>'Y' OR I_IsImported IS NULL"); .append("WHERE I_IsImported<>'Y' OR I_IsImported IS NULL");
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
log.info("Reset=" + no); log.info("Reset=" + no);
// Set Optional BPartner // Set Optional BPartner
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder ("UPDATE I_PriceList ")
+ "SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner p" .append("SET C_BPartner_ID=(SELECT C_BPartner_ID FROM C_BPartner p")
+ " WHERE I_PriceList.BPartner_Value=p.Value AND I_PriceList.AD_Client_ID=p.AD_Client_ID) " .append(" WHERE I_PriceList.BPartner_Value=p.Value AND I_PriceList.AD_Client_ID=p.AD_Client_ID) ")
+ "WHERE C_BPartner_ID IS NULL AND BPartner_Value IS NOT NULL" .append("WHERE C_BPartner_ID IS NULL AND BPartner_Value IS NOT NULL")
+ " AND I_IsImported<>'Y'").append(clientCheck); .append(" AND I_IsImported<>'Y'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
log.info("BPartner=" + no); log.info("BPartner=" + no);
// //
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder ("UPDATE I_PriceList ")
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid BPartner,' " .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid BPartner,' ")
+ "WHERE C_BPartner_ID IS NULL AND BPartner_Value IS NOT NULL" .append("WHERE C_BPartner_ID IS NULL AND BPartner_Value IS NOT NULL")
+ " AND I_IsImported<>'Y'").append(clientCheck); .append(" AND I_IsImported<>'Y'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.warning("Invalid BPartner=" + no); log.warning("Invalid BPartner=" + no);
// Product // Product
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder("UPDATE I_PriceList ")
+ "SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p" .append("SET M_Product_ID=(SELECT MAX(M_Product_ID) FROM M_Product p")
+ " WHERE I_PriceList.ProductValue=p.Value AND I_PriceList.AD_Client_ID=p.AD_Client_ID) " .append(" WHERE I_PriceList.ProductValue=p.Value AND I_PriceList.AD_Client_ID=p.AD_Client_ID) ")
+ "WHERE M_Product_ID IS NULL AND ProductValue IS NOT NULL" .append("WHERE M_Product_ID IS NULL AND ProductValue IS NOT NULL")
+ " AND I_IsImported<>'Y'").append (clientCheck); .append(" AND I_IsImported<>'Y'").append (clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("Set Product from Value=" + no); log.fine("Set Product from Value=" + no);
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder ("UPDATE I_PriceList ")
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Product, ' " .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid Product, ' ")
+ "WHERE M_Product_ID IS NULL AND (ProductValue IS NOT NULL)" .append("WHERE M_Product_ID IS NULL AND (ProductValue IS NOT NULL)")
+ " AND I_IsImported<>'Y'").append (clientCheck); .append(" AND I_IsImported<>'Y'").append (clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.warning ("Invalid Product=" + no); log.warning ("Invalid Product=" + no);
// **** Find Price List // **** Find Price List
// Name // Name
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder ("UPDATE I_PriceList ")
+ "SET M_PriceList_ID=(SELECT M_PriceList_ID FROM M_PriceList p" .append("SET M_PriceList_ID=(SELECT M_PriceList_ID FROM M_PriceList p")
+ " WHERE I_PriceList.Name=p.Name AND I_PriceList.AD_Client_ID=p.AD_Client_ID) " .append(" WHERE I_PriceList.Name=p.Name AND I_PriceList.AD_Client_ID=p.AD_Client_ID) ")
+ "WHERE M_PriceList_ID IS NULL" .append("WHERE M_PriceList_ID IS NULL")
+ " AND I_IsImported='N'").append(clientCheck); .append(" AND I_IsImported='N'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
log.info("Price List Existing Value=" + no); log.info("Price List Existing Value=" + no);
// **** Find Price List Version // **** Find Price List Version
// List Name (ID) + ValidFrom // List Name (ID) + ValidFrom
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder ("UPDATE I_PriceList ")
+ "SET M_PriceList_Version_ID=(SELECT M_PriceList_Version_ID FROM M_PriceList_Version p" .append("SET M_PriceList_Version_ID=(SELECT M_PriceList_Version_ID FROM M_PriceList_Version p")
+ " WHERE I_PriceList.ValidFrom=p.ValidFrom AND I_PriceList.M_PriceList_ID=p.M_PriceList_ID) " .append(" WHERE I_PriceList.ValidFrom=p.ValidFrom AND I_PriceList.M_PriceList_ID=p.M_PriceList_ID) ")
+ "WHERE M_PriceList_ID IS NOT NULL AND M_PriceList_Version_ID IS NULL" .append("WHERE M_PriceList_ID IS NOT NULL AND M_PriceList_Version_ID IS NULL")
+ " AND I_IsImported='N'").append(clientCheck); .append(" AND I_IsImported='N'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
log.info("Price List Version Existing Value=" + no); log.info("Price List Version Existing Value=" + no);
@ -208,55 +208,55 @@ public class ImportPriceList extends SvrProcess
*/ */
// Set Currency // Set Currency
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder("UPDATE I_PriceList ")
+ "SET ISO_Code=(SELECT ISO_Code FROM C_Currency c" .append("SET ISO_Code=(SELECT ISO_Code FROM C_Currency c")
+ " INNER JOIN C_AcctSchema a ON (a.C_Currency_ID=c.C_Currency_ID)" .append(" INNER JOIN C_AcctSchema a ON (a.C_Currency_ID=c.C_Currency_ID)")
+ " INNER JOIN AD_ClientInfo ci ON (a.C_AcctSchema_ID=ci.C_AcctSchema1_ID)" .append(" INNER JOIN AD_ClientInfo ci ON (a.C_AcctSchema_ID=ci.C_AcctSchema1_ID)")
+ " WHERE ci.AD_Client_ID=I_PriceList.AD_Client_ID) " .append(" WHERE ci.AD_Client_ID=I_PriceList.AD_Client_ID) ")
+ "WHERE C_Currency_ID IS NULL AND ISO_Code IS NULL" .append("WHERE C_Currency_ID IS NULL AND ISO_Code IS NULL")
+ " AND I_IsImported<>'Y'").append(clientCheck); .append(" AND I_IsImported<>'Y'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("Set Currency Default=" + no); log.fine("Set Currency Default=" + no);
// //
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder ("UPDATE I_PriceList ")
+ "SET C_Currency_ID=(SELECT C_Currency_ID FROM C_Currency c" .append("SET C_Currency_ID=(SELECT C_Currency_ID FROM C_Currency c")
+ " WHERE I_PriceList.ISO_Code=c.ISO_Code AND c.AD_Client_ID IN (0,I_PriceList.AD_Client_ID)) " .append(" WHERE I_PriceList.ISO_Code=c.ISO_Code AND c.AD_Client_ID IN (0,I_PriceList.AD_Client_ID)) ")
+ "WHERE C_Currency_ID IS NULL" .append("WHERE C_Currency_ID IS NULL")
+ " AND I_IsImported<>'Y'").append(clientCheck); .append(" AND I_IsImported<>'Y'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
log.info("doIt- Set Currency=" + no); log.info("doIt- Set Currency=" + no);
// //
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder ("UPDATE I_PriceList ")
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Currency,' " .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Currency,' ")
+ "WHERE C_Currency_ID IS NULL" .append("WHERE C_Currency_ID IS NULL")
+ " AND I_IsImported<>'Y'").append(clientCheck); .append(" AND I_IsImported<>'Y'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.warning("Invalid Currency=" + no); log.warning("Invalid Currency=" + no);
// Mandatory Name or PriceListID // Mandatory Name or PriceListID
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder ("UPDATE I_PriceList ")
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Mandatory Name or PriceListID,' " .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Mandatory Name or PriceListID,' ")
+ "WHERE Name IS NULL AND M_PriceList_ID IS NULL" .append("WHERE Name IS NULL AND M_PriceList_ID IS NULL")
+ " AND I_IsImported<>'Y'").append(clientCheck); .append(" AND I_IsImported<>'Y'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.warning("No Mandatory Name=" + no); log.warning("No Mandatory Name=" + no);
// Mandatory ValidFrom or PriceListVersionID // Mandatory ValidFrom or PriceListVersionID
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder ("UPDATE I_PriceList ")
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Mandatory ValidFrom or PriceListVersionID,' " .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Mandatory ValidFrom or PriceListVersionID,' ")
+ "WHERE ValidFrom IS NULL AND M_PriceList_Version_ID IS NULL" .append("WHERE ValidFrom IS NULL AND M_PriceList_Version_ID IS NULL")
+ " AND I_IsImported<>'Y'").append(clientCheck); .append(" AND I_IsImported<>'Y'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.warning("No Mandatory ValidFrom=" + no); log.warning("No Mandatory ValidFrom=" + no);
// Mandatory BreakValue if BPartner set // Mandatory BreakValue if BPartner set
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder ("UPDATE I_PriceList ")
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Mandatory BreakValue,' " .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=No Mandatory BreakValue,' ")
+ "WHERE BreakValue IS NULL AND (C_BPartner_ID IS NOT NULL OR BPartner_Value IS NOT NULL)" .append("WHERE BreakValue IS NULL AND (C_BPartner_ID IS NOT NULL OR BPartner_Value IS NOT NULL)")
+ " AND I_IsImported<>'Y'").append(clientCheck); .append(" AND I_IsImported<>'Y'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)
log.warning("No Mandatory BreakValue=" + no); log.warning("No Mandatory BreakValue=" + no);
@ -273,7 +273,7 @@ public class ImportPriceList extends SvrProcess
// Go through Records // Go through Records
log.fine("start inserting/updating ..."); log.fine("start inserting/updating ...");
sql = new StringBuffer ("SELECT * FROM I_PriceList WHERE I_IsImported='N'") sql = new StringBuilder ("SELECT * FROM I_PriceList WHERE I_IsImported='N'")
.append(clientCheck); .append(clientCheck);
PreparedStatement pstmt_setImported = null; PreparedStatement pstmt_setImported = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
@ -300,7 +300,8 @@ public class ImportPriceList extends SvrProcess
M_PriceList_ID = 0; M_PriceList_ID = 0;
} }
boolean newPriceList = M_PriceList_ID == 0; boolean newPriceList = M_PriceList_ID == 0;
log.fine("I_PriceList_ID=" + I_PriceList_ID + ", M_PriceList_ID=" + M_PriceList_ID); StringBuilder msglog = new StringBuilder("I_PriceList_ID=").append(I_PriceList_ID).append(", M_PriceList_ID=").append(M_PriceList_ID);
log.fine(msglog.toString());
MPriceList pricelist = null; MPriceList pricelist = null;
// PriceList // PriceList
@ -315,8 +316,8 @@ public class ImportPriceList extends SvrProcess
} }
else else
{ {
StringBuffer sql0 = new StringBuffer ("UPDATE I_PriceList i " StringBuilder sql0 = new StringBuilder ("UPDATE I_PriceList i ")
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert Price List failed")) .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert Price List failed"))
.append("WHERE I_PriceList_ID=").append(I_PriceList_ID); .append("WHERE I_PriceList_ID=").append(I_PriceList_ID);
DB.executeUpdate(sql0.toString(), get_TrxName()); DB.executeUpdate(sql0.toString(), get_TrxName());
continue; continue;
@ -334,7 +335,8 @@ public class ImportPriceList extends SvrProcess
M_PriceList_Version_ID = 0; M_PriceList_Version_ID = 0;
} }
boolean newPriceListVersion = M_PriceList_Version_ID == 0; boolean newPriceListVersion = M_PriceList_Version_ID == 0;
log.fine("I_PriceList_ID=" + I_PriceList_ID + ", M_PriceList_Version_ID=" + M_PriceList_Version_ID); msglog = new StringBuilder("I_PriceList_ID=").append(I_PriceList_ID).append(", M_PriceList_Version_ID=").append(M_PriceList_Version_ID);
log.fine(msglog.toString());
MPriceListVersion pricelistversion = null; MPriceListVersion pricelistversion = null;
// PriceListVersion // PriceListVersion
@ -352,8 +354,8 @@ public class ImportPriceList extends SvrProcess
} }
else else
{ {
StringBuffer sql0 = new StringBuffer ("UPDATE I_PriceList i " StringBuilder sql0 = new StringBuilder ("UPDATE I_PriceList i ")
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert Price List Version failed")) .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert Price List Version failed"))
.append("WHERE I_PriceList_ID=").append(I_PriceList_ID); .append("WHERE I_PriceList_ID=").append(I_PriceList_ID);
DB.executeUpdate(sql0.toString(), get_TrxName()); DB.executeUpdate(sql0.toString(), get_TrxName());
continue; continue;
@ -401,8 +403,8 @@ public class ImportPriceList extends SvrProcess
} }
else else
{ {
StringBuffer sql0 = new StringBuffer ("UPDATE I_PriceList i " StringBuilder sql0 = new StringBuilder ("UPDATE I_PriceList i ")
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert/Update Product Price Vendor Break Version failed")) .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert/Update Product Price Vendor Break Version failed"))
.append("WHERE I_PriceList_ID=").append(I_PriceList_ID); .append("WHERE I_PriceList_ID=").append(I_PriceList_ID);
DB.executeUpdate(sql0.toString(), get_TrxName()); DB.executeUpdate(sql0.toString(), get_TrxName());
continue; continue;
@ -432,8 +434,8 @@ public class ImportPriceList extends SvrProcess
} }
else else
{ {
StringBuffer sql0 = new StringBuffer ("UPDATE I_PriceList i " StringBuilder sql0 = new StringBuilder ("UPDATE I_PriceList i ")
+ "SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert/Update Product Price failed")) .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||").append(DB.TO_STRING("Insert/Update Product Price failed"))
.append("WHERE I_PriceList_ID=").append(I_PriceList_ID); .append("WHERE I_PriceList_ID=").append(I_PriceList_ID);
DB.executeUpdate(sql0.toString(), get_TrxName()); DB.executeUpdate(sql0.toString(), get_TrxName());
continue; continue;
@ -460,9 +462,9 @@ public class ImportPriceList extends SvrProcess
} }
// Set Error to indicator to not imported // Set Error to indicator to not imported
sql = new StringBuffer ("UPDATE I_PriceList " sql = new StringBuilder ("UPDATE I_PriceList ")
+ "SET I_IsImported='N', Updated=SysDate " .append("SET I_IsImported='N', Updated=SysDate ")
+ "WHERE I_IsImported<>'Y'").append(clientCheck); .append("WHERE I_IsImported<>'Y'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
addLog (0, null, new BigDecimal (no), "@Errors@"); addLog (0, null, new BigDecimal (no), "@Errors@");
addLog (0, null, new BigDecimal (noInsertpl), "@M_PriceList_ID@: @Inserted@"); addLog (0, null, new BigDecimal (noInsertpl), "@M_PriceList_ID@: @Inserted@");

View File

@ -236,8 +236,9 @@ public class InOutGenerateRMA extends SvrProcess
if (shipmentLines.length == 0) if (shipmentLines.length == 0)
{ {
log.log(Level.WARNING, "No shipment lines created: M_RMA_ID=" StringBuilder msglog = new StringBuilder("No shipment lines created: M_RMA_ID=")
+ M_RMA_ID + ", M_InOut_ID=" + shipment.get_ID()); .append(M_RMA_ID).append(", M_InOut_ID=").append(shipment.get_ID());
log.log(Level.WARNING, msglog.toString());
} }
StringBuffer processMsg = new StringBuffer(shipment.getDocumentNo()); StringBuffer processMsg = new StringBuffer(shipment.getDocumentNo());
@ -245,7 +246,8 @@ public class InOutGenerateRMA extends SvrProcess
if (!shipment.processIt(p_docAction)) if (!shipment.processIt(p_docAction))
{ {
processMsg.append(" (NOT Processed)"); processMsg.append(" (NOT Processed)");
log.warning("Shipment Processing failed: " + shipment + " - " + shipment.getProcessMsg()); StringBuilder msglog = new StringBuilder("Shipment Processing failed: ").append(shipment).append(" - ").append(shipment.getProcessMsg());
log.warning(msglog.toString());
throw new IllegalStateException("Shipment Processing failed: " + shipment + " - " + shipment.getProcessMsg()); throw new IllegalStateException("Shipment Processing failed: " + shipment + " - " + shipment.getProcessMsg());
} }

View File

@ -149,24 +149,26 @@ public class InitialClientSetup extends SvrProcess
*/ */
protected String doIt () throws Exception protected String doIt () throws Exception
{ {
log.info("InitialClientSetup"
+ ": ClientName=" + p_ClientName StringBuilder msglog = new StringBuilder("InitialClientSetup")
+ ", OrgValue=" + p_OrgValue .append(": ClientName=").append(p_ClientName)
+ ", OrgName=" + p_OrgName .append(", OrgValue=").append(p_OrgValue)
+ ", AdminUserName=" + p_AdminUserName .append(", OrgName=").append(p_OrgName)
+ ", NormalUserName=" + p_NormalUserName .append(", AdminUserName=").append(p_AdminUserName)
+ ", C_Currency_ID=" + p_C_Currency_ID .append(", NormalUserName=").append(p_NormalUserName)
+ ", C_Country_ID=" + p_C_Country_ID .append(", C_Currency_ID=").append(p_C_Currency_ID)
+ ", C_Region_ID=" + p_C_Region_ID .append(", C_Country_ID=").append(p_C_Country_ID)
+ ", CityName=" + p_CityName .append(", C_Region_ID=").append(p_C_Region_ID)
+ ", C_City_ID=" + p_C_City_ID .append(", CityName=").append(p_CityName)
+ ", IsUseBPDimension=" + p_IsUseBPDimension .append(", C_City_ID=").append(p_C_City_ID)
+ ", IsUseProductDimension=" + p_IsUseProductDimension .append(", IsUseBPDimension=").append(p_IsUseBPDimension)
+ ", IsUseProjectDimension=" + p_IsUseProjectDimension .append(", IsUseProductDimension=").append(p_IsUseProductDimension)
+ ", IsUseCampaignDimension=" + p_IsUseCampaignDimension .append(", IsUseProjectDimension=").append(p_IsUseProjectDimension)
+ ", IsUseSalesRegionDimension=" + p_IsUseSalesRegionDimension .append(", IsUseCampaignDimension=").append(p_IsUseCampaignDimension)
+ ", CoAFile=" + p_CoAFile .append(", IsUseSalesRegionDimension=").append(p_IsUseSalesRegionDimension)
); .append(", CoAFile=").append(p_CoAFile);
log.info(msglog.toString());
// Validations // Validations
@ -196,7 +198,8 @@ public class InitialClientSetup extends SvrProcess
if (p_C_City_ID > 0) { if (p_C_City_ID > 0) {
MCity city = MCity.get(getCtx(), p_C_City_ID); MCity city = MCity.get(getCtx(), p_C_City_ID);
if (! city.getName().equals(p_CityName)) { if (! city.getName().equals(p_CityName)) {
log.info("City name changed from " + p_CityName + " to " + city.getName()); msglog = new StringBuilder("City name changed from ").append(p_CityName).append(" to ").append(city.getName());
log.info(msglog.toString());
p_CityName = city.getName(); p_CityName = city.getName();
} }
} }

View File

@ -165,8 +165,9 @@ public class InvoiceGenerateRMA extends SvrProcess
{ {
if (rmaLine.getM_InOutLine_ID() == 0) if (rmaLine.getM_InOutLine_ID() == 0)
{ {
throw new IllegalStateException("No customer return line - RMA = " StringBuilder msgiste = new StringBuilder("No customer return line - RMA = ")
+ rma.getDocumentNo() + ", Line = " + rmaLine.getLine()); .append(rma.getDocumentNo()).append(", Line = ").append(rmaLine.getLine());
throw new IllegalStateException(msgiste.toString());
} }
MInvoiceLine invLine = new MInvoiceLine(invoice); MInvoiceLine invLine = new MInvoiceLine(invoice);
@ -197,17 +198,19 @@ public class InvoiceGenerateRMA extends SvrProcess
if (invoiceLines.length == 0) if (invoiceLines.length == 0)
{ {
log.log(Level.WARNING, "No invoice lines created: M_RMA_ID=" StringBuilder msglog = new StringBuilder("No invoice lines created: M_RMA_ID=")
+ M_RMA_ID + ", M_Invoice_ID=" + invoice.get_ID()); .append(M_RMA_ID).append(", M_Invoice_ID=").append(invoice.get_ID());
log.log(Level.WARNING, msglog.toString());
} }
StringBuffer processMsg = new StringBuffer(invoice.getDocumentNo()); StringBuilder processMsg = new StringBuilder(invoice.getDocumentNo());
if (!invoice.processIt(p_docAction)) if (!invoice.processIt(p_docAction))
{ {
processMsg.append(" (NOT Processed)"); processMsg.append(" (NOT Processed)");
log.warning("Invoice Processing failed: " + invoice + " - " + invoice.getProcessMsg()); StringBuilder msg = new StringBuilder("Invoice Processing failed: ").append(invoice).append(" - ").append(invoice.getProcessMsg());
throw new IllegalStateException("Invoice Processing failed: " + invoice + " - " + invoice.getProcessMsg()); log.warning(msg.toString());
throw new IllegalStateException(msg.toString());
} }
if (!invoice.save()) if (!invoice.save())

View File

@ -72,18 +72,19 @@ public class PrepareMigrationScripts extends SvrProcess {
}; };
dirList = dir.listFiles(filter); dirList = dir.listFiles(filter);
log.info("Searching for SQL files in the " + dir + " directory"); StringBuilder msglog = new StringBuilder("Searching for SQL files in the ").append(dir).append(" directory");
log.info(msglog.toString());
String msg = ""; StringBuilder msg = new StringBuilder();
// Get Filenames // Get Filenames
for (int i = 0; i < dirList.length; i++) { for (int i = 0; i < dirList.length; i++) {
fileName.add(dirList[i].toString() fileName.add(dirList[i].toString()
.substring(directory.length() + 1)); .substring(directory.length() + 1));
log msglog = new StringBuilder("Found file [")
.fine("Found file [" .append(fileName.get(i))
+ fileName.get(i) .append("]. Finding out if the script has or hasn't been applied yet...");
+ "]. Finding out if the script has or hasn't been applied yet..."); log.fine(msglog.toString());
try { try {
// First of all, check if the script hasn't been applied yet... // First of all, check if the script hasn't been applied yet...
String checkScript = "select ad_migrationscript_id from ad_migrationscript where name = ?"; String checkScript = "select ad_migrationscript_id from ad_migrationscript where name = ?";
@ -92,15 +93,16 @@ public class PrepareMigrationScripts extends SvrProcess {
pstmt.setString(1, fileName.get(i)); pstmt.setString(1, fileName.get(i));
ResultSet rs = pstmt.executeQuery(); ResultSet rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next()) {
log.warning("Script " + fileName.get(i) msglog = new StringBuilder("Script ").append(fileName.get(i))
+ " already in the database"); .append(" already in the database");
log.warning(msglog.toString());
pstmt.close(); pstmt.close();
continue; continue;
} }
pstmt.close(); pstmt.close();
// first use a Scanner to get each line // first use a Scanner to get each line
Scanner scanner = new Scanner(dirList[i]); Scanner scanner = new Scanner(dirList[i]);
StringBuffer body = new StringBuffer(); StringBuilder body = new StringBuilder();
boolean blHeader = false; boolean blHeader = false;
boolean blBody = false; boolean blBody = false;
boolean isFirstLine = true; boolean isFirstLine = true;
@ -215,8 +217,9 @@ public class PrepareMigrationScripts extends SvrProcess {
if (result > 0) if (result > 0)
log.info("Header inserted. Now inserting the script body"); log.info("Header inserted. Now inserting the script body");
else { else {
log.severe("Script " + fileName.get(i) + " failed!"); msglog = new StringBuilder("Script ").append(fileName.get(i)).append(" failed!");
msg = msg + "Script " + fileName.get(i) + " failed!"; log.severe(msglog.toString());
msg.append(msglog);
continue; continue;
} }
sql = "UPDATE AD_MigrationScript SET script = ? WHERE AD_MigrationScript_ID = ?"; sql = "UPDATE AD_MigrationScript SET script = ? WHERE AD_MigrationScript_ID = ?";
@ -228,8 +231,9 @@ public class PrepareMigrationScripts extends SvrProcess {
if (result > 0) if (result > 0)
log.info("Script Body inserted."); log.info("Script Body inserted.");
else { else {
log.severe("Script Body " + fileName.get(i) + " failed!"); msglog = new StringBuilder("Script Body ").append(fileName.get(i)).append(" failed!");
msg = msg + "Script Body " + fileName.get(i) + " failed!"; log.severe(msglog.toString());
msg.append(msglog.toString());
pstmt = DB pstmt = DB
.prepareStatement( .prepareStatement(
"DELETE FROM ad_migrationscript WHERE ad_migrationscript_id = ?", "DELETE FROM ad_migrationscript WHERE ad_migrationscript_id = ?",

View File

@ -38,9 +38,9 @@ public class UpdateRoleMenu extends SvrProcess
private MRoleMenu addUpdateRole(Properties ctx, int roleId, int menuId, boolean active, String trxName) private MRoleMenu addUpdateRole(Properties ctx, int roleId, int menuId, boolean active, String trxName)
{ {
String whereClause = "AD_Role_ID=" + roleId + " AND U_WebMenu_ID=" + menuId; StringBuilder whereClause = new StringBuilder("AD_Role_ID=").append(roleId).append(" AND U_WebMenu_ID=").append(menuId);
int roleMenuIds[] = MRoleMenu.getAllIDs(MRoleMenu.Table_Name, whereClause, trxName); int roleMenuIds[] = MRoleMenu.getAllIDs(MRoleMenu.Table_Name, whereClause.toString(), trxName);
MRoleMenu roleMenu; MRoleMenu roleMenu;