Skip to content
Snippets Groups Projects
Commit 7d62fb8f authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

Object relation fixes & documentation

parent e955b198
No related branches found
No related tags found
No related merge requests found
Showing
with 103 additions and 37 deletions
......@@ -2,6 +2,7 @@
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.2.0">
<name>Context_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<documentation>%aditoprj%/entity/Context_entity/documentation.adoc</documentation>
<titleProcess>%aditoprj%/entity/Context_entity/titleProcess.js</titleProcess>
<recordContainer>jdito</recordContainer>
<entityFields>
......@@ -29,6 +30,7 @@
<name>ContextId_param</name>
<expose v="true" />
<mandatory v="false" />
<documentation>%aditoprj%/entity/Context_entity/entityfields/contextid_param/documentation.adoc</documentation>
<description>PARAMETER</description>
</entityParameter>
<entityProvider>
......
== Context_entity ==
This Entity provides access to contexts.
It provides:
- the context ID (currently (12.02.2019) it is the context name)
- the context name (the name which is used in the designer)
- the context title (the title of the context which is a property of the context. If it is not defined you get the context name.
\ No newline at end of file
If you provide the ContextId_param only this context is provided.
\ No newline at end of file
import("system.vars");
import("system.result");
import("system.project");
import("Context_lib");
if (vars.exists("$param.ContextId_param") && vars.get("$param.ContextId_param"))
{
result.object(_contextDataMapping(project.getDataModel(project.DATAMODEL_KIND_CONTEXT, vars.get("$param.ContextId_param"))));
result.object(ContextUtils.getContext(vars.get("$param.ContextId_param")));
}
else
{
result.object(project.getDataModels(project.DATAMODEL_KIND_CONTEXT).map(_contextDataMapping).sort(function(pContext1, pContext2) {
if (pContext1[2] > pContext2[2])
return 1;
if (pContext1[2] < pContext2[2])
return -1;
return 0;
}));
}
function _contextDataMapping(pContext)
{
var contextName = ContextUtils.getContextName(pContext[0]);
return [pContext[0], contextName, (pContext[1] ? pContext[1] : contextName)];
result.object(ContextUtils.getContexts(true));
}
\ No newline at end of file
......@@ -62,6 +62,7 @@
<fieldType>DEPENDENCY_IN</fieldType>
<targetContextField>OBJECT2_TYPE</targetContextField>
<targetIdField>OBJECT2_ROWID</targetIdField>
<documentation>%aditoprj%/entity/ObjectRelation_entity/entityfields/object1/documentation.adoc</documentation>
<recordContainer>db</recordContainer>
<dependencies>
<entityDependency>
......@@ -113,6 +114,7 @@
<fieldType>DEPENDENCY_IN</fieldType>
<targetContextField>OBJECT1_TYPE</targetContextField>
<targetIdField>OBJECT1_ROWID</targetIdField>
<documentation>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2/documentation.adoc</documentation>
<recordContainer>db</recordContainer>
<children>
<entityParameter>
......@@ -146,6 +148,7 @@
<fieldType>DEPENDENCY_IN</fieldType>
<targetContextField>OBJECT2_TYPE</targetContextField>
<targetIdField>OBJECT2_ROWID</targetIdField>
<documentation>%aditoprj%/entity/ObjectRelation_entity/entityfields/bothobjects/documentation.adoc</documentation>
<recordContainer>db</recordContainer>
<children>
<entityParameter>
......@@ -203,6 +206,7 @@
<fieldType>DEPENDENCY_IN</fieldType>
<targetContextField>AnyTargetType</targetContextField>
<targetIdField>AnyTargetRowid</targetIdField>
<documentation>%aditoprj%/entity/ObjectRelation_entity/entityfields/anyobject/documentation.adoc</documentation>
<recordContainer>db</recordContainer>
<dependencies>
<entityDependency>
......
== Object Relation ==
This entity is for relation between Objects. It should be used if everything can be related to something.
This entity is for relation between Objects. It should be used if something can be related to something.
If only special objects should be connected where you always know what it is, it is better to create a custom relation table/entity which is only for this purpose. (e.g. Prod2Prod, Relation, ActitvityLink, ...)
The Object type is the ID of the context.
......
== AnyObject provider ==
is for bidirectional Objectrelations.
Example:
if you provide the contact "Lisa Sommer" as parameters (any..._param) you will get all relations which contain "Lisa Sommer" as Object1 OR Object2.
You will get both:
Object1 = "Lisa Sommer", Object2 = "GFK"
Object1 = "GFK", Object2 = "Lisa Sommer"
\ No newline at end of file
......@@ -8,18 +8,18 @@ var openedRowid;
if (vars.exists("$param.AnyObjectType_param") && vars.get("$param.AnyObjectType_param"))
{
openedType = vars.get("$param.AnyObjectType_param");
if (vars.exists("$param.Object1Rowid_param") && vars.get("$param.Object1Rowid_param"))
if (vars.exists("$param.AnyObjectRowid_param") && vars.get("$param.AnyObjectRowid_param"))
{
openedRowid = vars.get("$param.Object1Rowid_param");
openedRowid = vars.get("$param.AnyObjectRowid_param");
// anyObject and object 1 == opened object --> target is object2
if (vars.get("$field.OBJECT1_ROWID") == openedRowid && vars.get("$field.OBJECT1_TYPE") == openedType)
{
result.string(vars.get(vars.get("$field.OBJECT2_ROWID")));
result.string(vars.get("$field.OBJECT2_ROWID"));
}
// anyObject and object 2 == opened object --> target is object1
else if (vars.get("$field.OBJECT2_ROWID") == openedRowid && vars.get("$field.OBJECT2_TYPE") == openedType)
{
result.string(vars.get(vars.get("$field.OBJECT1_ROWID")));
result.string(vars.get("$field.OBJECT1_ROWID"));
}
}
}
\ No newline at end of file
import("system.logging");
import("system.result");
import("system.vars");
......@@ -9,18 +8,18 @@ var openedRowid;
if (vars.exists("$param.AnyObjectType_param") && vars.get("$param.AnyObjectType_param"))
{
openedType = vars.get("$param.AnyObjectType_param");
if (vars.exists("$param.Object1Rowid_param") && vars.get("$param.Object1Rowid_param"))
if (vars.exists("$param.AnyObjectRowid_param") && vars.get("$param.AnyObjectRowid_param"))
{
openedRowid = vars.get("$param.Object1Rowid_param");
openedRowid = vars.get("$param.AnyObjectRowid_param");
// anyObject and object 1 == opened object --> target is object2
if (vars.get("$field.OBJECT1_ROWID") == openedRowid && vars.get("$field.OBJECT1_TYPE") == openedType)
{
result.string(vars.get(vars.get("$field.OBJECT2_TYPE")));
result.string(vars.get("$field.OBJECT2_TYPE"));
}
// anyObject and object 2 == opened object --> target is object1
else if (vars.get("$field.OBJECT2_ROWID") == openedRowid && vars.get("$field.OBJECT2_TYPE") == openedType)
{
result.string(vars.get(vars.get("$field.OBJECT1_TYPE")));
result.string(vars.get("$field.OBJECT1_TYPE"));
}
}
}
\ No newline at end of file
== BothObject provider ==
is for getting relations between TWO SPECIFIC objects.
Example:
if you provide the contact "Lisa Sommer" and organisation "GFK" as parameters (objectX..._param) you will get all relations which contain "Lisa Sommer" as Object1 and "GFK" as Object2.
You will get only:
Object1 = "Lisa Sommer", Object2 = "GFK"
You WON'T get:
Object1 = "GFK", Object2 = "Lisa Sommer"
Object1 = "Peter Pfiffig", Object2 = "Lisa Sommer"
Object1 = "Peter Pfiffig", Object2 = "GFK"
...
\ No newline at end of file
== Object1 provider ==
is for getting relations between Object1 and something.
Example:
if you provide the contact "Lisa Sommer" as parameter (object1..._param) you will get all relations which contain "Lisa Sommer" as Object1.
You will get:
Object1 = "Lisa Sommer", Object2 = "GFK"
You WON'T get:
Object1 = "GFK", Object2 = "Lisa Sommer"
Object1 = "Peter Pfiffig", Object2 = "Lisa Sommer"
Object1 = "Peter Pfiffig", Object2 = "GFK"
...
\ No newline at end of file
import("system.logging");
import("system.neon");
import("system.vars");
import("system.result");
......@@ -19,10 +18,8 @@ if (recordstate == neon.OPERATINGSTATE_NEW)
}
else if (recordstate == neon.OPERATINGSTATE_EDIT)
{
logging.log("edit")
if (vars.exists("$field.OBJECT1_ROWID") && vars.get("$field.OBJECT1_ROWID") && vars.exists("$field.OBJECT1_TYPE") && vars.get("$field.OBJECT1_TYPE"))
{
logging.log(db.cell(ContextUtils.getNameSql(vars.get("$field.OBJECT1_TYPE"), vars.get("$field.OBJECT1_ROWID"))))
result.string(db.cell(ContextUtils.getNameSql(vars.get("$field.OBJECT1_TYPE"), vars.get("$field.OBJECT1_ROWID"))));
}
}
\ No newline at end of file
import("system.logging");
import("system.result");
import("system.neon");
import("system.vars");
var recordstate = vars.get("$sys.recordstate");
logging.log(recordstate)
if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT)
{
......
== Object2 provider ==
is for getting relations between something and Object2.
Example:
if you provide the contact "Lisa Sommer" as parameter (object2..._param) you will get all relations which contain "Lisa Sommer" as Object2.
You will get:
Object1 = "GFK", Object2 = "Lisa Sommer"
Object1 = "Peter Pfiffig", Object2 = "Lisa Sommer"
You WON'T get:
Object1 = "Lisa Sommer", Object2 = "GFK"
Object1 = "Peter Pfiffig", Object2 = "GFK"
Object1 = "Lisa Sommer", Object2 = "Peter Pfiffig"
...
\ No newline at end of file
import("system.logging");
import("system.result");
import("system.neon");
import("system.vars");
......@@ -6,7 +5,6 @@ import("system.vars");
var recordstate = vars.get("$sys.recordstate");
if (recordstate == neon.OPERATINGSTATE_NEW || recordstate == neon.OPERATINGSTATE_EDIT)
{
logging.log(vars.exists("$param.Object2Rowid_param") && vars.get("$param.Object2Rowid_param"))
if (vars.exists("$param.Object2Rowid_param") && vars.get("$param.Object2Rowid_param"))
result.string(neon.COMPONENTSTATE_READONLY);
}
\ No newline at end of file
import("system.vars");
import("system.logging");
import("system.result");
import("system.db");
import("Sql_lib");
......
......@@ -2,12 +2,12 @@
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.2.0">
<name>Object_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<documentation>%aditoprj%/entity/Object_entity/documentation.adoc</documentation>
<titleProcess>%aditoprj%/entity/Object_entity/titleProcess.js</titleProcess>
<recordContainer>jdito</recordContainer>
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
<recordContainer>jdito</recordContainer>
<children>
<entityParameter>
<name>ObjectRowId_param</name>
......@@ -37,6 +37,7 @@
<entityProvider>
<name>OneObject</name>
<fieldType>DEPENDENCY_IN</fieldType>
<documentation>%aditoprj%/entity/Object_entity/entityfields/oneobject/documentation.adoc</documentation>
<recordContainer>jdito</recordContainer>
<dependencies>
<entityDependency>
......@@ -70,6 +71,7 @@
<entityProvider>
<name>AllObjects</name>
<fieldType>DEPENDENCY_IN</fieldType>
<documentation>%aditoprj%/entity/Object_entity/entityfields/allobjects/documentation.adoc</documentation>
<recordContainer>jdito</recordContainer>
<dependencies>
<entityDependency>
......
== Object_entity ==
This Entity provides access to different Objects.
It provides:
- the object ID (the UUID of the object)
- the object title (the display name. Currently (12.02.2019) it is configured in the Context_lib. This may change!
\ No newline at end of file
== AllObjects provider ==
This provider returns all objects of one type.
\ No newline at end of file
== OneObjects provider ==
This provider returns one specific object.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment