Skip to content

Commit e0ecd23

Browse files
author
Open Lowcode SAS
committed
Close #242
1 parent e945b3e commit e0ecd23

15 files changed

Lines changed: 264 additions & 94 deletions

src/org/openlowcode/design/data/DataObjectDefinition.java

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,7 @@ private PageDefinition generateShowPage(DataObjectDefinition companion) {
11531153
showpage.addInputParameter(new ArrayArgument(
11541154
new ObjectArgument(thislinkedfromchildren.getName(), thislinkedfromchildren.getChildObject())));
11551155
}
1156+
11561157
if (thisproperty instanceof LeftForLink) {
11571158
LeftForLink<?, ?> thisleftforlink = (LeftForLink<?, ?>) thisproperty;
11581159
showpage.addInputParameter(new ArrayArgument(
@@ -1212,7 +1213,14 @@ private PageDefinition generateShowPage(DataObjectDefinition companion) {
12121213
}
12131214

12141215
}
1216+
for (int i = 0; i < this.propertylist.getSize(); i++) {
1217+
Property<?> thisproperty = this.propertylist.get(i);
1218+
if (thisproperty instanceof Typed) {
1219+
showpage.addInputParameter(
1220+
new ChoiceArgument("TYPECHOICE", ((Typed) (this.getPropertyByName("TYPED"))).getTypes()));
12151221

1222+
}
1223+
}
12161224
return showpage;
12171225
}
12181226

@@ -1972,6 +1980,7 @@ private ActionDefinition generateShowAction(DataObjectDefinition companion) {
19721980
showaction.addOutputArgument(new ArrayArgument(
19731981
new ObjectArgument(thislinkedfromchildren.getName(), thislinkedfromchildren.getChildObject())));
19741982
}
1983+
19751984
if (thisproperty instanceof LeftForLink) {
19761985
@SuppressWarnings("rawtypes")
19771986
LeftForLink<?, ?> thisleftforlink = (LeftForLink) thisproperty;
@@ -2037,7 +2046,14 @@ private ActionDefinition generateShowAction(DataObjectDefinition companion) {
20372046
}
20382047

20392048
}
2049+
for (int i = 0; i < this.propertylist.getSize(); i++) {
2050+
Property<?> thisproperty = this.propertylist.get(i);
2051+
if (thisproperty instanceof Typed) {
2052+
showaction.addOutputArgument(
2053+
new ChoiceArgument("TYPECHOICE", ((Typed) (this.getPropertyByName("TYPED"))).getTypes()));
20402054

2055+
}
2056+
}
20412057
return showaction;
20422058
}
20432059

@@ -2284,7 +2300,7 @@ public void generateAutomaticPagesAndActions(Module module) {
22842300
|| (this.isShowActionAutomaticallyGenerated())) {
22852301
module.addAction(this.generatePrepareStandardCreateAction());
22862302
module.addAction(this.generateStandardCreateAction());
2287-
2303+
22882304
if (this.getPropertyByName("TYPED") != null) {
22892305
Typed typed = (Typed) (this.getPropertyByName("TYPED"));
22902306
for (int i = 0; i < typed.getCompanionNumber(); i++) {
@@ -2293,7 +2309,7 @@ public void generateAutomaticPagesAndActions(Module module) {
22932309
module.addAction(generateStandardCreateAction(companion));
22942310
}
22952311
}
2296-
2312+
22972313
this.addActionOnObjectPageOnManageMenu(this.generateDuplicateAction(),
22982314
"Create new " + this.getLabel() + " with similar data");
22992315
module.AddPage(this.generateStandardCreatePage());
@@ -2303,7 +2319,7 @@ public void generateAutomaticPagesAndActions(Module module) {
23032319
DataObjectDefinition companion = typed.getCompanion(i);
23042320
module.AddPage(this.generateStandardCreatePage(companion));
23052321
}
2306-
}
2322+
}
23072323
}
23082324
for (int i = 0; i < this.propertylist.getSize(); i++) {
23092325
Property<?> thisproperty = this.propertylist.get(i);
@@ -2466,11 +2482,11 @@ private ActionDefinition generateLaunchSearchAction() {
24662482
}
24672483

24682484
private PageDefinition generateStandardCreatePage(DataObjectDefinition companion) {
2469-
2485+
24702486
String actionname = this.getName().toUpperCase();
2471-
if (companion!=null) actionname = companion.getName().toUpperCase();
2472-
DynamicPageDefinition standardcreatepage = new DynamicPageDefinition(
2473-
"STANDARDCREATE" + actionname);
2487+
if (companion != null)
2488+
actionname = companion.getName().toUpperCase();
2489+
DynamicPageDefinition standardcreatepage = new DynamicPageDefinition("STANDARDCREATE" + actionname);
24742490
for (int i = 0; i < this.propertylist.getSize(); i++) {
24752491
Property<?> property = this.propertylist.get(i);
24762492
for (int j = 0; j < property.getContextDataForCreationSize(); j++) {
@@ -2495,13 +2511,13 @@ private PageDefinition generateStandardCreatePage(DataObjectDefinition companion
24952511
}
24962512
}
24972513
standardcreatepage.addInputParameter(new ObjectArgument("object", this));
2498-
if (companion!=null) {
2499-
standardcreatepage.addInputParameter(new ObjectArgument("COMPANION",companion));
2500-
2514+
if (companion != null) {
2515+
standardcreatepage.addInputParameter(new ObjectArgument("COMPANION", companion));
2516+
25012517
}
25022518
return standardcreatepage;
25032519
}
2504-
2520+
25052521
private PageDefinition generateStandardCreatePage() {
25062522
return generateStandardCreatePage(null);
25072523
}
@@ -2557,21 +2573,23 @@ private DynamicActionDefinition generateDuplicateAction() {
25572573
}
25582574

25592575
private ActionDefinition generateStandardCreateAction(DataObjectDefinition companion) {
2560-
DynamicActionDefinition standardcreationaction = new DynamicActionDefinition(
2561-
"STANDARDCREATE" + (companion==null?this.getName().toUpperCase():companion.getName().toUpperCase()), true);
2576+
DynamicActionDefinition standardcreationaction = new DynamicActionDefinition("STANDARDCREATE"
2577+
+ (companion == null ? this.getName().toUpperCase() : companion.getName().toUpperCase()), true);
25622578
addAttributesToCreateobject(standardcreationaction, this);
2563-
if (companion!=null) standardcreationaction.addInputArgument(new ObjectArgument("COMPANION",companion));
2579+
if (companion != null)
2580+
standardcreationaction.addInputArgument(new ObjectArgument("COMPANION", companion));
25642581
standardcreationaction.addOutputArgument(new ObjectIdArgument("createdobjectid", this));
25652582
this.addActionToCreateNewGroup(standardcreationaction);
25662583
return standardcreationaction;
25672584
}
2585+
25682586
private ActionDefinition generateStandardCreateAction() {
25692587
return generateStandardCreateAction(null);
25702588
}
25712589

25722590
private ActionDefinition generatePrepareStandardCreateAction(DataObjectDefinition companion) {
2573-
DynamicActionDefinition preparestandardcreationaction = new DynamicActionDefinition(
2574-
"PREPARESTANDARDCREATE" + (companion==null?this.getName().toUpperCase():companion.getName().toUpperCase()), true);
2591+
DynamicActionDefinition preparestandardcreationaction = new DynamicActionDefinition("PREPARESTANDARDCREATE"
2592+
+ (companion == null ? this.getName().toUpperCase() : companion.getName().toUpperCase()), true);
25752593
// -- contextattributes
25762594
for (int i = 0; i < this.propertylist.getSize(); i++) {
25772595
Property<?> property = this.propertylist.get(i);
@@ -2611,11 +2629,12 @@ private ActionDefinition generatePrepareStandardCreateAction(DataObjectDefinitio
26112629
}
26122630
}
26132631
preparestandardcreationaction.addOutputArgument(new ObjectArgument("OBJECT", this));
2614-
if (companion!=null) preparestandardcreationaction.addOutputArgument(new ObjectArgument("COMPANION", companion));
2632+
if (companion != null)
2633+
preparestandardcreationaction.addOutputArgument(new ObjectArgument("COMPANION", companion));
26152634
this.addActionToCreateNewGroup(preparestandardcreationaction);
26162635
return preparestandardcreationaction;
26172636
}
2618-
2637+
26192638
private ActionDefinition generatePrepareStandardCreateAction() {
26202639
return generatePrepareStandardCreateAction(null);
26212640
}
@@ -3632,7 +3651,7 @@ public void generateDefinitionToFile(SourceGenerator sg, Module module) throws I
36323651
+ thisproperty.getDataObjectConstructorAttributes() + ");");
36333652
for (int j = 0; j < thisproperty.getBusinessRuleNumber(); j++) {
36343653
PropertyBusinessRule<?> thisbusinessrule = thisproperty.getBusinessRule(j);
3635-
3654+
36363655
thisbusinessrule.writeInitialization(sg);
36373656
}
36383657

src/org/openlowcode/design/data/DataObjectDefinitionShowAction.java

Lines changed: 54 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.openlowcode.design.generation.SourceGenerator;
3232
import org.openlowcode.design.generation.StringFormatter;
3333
import org.openlowcode.design.module.Module;
34-
import org.openlowcode.module.designer.data.Propertydef;
3534
import 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

Comments
 (0)