This commit is contained in:
parent
9355459b27
commit
41e9ce441d
|
@ -464,7 +464,7 @@ public class ModelClassGenerator
|
||||||
// List Validation
|
// List Validation
|
||||||
if (AD_Reference_ID != 0 && String.class == clazz)
|
if (AD_Reference_ID != 0 && String.class == clazz)
|
||||||
{
|
{
|
||||||
String staticVar = addListValidation (sb, AD_Reference_ID, columnName, !isMandatory);
|
String staticVar = addListValidation (sb, AD_Reference_ID, columnName);
|
||||||
sb.insert(0, staticVar);
|
sb.insert(0, staticVar);
|
||||||
}
|
}
|
||||||
// setValue ("ColumnName", xx);
|
// setValue ("ColumnName", xx);
|
||||||
|
@ -478,36 +478,24 @@ public class ModelClassGenerator
|
||||||
if (columnName.endsWith("_ID"))
|
if (columnName.endsWith("_ID"))
|
||||||
{
|
{
|
||||||
int firstOK = 1;
|
int firstOK = 1;
|
||||||
if (isMandatory) // check mandatory ID
|
// check special column
|
||||||
{
|
|
||||||
if (columnName.equals("AD_Client_ID") || columnName.equals("AD_Org_ID")
|
if (columnName.equals("AD_Client_ID") || columnName.equals("AD_Org_ID")
|
||||||
|| columnName.equals("Record_ID") || columnName.equals("C_DocType_ID")
|
|| columnName.equals("Record_ID") || columnName.equals("C_DocType_ID")
|
||||||
|| columnName.equals("Node_ID") || columnName.equals("AD_Role_ID")
|
|| columnName.equals("Node_ID") || columnName.equals("AD_Role_ID")
|
||||||
|| columnName.equals("M_AttributeSet_ID") || columnName.equals("M_AttributeSetInstance_ID"))
|
|| columnName.equals("M_AttributeSet_ID") || columnName.equals("M_AttributeSetInstance_ID"))
|
||||||
firstOK = 0;
|
firstOK = 0;
|
||||||
sb.append("\t\tif (").append (columnName).append (" < ").append(firstOK).append(")").append(NL)
|
// set _ID to null if < 0 for special column or < 1 for others
|
||||||
.append("\t\t\t throw new IllegalArgumentException (\"")
|
|
||||||
.append(columnName).append(" is mandatory.\");").append(NL);
|
|
||||||
}
|
|
||||||
else // set optional _ID to null if 0
|
|
||||||
sb.append("\t\tif (").append (columnName).append (" < ").append(firstOK).append(") ").append(NL)
|
sb.append("\t\tif (").append (columnName).append (" < ").append(firstOK).append(") ").append(NL)
|
||||||
.append("\t").append(setValue).append(" (").append ("COLUMNNAME_").append(columnName).append(", null);").append(NL)
|
.append("\t").append(setValue).append(" (").append ("COLUMNNAME_").append(columnName).append(", null);").append(NL)
|
||||||
.append("\t\telse ").append(NL).append("\t");
|
.append("\t\telse ").append(NL).append("\t");
|
||||||
}
|
}
|
||||||
sb.append(setValue).append(" (").append ("COLUMNNAME_").append(columnName).append(", Integer.valueOf(").append(columnName).append("));").append(NL);
|
sb.append(setValue).append(" (").append ("COLUMNNAME_").append(columnName).append(", Integer.valueOf(").append(columnName).append("));").append(NL);
|
||||||
}
|
}
|
||||||
// Boolean
|
// Boolean
|
||||||
else if (clazz.equals(Boolean.class))
|
else if (clazz.equals(Boolean.class))
|
||||||
sb.append(setValue).append(" (").append ("COLUMNNAME_").append(columnName).append(", Boolean.valueOf(").append(columnName).append("));").append(NL);
|
sb.append(setValue).append(" (").append ("COLUMNNAME_").append(columnName).append(", Boolean.valueOf(").append(columnName).append("));").append(NL);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (isMandatory && AD_Reference_ID == 0) // does not apply to int/boolean
|
|
||||||
{
|
|
||||||
sb.append("\t\tif (").append(columnName).append (" == null)").append(NL)
|
|
||||||
.append("\t\t\tthrow new IllegalArgumentException (\"")
|
|
||||||
.append(columnName).append(" is mandatory.\");").append(NL);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
sb.append(setValue).append(" (").append ("COLUMNNAME_").append (columnName).append (", ")
|
sb.append(setValue).append(" (").append ("COLUMNNAME_").append (columnName).append (", ")
|
||||||
.append(columnName).append (");").append(NL);
|
.append(columnName).append (");").append(NL);
|
||||||
}
|
}
|
||||||
|
@ -637,14 +625,13 @@ public class ModelClassGenerator
|
||||||
else throw new IllegalArgumentException ("NextAction Invalid value - Reference_ID=219 - N - F");
|
else throw new IllegalArgumentException ("NextAction Invalid value - Reference_ID=219 - N - F");
|
||||||
* @param AD_Reference_ID reference
|
* @param AD_Reference_ID reference
|
||||||
* @param columnName column
|
* @param columnName column
|
||||||
* @param nullable the validation must allow null values
|
|
||||||
* @return static parameter - Example:
|
* @return static parameter - Example:
|
||||||
public static final int NEXTACTION_AD_Reference_ID=219;
|
public static final int NEXTACTION_AD_Reference_ID=219;
|
||||||
public static final String NEXTACTION_None = "N";
|
public static final String NEXTACTION_None = "N";
|
||||||
public static final String NEXTACTION_FollowUp = "F";
|
public static final String NEXTACTION_FollowUp = "F";
|
||||||
*/
|
*/
|
||||||
private String addListValidation (StringBuffer sb, int AD_Reference_ID,
|
private String addListValidation (StringBuffer sb, int AD_Reference_ID,
|
||||||
String columnName, boolean nullable)
|
String columnName)
|
||||||
{
|
{
|
||||||
StringBuffer retValue = new StringBuffer();
|
StringBuffer retValue = new StringBuffer();
|
||||||
retValue.append("\n\t/** ").append(columnName).append(" AD_Reference_ID=").append(AD_Reference_ID) .append(" */")
|
retValue.append("\n\t/** ").append(columnName).append(" AD_Reference_ID=").append(AD_Reference_ID) .append(" */")
|
||||||
|
@ -655,8 +642,6 @@ public class ModelClassGenerator
|
||||||
StringBuffer values = new StringBuffer("Reference_ID=")
|
StringBuffer values = new StringBuffer("Reference_ID=")
|
||||||
.append(AD_Reference_ID);
|
.append(AD_Reference_ID);
|
||||||
StringBuffer statement = new StringBuffer();
|
StringBuffer statement = new StringBuffer();
|
||||||
if (nullable)
|
|
||||||
statement.append("\n\t\tif (").append(columnName).append(" == null");
|
|
||||||
//
|
//
|
||||||
String sql = "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=? ORDER BY AD_Ref_List_ID";
|
String sql = "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=? ORDER BY AD_Ref_List_ID";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
@ -680,11 +665,6 @@ public class ModelClassGenerator
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
if (!nullable)
|
|
||||||
sb.append("\t\tif (")
|
|
||||||
.append (columnName).append (" == null)"
|
|
||||||
+ " throw new IllegalArgumentException (\"")
|
|
||||||
.append(columnName).append(" is mandatory\");");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -716,9 +716,7 @@ public abstract class PO
|
||||||
{
|
{
|
||||||
if (p_info.isColumnMandatory(index))
|
if (p_info.isColumnMandatory(index))
|
||||||
{
|
{
|
||||||
log.log(Level.WARNING, "Cannot set mandatory column to null " + colInfo);
|
throw new IllegalArgumentException (ColumnName + " is mandatory.");
|
||||||
// Trace.printStack();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
m_newValues[index] = Null.NULL; // correct
|
m_newValues[index] = Null.NULL; // correct
|
||||||
log.finer(ColumnName + " = null");
|
log.finer(ColumnName + " = null");
|
||||||
|
|
Loading…
Reference in New Issue