diff --git a/src/org/openlowcode/client/action/CActionDataLoc.java b/src/org/openlowcode/client/action/CActionDataLoc.java index 785fa162..62604f5e 100644 --- a/src/org/openlowcode/client/action/CActionDataLoc.java +++ b/src/org/openlowcode/client/action/CActionDataLoc.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2019 [Open Lowcode SAS](https://openlowcode.com/) + * Copyright (c) 2019-2020 [Open Lowcode SAS](https://openlowcode.com/) * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -32,6 +32,7 @@ public class CActionDataLoc extends Named { public static final String TEXT_TYPE = "TXT"; public static final String OBJ_TYPE = "OBJ"; public static final String OBJ_ID_TYPE = "OID"; + public static final String OBJ_MS_ID_TYPE = "OMI"; public static final String CHOICE_TYPE = "CHT"; public static final String MULTI_CHOICE_TYPE = "MLC"; public static final String ARRAY_PREFIX = "ARR/"; @@ -58,6 +59,8 @@ public CActionDataLoc(MessageReader reader) throws OLcRemoteException, IOExcepti typesupported = true; if (this.type.compareTo(OBJ_ID_TYPE) == 0) typesupported = true; + if (this.type.compareTo(OBJ_MS_ID_TYPE) == 0) + typesupported=true; if (this.type.compareTo(CHOICE_TYPE) == 0) typesupported = true; if (this.type.compareTo(MULTI_CHOICE_TYPE) == 0) @@ -81,6 +84,8 @@ public CActionDataLoc(MessageReader reader) throws OLcRemoteException, IOExcepti typesupported = true; if (subtype.compareTo(CHOICE_TYPE) == 0) typesupported = true; + if (subtype.compareTo(OBJ_MS_ID_TYPE) == 0) + typesupported = true; } if (!typesupported) throw new RuntimeException("the type put in the action field " + this.getName() diff --git a/src/org/openlowcode/client/graphic/widget/CObjectArray.java b/src/org/openlowcode/client/graphic/widget/CObjectArray.java index 8ffb79d0..a933cc06 100644 --- a/src/org/openlowcode/client/graphic/widget/CObjectArray.java +++ b/src/org/openlowcode/client/graphic/widget/CObjectArray.java @@ -49,6 +49,8 @@ import org.openlowcode.tools.structure.ObjectDataEltType; import org.openlowcode.tools.structure.ObjectIdDataElt; import org.openlowcode.tools.structure.ObjectIdDataEltType; +import org.openlowcode.tools.structure.ObjectMasterIdDataElt; +import org.openlowcode.tools.structure.ObjectMasterIdDataEltType; import org.openlowcode.tools.structure.SimpleDataElt; import org.openlowcode.tools.structure.TextDataElt; import org.openlowcode.tools.structure.TextDataEltType; @@ -894,6 +896,21 @@ public DataElt getDataElt(DataEltType type, String eltname, String objectfieldna ObjectIdDataElt objectid = new ObjectIdDataElt(eltname, textfield.getPayload()); return objectid; } + + if (type instanceof ObjectMasterIdDataEltType) { + if (objectfieldname == null) + throw new RuntimeException("objectid field should have an objectfieldname"); + ObjectDataElt object = this.thistable.getSelectionModel().getSelectedItem().getObject(); + SimpleDataElt field = object.lookupEltByName(objectfieldname); + if (field == null) + throw new RuntimeException( + "field not found " + objectfieldname + ", available fields = " + object.dropFieldNames()); + if (!(field instanceof TextDataElt)) + throw new RuntimeException("field for name = " + objectfieldname + " is not text"); + TextDataElt textfield = (TextDataElt) field; + ObjectMasterIdDataElt objectid = new ObjectMasterIdDataElt(eltname, textfield.getPayload()); + return objectid; + } if (type instanceof TextDataEltType) { TextDataElt updatenote = new TextDataElt(eltname, this.updatenotecomment); @@ -977,6 +994,27 @@ public DataElt getDataElt(DataEltType type, String eltname, String objectfieldna return output; } + + if (payloadtypeinarray instanceof ObjectMasterIdDataEltType) { + Iterator selectedobjects = this.thistable.getSelectionModel().getSelectedItems() + .iterator(); + ArrayDataElt output = new ArrayDataElt(eltname, payloadtypeinarray); + while (selectedobjects.hasNext()) { + ObjectDataElt thisobject = selectedobjects.next().getObject(); + SimpleDataElt field = thisobject.lookupEltByName(objectfieldname); + if (field == null) + throw new RuntimeException("field not found " + objectfieldname + ", available fields = " + + thisobject.dropFieldNames()); + if (!(field instanceof TextDataElt)) + throw new RuntimeException("field for name = " + objectfieldname + " is not text"); + TextDataElt textfield = (TextDataElt) field; + ObjectMasterIdDataElt objectid = new ObjectMasterIdDataElt(eltname, textfield.getPayload()); + output.addElement(objectid); + } + return output; + } + + } // add here treatment of array element. diff --git a/src/org/openlowcode/design/data/properties/basic/LeftForLink.java b/src/org/openlowcode/design/data/properties/basic/LeftForLink.java index 35ea7b8b..52a3e8ac 100644 --- a/src/org/openlowcode/design/data/properties/basic/LeftForLink.java +++ b/src/org/openlowcode/design/data/properties/basic/LeftForLink.java @@ -446,7 +446,7 @@ public void generateWidgetCode(SourceGenerator sg, Module module, String locatio + "(blanklinkforaddtoleft" + linkobjectvariable + "s.getObjectInput());"); sg.wl(" createlinkactionforaddtoleft" + linkobjectvariable + "s.setRight" + rightobjectvariable + "id(" + rightobjectvariable + "searchforaddtoleft" + linkobjectvariable - + "s.getresultarray().getAttributeArrayInput(" + rightobjectclass + ".getLinkobjecttomasterrightidMarker()));"); + + "s.getresultarray().getAttributeArrayInput(" + rightobjectclass + ".getIdMarker()));"); sg.wl(" "); sg.wl(" SActionButton createlinkbuttonforaddtoleft" + linkobjectvariable + " = new SActionButton(\"Add Link\", createlinkactionforaddtoleft" + linkobjectvariable diff --git a/src/org/openlowcode/design/data/properties/basic/LeftForLinkToMaster.java b/src/org/openlowcode/design/data/properties/basic/LeftForLinkToMaster.java index b3ee7615..7890c743 100644 --- a/src/org/openlowcode/design/data/properties/basic/LeftForLinkToMaster.java +++ b/src/org/openlowcode/design/data/properties/basic/LeftForLinkToMaster.java @@ -1,3 +1,13 @@ +/******************************************************************************** + * Copyright (c) 2020 [Open Lowcode SAS](https://openlowcode.com/) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 . + * + * SPDX-License-Identifier: EPL-2.0 + ********************************************************************************/ + package org.openlowcode.design.data.properties.basic; import java.io.IOException; @@ -16,6 +26,16 @@ import org.openlowcode.design.pages.PageDefinition; import org.openlowcode.tools.misc.NamedList; +/** + * The property for an object that is left for a link to master relationship + * + * @author Open Lowcode + * SAS + * + * @param current object + * @param link to master object + * @since 1.9 + */ public class LeftForLinkToMaster extends Property> { @@ -111,7 +131,9 @@ public DataObjectDefinition getLinkObjectDefinition() { public LinkObjectToMaster getLinkObjectProperty() { DataObjectDefinition linkobject = linkdataobject; @SuppressWarnings("unchecked") - LinkObjectToMaster linkobjectproperty = (LinkObjectToMaster) linkobject.getPropertyByName("LINKOBJECTTOMASTER"); + LinkObjectToMaster< + E, + F> linkobjectproperty = (LinkObjectToMaster) linkobject.getPropertyByName("LINKOBJECTTOMASTER"); if (linkobjectproperty == null) throw new RuntimeException("link object does not have property"); return linkobjectproperty; @@ -318,15 +340,16 @@ public void generateWidgetCode(SourceGenerator sg, Module module, String locatio .formatForAttribute(parentproperty.getRightObjectForLink().getName()); String rightobjectclass = StringFormatter .formatForJavaClass(parentproperty.getRightObjectForLink().getName()); - + // ---- temporary code. DisplayLinkAsAttributeFromLeftObject attributeasleft = null; /* - @SuppressWarnings("unchecked") - DisplayLinkAsAttributeFromLeftObject attributeasleft = (DisplayLinkAsAttributeFromLeftObject< - E, F>) parentproperty.getLinkObjectProperty().getBusinessRuleByName("DISPLAYASATTRIBUTEFROMLEFT"); -*/ - + * @SuppressWarnings("unchecked") DisplayLinkAsAttributeFromLeftObject + * attributeasleft = (DisplayLinkAsAttributeFromLeftObject< E, F>) + * parentproperty.getLinkObjectProperty().getBusinessRuleByName( + * "DISPLAYASATTRIBUTEFROMLEFT"); + */ + if (attributeasleft == null) { // ------------------------------------------------------------------------------------------------- // show link as table. This is the classical display @@ -346,7 +369,7 @@ public void generateWidgetCode(SourceGenerator sg, Module module, String locatio sg.wl(" this);"); sg.wl(" left" + linkobjectvariable + "s.addDisplayProfile(" + linkobjectclass + "Definition.get" + linkobjectclass + "Definition().getDisplayProfileHideleftobjectfields());"); - + sg.wl(" left" + linkobjectvariable + "s.setMinFieldPriority(-900);"); sg.wl(" left" + linkobjectvariable + "s.setWarningForUnsavedEdition();"); sg.wl(" AtgMassupdate" + linkobjectvariable + "andshowleftAction.ActionRef updateleft" + linkobjectvariable + "s = AtgMassupdate" + linkobjectvariable @@ -366,7 +389,8 @@ public void generateWidgetCode(SourceGenerator sg, Module module, String locatio + linkobjectvariable + "action = AtgShow" + rightobjectvariable + "Action.get().getActionRef();"); sg.wl(" showright" + rightobjectvariable + "for" + linkobjectvariable + "action.setId(left" - + linkobjectvariable + "s.getAttributeInput(" + linkobjectclass + ".getRgmsidMarker()));"); + + linkobjectvariable + "s.getAttributeInput(" + linkobjectclass + + ".getLinkobjecttomasterrightidMarker()));"); sg.wl(" left" + linkobjectvariable + "s.addDefaultAction(showright" + rightobjectvariable + "for" + linkobjectvariable + "action);"); sg.wl(" "); @@ -414,8 +438,8 @@ public void generateWidgetCode(SourceGenerator sg, Module module, String locatio + "s = new SObjectDisplay<" + linkobjectclass + ">(\"BLANK" + linkobject.getName().toUpperCase() + "FORADD\","); - sg.wl(" this.getLeftforlinktomasterfor" + linkobjectvariable + "blankforadd(), " + linkobjectclass - + ".getDefinition(),this, false);"); + sg.wl(" this.getLeftforlinktomasterfor" + linkobjectvariable + "blankforadd(), " + + linkobjectclass + ".getDefinition(),this, false);"); sg.wl(" blanklinkforaddtoleft" + linkobjectvariable + "s.setHideReadOnly();"); sg.wl(" "); sg.wl(" addtoleft" + linkobjectvariable + "s.addElement(blanklinkforaddtoleft" + linkobjectvariable @@ -462,7 +486,7 @@ public void generateWidgetCode(SourceGenerator sg, Module module, String locatio + "button);"); sg.wl(" " + locationname + ".addElement(left" + linkobjectvariable + "buttonbar);"); sg.wl(" " + locationname + ".addElement(left" + linkobjectvariable + "s);"); - } + } } diff --git a/src/org/openlowcode/server/data/DataObjectDefinition.java b/src/org/openlowcode/server/data/DataObjectDefinition.java index 17dfd6f3..631544f4 100644 --- a/src/org/openlowcode/server/data/DataObjectDefinition.java +++ b/src/org/openlowcode/server/data/DataObjectDefinition.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.function.Function; import java.util.logging.Logger; import org.openlowcode.tools.messages.MessageWriter; @@ -282,12 +283,12 @@ public QueryCondition getUniversalQueryCondition(DataObjectPropertyDefinition * @return generates a data object id array template. */ public abstract DataObjectId[] generateIdArrayTemplate(); - + /** * @return generates a data object master id array template */ public abstract DataObjectMasterId[] generateMasterIdArrayTemplate(); - + /** * @return a blank object */ @@ -335,6 +336,48 @@ public JoinQueryConditionDefinition generateJoinQueryDefin this, operator); } + /** + * generates a join query definition + * + * @param maintable the main table to join this + * object into + * @param maintablefield the field to use on main table + * @param propertyname name of the property to join in + * @param propertyfield field of the property + * @param sidetablesuffix suffix to add to this table + * @param operator typically equals for a foreign + * key + * @param additionalqueryconditiononsideobject additional condition on side + * object (e.g. only get latest + * version) + * @return a join query condition + * @since 1.9 + */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public JoinQueryConditionDefinition generateJoinQueryDefinition( + StoredTableSchema maintable, + StoredFieldSchema maintablefield, + String propertyname, + String propertyfield, + String sidetablesuffix, + QueryOperator operator, + Function additionalqueryconditiononsideobject) { + DataObjectPropertyDefinition propertydefinition = propertydeflist.lookupOnName(propertyname); + if (propertydefinition == null) + throw new RuntimeException("did not find property with name = '" + propertyname + "', available list = " + + propertydeflist.dropNameList()); + FieldSchema field = propertydefinition.getFieldSchemaByName(propertyfield); + if (field == null) + throw new RuntimeException("did not find field with name '" + propertyfield + ", , available list = " + + propertydefinition.dropfieldnamelist()); + if (!(field instanceof StoredFieldSchema)) + throw new RuntimeException("definition of externalfield joinquerycondition " + maintablefield.getName() + + " is referencing another external field : " + field); + StoredFieldSchema storedfield = (StoredFieldSchema) field; + return new JoinQueryConditionDefinition(maintable, maintablefield, tableschema, sidetablesuffix, storedfield, + this, operator, additionalqueryconditiononsideobject); + } + /** * checks if the property with the given name exists * diff --git a/src/org/openlowcode/server/data/properties/LinkobjecttomasterDefinition.java b/src/org/openlowcode/server/data/properties/LinkobjecttomasterDefinition.java index 9eb2c878..890fa7f4 100644 --- a/src/org/openlowcode/server/data/properties/LinkobjecttomasterDefinition.java +++ b/src/org/openlowcode/server/data/properties/LinkobjecttomasterDefinition.java @@ -1,3 +1,13 @@ +/******************************************************************************** + * Copyright (c) 2020 [Open Lowcode SAS](https://openlowcode.com/) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 . + * + * SPDX-License-Identifier: EPL-2.0 + ********************************************************************************/ + package org.openlowcode.server.data.properties; import java.util.ArrayList; @@ -22,496 +32,512 @@ import org.openlowcode.server.data.storage.StoredTableIndex; import org.openlowcode.server.data.storage.StringStoredField; -public class LinkobjecttomasterDefinition< -E extends DataObject & LinkobjecttomasterInterface, -F extends DataObject & UniqueidentifiedInterface, -G extends DataObject & VersionedInterface> -extends -DataObjectPropertyDefinition { -private DataObjectDefinition leftobjectdefinition; -private DataObjectDefinition rightobjectdefinition; -private StringStoredField leftid; -private StringStoredField rightmasterid; -private ArrayList> constraintsonlinkobject; -private UniqueidentifiedDefinition uniqueidentifieddefinition; -private UniqueidentifiedDefinition leftuniqueidentifieddefinition; -private VersionedDefinition rightversionedefinition; -private DisplayProfile displayprofilehideleftobjectfields; -private DisplayProfile displayprofilehiderightobjectfields; -private DataObjectDefinition linkobjectdefinition; -private boolean constraintmaxonelinkfromleft; -private boolean replaceifmorethanonefromleft; -private boolean replaceifnotuniqueforleftandright; -private boolean constraintuniqueforleftandright; - -private boolean showfieldsforleftobject; -private boolean showfieldsforrightobject; -private int minpriorityforleftobjectfields; -private int minpriorityforrightobjectfields; -private boolean makesidmodifiable = false; -private static Logger logger = Logger.getLogger(LinkobjectDefinition.class.getName()); - /** -* @return -*/ -protected DataObjectDefinition getRightObjectDefinition() { -return this.rightobjectdefinition; -} + * @author Open Lowcode + * SAS + * + * @param current link object + * @param left object for link (linked through ID) + * @param right object for link (linked through master id + * @since 1.9 + */ +public class LinkobjecttomasterDefinition< + E extends DataObject & LinkobjecttomasterInterface, + F extends DataObject & UniqueidentifiedInterface, + G extends DataObject & VersionedInterface> + extends + DataObjectPropertyDefinition { + private DataObjectDefinition leftobjectdefinition; + private DataObjectDefinition rightobjectdefinition; + private StringStoredField leftid; + private StringStoredField rightmasterid; + private ArrayList> constraintsonlinkobject; + private UniqueidentifiedDefinition uniqueidentifieddefinition; + private UniqueidentifiedDefinition leftuniqueidentifieddefinition; + private VersionedDefinition rightversionedefinition; + private DisplayProfile displayprofilehideleftobjectfields; + private DisplayProfile displayprofilehiderightobjectfields; + private DataObjectDefinition linkobjectdefinition; + private boolean constraintmaxonelinkfromleft; + private boolean replaceifmorethanonefromleft; + private boolean replaceifnotuniqueforleftandright; + private boolean constraintuniqueforleftandright; + + private boolean showfieldsforleftobject; + private boolean showfieldsforrightobject; + private int minpriorityforleftobjectfields; + private int minpriorityforrightobjectfields; + private boolean makesidmodifiable = false; + private static Logger logger = Logger.getLogger(LinkobjectDefinition.class.getName()); + + /** + * @return + */ + protected DataObjectDefinition getRightObjectDefinition() { + return this.rightobjectdefinition; + } -/** -* @return -*/ -protected DataObjectDefinition getLeftObjectDefinition() { -return this.leftobjectdefinition; -} + /** + * @return + */ + protected DataObjectDefinition getLeftObjectDefinition() { + return this.leftobjectdefinition; + } -public DataObjectDefinition getLinkObjectDefinition() { -return this.linkobjectdefinition; -} + public DataObjectDefinition getLinkObjectDefinition() { + return this.linkobjectdefinition; + } -/** -* gets the related uniqueidentified definition -* -* @return the related uniqueidentified property definition -*/ -public UniqueidentifiedDefinition getUniqueidentifiedDefinitionForLinkObject() { -return this.uniqueidentifieddefinition; -} + /** + * gets the related uniqueidentified definition + * + * @return the related uniqueidentified property definition + */ + public UniqueidentifiedDefinition getUniqueidentifiedDefinitionForLinkObject() { + return this.uniqueidentifieddefinition; + } -/** -* if this property is set, only one link is authorized from left object -* -* @param replaceifmorethanone true if the link will replace if more than one -*/ -public void setMaxOneLinkFromLeft(boolean replaceifmorethanone) { -this.constraintmaxonelinkfromleft = true; -this.replaceifmorethanonefromleft = replaceifmorethanone; -} + /** + * if this property is set, only one link is authorized from left object + * + * @param replaceifmorethanone true if the link will replace if more than one + */ + public void setMaxOneLinkFromLeft(boolean replaceifmorethanone) { + this.constraintmaxonelinkfromleft = true; + this.replaceifmorethanonefromleft = replaceifmorethanone; + } -/** -* if this parameter is set, only one link is allowed between two objects -* -* @param replaceifmorethanone true if a new link created will replace the older -* ones -*/ -public void setUniqueForLeftAndRight(boolean replaceifmorethanone) { -this.constraintuniqueforleftandright = true; -this.replaceifnotuniqueforleftandright = replaceifmorethanone; -} + /** + * if this parameter is set, only one link is allowed between two objects + * + * @param replaceifmorethanone true if a new link created will replace the older + * ones + */ + public void setUniqueForLeftAndRight(boolean replaceifmorethanone) { + this.constraintuniqueforleftandright = true; + this.replaceifnotuniqueforleftandright = replaceifmorethanone; + } -/** -* if the link is unique for left and right, only one link is allowed between -* two objects -* -* @return true if 'UniqueForLeftAndRight' behaviour is set -*/ -public boolean isUniqueForLeftAndRight() { -return this.constraintuniqueforleftandright; -} + /** + * if the link is unique for left and right, only one link is allowed between + * two objects + * + * @return true if 'UniqueForLeftAndRight' behaviour is set + */ + public boolean isUniqueForLeftAndRight() { + return this.constraintuniqueforleftandright; + } -/** -* if this property is set, will replace existing link if new link is created -* between two objects -* -* @return if the 'replaceIfNotUniqueForLeftAndRight' property is set -*/ -public boolean isReplaceIfNotUniqueForLeftAndRight() { -return this.replaceifnotuniqueforleftandright; -} + /** + * if this property is set, will replace existing link if new link is created + * between two objects + * + * @return if the 'replaceIfNotUniqueForLeftAndRight' property is set + */ + public boolean isReplaceIfNotUniqueForLeftAndRight() { + return this.replaceifnotuniqueforleftandright; + } -/** -* if this property is set, only one link is allowed from a given left object -* -* @return true if only one link is allowed from left object -*/ -public boolean isMaxOneLinkFromLeft() { -return this.constraintmaxonelinkfromleft; -} + /** + * if this property is set, only one link is allowed from a given left object + * + * @return true if only one link is allowed from left object + */ + public boolean isMaxOneLinkFromLeft() { + return this.constraintmaxonelinkfromleft; + } -/** -* if this property is set, will replace existing link if a link is already -* existing from the left object -* -* @return true if replacing existing link from left object -*/ -public boolean isReplaceifmorethanonefromleft() { -return this.replaceifmorethanonefromleft; -} + /** + * if this property is set, will replace existing link if a link is already + * existing from the left object + * + * @return true if replacing existing link from left object + */ + public boolean isReplaceifmorethanonefromleft() { + return this.replaceifmorethanonefromleft; + } -/** -* creates the definition of the link object property that turns this data -* object into a link between a left data object and a right data object -* -* @param parentobject parent object definition -* @param leftobjectdefinition definition of the left object for link -* @param rightobjectdefinition definition of the right object for link -* @param showleftfieldswithpriority if set, left fields above the priority are -* shown on the link -* @param showrightfieldswithpriority if set, right fields above the priority -* are shown on the link -* @param makesidmodifiable if true, the ids of links can be sent to a -* client before having been persisted. This may be -* a security risk that the data is tampered on the -* client side -*/ -public LinkobjecttomasterDefinition( - DataObjectDefinition parentobject, - DataObjectDefinition leftobjectdefinition, - DataObjectDefinition rightobjectdefinition, - int showleftfieldswithpriority, - int showrightfieldswithpriority,boolean makesidmodifiable) { -this(parentobject, leftobjectdefinition, rightobjectdefinition,makesidmodifiable); -if (showleftfieldswithpriority < 1000) { - this.showfieldsforleftobject = true; - this.minpriorityforleftobjectfields = showleftfieldswithpriority; - logger.fine("Show fields for left object " + this.minpriorityforleftobjectfields); -} -if (showrightfieldswithpriority < 1000) { - this.showfieldsforrightobject = true; - this.minpriorityforrightobjectfields = showrightfieldswithpriority; - logger.fine("Show fields for right object " + this.minpriorityforrightobjectfields); -} -} + /** + * creates the definition of the link object property that turns this data + * object into a link between a left data object and a right data object (right + * data object linked through master) + * + * @param parentobject parent object definition + * @param leftobjectdefinition definition of the left object for link + * @param rightobjectdefinition definition of the right object for link + * @param showleftfieldswithpriority if set, left fields above the priority are + * shown on the link + * @param showrightfieldswithpriority if set, right fields above the priority + * are shown on the link + * @param makesidmodifiable if true, the ids of links can be sent to a + * client before having been persisted. This + * may be a security risk that the data is + * tampered on the client side + */ + public LinkobjecttomasterDefinition( + DataObjectDefinition parentobject, + DataObjectDefinition leftobjectdefinition, + DataObjectDefinition rightobjectdefinition, + int showleftfieldswithpriority, + int showrightfieldswithpriority, + boolean makesidmodifiable) { + this(parentobject, leftobjectdefinition, rightobjectdefinition, makesidmodifiable); + if (showleftfieldswithpriority < 1000) { + this.showfieldsforleftobject = true; + this.minpriorityforleftobjectfields = showleftfieldswithpriority; + logger.fine("Show fields for left object " + this.minpriorityforleftobjectfields); + } + if (showrightfieldswithpriority < 1000) { + this.showfieldsforrightobject = true; + this.minpriorityforrightobjectfields = showrightfieldswithpriority; + logger.fine("Show fields for right object " + this.minpriorityforrightobjectfields); + } + } -/** -* creates the definition of the link object property that turns this data -* object into a link between a left data object and a right data object -* -* @param parentobject parent object definition -* @param leftobjectdefinition definition of the left object for link -* @param rightobjectdefinition definition of the right object for link -* @param makesidmodifiable if true, the ids of links can be sent to a -* client before having been persisted. This may be -* a security risk that the data is tampered on the -* client side -*/ -public LinkobjecttomasterDefinition( - DataObjectDefinition parentobject, - DataObjectDefinition leftobjectdefinition, - DataObjectDefinition rightobjectdefinition, - boolean makesidmodifiable) { -super(parentobject, "LINKOBJECT"); -this.leftobjectdefinition = leftobjectdefinition; -this.rightobjectdefinition = rightobjectdefinition; -this.linkobjectdefinition = parentobject; - -leftid = new StringStoredField("LFID", null, 200); -rightmasterid = new StringStoredField("RGMSID", null, 200); -this.addFieldSchema(leftid); -this.addFieldSchema(rightmasterid); - -StoredTableIndex lfidindex = new StoredTableIndex("LFID"); -lfidindex.addStoredFieldSchame(leftid); -this.addIndex(lfidindex); - -StoredTableIndex rgidindex = new StoredTableIndex("RGMSID"); -rgidindex.addStoredFieldSchame(rightmasterid); -this.addIndex(rgidindex); - -this.constraintsonlinkobject = new ArrayList>(); -this.displayprofilehideleftobjectfields = parentobject.getDisplayProfileByName("HIDELEFTOBJECTFIELDS"); -this.displayprofilehiderightobjectfields = parentobject.getDisplayProfileByName("HIDERIGHTOBJECTFIELDS"); -this.constraintmaxonelinkfromleft = false; -this.replaceifmorethanonefromleft = false; -this.showfieldsforleftobject = false; -this.showfieldsforrightobject = false; -this.makesidmodifiable=makesidmodifiable; -} + /** + * creates the definition of the link object to master property that turns this + * data object into a link between a left data object and a right data object + * + * @param parentobject parent object definition + * @param leftobjectdefinition definition of the left object for link + * @param rightobjectdefinition definition of the right object for link + * @param makesidmodifiable if true, the ids of links can be sent to a + * client before having been persisted. This may be + * a security risk that the data is tampered on the + * client side + */ + public LinkobjecttomasterDefinition( + DataObjectDefinition parentobject, + DataObjectDefinition leftobjectdefinition, + DataObjectDefinition rightobjectdefinition, + boolean makesidmodifiable) { + super(parentobject, "LINKOBJECTTOMASTER"); + this.leftobjectdefinition = leftobjectdefinition; + this.rightobjectdefinition = rightobjectdefinition; + this.linkobjectdefinition = parentobject; + + leftid = new StringStoredField("LFID", null, 200); + rightmasterid = new StringStoredField("RGMSID", null, 200); + this.addFieldSchema(leftid); + this.addFieldSchema(rightmasterid); + + StoredTableIndex lfidindex = new StoredTableIndex("LFID"); + lfidindex.addStoredFieldSchame(leftid); + this.addIndex(lfidindex); + + StoredTableIndex rgidindex = new StoredTableIndex("RGMSID"); + rgidindex.addStoredFieldSchame(rightmasterid); + this.addIndex(rgidindex); + + this.constraintsonlinkobject = new ArrayList>(); + this.displayprofilehideleftobjectfields = parentobject.getDisplayProfileByName("HIDELEFTOBJECTFIELDS"); + this.displayprofilehiderightobjectfields = parentobject.getDisplayProfileByName("HIDERIGHTOBJECTFIELDS"); + this.constraintmaxonelinkfromleft = false; + this.replaceifmorethanonefromleft = false; + this.showfieldsforleftobject = false; + this.showfieldsforrightobject = false; + this.makesidmodifiable = makesidmodifiable; + } -/** -* sets a constraint on link object (restricts the objects that can be linked -* together -* -* @param constraintonlinkobject the constraint -*/ -public void setConstraintOnLinkToMaster(ConstraintOnLinkToMaster constraintonlinkobject) { -this.constraintsonlinkobject.add(constraintonlinkobject); -} + /** + * sets a constraint on link object (restricts the objects that can be linked + * together + * + * @param constraintonlinkobject the constraint + */ + public void setConstraintOnLinkToMaster(ConstraintOnLinkToMaster constraintonlinkobject) { + this.constraintsonlinkobject.add(constraintonlinkobject); + } -/** -* gets the constraint at the given index -* -* @param index an index between 0 (included) and -* getConstraintOnLinkObjectNumber (excluded) -* @return the constraint at the given index -*/ -public ConstraintOnLinkToMaster getConstraintOnLinkToMaster(int index) { -return this.constraintsonlinkobject.get(index); -} + /** + * gets the constraint at the given index + * + * @param index an index between 0 (included) and + * getConstraintOnLinkObjectNumber (excluded) + * @return the constraint at the given index + */ + public ConstraintOnLinkToMaster getConstraintOnLinkToMaster(int index) { + return this.constraintsonlinkobject.get(index); + } -/** -* gets the number of constraints for the link object -* -* @return the number of constraints for the link object -*/ -public int getConstraintOnLinkToMasterNumber() { -return this.constraintsonlinkobject.size(); -} + /** + * gets the number of constraints for the link object + * + * @return the number of constraints for the link object + */ + public int getConstraintOnLinkToMasterNumber() { + return this.constraintsonlinkobject.size(); + } -/** -* sets the related unique identified property for the left object -* -* @param leftuniqueidentifieddefinition unique identified property for the left -* object -*/ -public void setGenericsLeftobjectforlinkProperty(UniqueidentifiedDefinition leftuniqueidentifieddefinition) { -this.leftuniqueidentifieddefinition = leftuniqueidentifieddefinition; + /** + * sets the related unique identified property for the left object + * + * @param leftuniqueidentifieddefinition unique identified property for the left + * object + */ + public void setGenericsLeftobjectforlinkProperty(UniqueidentifiedDefinition leftuniqueidentifieddefinition) { + this.leftuniqueidentifieddefinition = leftuniqueidentifieddefinition; -} + } -/** -* sets the related unique identified property for the right object -* -* @param rightuniqueidentifieddefinition unique identified property for the -* right object -*/ -public void setGenericsRightobjectforlinkProperty(VersionedDefinition rightversionedefinition) { -this.rightversionedefinition = rightversionedefinition; + /** + * sets the related unique identified property for the right object + * + * @param rightuniqueidentifieddefinition unique identified property for the + * right object + */ + public void setGenericsRightobjectforlinkProperty(VersionedDefinition rightversionedefinition) { + this.rightversionedefinition = rightversionedefinition; -} + } -/** -* @return the unique identified property for the left object -*/ -public UniqueidentifiedDefinition getLeftuniqueidentifieddefinition() { -return leftuniqueidentifieddefinition; -} + /** + * @return the unique identified property for the left object + */ + public UniqueidentifiedDefinition getLeftuniqueidentifieddefinition() { + return leftuniqueidentifieddefinition; + } -/** -* @return the unique identified property for the right object -*/ -public VersionedDefinition getRightversioneddefinition() { -return this.rightversionedefinition; -} + /** + * @return the unique identified property for the right object + */ + public VersionedDefinition getRightversioneddefinition() { + return this.rightversionedefinition; + } -/** -* sets the dependent property unique identified for the link object -* -* @param uniqueidentifieddefinition unique identified property for the left -* object -*/ -public void setDependentDefinitionUniqueidentified(UniqueidentifiedDefinition uniqueidentifieddefinition) { -this.uniqueidentifieddefinition = uniqueidentifieddefinition; + /** + * sets the dependent property unique identified for the link object + * + * @param uniqueidentifieddefinition unique identified property for the left + * object + */ + public void setDependentDefinitionUniqueidentified(UniqueidentifiedDefinition uniqueidentifieddefinition) { + this.uniqueidentifieddefinition = uniqueidentifieddefinition; -} + } -/** -* gets all the constraints at once -* -* @return all the constraints in an array -*/ -@SuppressWarnings("unchecked") -public ConstraintOnLinkToMaster[] getAllConstraints() { -return this.constraintsonlinkobject.toArray(new ConstraintOnLinkToMaster[0]); -} + /** + * gets all the constraints at once + * + * @return all the constraints in an array + */ + @SuppressWarnings("unchecked") + public ConstraintOnLinkToMaster[] getAllConstraints() { + return this.constraintsonlinkobject.toArray(new ConstraintOnLinkToMaster[0]); + } -@Override -public ArrayList> generateExternalSchema() { -ArrayList> externalfieldlist = new ArrayList>(); + @Override + public ArrayList> generateExternalSchema() { + ArrayList> externalfieldlist = new ArrayList>(); // - Left join query condition // adds an external field is the target object is named -JoinQueryConditionDefinition leftjoincondition = leftobjectdefinition.generateJoinQueryDefinition( - this.parentobject.getTableschema(), leftid, "UNIQUEIDENTIFIED", "ID", this.getName() + "_LEFT", - new QueryOperatorEqual()); + JoinQueryConditionDefinition leftjoincondition = leftobjectdefinition.generateJoinQueryDefinition( + this.parentobject.getTableschema(), leftid, "UNIQUEIDENTIFIED", "ID", this.getName() + "_LEFT", + new QueryOperatorEqual()); // get named property for left object -if (leftobjectdefinition.hasProperty("NAMED")) { - NamedDefinition nameddefinition = (NamedDefinition) leftobjectdefinition.getProperty("NAMED"); - ExternalFieldSchema leftexternalfield = leftobjectdefinition.generateExternalField( - this.getName() + "LEFTNAME", leftobjectdefinition.getLabel() + " " + nameddefinition.getNameLabel(), - "", "NAMED", "OBJECTNAME", leftjoincondition, this.displayprofilehideleftobjectfields, 800, 80); - leftexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehiderightobjectfields, - nameddefinition.getNameLabel()); - externalfieldlist.add(leftexternalfield); -} + if (leftobjectdefinition.hasProperty("NAMED")) { + NamedDefinition nameddefinition = (NamedDefinition) leftobjectdefinition.getProperty("NAMED"); + ExternalFieldSchema leftexternalfield = leftobjectdefinition.generateExternalField( + this.getName() + "LEFTNAME", leftobjectdefinition.getLabel() + " " + nameddefinition.getNameLabel(), + "", "NAMED", "OBJECTNAME", leftjoincondition, this.displayprofilehideleftobjectfields, 800, 80); + leftexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehiderightobjectfields, + nameddefinition.getNameLabel()); + externalfieldlist.add(leftexternalfield); + } // get named property for left object -if (leftobjectdefinition.hasProperty("NUMBERED")) { - NumberedDefinition< - F> numbereddefinition = (NumberedDefinition) leftobjectdefinition.getProperty("NUMBERED"); - boolean orderedasnumber = false; - int numberoffset = 0; - if (numbereddefinition.getAutonumberingRule() != null) - if (numbereddefinition.getAutonumberingRule().orderedAsNumber()) { - orderedasnumber = true; - numberoffset = numbereddefinition.getAutonumberingRule().getNumberOffset(); + if (leftobjectdefinition.hasProperty("NUMBERED")) { + NumberedDefinition< + F> numbereddefinition = (NumberedDefinition) leftobjectdefinition.getProperty("NUMBERED"); + boolean orderedasnumber = false; + int numberoffset = 0; + if (numbereddefinition.getAutonumberingRule() != null) + if (numbereddefinition.getAutonumberingRule().orderedAsNumber()) { + orderedasnumber = true; + numberoffset = numbereddefinition.getAutonumberingRule().getNumberOffset(); + } + ExternalFieldSchema leftexternalfield; + if (orderedasnumber) { + leftexternalfield = leftobjectdefinition.generateExternalField(this.getName() + "LEFTNR", + leftobjectdefinition.getLabel() + " " + numbereddefinition.getNumberLabel(), + "this is a stupid comment", "NUMBERED", "NR", leftjoincondition, + this.displayprofilehideleftobjectfields, 900, 25, orderedasnumber, numberoffset); + } else { + leftexternalfield = leftobjectdefinition.generateExternalField(this.getName() + "LEFTNR", + leftobjectdefinition.getLabel() + " " + numbereddefinition.getNumberLabel(), + "this is a stupid comment", "NUMBERED", "NR", leftjoincondition, + this.displayprofilehideleftobjectfields, 900, 60); + } + leftexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehiderightobjectfields, + numbereddefinition.getNumberLabel()); + externalfieldlist.add(leftexternalfield); } - ExternalFieldSchema leftexternalfield; - if (orderedasnumber) { - leftexternalfield = leftobjectdefinition.generateExternalField(this.getName() + "LEFTNR", - leftobjectdefinition.getLabel() + " " + numbereddefinition.getNumberLabel(), - "this is a stupid comment", "NUMBERED", "NR", leftjoincondition, - this.displayprofilehideleftobjectfields, 900, 25, orderedasnumber, numberoffset); - } else { - leftexternalfield = leftobjectdefinition.generateExternalField(this.getName() + "LEFTNR", - leftobjectdefinition.getLabel() + " " + numbereddefinition.getNumberLabel(), - "this is a stupid comment", "NUMBERED", "NR", leftjoincondition, - this.displayprofilehideleftobjectfields, 900, 60); - } - leftexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehiderightobjectfields, - numbereddefinition.getNumberLabel()); - externalfieldlist.add(leftexternalfield); -} // get state property for left object -if (leftobjectdefinition.hasProperty("LIFECYCLE")) { - LifecycleDefinition< - ?, ?> lifecycle = (LifecycleDefinition) (leftobjectdefinition.getProperty("LIFECYCLE")); - ExternalFieldSchema leftexternalfield = leftobjectdefinition.generateExternalField( - this.getName() + "LEFTSTATE", "Left state", "this is a stupid comment", "LIFECYCLE", "STATE", - lifecycle.getLifecycleHelper(), leftjoincondition, this.displayprofilehideleftobjectfields, 500, - 35); - leftexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehiderightobjectfields, "State"); - externalfieldlist.add(leftexternalfield); -} - -if (this.showfieldsforleftobject) { - logger.finer("--------------- Show fields for left object ---------------------- fields presents = " - + leftobjectdefinition.getFieldNumber() + " "); - for (int i = 0; i < leftobjectdefinition.getFieldNumber(); i++) { - DataObjectFieldDefinition thisfield = leftobjectdefinition.getFieldAt(i); - if (thisfield.getPriority() > this.minpriorityforleftobjectfields) { - logger.finer(" ++ Field in for left " + thisfield.getName()); - ExternalFieldSchema leftexternalfield = leftobjectdefinition.generateExternalFieldFromField( - thisfield.getName() + "LEFTFIELD", thisfield.getDisplayname(), thisfield.getTooltip(), - thisfield.getName(), leftjoincondition, this.displayprofilehideleftobjectfields, - thisfield.getPriority(), thisfield.getDefaultcolumnintable()); - leftexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehiderightobjectfields, - thisfield.getDisplayname()); + if (leftobjectdefinition.hasProperty("LIFECYCLE")) { + LifecycleDefinition< + ?, ?> lifecycle = (LifecycleDefinition) (leftobjectdefinition.getProperty("LIFECYCLE")); + ExternalFieldSchema leftexternalfield = leftobjectdefinition.generateExternalField( + this.getName() + "LEFTSTATE", "Left state", "this is a stupid comment", "LIFECYCLE", "STATE", + lifecycle.getLifecycleHelper(), leftjoincondition, this.displayprofilehideleftobjectfields, 500, + 35); + leftexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehiderightobjectfields, "State"); externalfieldlist.add(leftexternalfield); - } else { - logger.finer(" -- Field out for left " + thisfield.getName()); } - } -} -JoinQueryConditionDefinition rightjoincondition = rightobjectdefinition.generateJoinQueryDefinition( - this.parentobject.getTableschema(), rightmasterid, "UNIQUEIDENTIFIED", "ID", this.getName() + "_RIGHT", - new QueryOperatorEqual()); + if (this.showfieldsforleftobject) { + logger.finer("--------------- Show fields for left object ---------------------- fields presents = " + + leftobjectdefinition.getFieldNumber() + " "); + for (int i = 0; i < leftobjectdefinition.getFieldNumber(); i++) { + DataObjectFieldDefinition thisfield = leftobjectdefinition.getFieldAt(i); + if (thisfield.getPriority() > this.minpriorityforleftobjectfields) { + logger.finer(" ++ Field in for left " + thisfield.getName()); + ExternalFieldSchema leftexternalfield = leftobjectdefinition.generateExternalFieldFromField( + thisfield.getName() + "LEFTFIELD", thisfield.getDisplayname(), thisfield.getTooltip(), + thisfield.getName(), leftjoincondition, this.displayprofilehideleftobjectfields, + thisfield.getPriority(), thisfield.getDefaultcolumnintable()); + leftexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehiderightobjectfields, + thisfield.getDisplayname()); + externalfieldlist.add(leftexternalfield); + } else { + logger.finer(" -- Field out for left " + thisfield.getName()); + } + } + } + + JoinQueryConditionDefinition rightjoincondition = rightobjectdefinition.generateJoinQueryDefinition( + this.parentobject.getTableschema(), rightmasterid, "VERSIONED", "MASTERID", this.getName() + "_RIGHT", + new QueryOperatorEqual(), (a) -> (VersionedQueryHelper + .getLatestVersionQueryCondition(rightobjectdefinition.getAlias(a), rightobjectdefinition))); // get named property for right object -if (rightobjectdefinition.hasProperty("NAMED")) { - // adds an external field is the target object is named -- currently, there is - // an error - NamedDefinition namedproperty = (NamedDefinition) rightobjectdefinition.getProperty("NAMED"); - ExternalFieldSchema rightexternalfield = rightobjectdefinition.generateExternalField( - this.getName() + "RIGHTNAME", rightobjectdefinition.getLabel() + " " + namedproperty.getNameLabel(), - "this is a stupid comment", "NAMED", "OBJECTNAME", rightjoincondition, - this.displayprofilehiderightobjectfields, 800, 80); - rightexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehideleftobjectfields, - namedproperty.getNameLabel()); - externalfieldlist.add(rightexternalfield); -} - -if (rightobjectdefinition.hasProperty("NUMBERED")) { - // adds an external field is the target object is named -- currently, there is - // an error - @SuppressWarnings("unchecked") - NumberedDefinition< - F> numbereddefinition = (NumberedDefinition) rightobjectdefinition.getProperty("NUMBERED"); - boolean orderedasnumber = false; - int numberoffset = 0; - if (numbereddefinition.getAutonumberingRule() != null) - if (numbereddefinition.getAutonumberingRule().orderedAsNumber()) { - orderedasnumber = true; - numberoffset = numbereddefinition.getAutonumberingRule().getNumberOffset(); + if (rightobjectdefinition.hasProperty("NAMED")) { + // adds an external field is the target object is named -- currently, there is + // an error + NamedDefinition namedproperty = (NamedDefinition) rightobjectdefinition.getProperty("NAMED"); + ExternalFieldSchema rightexternalfield = rightobjectdefinition.generateExternalField( + this.getName() + "RIGHTNAME", rightobjectdefinition.getLabel() + " " + namedproperty.getNameLabel(), + "this is a stupid comment", "NAMED", "OBJECTNAME", rightjoincondition, + this.displayprofilehiderightobjectfields, 800, 80); + rightexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehideleftobjectfields, + namedproperty.getNameLabel()); + externalfieldlist.add(rightexternalfield); } - ExternalFieldSchema rightexternalfield; - if (orderedasnumber) { - rightexternalfield = rightobjectdefinition.generateExternalField(this.getName() + "RIGHTNR", - rightobjectdefinition.getLabel() + " " + numbereddefinition.getNumberLabel(), - "this is a stupid comment", "NUMBERED", "NR", rightjoincondition, - this.displayprofilehiderightobjectfields, 900, 25, orderedasnumber, numberoffset); - - } else { - rightexternalfield = rightobjectdefinition.generateExternalField(this.getName() + "RIGHTNR", - rightobjectdefinition.getLabel() + " " + numbereddefinition.getNumberLabel(), - "this is a stupid comment", "NUMBERED", "NR", rightjoincondition, - this.displayprofilehiderightobjectfields, 900, 60); - } - rightexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehideleftobjectfields, - numbereddefinition.getNumberLabel()); - externalfieldlist.add(rightexternalfield); -} -if (rightobjectdefinition.hasProperty("LIFECYCLE")) { - LifecycleDefinition< - ?, ?> lifecycle = (LifecycleDefinition) (rightobjectdefinition.getProperty("LIFECYCLE")); - ExternalFieldSchema rightexternalfield = rightobjectdefinition.generateExternalField( - this.getName() + "RIGHTSTATE", "Right object state", "this is a stupid comment", "LIFECYCLE", - "STATE", lifecycle.getLifecycleHelper(), rightjoincondition, - this.displayprofilehiderightobjectfields, 500, 35); - rightexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehideleftobjectfields, "State"); - externalfieldlist.add(rightexternalfield); -} -if (this.showfieldsforrightobject) { - logger.finer("--------------- Show fields for right object ---------------------- fields presents = " - + leftobjectdefinition.getFieldNumber() + " "); - for (int i = 0; i < rightobjectdefinition.getFieldNumber(); i++) { - DataObjectFieldDefinition thisfield = rightobjectdefinition.getFieldAt(i); - if (thisfield.getPriority() > this.minpriorityforrightobjectfields) { - ExternalFieldSchema rightexternalfield = rightobjectdefinition.generateExternalFieldFromField( - thisfield.getName() + "RIGHTFIELD", thisfield.getDisplayname(), thisfield.getTooltip(), - thisfield.getName(), rightjoincondition, this.displayprofilehiderightobjectfields, - thisfield.getPriority(), thisfield.getDefaultcolumnintable()); + if (rightobjectdefinition.hasProperty("NUMBERED")) { + // adds an external field is the target object is named -- currently, there is + // an error + @SuppressWarnings("unchecked") + NumberedDefinition< + F> numbereddefinition = (NumberedDefinition) rightobjectdefinition.getProperty("NUMBERED"); + boolean orderedasnumber = false; + int numberoffset = 0; + if (numbereddefinition.getAutonumberingRule() != null) + if (numbereddefinition.getAutonumberingRule().orderedAsNumber()) { + orderedasnumber = true; + numberoffset = numbereddefinition.getAutonumberingRule().getNumberOffset(); + } + ExternalFieldSchema rightexternalfield; + if (orderedasnumber) { + rightexternalfield = rightobjectdefinition.generateExternalField(this.getName() + "RIGHTNR", + rightobjectdefinition.getLabel() + " " + numbereddefinition.getNumberLabel(), + "this is a stupid comment", "NUMBERED", "NR", rightjoincondition, + this.displayprofilehiderightobjectfields, 900, 25, orderedasnumber, numberoffset); + + } else { + rightexternalfield = rightobjectdefinition.generateExternalField(this.getName() + "RIGHTNR", + rightobjectdefinition.getLabel() + " " + numbereddefinition.getNumberLabel(), + "this is a stupid comment", "NUMBERED", "NR", rightjoincondition, + this.displayprofilehiderightobjectfields, 900, 60); + + } rightexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehideleftobjectfields, - thisfield.getDisplayname()); + numbereddefinition.getNumberLabel()); externalfieldlist.add(rightexternalfield); - logger.fine(" ++ Field in for right " + thisfield.getName()); - } else { - logger.fine(" -- Field out for left " + thisfield.getName()); } - } -} -return externalfieldlist; + if (rightobjectdefinition.hasProperty("LIFECYCLE")) { + LifecycleDefinition< + ?, ?> lifecycle = (LifecycleDefinition) (rightobjectdefinition.getProperty("LIFECYCLE")); + ExternalFieldSchema rightexternalfield = rightobjectdefinition.generateExternalField( + this.getName() + "RIGHTSTATE", "Right object state", "this is a stupid comment", "LIFECYCLE", + "STATE", lifecycle.getLifecycleHelper(), rightjoincondition, + this.displayprofilehiderightobjectfields, 500, 35); + rightexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehideleftobjectfields, "State"); + externalfieldlist.add(rightexternalfield); + } + if (this.showfieldsforrightobject) { + logger.finer("--------------- Show fields for right object ---------------------- fields presents = " + + leftobjectdefinition.getFieldNumber() + " "); + for (int i = 0; i < rightobjectdefinition.getFieldNumber(); i++) { + DataObjectFieldDefinition thisfield = rightobjectdefinition.getFieldAt(i); + if (thisfield.getPriority() > this.minpriorityforrightobjectfields) { + ExternalFieldSchema rightexternalfield = rightobjectdefinition.generateExternalFieldFromField( + thisfield.getName() + "RIGHTFIELD", thisfield.getDisplayname(), thisfield.getTooltip(), + thisfield.getName(), rightjoincondition, this.displayprofilehiderightobjectfields, + thisfield.getPriority(), thisfield.getDefaultcolumnintable()); + rightexternalfield.addSpecialdisplaynamewhenprofileactive(this.displayprofilehideleftobjectfields, + thisfield.getDisplayname()); + externalfieldlist.add(rightexternalfield); + logger.fine(" ++ Field in for right " + thisfield.getName()); + } else { + logger.fine(" -- Field out for left " + thisfield.getName()); + } + } + } + ExternalFieldSchema rightid = rightobjectdefinition.generateExternalField(this.getName() + "RIGHTID", + "Right object Id", "", "UNIQUEIDENTIFIED", "ID", rightjoincondition, + this.displayprofilehiderightobjectfields, -990, 16); + externalfieldlist.add(rightid); + return externalfieldlist; -} + } -@Override -public FieldSchemaForDisplay[] setFieldSchemaToDisplay() { -@SuppressWarnings("unchecked") -FieldSchemaForDisplay[] returnvalue = new FieldSchemaForDisplay[2]; -returnvalue[0] = new FieldSchemaForDisplay("Left id", - "the technical id generated by the system for the left object of the part", leftid, false, true, - !makesidmodifiable, -200, 16, this.parentobject); -returnvalue[1] = new FieldSchemaForDisplay("Right id", - "the technical id generated by the system for the right object of the part", rightmasterid, false, true, - !makesidmodifiable, -200, 16, this.parentobject); - -return returnvalue; -} + @Override + public FieldSchemaForDisplay[] setFieldSchemaToDisplay() { + @SuppressWarnings("unchecked") + FieldSchemaForDisplay[] returnvalue = new FieldSchemaForDisplay[2]; + returnvalue[0] = new FieldSchemaForDisplay("Left id", + "the technical id generated by the system for the left object of the part", leftid, false, true, + !makesidmodifiable, -200, 16, this.parentobject); + returnvalue[1] = new FieldSchemaForDisplay("Right id", + "the technical id generated by the system for the right object of the part", rightmasterid, false, true, + !makesidmodifiable, -200, 16, this.parentobject); + + return returnvalue; + } -@SuppressWarnings({ "unchecked", "rawtypes" }) -@Override -public DataObjectElement initiateFieldInstance(DataObjectPayload parentpayload) { -return new Linkobjecttomaster(this, parentpayload, leftobjectdefinition, rightobjectdefinition); -} + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public DataObjectElement initiateFieldInstance(DataObjectPayload parentpayload) { + return new Linkobjecttomaster(this, parentpayload, leftobjectdefinition, rightobjectdefinition); + } -@Override -public QueryCondition getUniversalQueryCondition(String alias) { + @Override + public QueryCondition getUniversalQueryCondition(String alias) { -return null; -} + return null; + } -@Override -public FlatFileLoaderColumn getFlatFileLoaderColumn( - DataObjectDefinition objectdefinition, - String[] columnattributes, - PropertyExtractor propertyextractor, - ChoiceValue locale) { -throw new RuntimeException("Not yet implemented"); -} + @Override + public FlatFileLoaderColumn getFlatFileLoaderColumn( + DataObjectDefinition objectdefinition, + String[] columnattributes, + PropertyExtractor propertyextractor, + ChoiceValue locale) { + throw new RuntimeException("Not yet implemented"); + } -@Override -public String[] getLoaderFieldList() { -return new String[0]; -} + @Override + public String[] getLoaderFieldList() { + return new String[0]; + } -@Override -public String[] getLoaderFieldSample(String name) { -return null; -} + @Override + public String[] getLoaderFieldSample(String name) { + return null; + } } diff --git a/src/org/openlowcode/server/data/properties/LinkobjecttomasterQueryHelper.java b/src/org/openlowcode/server/data/properties/LinkobjecttomasterQueryHelper.java index 986db46f..c2ee1d31 100644 --- a/src/org/openlowcode/server/data/properties/LinkobjecttomasterQueryHelper.java +++ b/src/org/openlowcode/server/data/properties/LinkobjecttomasterQueryHelper.java @@ -36,7 +36,7 @@ * * @author Open Lowcode * SAS - * + * @since 1.9 */ public class LinkobjecttomasterQueryHelper { @@ -795,7 +795,7 @@ G extends DataObject & VersionedInterface> TwoDataObjects[] getlinks joinquerycondition.addCondition(uniqueidcondition); joinquerycondition.addCondition( new JoinQueryCondition(linkalias, this.getRightMasterIdFieldSchema(propertyDefinition), - rightobjectalias, rightobjectdefinition.getTableschema().lookupFieldByName("MSID"), + rightobjectalias, rightobjectdefinition.getTableschema().lookupFieldByName("MASTERID"), new QueryOperatorEqual())); joinquerycondition.addCondition(VersionedQueryHelper.getLatestVersionQueryCondition(rightobjectalias, rightobjectdefinition)); if (additionalcondition != null) diff --git a/src/org/openlowcode/server/data/specificstorage/JoinQueryConditionDefinition.java b/src/org/openlowcode/server/data/specificstorage/JoinQueryConditionDefinition.java index f48921e5..179d0373 100644 --- a/src/org/openlowcode/server/data/specificstorage/JoinQueryConditionDefinition.java +++ b/src/org/openlowcode/server/data/specificstorage/JoinQueryConditionDefinition.java @@ -14,7 +14,11 @@ import org.openlowcode.server.data.storage.StoredFieldSchema; import org.openlowcode.server.data.storage.QueryOperator; import org.openlowcode.server.data.storage.QueryCondition; + +import java.util.function.Function; + import org.openlowcode.server.data.DataObjectDefinition; +import org.openlowcode.server.data.storage.AndQueryCondition; import org.openlowcode.server.data.storage.JoinQueryCondition; import org.openlowcode.server.data.storage.TableAlias; @@ -35,6 +39,7 @@ public class JoinQueryConditionDefinition { private String sidetablesuffix; private QueryOperator joinqueryoperator; private DataObjectDefinition sidetableobjectdefinition; + private Function additionalqueryconditiononsideobject; /** * creates a join query condition definition @@ -45,9 +50,14 @@ public class JoinQueryConditionDefinition { * @param sidetablefield side table field for the join query * @param joinqueryoperator Operator (typically equal) */ - public JoinQueryConditionDefinition(StoredTableSchema maintable, StoredFieldSchema maintablefield, - StoredTableSchema sidetable, String sidetablesuffix, StoredFieldSchema sidetablefield, - DataObjectDefinition sidetableobjectdefinition, QueryOperator joinqueryoperator) { + public JoinQueryConditionDefinition( + StoredTableSchema maintable, + StoredFieldSchema maintablefield, + StoredTableSchema sidetable, + String sidetablesuffix, + StoredFieldSchema sidetablefield, + DataObjectDefinition sidetableobjectdefinition, + QueryOperator joinqueryoperator) { super(); this.maintable = maintable; this.maintablefield = maintablefield; @@ -59,6 +69,43 @@ public JoinQueryConditionDefinition(StoredTableSchema maintable, StoredFieldSche } + /** + * creates a join query condition definition with extra condition on side table + * + * @param maintable main table + * @param maintablefield main table field for the join + * query + * @param sidetable side table + * @param sidetablesuffix suffix for side table alias + * @param sidetablefield side table field for the join + * query + * @param sidetableobjectdefinition definition of the side object + * @param joinqueryoperator Operator (typically equal) + * @param additionalqueryconditiononsideobject an additional query condition + * (typically get only latest + * version...) + * @since 1.9 + */ + public JoinQueryConditionDefinition( + StoredTableSchema maintable, + StoredFieldSchema maintablefield, + StoredTableSchema sidetable, + String sidetablesuffix, + StoredFieldSchema sidetablefield, + DataObjectDefinition sidetableobjectdefinition, + QueryOperator joinqueryoperator, + Function additionalqueryconditiononsideobject) { + super(); + this.maintable = maintable; + this.maintablefield = maintablefield; + this.sidetable = sidetable; + this.sidetablefield = sidetablefield; + this.sidetablesuffix = sidetablesuffix; + this.sidetableobjectdefinition = sidetableobjectdefinition; + this.joinqueryoperator = joinqueryoperator; + this.additionalqueryconditiononsideobject = additionalqueryconditiononsideobject; + } + /** * generates the query condition for the specified main table alias * @@ -79,7 +126,11 @@ public JoinQueryCondition generateJoinQueryCondition(String maintablealias) { * @return the universal query condition for the side object */ public QueryCondition generateSideTableUniversalQueryCondition(String maintablealias) { - return sidetableobjectdefinition.getUniversalQueryCondition(null, maintablealias + sidetablesuffix); + if (this.additionalqueryconditiononsideobject == null) + return sidetableobjectdefinition.getUniversalQueryCondition(null, maintablealias + sidetablesuffix); + return new AndQueryCondition( + sidetableobjectdefinition.getUniversalQueryCondition(null, maintablealias + sidetablesuffix), + additionalqueryconditiononsideobject.apply(maintablealias + sidetablesuffix)); } } diff --git a/src/org/openlowcode/tools/structure/ArrayDataElt.java b/src/org/openlowcode/tools/structure/ArrayDataElt.java index 6bbe977c..0f31f3e4 100644 --- a/src/org/openlowcode/tools/structure/ArrayDataElt.java +++ b/src/org/openlowcode/tools/structure/ArrayDataElt.java @@ -94,7 +94,7 @@ public void addElement(E arrayelt) { if (!arrayelt.getType().equals(arrayelementtype)) throw new RuntimeException(String.format( "try to add objects with incompatible types in an array with name %s, array type: %s, object type: %s ", - this.getName(), this.getType(), arrayelt.getType())); + this.getName(), arrayelementtype, arrayelt.getType())); arraycontent.add(arrayelt); } diff --git a/src/org/openlowcode/tools/structure/ObjectMasterIdDataElt.java b/src/org/openlowcode/tools/structure/ObjectMasterIdDataElt.java index fd7d3a6c..789efa75 100644 --- a/src/org/openlowcode/tools/structure/ObjectMasterIdDataElt.java +++ b/src/org/openlowcode/tools/structure/ObjectMasterIdDataElt.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2019 [Open Lowcode SAS](https://openlowcode.com/) + * Copyright (c) 2019-2020 [Open Lowcode SAS](https://openlowcode.com/) * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -50,7 +50,7 @@ public String getObjectId() { * @param name name of the data element */ public ObjectMasterIdDataElt(String name) { - super(name, new ObjectIdDataEltType()); + super(name, new ObjectMasterIdDataEltType()); } /** @@ -59,7 +59,7 @@ public ObjectMasterIdDataElt(String name) { * @param objectid id of the type of object */ public ObjectMasterIdDataElt(String name, String id, String objectid) { - super(name, new ObjectIdDataEltType()); + super(name, new ObjectMasterIdDataEltType()); this.id = id; this.objectid = objectid; } @@ -69,7 +69,7 @@ public ObjectMasterIdDataElt(String name, String id, String objectid) { * @param id id of the instance of the object */ public ObjectMasterIdDataElt(String name, String id) { - super(name, new ObjectIdDataEltType()); + super(name, new ObjectMasterIdDataEltType()); this.id = id; } @@ -78,12 +78,12 @@ public ObjectMasterIdDataElt(String name, String id) { * @param objectid id of the type of object */ public ObjectMasterIdDataElt(String name, ObjectIdInterface objectid) { - super(name, new ObjectIdDataEltType()); + super(name, new ObjectMasterIdDataEltType()); this.id = objectid.getId(); this.objectid = objectid.getObjectId(); } - private ObjectMasterIdDataElt(String name, ObjectIdDataEltType type, String id) { + private ObjectMasterIdDataElt(String name, ObjectMasterIdDataEltType type, String id) { super(name, type); this.id = id; } @@ -109,7 +109,7 @@ public String defaultTextRepresentation() { @Override public ObjectMasterIdDataElt cloneElt() { - return new ObjectMasterIdDataElt(this.getName(), (ObjectIdDataEltType) this.getType(), this.id); + return new ObjectMasterIdDataElt(this.getName(), (ObjectMasterIdDataEltType) this.getType(), this.id); } @Override