@@ -1135,6 +1135,7 @@ public static void generateShowAutoLinkTreeToFile(
11351135 * @param module parent module
11361136 * @throws IOException if anything bad happens during the generation
11371137 */
1138+ @ SuppressWarnings ({ "rawtypes" })
11381139 public static void generateStandardCreateActionToFile (
11391140 DataObjectDefinition dataobject ,
11401141 DataObjectDefinition companion ,
@@ -1155,6 +1156,21 @@ public static void generateStandardCreateActionToFile(
11551156 HashMap <String , String > importdeclaration = dataobject .getImportDeclarationForCreation (dataobject );
11561157
11571158 StringBuffer extraattributesdeclaration = dataobject .generateCreateObjectExtraAttributes (dataobject );
1159+ if (extraattributesdeclaration .length () > 0 )
1160+ extraattributesdeclaration .append (',' );
1161+
1162+ for (int i = 0 ; i < dataobject .propertylist .getSize (); i ++) {
1163+ Property <?> property = dataobject .propertylist .get (i );
1164+ if (property instanceof LeftForLink ) {
1165+ LeftForLink leftforlink = (LeftForLink ) property ;
1166+ if (leftforlink .getLinkObjectProperty ().getBusinessRuleByName ("DISPLAYASATTRIBUTEFROMLEFT" ) != null ) {
1167+ extraattributesdeclaration .append ("\n "
1168+ + StringFormatter .formatForJavaClass (
1169+ leftforlink .getLinkObjectProperty ().getRightobjectforlink ().getName ())
1170+ + "[] left" + leftforlink .getLinkObjectDefinition ().getName ().toLowerCase () + "," );
1171+ }
1172+ }
1173+ }
11581174
11591175 String objectimport = "import " + module .getPath () + ".data." + objectclass + ";" ;
11601176 if (companion != null ) {
@@ -1175,6 +1191,28 @@ public static void generateStandardCreateActionToFile(
11751191 sg .wl ("import org.openlowcode.server.graphic.SPage;" );
11761192 sg .wl ("import org.openlowcode.server.runtime.SModule;" );
11771193 sg .wl ("import java.util.function.Function;" );
1194+ boolean firstleftattribute = true ;
1195+ for (int i = 0 ; i < dataobject .propertylist .getSize (); i ++) {
1196+ Property <?> property = dataobject .propertylist .get (i );
1197+ if (property instanceof LeftForLink ) {
1198+ LeftForLink leftforlink = (LeftForLink ) property ;
1199+ if (leftforlink .getLinkObjectProperty ().getBusinessRuleByName ("DISPLAYASATTRIBUTEFROMLEFT" ) != null ) {
1200+ if (firstleftattribute )
1201+ sg .wl ("import java.util.ArrayList;" );
1202+ sg .wl ("import " + leftforlink .getLinkObjectDefinition ().getOwnermodule ().getPath () + ".data."
1203+ + StringFormatter .formatForJavaClass (leftforlink .getLinkObjectDefinition ().getName ())
1204+ + ";" );
1205+ sg .wl ("import "
1206+ + leftforlink .getLinkObjectProperty ().getRightobjectforlink ().getOwnermodule ().getPath ()
1207+ + ".data." + StringFormatter .formatForJavaClass (
1208+ leftforlink .getLinkObjectProperty ().getRightobjectforlink ().getName ())
1209+ + ";" );
1210+
1211+ }
1212+ }
1213+
1214+ }
1215+
11781216 sg .wl ("import org.openlowcode.server.data.storage.QueryFilter;" );
11791217 sg .wl ("import org.openlowcode.server.data.storage.QueryCondition;" );
11801218 sg .wl ("import org.openlowcode.server.data.storage.TableAlias;" );
@@ -1189,8 +1227,7 @@ public static void generateStandardCreateActionToFile(
11891227 sg .wl (" }" );
11901228 sg .wl ("" );
11911229 sg .wl (" @Override" );
1192- if (extraattributesdeclaration .length () > 0 )
1193- extraattributesdeclaration .append (',' );
1230+
11941231 sg .wl (" public DataObjectId<" + objectclass + "> executeActionLogic( " + extraattributesdeclaration .toString ()
11951232 + " " + objectclass + " object" + (companion != null ? "," + companionclass + " companion" : "" )
11961233 + ",Function<TableAlias,QueryFilter> datafilter)" );
@@ -1215,6 +1252,34 @@ public static void generateStandardCreateActionToFile(
12151252 sg .wl (" object.insert(this,SecurityInDataMethod.FAIL_IF_NOT_AUTHORIZED);" );
12161253 }
12171254
1255+ for (int i = 0 ; i < dataobject .propertylist .getSize (); i ++) {
1256+ Property <?> property = dataobject .propertylist .get (i );
1257+ if (property instanceof LeftForLink ) {
1258+ LeftForLink leftforlink = (LeftForLink ) property ;
1259+ if (leftforlink .getLinkObjectProperty ().getBusinessRuleByName ("DISPLAYASATTRIBUTEFROMLEFT" ) != null ) {
1260+ String linkobjectclass = StringFormatter
1261+ .formatForJavaClass (leftforlink .getLinkObjectDefinition ().getName ());
1262+ String linkobjectattribute = StringFormatter
1263+ .formatForAttribute (leftforlink .getLinkObjectDefinition ().getName ());
1264+
1265+ sg .wl (" if (left" + linkobjectattribute + " != null)" );
1266+ sg .wl (" if (left" + linkobjectattribute + ".length > 0) {" );
1267+ sg .wl (" ArrayList<" + linkobjectclass + "> linkstoadd = new ArrayList<"
1268+ + linkobjectclass + ">();" );
1269+ sg .wl (" for (int i = 0; i < left" + linkobjectattribute + ".length; i++) {" );
1270+ sg .wl (" " + linkobjectclass + " linktoadd = new " + linkobjectclass + "();" );
1271+ sg .wl (" linktoadd.setleftobject(object.getId());" );
1272+ sg .wl (" linktoadd.setrightobject(left" + linkobjectattribute + "[i].getId());" );
1273+ sg .wl (" linkstoadd.add(linktoadd);" );
1274+ sg .wl (" }" );
1275+ sg .wl (" " + linkobjectclass + ".insert(linkstoadd.toArray(new " + linkobjectclass
1276+ + "[0]));" );
1277+ sg .wl (" }" );
1278+
1279+ }
1280+
1281+ }
1282+ }
12181283 sg .wl (" return object.getId();" );
12191284 sg .wl (" }" );
12201285 sg .wl ("" );
@@ -1749,7 +1814,7 @@ public static void generatePrepareStandardCreateActionToFile(
17491814 StringBuffer extraattributesdeclaration = new StringBuffer ();
17501815 StringBuffer extraattributesfilling = new StringBuffer ();
17511816 StringBuffer extraattributestopage = new StringBuffer ();
1752- StringBuffer companionactionattributecall = new StringBuffer ();
1817+ StringBuffer companionactionattributecall = new StringBuffer ();
17531818 // ------------------------ Attributes for properties ---------------------
17541819 for (int i = 0 ; i < dataobject .propertylist .getSize (); i ++) {
17551820 Property <?> thisproperty = dataobject .propertylist .get (i );
@@ -1769,13 +1834,13 @@ public static void generatePrepareStandardCreateActionToFile(
17691834 extraattributestopage .append (" , " );
17701835 extraattributestopage .append ("logicoutput.getCopy" + thisargument .getName ().toLowerCase () + "()" );
17711836
1772- if (companionactionattributecall .length ()> 0 )
1837+ if (companionactionattributecall .length () > 0 )
17731838 companionactionattributecall .append (" , " );
17741839
17751840 companionactionattributecall .append ("logicoutput.getCopy" );
17761841 companionactionattributecall .append (thisargument .getName ().toLowerCase ());
17771842 companionactionattributecall .append ("()" );
1778-
1843+
17791844 ArrayList <String > imports = thisargument .getImports ();
17801845 for (int k = 0 ; k < imports .size (); k ++) {
17811846 importdeclaration .put (imports .get (k ), imports .get (k ));
@@ -1829,11 +1894,12 @@ public static void generatePrepareStandardCreateActionToFile(
18291894
18301895 sg .wl ("" );
18311896 sg .wl ("import " + module .getPath () + ".page.generated.AtgStandardcreate" + actionname + "Page;" );
1832- if (dataobject .getPropertyByName ("TYPED" )!= null ) {
1833- Typed typedproperty =(Typed ) dataobject .getPropertyByName ("TYPED" );
1834- for (int i = 0 ; i < typedproperty .getCompanionNumber ();i ++) {
1897+ if (dataobject .getPropertyByName ("TYPED" ) != null ) {
1898+ Typed typedproperty = (Typed ) dataobject .getPropertyByName ("TYPED" );
1899+ for (int i = 0 ; i < typedproperty .getCompanionNumber (); i ++) {
18351900 DataObjectDefinition specificcompanion = typedproperty .getCompanion (i );
1836- sg .wl ("import " + specificcompanion .getOwnermodule ().getPath () + ".page.generated.AtgStandardcreate" + specificcompanion .getName ().toLowerCase () + "Page;" );
1901+ sg .wl ("import " + specificcompanion .getOwnermodule ().getPath () + ".page.generated.AtgStandardcreate"
1902+ + specificcompanion .getName ().toLowerCase () + "Page;" );
18371903 }
18381904 }
18391905 sg .wl ("import org.openlowcode.server.graphic.SPage;" );
@@ -1890,12 +1956,13 @@ public static void generatePrepareStandardCreateActionToFile(
18901956 ChoiceValue thistype = types .next ();
18911957 DataObjectDefinition specificcompanion = typed .getCompanionForType (thistype );
18921958 if (specificcompanion != null ) {
1893-
1894- sg .wl (" if (" +StringFormatter .formatForJavaClass (typed .getTypes ().getName ())+"ChoiceDefinition.get()." +thistype .getName ().toUpperCase ()+".getStorageCode().equals(logicoutput.getCopytype().getStorageCode()))" );
1895- sg .wl (" return AtgPreparestandardcreate" +specificcompanion .getName ().toLowerCase ()+"Action.get().executeAndShowPage(" + companionactionattributecall .toString ()+");" );
18961959
1960+ sg .wl (" if (" + StringFormatter .formatForJavaClass (typed .getTypes ().getName ())
1961+ + "ChoiceDefinition.get()." + thistype .getName ().toUpperCase ()
1962+ + ".getStorageCode().equals(logicoutput.getCopytype().getStorageCode()))" );
1963+ sg .wl (" return AtgPreparestandardcreate" + specificcompanion .getName ().toLowerCase ()
1964+ + "Action.get().executeAndShowPage(" + companionactionattributecall .toString () + ");" );
18971965
1898-
18991966 }
19001967 }
19011968 }
0 commit comments