Feature Request: [ 1772015 ] Generate java Interface and implementation instead of X_ classes
http://sourceforge.net/tracker/index.php?func=detail&aid=1772015&group_id=176962&atid=879335
This commit is contained in:
parent
86fe300dde
commit
368823c08c
|
@ -1,18 +1,18 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.adempiere.util.GenerateInterfaceTrifon"/>
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listEntry value="/base/src/org/adempiere/util/GenerateInterfaceTrifon.java"/>
|
||||||
<listEntry value="4"/>
|
</listAttribute>
|
||||||
</listAttribute>
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="${workspace_loc:base}/src/org/compiere/model/ org.compiere.model 'D'"/>
|
<listEntry value="1"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="base"/>
|
</listAttribute>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-DPropertyFile=${workspace_loc}/adempiere/Adempiere/Adempiere.properties"/>
|
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.adempiere.util.GenerateInterfaceTrifon"/>
|
||||||
<listEntry value="/base"/>
|
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="${workspace_loc:base}/src/org/compiere/model/ org.compiere.model 'D'"/>
|
||||||
</listAttribute>
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="base"/>
|
||||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-DPropertyFile=${workspace_loc}/adempiere/Adempiere/Adempiere.properties"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.adempiere.util.GenerateModelTrifon"/>
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
<listEntry value="/base/src/org/adempiere/util/GenerateModelTrifon.java"/>
|
||||||
<listEntry value="4"/>
|
</listAttribute>
|
||||||
</listAttribute>
|
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="${workspace_loc:base}/src/org/compiere/model/ org.compiere.model 'D'"/>
|
<listEntry value="1"/>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="base"/>
|
</listAttribute>
|
||||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-DPropertyFile=${workspace_loc}/adempiere/Adempiere/Adempiere.properties"/>
|
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||||
</listAttribute>
|
</listAttribute>
|
||||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.adempiere.util.GenerateModelTrifon"/>
|
||||||
<listEntry value="/base"/>
|
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="${workspace_loc:base}/src/org/compiere/model/ org.compiere.model "'D', 'U', 'A'""/>
|
||||||
</listAttribute>
|
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="base"/>
|
||||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-DPropertyFile=${workspace_loc}/adempiere/Adempiere/Adempiere.properties"/>
|
||||||
</launchConfiguration>
|
</launchConfiguration>
|
||||||
|
|
|
@ -185,16 +185,16 @@ public class GenerateInterfaceTrifon {
|
||||||
.append(" public static final int Table_ID = MTable.getTable_ID(Table_Name);\n")
|
.append(" public static final int Table_ID = MTable.getTable_ID(Table_Name);\n")
|
||||||
|
|
||||||
//.append(" protected KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);\n")
|
//.append(" protected KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);\n")
|
||||||
.append(" KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);\n") // TODO - Should this be here???
|
.append(" KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);\n") // INFO - Should this be here???
|
||||||
|
|
||||||
.append(" /** AccessLevel = ").append(accessLevelInfo).append("\n")
|
.append(" /** AccessLevel = ").append(accessLevelInfo).append("\n")
|
||||||
.append(" */\n")
|
.append(" */\n")
|
||||||
//.append(" protected BigDecimal AccessLevel = new BigDecimal(").append(accessLevel).append(");\n")
|
//.append(" protected BigDecimal AccessLevel = new BigDecimal(").append(accessLevel).append(");\n")
|
||||||
.append(" BigDecimal AccessLevel = new BigDecimal(").append(accessLevel).append(");\n") // TODO - Should this be here???
|
.append(" BigDecimal accessLevel = new BigDecimal(").append(accessLevel).append(");\n") // INFO - Should this be here???
|
||||||
|
|
||||||
.append(" /** Load Meta Data */\n")
|
.append(" /** Load Meta Data */\n")
|
||||||
//.append(" protected POInfo initPO (Properties ctx);")
|
//.append(" protected POInfo initPO (Properties ctx);")
|
||||||
//.append(" POInfo initPO (Properties ctx);") // TODO - Should this be here???
|
//.append(" POInfo initPO (Properties ctx);") // INFO - Should this be here???
|
||||||
;
|
;
|
||||||
|
|
||||||
StringBuffer end = new StringBuffer("}");
|
StringBuffer end = new StringBuffer("}");
|
||||||
|
@ -308,7 +308,7 @@ public class GenerateInterfaceTrifon {
|
||||||
String defaultValue, String ValueMin, String ValueMax,
|
String defaultValue, String ValueMin, String ValueMax,
|
||||||
String VFormat, String Callout, String Name, String Description,
|
String VFormat, String Callout, String Name, String Description,
|
||||||
boolean virtualColumn, boolean IsEncrypted, boolean IsKey) {
|
boolean virtualColumn, boolean IsEncrypted, boolean IsKey) {
|
||||||
Class clazz = DisplayType.getClass(displayType, true);
|
Class<?> clazz = DisplayType.getClass(displayType, true);
|
||||||
if (defaultValue == null)
|
if (defaultValue == null)
|
||||||
defaultValue = "";
|
defaultValue = "";
|
||||||
// Handle Posted
|
// Handle Posted
|
||||||
|
@ -326,14 +326,15 @@ public class GenerateInterfaceTrifon {
|
||||||
// String Key
|
// String Key
|
||||||
else if (columnName.equalsIgnoreCase("AD_Language")) {
|
else if (columnName.equalsIgnoreCase("AD_Language")) {
|
||||||
clazz = String.class;
|
clazz = String.class;
|
||||||
|
// String Key
|
||||||
|
} else if (columnName.equalsIgnoreCase("EntityType")) {
|
||||||
|
clazz = String.class;
|
||||||
}
|
}
|
||||||
// Data Type
|
// Data Type
|
||||||
String dataType = clazz.getName();
|
String dataType = clazz.getName();
|
||||||
dataType = dataType.substring(dataType.lastIndexOf('.') + 1);
|
dataType = dataType.substring(dataType.lastIndexOf('.') + 1);
|
||||||
if (dataType.equals("Boolean"))
|
if (dataType.equals("Boolean")) {
|
||||||
dataType = "boolean";
|
dataType = "boolean";
|
||||||
else if (DisplayType.isID(displayType)) { // Added by @Trifon
|
|
||||||
dataType = "int";
|
|
||||||
} else if (dataType.equals("Integer"))
|
} else if (dataType.equals("Integer"))
|
||||||
dataType = "int";
|
dataType = "int";
|
||||||
else if (displayType == DisplayType.Binary
|
else if (displayType == DisplayType.Binary
|
||||||
|
@ -369,7 +370,7 @@ public class GenerateInterfaceTrifon {
|
||||||
String referenceClassName = "I_"+columnName.substring(0, columnName.length()-3);
|
String referenceClassName = "I_"+columnName.substring(0, columnName.length()-3);
|
||||||
|
|
||||||
sb.append("\n")
|
sb.append("\n")
|
||||||
.append("\tpublic "+referenceClassName+" get").append(referenceClassName).append("();")
|
.append("\tpublic "+referenceClassName+" get").append(referenceClassName).append("() throws Exception;")
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
// TODO - Handle other types
|
// TODO - Handle other types
|
||||||
|
@ -492,11 +493,18 @@ public class GenerateInterfaceTrifon {
|
||||||
entityType).append(")");
|
entityType).append(")");
|
||||||
log.info(sql.toString());
|
log.info(sql.toString());
|
||||||
log.info("----------------------------------");
|
log.info("----------------------------------");
|
||||||
|
|
||||||
|
// Table name like
|
||||||
|
String tableLike = "'%'"; // All tables
|
||||||
|
if (args.length > 3)
|
||||||
|
tableLike = args[3];
|
||||||
|
log.info("Table Like: " + tableLike);
|
||||||
|
|
||||||
// complete sql
|
// complete sql
|
||||||
sql.insert(0, "SELECT AD_Table_ID " + "FROM AD_Table "
|
sql.insert(0, "SELECT AD_Table_ID " + "FROM AD_Table "
|
||||||
+ "WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')" // special views
|
+ "WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')" // special views
|
||||||
+ " OR IsView='N')" + " AND TableName NOT LIKE '%_Trl' AND ");
|
+ " OR IsView='N')" + " AND TableName NOT LIKE '%_Trl' AND ");
|
||||||
|
sql.append(" AND TableName LIKE ").append(tableLike);
|
||||||
sql.append(" ORDER BY TableName");
|
sql.append(" ORDER BY TableName");
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -147,79 +147,99 @@ public class GenerateModelTrifon
|
||||||
//
|
//
|
||||||
StringBuffer start = new StringBuffer ()
|
StringBuffer start = new StringBuffer ()
|
||||||
.append (COPY)
|
.append (COPY)
|
||||||
.append ("/** Generated Model - DO NOT CHANGE */\n")
|
.append ("/** Generated Model - DO NOT CHANGE */").append(Env.NL)
|
||||||
.append("package " + packageName + ";")
|
.append("package " + packageName + ";").append(Env.NL)
|
||||||
|
.append(Env.NL)
|
||||||
;
|
;
|
||||||
if (!packageName.equals("org.compiere.model"))
|
if (!packageName.equals("org.compiere.model"))
|
||||||
start.append("import org.compiere.model.*;");
|
start.append("import org.compiere.model.*;").append(Env.NL);
|
||||||
|
|
||||||
start.append("import java.util.*;")
|
start.append("import java.util.*;").append(Env.NL)
|
||||||
.append("import java.sql.*;")
|
.append("import java.sql.*;").append(Env.NL)
|
||||||
.append("import java.math.*;")
|
.append("import java.math.*;").append(Env.NL)
|
||||||
.append("import java.lang.reflect.Constructor;")
|
.append("import java.lang.reflect.Constructor;").append(Env.NL)
|
||||||
.append("import java.util.logging.Level;")
|
.append("import java.util.logging.Level;").append(Env.NL)
|
||||||
.append("import org.compiere.util.*;")
|
.append("import org.compiere.util.*;").append(Env.NL)
|
||||||
|
.append(Env.NL)
|
||||||
// Class
|
// Class
|
||||||
.append("/** Generated Model for ").append(tableName).append("\n")
|
.append("/** Generated Model for ").append(tableName).append(Env.NL)
|
||||||
.append(" * @author Adempiere (generated) \n")
|
.append(" * @author Adempiere (generated) ").append(Env.NL)
|
||||||
.append(" * @version ").append(Adempiere.MAIN_VERSION).append(" - $Id$ */\n")
|
.append(" * @version ").append(Adempiere.MAIN_VERSION).append(" - $Id$ */").append(Env.NL)
|
||||||
.append("public class ").append(className).append(" extends PO implements I_").append(tableName)
|
.append("public class ").append(className).append(" extends PO implements I_").append(tableName).append(Env.NL)
|
||||||
.append("{")
|
.append("{").append(Env.NL)
|
||||||
|
|
||||||
|
// serialVersionUID
|
||||||
|
.append(Env.NL)
|
||||||
|
.append("\t/**").append(Env.NL)
|
||||||
|
.append("\t *").append(Env.NL)
|
||||||
|
.append("\t */").append(Env.NL)
|
||||||
|
//.append("\tprivate static final long serialVersionUID = ").append(Adempiere.MAIN_VERSION.substring(8)).append(";").append(Env.NL)
|
||||||
|
.append("\tprivate static final long serialVersionUID = 1L;").append(Env.NL)
|
||||||
|
|
||||||
// Standard Constructor
|
// Standard Constructor
|
||||||
.append(" /** Standard Constructor */\n")
|
.append(Env.NL)
|
||||||
.append(" public ").append(className).append(" (Properties ctx, int ").append(keyColumn).append(", String trxName)")
|
.append(" /** Standard Constructor */").append(Env.NL)
|
||||||
.append(" {")
|
.append(" public ").append(className).append(" (Properties ctx, int ").append(keyColumn).append(", String trxName)").append(Env.NL)
|
||||||
.append(" super (ctx, ").append(keyColumn).append(", trxName);")
|
.append(" {").append(Env.NL)
|
||||||
|
.append(" super (ctx, ").append(keyColumn).append(", trxName);").append(Env.NL)
|
||||||
.append(" /** if (").append(keyColumn).append(" == 0)")
|
.append(" /** if (").append(keyColumn).append(" == 0)")
|
||||||
.append(" {").append(mandatory).append("} */\n")
|
.append(" {").append(mandatory).append("} */").append(Env.NL)
|
||||||
.append(" }")
|
.append(" }").append(Env.NL)
|
||||||
// Constructor End
|
// Constructor End
|
||||||
|
|
||||||
// Load Constructor
|
// Load Constructor
|
||||||
.append(" /** Load Constructor */\n")
|
.append(Env.NL)
|
||||||
.append(" public ").append(className).append(" (Properties ctx, ResultSet rs, String trxName)")
|
.append(" /** Load Constructor */").append(Env.NL)
|
||||||
.append(" {")
|
.append(" public ").append(className).append(" (Properties ctx, ResultSet rs, String trxName)").append(Env.NL)
|
||||||
.append(" super (ctx, rs, trxName);")
|
.append(" {").append(Env.NL)
|
||||||
.append(" }")
|
.append(" super (ctx, rs, trxName);").append(Env.NL)
|
||||||
|
.append(" }").append(Env.NL)
|
||||||
// Load Constructor End
|
// Load Constructor End
|
||||||
|
|
||||||
// TableName
|
// TableName
|
||||||
.append(" /** TableName=").append(tableName).append(" */\n")
|
// .append(Env.NL)
|
||||||
.append(" public static final String Table_Name = \"").append(tableName).append("\";\n")
|
// .append(" /** TableName=").append(tableName).append(" */").append(Env.NL)
|
||||||
|
// .append(" public static final String Table_Name = \"").append(tableName).append("\";").append(Env.NL)
|
||||||
|
|
||||||
// AD_Table_ID
|
// AD_Table_ID
|
||||||
.append(" /** AD_Table_ID=").append(AD_Table_ID).append(" */\n")
|
// .append(Env.NL)
|
||||||
.append(" public static final int Table_ID = MTable.getTable_ID(Table_Name);\n")
|
// .append(" /** AD_Table_ID=").append(AD_Table_ID).append(" */").append(Env.NL)
|
||||||
|
// .append(" public static final int Table_ID = MTable.getTable_ID(Table_Name);").append(Env.NL)
|
||||||
|
|
||||||
// KeyNamePair
|
// KeyNamePair
|
||||||
.append(" protected static KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);\n")
|
// .append(Env.NL)
|
||||||
|
// .append(" protected static KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);").append(Env.NL)
|
||||||
|
|
||||||
// accessLevel
|
// accessLevel
|
||||||
.append(" protected BigDecimal accessLevel = BigDecimal.valueOf(").append(accessLevel).append(");")
|
// .append(Env.NL)
|
||||||
.append(" /** AccessLevel\n")
|
// .append(" protected BigDecimal accessLevel = BigDecimal.valueOf(").append(accessLevel).append(");").append(Env.NL)
|
||||||
.append(" * @return ").append(accessLevelInfo).append("\n")
|
.append(Env.NL)
|
||||||
.append(" */\n")
|
.append(" /** AccessLevel").append(Env.NL)
|
||||||
.append(" protected int get_AccessLevel()")
|
.append(" * @return ").append(accessLevelInfo).append(Env.NL)
|
||||||
.append(" {")
|
.append(" */").append(Env.NL)
|
||||||
.append(" return accessLevel.intValue();")
|
.append(" protected int get_AccessLevel()").append(Env.NL)
|
||||||
.append(" }")
|
.append(" {").append(Env.NL)
|
||||||
|
.append(" return accessLevel.intValue();").append(Env.NL)
|
||||||
|
.append(" }").append(Env.NL)
|
||||||
|
|
||||||
// initPO
|
// initPO
|
||||||
.append(" /** Load Meta Data */\n")
|
.append(Env.NL)
|
||||||
.append(" protected POInfo initPO (Properties ctx)")
|
.append(" /** Load Meta Data */").append(Env.NL)
|
||||||
.append(" {")
|
.append(" protected POInfo initPO (Properties ctx)").append(Env.NL)
|
||||||
.append(" POInfo poi = POInfo.getPOInfo (ctx, Table_ID);")
|
.append(" {").append(Env.NL)
|
||||||
.append(" return poi;")
|
.append(" POInfo poi = POInfo.getPOInfo (ctx, Table_ID);").append(Env.NL)
|
||||||
.append(" }")
|
.append(" return poi;").append(Env.NL)
|
||||||
|
.append(" }").append(Env.NL)
|
||||||
// initPO
|
// initPO
|
||||||
|
|
||||||
// toString()
|
// toString()
|
||||||
.append(" public String toString()")
|
.append(Env.NL)
|
||||||
.append(" {")
|
.append(" public String toString()").append(Env.NL)
|
||||||
.append(" StringBuffer sb = new StringBuffer (\"").append(className).append("[\")")
|
.append(" {").append(Env.NL)
|
||||||
.append(" .append(get_ID()).append(\"]\");")
|
.append(" StringBuffer sb = new StringBuffer (\"").append(className).append("[\")").append(Env.NL)
|
||||||
.append(" return sb.toString();")
|
.append(" .append(get_ID()).append(\"]\");").append(Env.NL)
|
||||||
.append(" }")
|
.append(" return sb.toString();").append(Env.NL)
|
||||||
|
.append(" }").append(Env.NL)
|
||||||
;
|
;
|
||||||
|
|
||||||
StringBuffer end = new StringBuffer ("}");
|
StringBuffer end = new StringBuffer ("}");
|
||||||
|
@ -338,9 +358,12 @@ public class GenerateModelTrifon
|
||||||
String Callout, String Name, String Description,
|
String Callout, String Name, String Description,
|
||||||
boolean virtualColumn, boolean IsEncrypted, boolean IsKey)
|
boolean virtualColumn, boolean IsEncrypted, boolean IsKey)
|
||||||
{
|
{
|
||||||
Class clazz = DisplayType.getClass(displayType, true);
|
Class<?> clazz = DisplayType.getClass(displayType, true);
|
||||||
if (defaultValue == null)
|
if (defaultValue == null)
|
||||||
defaultValue = "";
|
defaultValue = "";
|
||||||
|
if (DisplayType.isLOB(displayType)) // No length check for LOBs
|
||||||
|
fieldLength = 0;
|
||||||
|
|
||||||
// Handle Posted
|
// Handle Posted
|
||||||
if (columnName.equalsIgnoreCase("Posted")
|
if (columnName.equalsIgnoreCase("Posted")
|
||||||
|| columnName.equalsIgnoreCase("Processed")
|
|| columnName.equalsIgnoreCase("Processed")
|
||||||
|
@ -356,27 +379,24 @@ public class GenerateModelTrifon
|
||||||
AD_Reference_ID = 0;
|
AD_Reference_ID = 0;
|
||||||
}
|
}
|
||||||
// String Key
|
// String Key
|
||||||
else if (columnName.equalsIgnoreCase("AD_Language"))
|
else if (columnName.equalsIgnoreCase("AD_Language")
|
||||||
|
|| columnName.equalsIgnoreCase("EntityType"))
|
||||||
{
|
{
|
||||||
clazz = String.class;
|
clazz = String.class;
|
||||||
}
|
}
|
||||||
// Data Type
|
// Data Type
|
||||||
String dataType = clazz.getName();
|
String dataType = clazz.getName();
|
||||||
dataType = dataType.substring(dataType.lastIndexOf('.')+1);
|
dataType = dataType.substring(dataType.lastIndexOf('.')+1);
|
||||||
if (dataType.equals("Boolean"))
|
if (dataType.equals("Boolean")) {
|
||||||
dataType = "boolean";
|
dataType = "boolean";
|
||||||
else if (DisplayType.isID(displayType)) { // TODO - Added by @Trifon
|
} else if (dataType.equals("Integer")) {
|
||||||
dataType = "int";
|
dataType = "int";
|
||||||
|
} else if (displayType == DisplayType.Binary || displayType == DisplayType.Image) {
|
||||||
}
|
|
||||||
else if (dataType.equals("Integer"))
|
|
||||||
dataType = "int";
|
|
||||||
else if (displayType == DisplayType.Binary || displayType == DisplayType.Image)
|
|
||||||
dataType = "byte[]";
|
dataType = "byte[]";
|
||||||
|
}
|
||||||
|
|
||||||
// Set ********
|
// Set ********
|
||||||
String setValue = "\t\tset_Value";
|
String setValue = "\t\tset_Value";
|
||||||
// Handle IsEncrypted
|
|
||||||
if (IsEncrypted)
|
if (IsEncrypted)
|
||||||
setValue = "\t\tset_ValueE";
|
setValue = "\t\tset_ValueE";
|
||||||
// Handle isUpdateable
|
// Handle isUpdateable
|
||||||
|
@ -389,45 +409,48 @@ public class GenerateModelTrifon
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
|
|
||||||
// Create Java Comment
|
|
||||||
generateJavaComment("Set", Name, Description, sb);
|
|
||||||
// TODO - New functionality
|
// TODO - New functionality
|
||||||
// 1) Must understand which class to reference
|
// 1) Must understand which class to reference
|
||||||
if (DisplayType.isID(displayType) && !IsKey) {
|
if (DisplayType.isID(displayType) && !IsKey) {
|
||||||
if (displayType == DisplayType.TableDir) {
|
if (displayType == DisplayType.TableDir) {
|
||||||
String referenceClassName = "I_"+columnName.substring(0, columnName.length()-3);
|
String referenceClassName = "I_"+columnName.substring(0, columnName.length()-3);
|
||||||
|
|
||||||
sb.append("\tpublic "+referenceClassName+" get").append(referenceClassName)
|
sb.append(Env.NL)
|
||||||
.append("() {")
|
.append("\tpublic "+referenceClassName+" get").append(referenceClassName).append("() throws Exception ").append(Env.NL)
|
||||||
// .append(" return null; };")
|
.append(" {").append(Env.NL)
|
||||||
;
|
|
||||||
// TODO - here we can implement Lazy loading or Cache of class
|
// TODO - here we can implement Lazy loading or Cache of class
|
||||||
sb.append("Class clazz = MTable.getClass("+referenceClassName+".Table_Name);")
|
.append(" Class<?> clazz = MTable.getClass("+referenceClassName+".Table_Name);").append(Env.NL)
|
||||||
.append(referenceClassName).append(" result = null;")
|
.append(" ").append(referenceClassName).append(" result = null;").append(Env.NL)
|
||||||
.append("try {")
|
.append(" try {").append(Env.NL)
|
||||||
.append(" Constructor constructor = null;")
|
.append(" Constructor<?> constructor = null;").append(Env.NL)
|
||||||
.append(" try {")
|
// .append(" try {").append(Env.NL)
|
||||||
.append(" constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});")
|
.append(" constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, int.class, String.class});").append(Env.NL)
|
||||||
.append(" } catch (NoSuchMethodException e) {")
|
// .append(" } catch (NoSuchMethodException e) {").append(Env.NL)
|
||||||
.append(" log.warning(\"No transaction Constructor for \" + clazz + \" Exception[\" + e.toString() + \"]\");")
|
// .append(" log.warning(\"No transaction Constructor for \" + clazz + \" Exception[\" + e.toString() + \"]\");").append(Env.NL)
|
||||||
.append(" }")
|
// .append(" }").append(Env.NL)
|
||||||
// TODO - here we can implemnt Lazy loading or Cache of record. Like in Hibernate, objects can be loaded on demand or when master object is loaded.
|
// TODO - here we can implement Lazy loading or Cache of record. Like in Hibernate, objects can be loaded on demand or when master object is loaded.
|
||||||
.append(" result = ("+referenceClassName+")constructor.newInstance(new Object[] {getCtx(), new Integer(get"+columnName+"()), get_TrxName()});")
|
.append(" result = ("+referenceClassName+")constructor.newInstance(new Object[] {getCtx(), new Integer(get"+columnName+"()), get_TrxName()});").append(Env.NL)
|
||||||
.append(" return result;")
|
.append(" } catch (Exception e) {").append(Env.NL)
|
||||||
.append("} catch (Exception e) {")
|
.append(" log.log(Level.SEVERE, \"(id) - Table=\" + Table_Name + \",Class=\" + clazz, e);").append(Env.NL)
|
||||||
.append(" log.log(Level.SEVERE, \"(id) - Table=\" + Table_Name + \",Class=\" + clazz, e);")
|
.append(" log.saveError(\"Error\", \"Table=\" + Table_Name + \",Class=\" + clazz);").append(Env.NL)
|
||||||
.append(" log.saveError(\"Error\", \"Table=\" + Table_Name + \",Class=\" + clazz);")
|
.append(" throw e;").append(Env.NL)
|
||||||
.append("}")
|
.append(" }").append(Env.NL)
|
||||||
.append("return result;}")
|
.append(" return result;").append(Env.NL)
|
||||||
|
.append(" }").append(Env.NL)
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
// TODO - Handle other types
|
// TODO - Handle other types
|
||||||
//sb.append("\tpublic I_"+columnName+" getI_").append(columnName).append("(){return null; };");
|
//sb.append("\tpublic I_"+columnName+" getI_").append(columnName).append("(){return null; };");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create Java Comment
|
||||||
|
generateJavaSetComment(columnName, Name, Description, sb);
|
||||||
|
|
||||||
// public void setColumn (xxx variable)
|
// public void setColumn (xxx variable)
|
||||||
sb.append("\tpublic void set").append(columnName).append(" (").append(dataType).append(" ").append(columnName).append(")"
|
sb.append("\tpublic void set").append(columnName).append(" (").append(dataType).append(" ").append(columnName).append(")").append(Env.NL)
|
||||||
+ "\t{");
|
.append("\t{").append(Env.NL)
|
||||||
|
;
|
||||||
// List Validation
|
// List Validation
|
||||||
if (AD_Reference_ID != 0)
|
if (AD_Reference_ID != 0)
|
||||||
{
|
{
|
||||||
|
@ -437,48 +460,66 @@ public class GenerateModelTrifon
|
||||||
// setValue ("ColumnName", xx);
|
// setValue ("ColumnName", xx);
|
||||||
if (virtualColumn)
|
if (virtualColumn)
|
||||||
{
|
{
|
||||||
sb.append ("throw new IllegalArgumentException (\"").append(columnName).append(" is virtual column\");");
|
sb.append ("\t\tthrow new IllegalArgumentException (\"").append(columnName).append(" is virtual column\");");
|
||||||
}
|
}
|
||||||
|
// Integer
|
||||||
else if (clazz.equals(Integer.class))
|
else if (clazz.equals(Integer.class))
|
||||||
{
|
{
|
||||||
if (columnName.endsWith("_ID"))
|
if (columnName.endsWith("_ID"))
|
||||||
{
|
{
|
||||||
if (!isMandatory) // set optional _ID to null if 0
|
if (isMandatory) // check mandatory ID
|
||||||
sb.append("if (").append (columnName).append (" <= 0) ")
|
{
|
||||||
.append(setValue).append(" (\"").append(columnName).append("\", null); else \n");
|
int firstOK = 1; // Valid ID 0
|
||||||
|
if (columnName.equals("AD_Client_ID") || columnName.equals("AD_Org_ID")
|
||||||
|
|| columnName.equals("Record_ID") || columnName.equals("C_DocType_ID")
|
||||||
|
|| columnName.equals("Node_ID") || columnName.equals("AD_Role_ID")
|
||||||
|
|| columnName.equals("M_AttributeSet_ID") || columnName.equals("M_AttributeSetInstance_ID"))
|
||||||
|
firstOK = 0;
|
||||||
|
sb.append("\t\tif (").append (columnName).append (" < ").append(firstOK).append(")").append(Env.NL)
|
||||||
|
.append("\t\t\t throw new IllegalArgumentException (\"").append(columnName).append(" is mandatory.\");").append(Env.NL);
|
||||||
|
}
|
||||||
|
else // set optional _ID to null if 0
|
||||||
|
sb.append("\t\tif (").append (columnName).append (" <= 0) ")
|
||||||
|
.append(setValue).append(" (").append ("COLUMNNAME_").append(columnName).append(", null);").append(Env.NL)
|
||||||
|
.append(" else ").append(Env.NL);
|
||||||
}
|
}
|
||||||
sb.append(setValue).append(" (\"").append(columnName).append("\", new Integer(").append(columnName).append("));");
|
sb.append(setValue).append(" (").append ("COLUMNNAME_").append(columnName).append(", Integer.valueOf(").append(columnName).append("));").append(Env.NL);
|
||||||
}
|
}
|
||||||
|
// Boolean
|
||||||
else if (clazz.equals(Boolean.class))
|
else if (clazz.equals(Boolean.class))
|
||||||
sb.append(setValue).append(" (\"").append(columnName).append("\", new Boolean(").append(columnName).append("));");
|
sb.append(setValue).append(" (").append ("COLUMNNAME_").append(columnName).append(", Boolean.valueOf(").append(columnName).append("));").append(Env.NL);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (isMandatory) // does not apply to int/boolean
|
if (isMandatory && AD_Reference_ID == 0) // does not apply to int/boolean
|
||||||
sb.append ("if (").append (columnName).append (" == null)"
|
{
|
||||||
+ " throw new IllegalArgumentException (\"").append(columnName).append(" is mandatory\");");
|
sb.append("\t\tif (").append(columnName).append (" == null)").append(Env.NL)
|
||||||
|
.append("\t\t\tthrow new IllegalArgumentException (\"")
|
||||||
|
.append(columnName).append(" is mandatory.\");").append(Env.NL);
|
||||||
|
}
|
||||||
// String length check
|
// String length check
|
||||||
if (clazz.equals(String.class) && fieldLength > 0)
|
if (clazz.equals(String.class) && fieldLength > 0)
|
||||||
{
|
{
|
||||||
sb.append ("if (");
|
sb.append ("\t\tif (");
|
||||||
if (!isMandatory)
|
if (!isMandatory)
|
||||||
sb.append(columnName).append(" != null && ");
|
sb.append(columnName).append(" != null && ");
|
||||||
sb.append(columnName).append(".length() > ").append(fieldLength)
|
sb.append(columnName).append(".length() > ").append(fieldLength).append(")").append(Env.NL)
|
||||||
.append("){log.warning(\"Length > ")
|
.append("\t\t{").append(Env.NL)
|
||||||
.append(fieldLength).append(" - truncated\");")
|
.append("\t\t\tlog.warning(\"Length > ").append(fieldLength).append(" - truncated\");").append(Env.NL)
|
||||||
.append(columnName).append(" = ")
|
.append("\t\t\t").append(columnName).append(" = ").append(columnName).append(".substring(0, ").append(fieldLength-1).append(");").append(Env.NL)
|
||||||
.append(columnName).append(".substring(0,").append(fieldLength-1).append(");}");
|
.append("\t\t}").append(Env.NL)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
sb.append (setValue).append(" (\"").append (columnName).append ("\", ")
|
sb.append(setValue).append(" (").append ("COLUMNNAME_").append (columnName).append (", ")
|
||||||
.append (columnName).append (");");
|
.append(columnName).append (");").append(Env.NL);
|
||||||
}
|
}
|
||||||
sb.append("}");
|
sb.append("\t}").append(Env.NL);
|
||||||
|
|
||||||
// Mandatory call in constructor
|
// Mandatory call in constructor
|
||||||
if (isMandatory)
|
if (isMandatory)
|
||||||
{
|
{
|
||||||
mandatory.append("\tset").append(columnName).append(" (");
|
mandatory.append("\t\t\tset").append(columnName).append(" (");
|
||||||
if (clazz.equals(Integer.class))
|
if (clazz.equals(Integer.class))
|
||||||
mandatory.append("0");
|
mandatory.append("0");
|
||||||
else if (clazz.equals(Boolean.class))
|
else if (clazz.equals(Boolean.class))
|
||||||
|
@ -494,19 +535,19 @@ public class GenerateModelTrifon
|
||||||
mandatory.append("new Timestamp(System.currentTimeMillis())");
|
mandatory.append("new Timestamp(System.currentTimeMillis())");
|
||||||
else
|
else
|
||||||
mandatory.append("null");
|
mandatory.append("null");
|
||||||
mandatory.append(");");
|
mandatory.append(");").append(Env.NL);
|
||||||
if (defaultValue.length() > 0)
|
if (defaultValue.length() > 0)
|
||||||
mandatory.append("// ").append(defaultValue).append(Env.NL);
|
mandatory.append("// ").append(defaultValue).append(Env.NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ****** Get Comment ******
|
// ****** Get Comment ******
|
||||||
generateJavaComment("Get", Name, Description, sb);
|
generateJavaGetComment(Name, Description, sb);
|
||||||
|
|
||||||
// Get ********
|
// Get ********
|
||||||
String getValue = "\tget_Value";
|
String getValue = "get_Value";
|
||||||
if (IsEncrypted)
|
if (IsEncrypted)
|
||||||
getValue = "\tget_ValueE";
|
getValue = "get_ValueE";
|
||||||
|
|
||||||
sb.append("\tpublic ").append(dataType);
|
sb.append("\tpublic ").append(dataType);
|
||||||
if (clazz.equals(Boolean.class))
|
if (clazz.equals(Boolean.class))
|
||||||
|
@ -516,45 +557,71 @@ public class GenerateModelTrifon
|
||||||
sb.append(columnName.substring(2));
|
sb.append(columnName.substring(2));
|
||||||
else
|
else
|
||||||
sb.append(columnName);
|
sb.append(columnName);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
sb.append(" get").append(columnName);
|
sb.append(" get").append(columnName);
|
||||||
sb.append("() {");
|
}
|
||||||
|
sb.append(" () ").append(Env.NL)
|
||||||
|
.append("\t{").append(Env.NL)
|
||||||
|
.append("\t\t");
|
||||||
if (clazz.equals(Integer.class))
|
if (clazz.equals(Integer.class))
|
||||||
sb.append("Integer ii = (Integer)")
|
sb.append("Integer ii = (Integer)").append(getValue).append("(").append ("COLUMNNAME_").append(columnName).append(");").append(Env.NL)
|
||||||
.append(getValue).append("(\"").append(columnName).append("\");"
|
.append("\t\tif (ii == null)").append(Env.NL)
|
||||||
+ "if (ii == null)"
|
.append("\t\t\t return 0;").append(Env.NL)
|
||||||
+ " return 0;"
|
.append("\t\treturn ii.intValue();").append(Env.NL);
|
||||||
+ "return ii.intValue();");
|
|
||||||
else if (clazz.equals(BigDecimal.class))
|
else if (clazz.equals(BigDecimal.class))
|
||||||
sb.append("BigDecimal bd = (BigDecimal)").append(getValue)
|
sb.append("BigDecimal bd = (BigDecimal)").append(getValue).append("(").append ("COLUMNNAME_").append(columnName).append(");").append(Env.NL)
|
||||||
.append("(\"").append(columnName).append("\");"
|
.append("\t\tif (bd == null)").append(Env.NL)
|
||||||
+ "if (bd == null)"
|
.append("\t\t\t return Env.ZERO;").append(Env.NL)
|
||||||
+ " return Env.ZERO;"
|
.append("\t\treturn bd;").append(Env.NL);
|
||||||
+ "return bd;");
|
|
||||||
else if (clazz.equals(Boolean.class))
|
else if (clazz.equals(Boolean.class))
|
||||||
sb.append("Object oo = ").append(getValue)
|
sb.append("Object oo = ").append(getValue).append("(").append ("COLUMNNAME_").append(columnName).append(");").append(Env.NL)
|
||||||
.append("(\"").append(columnName).append("\");"
|
.append("\t\tif (oo != null) ").append(Env.NL)
|
||||||
+ "if (oo != null) { if (oo instanceof Boolean) return ((Boolean)oo).booleanValue(); return \"Y\".equals(oo);}"
|
.append("\t\t{").append(Env.NL)
|
||||||
+ "return false;");
|
.append("\t\t\t if (oo instanceof Boolean) ").append(Env.NL)
|
||||||
|
.append("\t\t\t\t return ((Boolean)oo).booleanValue(); ").append(Env.NL)
|
||||||
|
.append("\t\t\treturn \"Y\".equals(oo);").append(Env.NL)
|
||||||
|
.append("\t\t}").append(Env.NL)
|
||||||
|
.append("\t\treturn false;").append(Env.NL);
|
||||||
else if (dataType.equals("Object"))
|
else if (dataType.equals("Object"))
|
||||||
sb.append("return ").append(getValue)
|
sb.append("\t\treturn ").append(getValue)
|
||||||
.append("(\"").append(columnName).append("\");");
|
.append("(").append ("COLUMNNAME_").append(columnName).append(");").append(Env.NL);
|
||||||
else
|
else
|
||||||
sb.append("return (").append(dataType).append(")").append(getValue)
|
sb.append("return (").append(dataType).append(")").append(getValue)
|
||||||
.append("(\"").append(columnName).append("\");");
|
.append("(").append ("COLUMNNAME_").append(columnName).append(");").append(Env.NL);
|
||||||
sb.append("}");
|
sb.append("\t}").append(Env.NL);
|
||||||
//
|
//
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} // createColumnMethods
|
} // createColumnMethods
|
||||||
|
|
||||||
|
|
||||||
// ****** Set/Get Comment ******
|
// ****** Set Comment ******
|
||||||
public void generateJavaComment(String startOfComment, String propertyName, String description, StringBuffer result) {
|
public void generateJavaSetComment(String columnName, String propertyName, String description, StringBuffer result) {
|
||||||
result.append("\t/** ").append(startOfComment).append(" ").append(propertyName);
|
|
||||||
if (description != null && description.length() > 0)
|
result.append(Env.NL)
|
||||||
result.append(".\n\t\t").append(description).append(Env.NL);
|
.append("\t/** Set ").append(propertyName).append(".").append(Env.NL)
|
||||||
result.append("\t */\n");
|
.append("\t\t@param ").append(columnName).append(" ")
|
||||||
|
;
|
||||||
|
if (description != null && description.length() > 0) {
|
||||||
|
result.append(Env.NL)
|
||||||
|
.append("\t\t").append(description).append(Env.NL);
|
||||||
|
} else {
|
||||||
|
result.append(propertyName);
|
||||||
|
}
|
||||||
|
result.append("\t */").append(Env.NL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ****** Get Comment ******
|
||||||
|
public void generateJavaGetComment(String propertyName, String description, StringBuffer result) {
|
||||||
|
|
||||||
|
result.append(Env.NL)
|
||||||
|
.append("\t/** Get ").append(propertyName);
|
||||||
|
if (description != null && description.length() > 0) {
|
||||||
|
result.append(".").append(Env.NL)
|
||||||
|
.append("\t\t@return ").append(description).append(Env.NL);
|
||||||
|
} else {
|
||||||
|
result.append(".\n@return ").append(propertyName);
|
||||||
|
}
|
||||||
|
result.append("\t */").append(Env.NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -575,7 +642,8 @@ public class GenerateModelTrifon
|
||||||
String columnName, boolean nullable)
|
String columnName, boolean nullable)
|
||||||
{
|
{
|
||||||
StringBuffer retValue = new StringBuffer();
|
StringBuffer retValue = new StringBuffer();
|
||||||
retValue.append("public static final int ").append(columnName.toUpperCase())
|
retValue.append("\n/** ").append(columnName).append(" AD_Reference_ID=").append(AD_Reference_ID) .append(" */\n")
|
||||||
|
.append("public static final int ").append(columnName.toUpperCase())
|
||||||
.append("_AD_Reference_ID=").append(AD_Reference_ID).append(";");
|
.append("_AD_Reference_ID=").append(AD_Reference_ID).append(";");
|
||||||
//
|
//
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
@ -584,7 +652,7 @@ public class GenerateModelTrifon
|
||||||
StringBuffer statement = new StringBuffer();
|
StringBuffer statement = new StringBuffer();
|
||||||
if (nullable)
|
if (nullable)
|
||||||
statement.append("if (").append(columnName).append(" == null");
|
statement.append("if (").append(columnName).append(" == null");
|
||||||
|
//
|
||||||
String sql = "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=?";
|
String sql = "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=?";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
|
@ -602,7 +670,18 @@ public class GenerateModelTrifon
|
||||||
else
|
else
|
||||||
statement.append(" || ").append(columnName)
|
statement.append(" || ").append(columnName)
|
||||||
.append(".equals(\"").append(value).append("\")");
|
.append(".equals(\"").append(value).append("\")");
|
||||||
found = true;
|
//
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
if (!nullable)
|
||||||
|
sb.append("if (")
|
||||||
|
.append (columnName).append (" == null)"
|
||||||
|
+ " throw new IllegalArgumentException (\"")
|
||||||
|
.append(columnName).append(" is mandatory\");");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Name (SmallTalkNotation)
|
// Name (SmallTalkNotation)
|
||||||
String name = rs.getString(2);
|
String name = rs.getString(2);
|
||||||
char[] nameArray = name.toCharArray();
|
char[] nameArray = name.toCharArray();
|
||||||
|
@ -673,9 +752,10 @@ public class GenerateModelTrifon
|
||||||
+ "; "
|
+ "; "
|
||||||
+ "else "
|
+ "else "
|
||||||
+ "throw new IllegalArgumentException (\"").append(columnName)
|
+ "throw new IllegalArgumentException (\"").append(columnName)
|
||||||
.append(" Invalid value - ").append(values).append("\");");
|
.append(" Invalid value - \" + ").append(columnName)
|
||||||
|
.append(" + \" - ").append(values).append("\");");
|
||||||
//
|
//
|
||||||
if (found)
|
if (found && !columnName.equals("EntityType"))
|
||||||
sb.append (statement);
|
sb.append (statement);
|
||||||
return retValue.toString();
|
return retValue.toString();
|
||||||
} // addListValidation
|
} // addListValidation
|
||||||
|
@ -691,8 +771,16 @@ public class GenerateModelTrifon
|
||||||
String method = "get" + columnName + "()";
|
String method = "get" + columnName + "()";
|
||||||
if (displayType != DisplayType.String)
|
if (displayType != DisplayType.String)
|
||||||
method = "String.valueOf(" + method + ")";
|
method = "String.valueOf(" + method + ")";
|
||||||
StringBuffer sb = new StringBuffer(" public KeyNamePair getKeyNamePair() ")
|
|
||||||
.append(" {return new KeyNamePair(get_ID(), ").append(method).append(");}");
|
StringBuffer sb = new StringBuffer(Env.NL)
|
||||||
|
.append(" /** Get Record ID/ColumnName").append(Env.NL)
|
||||||
|
.append(" @return ID/ColumnName pair").append(Env.NL)
|
||||||
|
.append(" */").append(Env.NL)
|
||||||
|
.append(" public KeyNamePair getKeyNamePair() ").append(Env.NL)
|
||||||
|
.append(" {").append(Env.NL)
|
||||||
|
.append(" return new KeyNamePair(get_ID(), ").append(method).append(");").append(Env.NL)
|
||||||
|
.append(" }").append(Env.NL)
|
||||||
|
;
|
||||||
return sb;
|
return sb;
|
||||||
} // createKeyNamePair
|
} // createKeyNamePair
|
||||||
|
|
||||||
|
@ -715,17 +803,18 @@ public class GenerateModelTrifon
|
||||||
if (c == ';' || c == '}')
|
if (c == ';' || c == '}')
|
||||||
{
|
{
|
||||||
fw.write (c);
|
fw.write (c);
|
||||||
if (sb.substring(i+1).startsWith("//"))
|
if (sb.substring(i+1).startsWith("//")) {
|
||||||
fw.write('\t');
|
//fw.write('\t');
|
||||||
else
|
} else {
|
||||||
fw.write(Env.NL);
|
//fw.write(Env.NL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// before & after
|
// before & after
|
||||||
else if (c == '{')
|
else if (c == '{')
|
||||||
{
|
{
|
||||||
fw.write(Env.NL);
|
//fw.write(Env.NL);
|
||||||
fw.write (c);
|
fw.write (c);
|
||||||
fw.write(Env.NL);
|
//fw.write(Env.NL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fw.write (c);
|
fw.write (c);
|
||||||
|
@ -748,10 +837,9 @@ public class GenerateModelTrifon
|
||||||
*/
|
*/
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuffer sb = new StringBuffer ("GenerateModel[")
|
StringBuffer sb = new StringBuffer ("GenerateModel[").append("]");
|
||||||
.append("]");
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} // toString
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -810,12 +898,19 @@ public class GenerateModelTrifon
|
||||||
log.info(sql.toString());
|
log.info(sql.toString());
|
||||||
log.info("----------------------------------");
|
log.info("----------------------------------");
|
||||||
|
|
||||||
|
String tableLike = "'%'"; // All tables
|
||||||
|
if (args.length > 3)
|
||||||
|
tableLike = args[3];
|
||||||
|
log.info("Table Like: " + tableLike);
|
||||||
|
|
||||||
// complete sql
|
// complete sql
|
||||||
sql.insert(0, "SELECT AD_Table_ID "
|
sql.insert(0, "SELECT AD_Table_ID "
|
||||||
+ "FROM AD_Table "
|
+ "FROM AD_Table "
|
||||||
+ "WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')" // special views
|
+ "WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')" // special views
|
||||||
+ " OR IsView='N')"
|
+ " OR IsView='N')"
|
||||||
+ " AND TableName NOT LIKE '%_Trl' AND ");
|
+ " AND TableName NOT LIKE '%_Trl' AND ");
|
||||||
|
sql.append(" AND TableName LIKE ").append(tableLike);
|
||||||
|
|
||||||
sql.append(" ORDER BY TableName");
|
sql.append(" ORDER BY TableName");
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue