Skip to content

Commit

Permalink
Intermediate checkin for #119
Browse files Browse the repository at this point in the history
Calling show page for companion when relevant. Basic display of
companion on show page
  • Loading branch information
Open Lowcode SAS committed Oct 14, 2020
1 parent aa5c9ee commit cb580c3
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
Expand Up @@ -12,6 +12,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;

import org.openlowcode.design.data.properties.basic.ComplexWorkflow;
import org.openlowcode.design.data.properties.basic.FileContent;
Expand All @@ -26,12 +27,12 @@
import org.openlowcode.design.data.properties.basic.Schedule;
import org.openlowcode.design.data.properties.basic.SimpleTaskWorkflow;
import org.openlowcode.design.data.properties.basic.TimeSlot;
import org.openlowcode.design.data.properties.basic.Typed;
import org.openlowcode.design.generation.SourceGenerator;
import org.openlowcode.design.generation.StringFormatter;
import org.openlowcode.design.module.Module;
import org.openlowcode.tools.misc.NamedList;


/**
* A utility class generating the show action to file
*
Expand Down Expand Up @@ -130,6 +131,15 @@ public static void generateShowActionToFile(
sg.wl("import org.openlowcode.server.data.storage.TableAlias;");
sg.wl("import org.openlowcode.server.data.properties.DataObjectId;");
sg.wl("import org.openlowcode.server.data.NodeTree;");
if (dataobject.getPropertyByName("TYPED")!=null) {
Typed typed = (Typed) dataobject.getPropertyByName("TYPED");
SimpleChoiceCategory choice = typed.getTypes();
sg.wl("import "+choice.getParentModule().getPath()+".data.choice."+StringFormatter.formatForJavaClass(choice.getName())+"ChoiceDefinition;");
for (int i=0;i<typed.getCompanionNumber();i++) {
DataObjectDefinition thiscompanion = typed.getCompanion(i);
sg.wl("import "+thiscompanion.getOwnermodule().getPath()+".data."+StringFormatter.formatForJavaClass(thiscompanion.getName())+";");
}
}
if (companionobject!=null) {
sg.wl("import org.openlowcode.server.data.TwoDataObjects;");
sg.wl("import "+companionobject.getOwnermodule().getPath()+".data."+companionclass+";");
Expand Down Expand Up @@ -478,6 +488,20 @@ public static void generateShowActionToFile(
sg.wl(" @Override");
sg.wl(" public SPage choosePage(ActionOutputData logicoutput) {");
sg.wl(" ");
if (dataobject.getPropertyByName("TYPED")!=null) if (companionobject==null) {
Typed typed = (Typed) (dataobject.getPropertyByName("TYPED"));
Iterator<ChoiceValue> types = typed.getTypesIterator();
while (types.hasNext()) {
ChoiceValue thistype = types.next();
DataObjectDefinition companion = typed.getCompanionForType(thistype);
sg.wl(" if ("+StringFormatter.formatForJavaClass(typed.getTypes().getName())+"ChoiceDefinition.get()."+thistype.getName().toUpperCase()+".getStorageCode().equals(logicoutput.get"+objectclass+"().getType()))");
sg.wl(" return AtgShow"+companion.getName().toLowerCase()+"Action.get().executeAndShowPage(logicoutput.get"+objectclass+"().getId());");

}
}



sg.wl(" return new AtgShow" + (companionobject!=null?companionobject.getName().toLowerCase():objectvariable) + "Page(logicoutput.get" + objectclass
+ "(),"+(companionobject!=null?"logicoutput.get"+companionclass+"(),":"")+"logicoutput.getUserlocale(),logicoutput.getPrefencoding()");
for (int i = 0; i < extraargumentfordata.size(); i++) {
Expand Down
Expand Up @@ -805,7 +805,8 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
sg.wl(" objectdisplaydefinition.setReducedDisplay(false);");
sg.wl(" detailstab.addElement(objectdisplaydefinition);");
if (companion!=null) {
sg.wl(" SObjectDisplay<"+companionclass+"> companionobjectdisplay = new SObjectDisplay<"+companionclass+">(\"COMPANION\",this.get"+companionclass+"(),"+companionclass+".getDefinition(), this, false);");
sg.wl(" SObjectDisplay<"+companionclass+"> companionobjectdisplay = new SObjectDisplay<"+companionclass+">(\"COMPANION\",this.get"+companionclass+"(),"+companionclass+".getDefinition(), this, true);");
sg.wl(" companionobjectdisplay.setReducedDisplay(false);");
sg.wl(" detailstab.addElement(companionobjectdisplay);");

}
Expand All @@ -825,7 +826,8 @@ public void generateToFile(SourceGenerator sg, Module module) throws IOException
sg.wl(" objectdisplaydefinition.addPageNodeRightOfTitle(activetaskband);");
sg.wl("");
if (companion!=null) {
sg.wl(" SObjectDisplay<"+companionclass+"> companionobjectdisplay = new SObjectDisplay<"+companionclass+">(\"COMPANION\",this.get"+companionclass+"(),"+companionclass+".getDefinition(), this, false);");
sg.wl(" SObjectDisplay<"+companionclass+"> companionobjectdisplay = new SObjectDisplay<"+companionclass+">(\"COMPANION\",this.get"+companionclass+"(),"+companionclass+".getDefinition(), this, true);");
sg.wl(" companionobjectdisplay.setReducedDisplay(false);");
sg.wl(" mainband.addElement(companionobjectdisplay);");

}
Expand Down
18 changes: 17 additions & 1 deletion src/org/openlowcode/design/data/properties/basic/Typed.java
Expand Up @@ -23,12 +23,14 @@
import org.openlowcode.design.data.MethodArgument;
import org.openlowcode.design.data.Property;
import org.openlowcode.design.data.SimpleChoiceCategory;
import org.openlowcode.design.data.StoredElement;
import org.openlowcode.design.data.StringStoredElement;
import org.openlowcode.design.data.argument.ChoiceArgument;
import org.openlowcode.design.data.argument.ObjectArgument;
import org.openlowcode.design.data.argument.ObjectIdArgument;
import org.openlowcode.design.generation.SourceGenerator;
import org.openlowcode.design.generation.StringFormatter;
import org.openlowcode.design.module.Module;
import org.openlowcode.design.pages.SearchWidgetDefinition;

/**
* A Typed data object (e.g. vehicle) can be declared with a specialized type
Expand All @@ -52,6 +54,14 @@ public class Typed
private HashMap<DataObjectDefinition, ChoiceValue[]> typespercompanion;
private ArrayList<DataObjectDefinition> allcompanions;

public Iterator<ChoiceValue> getTypesIterator() {
return companionspertype.keySet().iterator();
}

public DataObjectDefinition getCompanionForType(ChoiceValue type) {
return companionspertype.get(type);
}

public DataObjectDefinition getCompanion(int index) {
return this.allcompanions.get(index);
}
Expand Down Expand Up @@ -122,6 +132,12 @@ public void controlAfterParentDefinition() {
ArgumentContent typeargument = new ChoiceArgument("TYPE", types);
typeargument.setOptional(false);
this.addContextForDataCreation(typeargument);

StoredElement type = new StringStoredElement("TYPE",types.getKeyStorageLength());
this.addElementasSearchElement(type, "Type", "Type of "+parent.getLabel(),
Property.FIELDDIPLSAY_TITLE_MOD, 860, 40,
new SearchWidgetDefinition(true, "TYPE", "Type", types));

}

@Override
Expand Down
3 changes: 3 additions & 0 deletions src/org/openlowcode/server/data/properties/Typed.java
Expand Up @@ -83,5 +83,8 @@ F extends FieldChoiceDefinition<F>> void postprocStoredobjectInsert(
for (int i = 0; i < object.length; i++)
preproctypesbatch[i].postprocStoredobjectInsert(object[i]);
}
public String getType() {
return this.type.getPayload();
}

}

0 comments on commit cb580c3

Please sign in to comment.