@@ -13661,29 +13661,61 @@ public String generateBean(Vector useCases, Vector cons, Vector entities,
1366113661 for (int i = 0; i < attributes.size(); i++)
1366213662 { Attribute att = (Attribute) attributes.get(i);
1366313663 String attnme = att.getName();
13664- String tname = att.getType().getName();
13665- res = res + " private String " + attnme + " = \"\";\n";
13664+ Type atttype = att.getType();
13665+ String tname = atttype.getName();
13666+
13667+ res = res + " private String " + attnme + " = \"\";\n";
1366613668 if (tname.equals("int"))
13667- { res = res + " private int i" + attnme + " = 0;\n"; }
13669+ { res = res + " private int i" + attnme + " = 0;\n"; }
1366813670 else if (tname.equals("double"))
13669- { res = res + " private double d" + attnme + " = 0;\n"; }
13671+ { res = res + " private double d" + attnme + " = 0;\n"; }
13672+ else if (att.isEnumeration())
13673+ { Vector vals = atttype.getValues();
13674+ res = res + " private " + tname + " e" + attnme + " = " + tname + "." + vals.get(0) + ";\n";
13675+ }
1367013676 // booleans are treated as strings.
13671- }
13677+ }
13678+
13679+ for (int j = 0; j < associations.size(); j++)
13680+ { Association ast = (Association) associations.get(j);
13681+ Entity ent2 = ast.getEntity2();
13682+ Attribute fkey = ent2.getPrincipalPrimaryKey();
13683+ if (fkey != null) // assume it is a string
13684+ { String keynme = fkey.getName();
13685+ String keytype = fkey.getType().getName();
13686+ res = res + " private " + keytype + " " + keynme + ";\n";
13687+ }
13688+ }
13689+
1367213690 res = res + " private Vector errors = new Vector();\n\n" +
1367313691 " public " + ename + "Bean() {}\n\n";
13692+
1367413693 for (int i = 0; i < attributes.size(); i++)
1367513694 { Attribute att = (Attribute) attributes.get(i);
1367613695 String attnme = att.getName();
1367713696 res = res + " public void set" + attnme + "(String " + attnme + "x)\n { " +
1367813697 attnme + " = " + attnme + "x; }\n\n";
1367913698 }
1368013699
13700+ for (int j = 0; j < associations.size(); j++)
13701+ { Association ast = (Association) associations.get(j);
13702+ Entity ent2 = ast.getEntity2();
13703+ Attribute fkey = ent2.getPrincipalPrimaryKey();
13704+ if (fkey != null) // assume it is a string
13705+ { String keynme = fkey.getName();
13706+ String keytype = fkey.getType().getName();
13707+ res = res + " public void set" + keynme + "(" + keytype + " " + keynme + "x)\n { " +
13708+ keynme + " = " + keynme + "x; }\n\n";
13709+ }
13710+ }
13711+
1368113712 res = res + " public void resetData()\n { ";
1368213713 for (int i = 0; i < attributes.size(); i++)
1368313714 { Attribute att = (Attribute) attributes.get(i);
1368413715 String attname = att.getName();
1368513716 res = res + attname + " = \"\";\n ";
1368613717 }
13718+
1368713719 res = res + "}\n\n";
1368813720
1368913721 for (int j = 0; j < useCases.size(); j++)
@@ -13704,7 +13736,8 @@ else if (tname.equals("double"))
1370413736 res = res + check;
1370513737 }
1370613738
13707- if (action.equals("create") || action.equals("edit") || action.equals("set"))
13739+ if (action.equals("create") ||
13740+ action.equals("edit") || action.equals("set"))
1370813741 { Vector tests = getInvariantCheckTests(pars);
1370913742 for (int p = 0; p < tests.size(); p++)
1371013743 { String test = (String) tests.get(p);
@@ -13742,7 +13775,8 @@ else if (tname.equals("double"))
1374213775 allinvs.addAll(invariants);
1374313776 allinvs.addAll(cons);
1374413777
13745- correc = att.sqlSetOperations(this,allinvs,entities,types);
13778+ correc = att.sqlSetOperations(
13779+ this,allinvs,entities,types);
1374613780 res = res + odname + "(" + att.getBeanForm() +
1374713781 ", i" + ename.toLowerCase() + "Id);\n ";
1374813782 }
@@ -13783,36 +13817,62 @@ public String generateJSPBean(String packageName, Vector useCases,
1378313817 { String ename = getName();
1378413818 String res = "package " + packageName + ";\n\n" +
1378513819 "import java.util.Vector;\n" +
13786- "import java.util.List;\n" +
13787- "import java.util.Iterator;\n\n" +
13820+ "import java.util.List;\n" +
13821+ "import java.util.Iterator;\n\n" +
1378813822
1378913823 "public class " + ename + "Bean\n{ ModelFacade model;\n";
13824+
1379013825 for (int i = 0; i < attributes.size(); i++)
1379113826 { Attribute att = (Attribute) attributes.get(i);
1379213827 String attnme = att.getName();
13793- Type atttype = att.getType();
13828+ Type atttype = att.getType();
1379413829 String tname = atttype.getName();
1379513830 res = res + " private String " + attnme + " = \"\";\n";
1379613831 if (tname.equals("int") || tname.equals("long"))
1379713832 { res = res + " private int i" + attnme + " = 0;\n"; }
1379813833 else if (tname.equals("double"))
1379913834 { res = res + " private double d" + attnme + " = 0;\n"; }
13800- else if (att.isEnumeration())
13801- { Vector vals = atttype.getValues();
13802- res = res + " private " + tname + " e" + attnme + " = " + tname + "." + vals.get(0) + ";\n";
13803- }
13835+ else if (att.isEnumeration())
13836+ { Vector vals = atttype.getValues();
13837+ res = res + " private " + tname + " e" + attnme + " = " + tname + "." + vals.get(0) + ";\n";
13838+ }
1380413839 // booleans are treated as strings.
13805- }
13840+ }
13841+
13842+ for (int j = 0; j < associations.size(); j++)
13843+ { Association ast = (Association) associations.get(j);
13844+ Entity ent2 = ast.getEntity2();
13845+ Attribute fkey = ent2.getPrincipalPrimaryKey();
13846+ if (fkey != null)
13847+ { String keynme = fkey.getName();
13848+ String keytype = fkey.getType().getName();
13849+ res = res + " private " + keytype + " " + keynme + ";\n";
13850+ }
13851+ }
13852+
1380613853 res = res + " private Vector errors = new Vector();\n\n" +
1380713854 " public " + ename + "Bean()\n" +
1380813855 " { model = ModelFacade.getInstance(); }\n\n";
13856+
1380913857 for (int i = 0; i < attributes.size(); i++)
1381013858 { Attribute att = (Attribute) attributes.get(i);
1381113859 String attnme = att.getName();
1381213860 res = res + " public void set" + attnme + "(String " + attnme + "x)\n { " +
1381313861 attnme + " = " + attnme + "x; }\n\n";
1381413862 }
1381513863
13864+ for (int j = 0; j < associations.size(); j++)
13865+ { Association ast = (Association) associations.get(j);
13866+ Entity ent2 = ast.getEntity2();
13867+ Attribute fkey = ent2.getPrincipalPrimaryKey();
13868+ if (fkey != null) // assume it is a string
13869+ { String keynme = fkey.getName();
13870+ String keytype = fkey.getType().getName();
13871+ res = res + " public void set" + keynme + "(" + keytype + " " + keynme + "x)\n { " +
13872+ keynme + " = " + keynme + "x; }\n\n";
13873+ }
13874+ }
13875+
1381613876 res = res + " public void resetData()\n { ";
1381713877 for (int i = 0; i < attributes.size(); i++)
1381813878 { Attribute att = (Attribute) attributes.get(i);
@@ -13839,7 +13899,8 @@ else if (att.isEnumeration())
1383913899 res = res + check;
1384013900 }
1384113901
13842- if (action.equals("create") || action.equals("edit") || action.equals("set"))
13902+ if (action.equals("create") ||
13903+ action.equals("edit") || action.equals("set"))
1384313904 { Vector tests = getInvariantCheckTests(types,entities,pars,cgs);
1384413905 for (int p = 0; p < tests.size(); p++)
1384513906 { String test = (String) tests.get(p);
@@ -13869,14 +13930,16 @@ else if (att.isEnumeration())
1386913930 action.equals("add") || action.equals("remove") ||
1387013931 action.equals("edit") || action.equals("set"))
1387113932 { res = res + " public void " + odname + "()\n" + " { ";
13872- res = res + dbiop + "\n ";
13933+ res = res + dbiop + "\n ";
13934+
1387313935 /* if (action.equals("set"))
1387413936 { Attribute att = (Attribute) pars.get(0);
1387513937 Vector allinvs = new Vector();
1387613938 allinvs.addAll(invariants);
1387713939 allinvs.addAll(cons);
1387813940
13879- correc = att.sqlSetOperations(this,allinvs,entities,types);
13941+ correc = att.sqlSetOperations(
13942+ this,allinvs,entities,types);
1388013943 res = res + odname + "(" + att.getBeanForm() +
1388113944 ", i" + ename.toLowerCase() + "Id);\n ";
1388213945 } */
@@ -13916,19 +13979,31 @@ public String generateAndroidBean(String packageName, Vector useCases,
1391613979 for (int i = 0; i < attributes.size(); i++)
1391713980 { Attribute att = (Attribute) attributes.get(i);
1391813981 String attnme = att.getName();
13919- Type atttype = att.getType();
13982+ Type atttype = att.getType();
1392013983 String tname = atttype.getName();
1392113984 res = res + " private String " + attnme + " = \"\";\n";
1392213985 if (tname.equals("int") || tname.equals("long"))
1392313986 { res = res + " private int i" + attnme + " = 0;\n"; }
1392413987 else if (tname.equals("double"))
1392513988 { res = res + " private double d" + attnme + " = 0;\n"; }
13926- else if (att.isEnumeration())
13927- { Vector vals = atttype.getValues();
13928- res = res + " private " + tname + " e" + attnme + " = " + tname + "." + vals.get(0) + ";\n";
13929- }
13989+ else if (att.isEnumeration())
13990+ { Vector vals = atttype.getValues();
13991+ res = res + " private " + tname + " e" + attnme + " = " + tname + "." + vals.get(0) + ";\n";
13992+ }
1393013993 // booleans are treated as strings.
1393113994 }
13995+
13996+ for (int j = 0; j < associations.size(); j++)
13997+ { Association ast = (Association) associations.get(j);
13998+ Entity ent2 = ast.getEntity2();
13999+ Attribute fkey = ent2.getPrincipalPrimaryKey();
14000+ if (fkey != null) // assumed to be of string type
14001+ { String keynme = fkey.getName();
14002+ String keytype = fkey.getType().getName();
14003+ res = res + " private " + keytype + " " + keynme + ";\n";
14004+ }
14005+ }
14006+
1393214007 res = res + " private Vector errors = new Vector();\n\n" +
1393314008 " public " + ename + "Bean(Context _c)\n" +
1393414009 " { model = ModelFacade.getInstance(_c); }\n\n";
@@ -13965,7 +14040,8 @@ else if (att.isEnumeration())
1396514040 res = res + check;
1396614041 }
1396714042
13968- if (action.equals("create") || action.equals("edit") || action.equals("set"))
14043+ if (action.equals("create") ||
14044+ action.equals("edit") || action.equals("set"))
1396914045 { Vector tests = getInvariantCheckTests(types,entities,pars,cgs);
1397014046 for (int p = 0; p < tests.size(); p++)
1397114047 { String test = (String) tests.get(p);
0 commit comments