IDEMPIERE-455 Discover and fix FindBugs problems / Pattern: SACM_STATIC_ARRAY_CREATED_IN_METHOD / Thanks to Richard Morales

This commit is contained in:
Carlos Ruiz 2012-12-05 17:18:28 -05:00
parent f8a4523e49
commit 3109d2584e
3 changed files with 113 additions and 94 deletions

View File

@ -75,6 +75,23 @@ public class ImportProduct extends SvrProcess implements ImportProcess
m_DateValue = new Timestamp (System.currentTimeMillis()); m_DateValue = new Timestamp (System.currentTimeMillis());
} // prepare } // prepare
// Field to copy From Product if Import does not have value
private String[] strFieldsToCopy = new String[] {
"Value",
"Name",
"Description",
"DocumentNote",
"Help",
"UPC",
"SKU",
"Classification",
"ProductType",
"Discontinued",
"DiscontinuedBy",
"DiscontinuedAt",
"ImageURL",
"DescriptionURL"
};
/** /**
* Perform process. * Perform process.
@ -183,20 +200,17 @@ public class ImportProduct extends SvrProcess implements ImportProcess
// Copy From Product if Import does not have value // Copy From Product if Import does not have value
String[] strFields = new String[] {"Value","Name","Description","DocumentNote","Help", for (int i = 0; i < strFieldsToCopy.length; i++)
"UPC","SKU","Classification","ProductType",
"Discontinued","DiscontinuedBy","DiscontinuedAt","ImageURL","DescriptionURL"};
for (int i = 0; i < strFields.length; i++)
{ {
sql = new StringBuilder ("UPDATE I_Product i ") sql = new StringBuilder ("UPDATE I_Product i ")
.append("SET ").append(strFields[i]).append(" = (SELECT ").append(strFields[i]).append(" FROM M_Product p") .append("SET ").append(strFieldsToCopy[i]).append(" = (SELECT ").append(strFieldsToCopy[i]).append(" FROM M_Product p")
.append(" WHERE i.M_Product_ID=p.M_Product_ID AND i.AD_Client_ID=p.AD_Client_ID) ") .append(" WHERE i.M_Product_ID=p.M_Product_ID AND i.AD_Client_ID=p.AD_Client_ID) ")
.append("WHERE M_Product_ID IS NOT NULL") .append("WHERE M_Product_ID IS NOT NULL")
.append(" AND ").append(strFields[i]).append(" IS NULL") .append(" AND ").append(strFieldsToCopy[i]).append(" IS NULL")
.append(" 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());
if (no != 0) if (no != 0)
log.fine(strFields[i] + " - default from existing Product=" + no); log.fine(strFieldsToCopy[i] + " - default from existing Product=" + no);
} }
String[] numFields = new String[] {"C_UOM_ID","M_Product_Category_ID", String[] numFields = new String[] {"C_UOM_ID","M_Product_Category_ID",
"Volume","Weight","ShelfWidth","ShelfHeight","ShelfDepth","UnitsPerPallet"}; "Volume","Weight","ShelfWidth","ShelfHeight","ShelfDepth","UnitsPerPallet"};

View File

@ -477,10 +477,8 @@ public abstract class Convert
} }
} }
private static boolean dontLog(String statement) {
// Do not log *Access records - teo_Sarca BF [ 2782095 ] private static String [] dontLogTables = new String[] {
// IDEMPIERE-323 Migration script log AD_Document_Action_Access (nmicoud / CarlosRuiz_globalqss)
String [] exceptionTables = new String[] {
"AD_ACCESSLOG", "AD_ACCESSLOG",
"AD_ALERTPROCESSORLOG", "AD_ALERTPROCESSORLOG",
"AD_CHANGELOG", "AD_CHANGELOG",
@ -522,6 +520,11 @@ public abstract class Convert
"T_TRANSACTION", "T_TRANSACTION",
"T_TRIALBALANCE" "T_TRIALBALANCE"
}; };
private static boolean dontLog(String statement) {
// Do not log *Access records - teo_Sarca BF [ 2782095 ]
// IDEMPIERE-323 Migration script log AD_Document_Action_Access (nmicoud / CarlosRuiz_globalqss)
String uppStmt = statement.toUpperCase().trim(); String uppStmt = statement.toUpperCase().trim();
// don't log selects // don't log selects
if (uppStmt.startsWith("SELECT ")) if (uppStmt.startsWith("SELECT "))
@ -532,16 +535,16 @@ public abstract class Convert
// Don't log DELETE FROM Some_Table WHERE AD_Table_ID=? AND Record_ID=? // Don't log DELETE FROM Some_Table WHERE AD_Table_ID=? AND Record_ID=?
if (uppStmt.startsWith("DELETE FROM ") && uppStmt.endsWith(" WHERE AD_TABLE_ID=? AND RECORD_ID=?")) if (uppStmt.startsWith("DELETE FROM ") && uppStmt.endsWith(" WHERE AD_TABLE_ID=? AND RECORD_ID=?"))
return true; return true;
for (int i = 0; i < exceptionTables.length; i++) { for (int i = 0; i < dontLogTables.length; i++) {
if (uppStmt.startsWith("INSERT INTO " + exceptionTables[i] + " ")) if (uppStmt.startsWith("INSERT INTO " + dontLogTables[i] + " "))
return true; return true;
if (uppStmt.startsWith("DELETE FROM " + exceptionTables[i] + " ")) if (uppStmt.startsWith("DELETE FROM " + dontLogTables[i] + " "))
return true; return true;
if (uppStmt.startsWith("DELETE " + exceptionTables[i] + " ")) if (uppStmt.startsWith("DELETE " + dontLogTables[i] + " "))
return true; return true;
if (uppStmt.startsWith("UPDATE " + exceptionTables[i] + " ")) if (uppStmt.startsWith("UPDATE " + dontLogTables[i] + " "))
return true; return true;
if (uppStmt.startsWith("INSERT INTO " + exceptionTables[i] + "(")) if (uppStmt.startsWith("INSERT INTO " + dontLogTables[i] + "("))
return true; return true;
} }

View File

@ -1310,8 +1310,7 @@ public class MSequence extends X_AD_Sequence
return retValue; return retValue;
} }
private static boolean isExceptionCentralized(String tableName) { private static String [] dontUseCentralized = new String[] {
String [] exceptionTables = new String[] {
"AD_ACCESSLOG", "AD_ACCESSLOG",
"AD_ALERTPROCESSORLOG", "AD_ALERTPROCESSORLOG",
"AD_CHANGELOG", "AD_CHANGELOG",
@ -1348,8 +1347,11 @@ public class MSequence extends X_AD_Sequence
"T_TRANSACTION", "T_TRANSACTION",
"T_TRIALBALANCE" "T_TRIALBALANCE"
}; };
for (int i = 0; i < exceptionTables.length; i++) {
if (tableName.equalsIgnoreCase(exceptionTables[i])) private static boolean isExceptionCentralized(String tableName) {
for (String exceptionTable : dontUseCentralized) {
if (tableName.equalsIgnoreCase(exceptionTable))
return true; return true;
} }