IDEMPIERE-834 improve performance - IDEMPIERE-3929 improve message

This commit is contained in:
Carlos Ruiz 2019-03-24 13:15:07 -03:00
parent 59655e3324
commit a70411da40
1 changed files with 19 additions and 8 deletions

View File

@ -200,6 +200,7 @@ public abstract class PO
m_oldValues = new Object[size]; m_oldValues = new Object[size];
m_newValues = new Object[size]; m_newValues = new Object[size];
m_setErrors = new ValueNamePair[size]; m_setErrors = new ValueNamePair[size];
m_setErrorsFilled = false;
if (rs != null) if (rs != null)
load(rs); // will not have virtual columns load(rs); // will not have virtual columns
@ -241,6 +242,7 @@ public abstract class PO
private Object[] m_newValues = null; private Object[] m_newValues = null;
/** Errors when setting */ /** Errors when setting */
private ValueNamePair[] m_setErrors = null; private ValueNamePair[] m_setErrors = null;
private boolean m_setErrorsFilled = false; // to optimize not traveling the array if no errors
/** Record_IDs */ /** Record_IDs */
private Object[] m_IDs = new Object[] {I_ZERO}; private Object[] m_IDs = new Object[] {I_ZERO};
@ -780,6 +782,7 @@ public abstract class PO
log.log(Level.WARNING, "Virtual Column" + colInfo); log.log(Level.WARNING, "Virtual Column" + colInfo);
log.saveError("VirtualColumn", "Virtual Column" + colInfo); log.saveError("VirtualColumn", "Virtual Column" + colInfo);
m_setErrors[index] = new ValueNamePair("VirtualColumn", "Virtual Column" + colInfo); m_setErrors[index] = new ValueNamePair("VirtualColumn", "Virtual Column" + colInfo);
m_setErrorsFilled = true;
return false; return false;
} }
@ -792,6 +795,7 @@ public abstract class PO
log.log(Level.WARNING, "Column not updateable" + colInfo); log.log(Level.WARNING, "Column not updateable" + colInfo);
log.saveError("ColumnReadonly", "Column not updateable" + colInfo); log.saveError("ColumnReadonly", "Column not updateable" + colInfo);
m_setErrors[index] = new ValueNamePair("ColumnReadonly", "Column not updateable" + colInfo); m_setErrors[index] = new ValueNamePair("ColumnReadonly", "Column not updateable" + colInfo);
m_setErrorsFilled = true;
return false; return false;
} }
} }
@ -800,8 +804,9 @@ public abstract class PO
{ {
if (checkWritable && p_info.isColumnMandatory(index)) if (checkWritable && p_info.isColumnMandatory(index))
{ {
log.saveError("FillMandatory", ColumnName + " is mandatory."); log.saveError("FillMandatory", ColumnName);
m_setErrors[index] = new ValueNamePair("FillMandatory", ColumnName + " is mandatory."); m_setErrors[index] = new ValueNamePair("FillMandatory", ColumnName);
m_setErrorsFilled = true;
return false; return false;
} }
m_newValues[index] = Null.NULL; // correct m_newValues[index] = Null.NULL; // correct
@ -842,6 +847,7 @@ public abstract class PO
log.log(Level.SEVERE, errmsg); log.log(Level.SEVERE, errmsg);
log.saveError("WrongDataType", errmsg); log.saveError("WrongDataType", errmsg);
m_setErrors[index] = new ValueNamePair("WrongDataType", errmsg); m_setErrors[index] = new ValueNamePair("WrongDataType", errmsg);
m_setErrorsFilled = true;
return false; return false;
} }
else else
@ -852,6 +858,7 @@ public abstract class PO
log.log(Level.SEVERE, errmsg); log.log(Level.SEVERE, errmsg);
log.saveError("WrongDataType", errmsg); log.saveError("WrongDataType", errmsg);
m_setErrors[index] = new ValueNamePair("WrongDataType", errmsg); m_setErrors[index] = new ValueNamePair("WrongDataType", errmsg);
m_setErrorsFilled = true;
return false; return false;
} }
// Validate (Min/Max) // Validate (Min/Max)
@ -867,6 +874,7 @@ public abstract class PO
log.saveError(error, ColumnName); log.saveError(error, ColumnName);
m_setErrors[index] = new ValueNamePair(error, ColumnName); m_setErrors[index] = new ValueNamePair(error, ColumnName);
} }
m_setErrorsFilled = true;
return false; return false;
} }
// Length for String // Length for String
@ -895,6 +903,7 @@ public abstract class PO
+ value + " - Reference_ID=" + p_info.getColumn(index).AD_Reference_Value_ID + validValues.toString(); + value + " - Reference_ID=" + p_info.getColumn(index).AD_Reference_Value_ID + validValues.toString();
log.saveError("Validate", errmsg); log.saveError("Validate", errmsg);
m_setErrors[index] = new ValueNamePair("Validate", errmsg); m_setErrors[index] = new ValueNamePair("Validate", errmsg);
m_setErrorsFilled = true;
return false; return false;
} }
} }
@ -2025,6 +2034,7 @@ public abstract class PO
return true; return true;
} }
if (m_setErrorsFilled) {
for (int i = 0; i < m_setErrors.length; i++) { for (int i = 0; i < m_setErrors.length; i++) {
ValueNamePair setError = m_setErrors[i]; ValueNamePair setError = m_setErrors[i];
if (setError != null) { if (setError != null) {
@ -2032,6 +2042,7 @@ public abstract class PO
return false; return false;
} }
} }
}
// Organization Check // Organization Check
if (getAD_Org_ID() == 0 if (getAD_Org_ID() == 0