I_X_xx Get_IX_xxx() made part of java interface.

This commit is contained in:
trifonnt 2007-08-11 03:01:32 +00:00
parent 1eca72d28b
commit 5f0f01c3a1
2 changed files with 19 additions and 3 deletions

View File

@ -217,7 +217,7 @@ public class GenerateInterfaceTrifon {
String sql = "SELECT c.ColumnName, c.IsUpdateable, c.IsMandatory," // 1..3 String sql = "SELECT c.ColumnName, c.IsUpdateable, c.IsMandatory," // 1..3
+ " c.AD_Reference_ID, c.AD_Reference_Value_ID, DefaultValue, SeqNo, " // 4..7 + " c.AD_Reference_ID, c.AD_Reference_Value_ID, DefaultValue, SeqNo, " // 4..7
+ " c.FieldLength, c.ValueMin, c.ValueMax, c.VFormat, c.Callout, " // 8..12 + " c.FieldLength, c.ValueMin, c.ValueMax, c.VFormat, c.Callout, " // 8..12
+ " c.Name, c.Description, c.ColumnSQL, c.IsEncrypted " + " c.Name, c.Description, c.ColumnSQL, c.IsEncrypted, c.IsKey " // 13..17
+ "FROM AD_Column c " + "FROM AD_Column c "
+ "WHERE c.AD_Table_ID=?" + "WHERE c.AD_Table_ID=?"
+ " AND c.ColumnName <> 'AD_Client_ID'" + " AND c.ColumnName <> 'AD_Client_ID'"
@ -250,6 +250,7 @@ public class GenerateInterfaceTrifon {
boolean virtualColumn = ColumnSQL != null boolean virtualColumn = ColumnSQL != null
&& ColumnSQL.length() > 0; && ColumnSQL.length() > 0;
boolean IsEncrypted = "Y".equals(rs.getString(16)); boolean IsEncrypted = "Y".equals(rs.getString(16));
boolean IsKey = "Y".equals(rs.getString(17));
// Create COLUMNNAME_ property (teo_sarca, [ 1662447 ]) // Create COLUMNNAME_ property (teo_sarca, [ 1662447 ])
sb.append("\n") sb.append("\n")
@ -262,7 +263,7 @@ public class GenerateInterfaceTrifon {
isUpdateable, isMandatory, displayType, isUpdateable, isMandatory, displayType,
AD_Reference_Value_ID, fieldLength, defaultValue, AD_Reference_Value_ID, fieldLength, defaultValue,
ValueMin, ValueMax, VFormat, Callout, Name, ValueMin, ValueMax, VFormat, Callout, Name,
Description, virtualColumn, IsEncrypted)); Description, virtualColumn, IsEncrypted, IsKey));
} }
rs.close(); rs.close();
pstmt.close(); pstmt.close();
@ -306,7 +307,7 @@ public class GenerateInterfaceTrifon {
int displayType, int AD_Reference_ID, int fieldLength, int displayType, int AD_Reference_ID, int fieldLength,
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 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 = "";
@ -362,6 +363,19 @@ public class GenerateInterfaceTrifon {
sb.append(" get").append(columnName); sb.append(" get").append(columnName);
sb.append("();"); sb.append("();");
// //
if (DisplayType.isID(displayType) && !IsKey) {
if (displayType == DisplayType.TableDir) {
String referenceClassName = "I_"+columnName.substring(0, columnName.length()-3);
sb.append("\n")
.append("\tpublic "+referenceClassName+" get").append(referenceClassName).append("();")
;
} else {
// TODO - Handle other types
//sb.append("\tpublic I_"+columnName+" getI_").append(columnName).append("(){return null; };");
}
}
return sb.toString(); return sb.toString();
} }

View File

@ -401,6 +401,7 @@ public class GenerateModelTrifon
.append("() {") .append("() {")
// .append(" return null; };") // .append(" return null; };")
; ;
// TODO - here we can implement Lazy loading or Cache of class
sb.append("Class clazz = MTable.getClass("+referenceClassName+".Table_Name);") sb.append("Class clazz = MTable.getClass("+referenceClassName+".Table_Name);")
.append(referenceClassName).append(" result = null;") .append(referenceClassName).append(" result = null;")
.append("try {") .append("try {")
@ -410,6 +411,7 @@ public class GenerateModelTrifon
.append(" } catch (NoSuchMethodException e) {") .append(" } catch (NoSuchMethodException e) {")
.append(" log.warning(\"No transaction Constructor for \" + clazz + \" Exception[\" + e.toString() + \"]\");") .append(" log.warning(\"No transaction Constructor for \" + clazz + \" Exception[\" + e.toString() + \"]\");")
.append(" }") .append(" }")
// 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.
.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(" return result;") .append(" return result;")
.append("} catch (Exception e) {") .append("} catch (Exception e) {")