3131import org .openlowcode .design .generation .SourceGenerator ;
3232import org .openlowcode .design .generation .StringFormatter ;
3333import org .openlowcode .design .module .Module ;
34- import org .openlowcode .module .designer .data .Propertydef ;
3534import org .openlowcode .tools .misc .NamedList ;
3635
3736/**
@@ -76,9 +75,9 @@ public static void generateShowActionToFile(
7675 String objectclass = StringFormatter .formatForJavaClass (dataobject .getName ());
7776 String objectvariable = StringFormatter .formatForAttribute (dataobject .getName ());
7877 String companionclass = null ;
79- if (companionobject != null ) {
78+ if (companionobject != null ) {
8079 companionclass = StringFormatter .formatForJavaClass (companionobject .getName ());
81-
80+
8281 }
8382 String lifecycleclass = null ;
8483 ChoiceCategory lifecycle = null ;
@@ -118,6 +117,7 @@ public static void generateShowActionToFile(
118117 if ((dataobjectproperty instanceof SimpleTaskWorkflow ) || (dataobjectproperty instanceof ComplexWorkflow )) {
119118 hasworkflow = true ;
120119 }
120+
121121 }
122122
123123 sg .wl ("package " + module .getPath () + ".action.generated;" );
@@ -132,27 +132,30 @@ public static void generateShowActionToFile(
132132 sg .wl ("import org.openlowcode.server.data.storage.TableAlias;" );
133133 sg .wl ("import org.openlowcode.server.data.properties.DataObjectId;" );
134134 sg .wl ("import org.openlowcode.server.data.NodeTree;" );
135- if (dataobject .getPropertyByName ("TYPED" )!= null ) {
135+ if (dataobject .getPropertyByName ("TYPED" ) != null ) {
136136 Typed typed = (Typed ) dataobject .getPropertyByName ("TYPED" );
137137 SimpleChoiceCategory choice = typed .getTypes ();
138- sg .wl ("import " +choice .getParentModule ().getPath ()+".data.choice." +StringFormatter .formatForJavaClass (choice .getName ())+"ChoiceDefinition;" );
139- for (int i =0 ;i <typed .getCompanionNumber ();i ++) {
138+ sg .wl ("import " + choice .getParentModule ().getPath () + ".data.choice."
139+ + StringFormatter .formatForJavaClass (choice .getName ()) + "ChoiceDefinition;" );
140+ for (int i = 0 ; i < typed .getCompanionNumber (); i ++) {
140141 DataObjectDefinition thiscompanion = typed .getCompanion (i );
141- sg .wl ("import " +thiscompanion .getOwnermodule ().getPath ()+".data." +StringFormatter .formatForJavaClass (thiscompanion .getName ())+";" );
142+ sg .wl ("import " + thiscompanion .getOwnermodule ().getPath () + ".data."
143+ + StringFormatter .formatForJavaClass (thiscompanion .getName ()) + ";" );
142144 }
143145 }
144- if (companionobject != null ) {
146+ if (companionobject != null ) {
145147 sg .wl ("import org.openlowcode.server.data.TwoDataObjects;" );
146- sg .wl ("import " + companionobject .getOwnermodule ().getPath ()+ ".data." + companionclass + ";" );
148+ sg .wl ("import " + companionobject .getOwnermodule ().getPath () + ".data." + companionclass + ";" );
147149 }
148150 sg .wl ("import org.openlowcode.module.system.data.choice.ApplocaleChoiceDefinition;" );
149151 sg .wl ("import org.openlowcode.module.system.data.choice.PreferedfileencodingChoiceDefinition;" );
150152 sg .wl ("import " + module .getPath () + ".action.generated.Abs" + actionname + ";" );
151153 sg .wl ("import " + module .getPath () + ".data." + objectclass + ";" );
152- if (companionobject == null ) {
154+ if (companionobject == null ) {
153155 sg .wl ("import " + module .getPath () + ".page.generated.AtgShow" + objectvariable + "Page;" );
154156 } else {
155- sg .wl ("import " +companionobject .getOwnermodule ().getPath ()+".page.generated.AtgShow" +companionobject .getName ().toLowerCase ()+"Page;" );
157+ sg .wl ("import " + companionobject .getOwnermodule ().getPath () + ".page.generated.AtgShow"
158+ + companionobject .getName ().toLowerCase () + "Page;" );
156159 }
157160 sg .wl ("import java.util.Date;" );
158161 if (dataobject .hasLifecycle ()) {
@@ -200,9 +203,10 @@ public static void generateShowActionToFile(
200203 if (companionobject == null ) {
201204 sg .wl (" " + objectclass + " " + objectvariable + " = " + objectclass + ".readone(id);" );
202205 } else {
203- sg .wl (" TwoDataObjects<" +objectclass +"," +companionclass +"> mainandcompanion = " +companionclass +".readtyped(id);" );
204- sg .wl (" " +objectclass +" " +objectvariable +" = mainandcompanion.getObjectOne();" );
205-
206+ sg .wl (" TwoDataObjects<" + objectclass + "," + companionclass + "> mainandcompanion = " + companionclass
207+ + ".readtyped(id);" );
208+ sg .wl (" " + objectclass + " " + objectvariable + " = mainandcompanion.getObjectOne();" );
209+
206210 }
207211 sg .wl (" ChoiceValue<ApplocaleChoiceDefinition> userlocale = OLcServer.getServer().getCurrentUser().getPreflang();" );
208212 sg .wl (" ChoiceValue<PreferedfileencodingChoiceDefinition> preffileencoding = OLcServer.getServer().getCurrentUser().getPreffileenc();" );
@@ -335,6 +339,9 @@ public static void generateShowActionToFile(
335339 extraargumentfordata .add (StringFormatter .formatForJavaClass (dataobjectlinkedfromchildren .getName ()));
336340
337341 }
342+
343+
344+
338345 if (dataobjectproperty instanceof LeftForLink ) {
339346 LeftForLink <?, ?> dataobjectleftforlink = (LeftForLink <?, ?>) dataobjectproperty ;
340347 DataObjectDefinition linkedobject = dataobjectleftforlink .getLinkObjectDefinition ();
@@ -463,13 +470,24 @@ public static void generateShowActionToFile(
463470 }
464471
465472 }
466-
473+ for (int i = 0 ; i < dataobject .propertylist .getSize (); i ++) {
474+ Property <?> dataobjectproperty = dataobject .propertylist .get (i );
475+ if (dataobjectproperty instanceof Typed ) {
476+ if (dataobjectproperty instanceof Typed ) {
477+ Typed typed = (Typed ) (dataobjectproperty );
478+ sg .wl (" ChoiceValue<" + StringFormatter .formatForJavaClass (typed .getTypes ().getName ())
479+ + "ChoiceDefinition> typechoice = " + objectvariable + ".getobjecttype();" );
480+ extravariableforaction .add ("typechoice" );
481+ extraargumentfordata .add ("Typechoice" );
482+ }
483+ }
484+ }
467485 sg .wl (" " );
468486 /* if (isextraobject) { */
469487// ActionOutputData is used only if output has more than one argument
470- if (companionobject == null ) {
471- sg .w (" ActionOutputData outputdata = new ActionOutputData(" + objectvariable
472- + ",userlocale,preffileencoding" );
488+ if (companionobject == null ) {
489+ sg .w (" ActionOutputData outputdata = new ActionOutputData(" + objectvariable
490+ + ",userlocale,preffileencoding" );
473491 } else {
474492 sg .w (" ActionOutputData outputdata = new ActionOutputData(mainandcompanion.getObjectOne(),mainandcompanion.getObjectTwo()"
475493 + ",userlocale,preffileencoding" );
@@ -489,22 +507,27 @@ public static void generateShowActionToFile(
489507 sg .wl (" @Override" );
490508 sg .wl (" public SPage choosePage(ActionOutputData logicoutput) {" );
491509 sg .wl (" " );
492- if (dataobject .getPropertyByName ("TYPED" )!=null ) if (companionobject ==null ) {
493- Typed typed = (Typed ) (dataobject .getPropertyByName ("TYPED" ));
494- Iterator <ChoiceValue > types = typed .getTypesIterator ();
495- while (types .hasNext ()) {
496- ChoiceValue thistype = types .next ();
497- DataObjectDefinition companion = typed .getCompanionForType (thistype );
498- sg .wl (" if (" +StringFormatter .formatForJavaClass (typed .getTypes ().getName ())+"ChoiceDefinition.get()." +thistype .getName ().toUpperCase ()+".getStorageCode().equals(logicoutput.get" +objectclass +"().getType()))" );
499- sg .wl (" return AtgShow" +companion .getName ().toLowerCase ()+"Action.get().executeAndShowPage(logicoutput.get" +objectclass +"().getId());" );
510+ if (dataobject .getPropertyByName ("TYPED" ) != null )
511+ if (companionobject == null ) {
512+ Typed typed = (Typed ) (dataobject .getPropertyByName ("TYPED" ));
513+ Iterator <ChoiceValue > types = typed .getTypesIterator ();
514+ while (types .hasNext ()) {
515+ ChoiceValue thistype = types .next ();
516+ DataObjectDefinition companion = typed .getCompanionForType (thistype );
517+ sg .wl (" if (" + StringFormatter .formatForJavaClass (typed .getTypes ().getName ())
518+ + "ChoiceDefinition.get()." + thistype .getName ().toUpperCase ()
519+ + ".getStorageCode().equals(logicoutput.get" + objectclass + "().getType()))" );
520+ sg .wl (" return AtgShow" + companion .getName ().toLowerCase ()
521+ + "Action.get().executeAndShowPage(logicoutput.get" + objectclass + "().getId());" );
500522
523+ }
501524 }
502- }
503525
504-
505-
506- sg .wl (" return new AtgShow" + (companionobject !=null ?companionobject .getName ().toLowerCase ():objectvariable ) + "Page(logicoutput.get" + objectclass
507- + "()," +(companionobject !=null ?"logicoutput.get" +companionclass +"()," :"" )+"logicoutput.getUserlocale(),logicoutput.getPrefencoding()" );
526+ sg .wl (" return new AtgShow"
527+ + (companionobject != null ? companionobject .getName ().toLowerCase () : objectvariable )
528+ + "Page(logicoutput.get" + objectclass + "(),"
529+ + (companionobject != null ? "logicoutput.get" + companionclass + "()," : "" )
530+ + "logicoutput.getUserlocale(),logicoutput.getPrefencoding()" );
508531 for (int i = 0 ; i < extraargumentfordata .size (); i ++) {
509532 sg .wl (" ,logicoutput.get" + extraargumentfordata .get (i ) + "()" );
510533 }
0 commit comments