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

remove old object relation context & fix relation type administration

parent 8ce51c84
No related branches found
No related tags found
No related merge requests found
Showing
with 81 additions and 329 deletions
......@@ -10,12 +10,6 @@
<name>#PROVIDER</name>
<recordContainer>jdito</recordContainer>
<dependencies>
<entityDependency>
<name>fcccd077-46c9-4d57-9d9f-27915e40dbce</name>
<entityName>ObjectRelation_entity</entityName>
<fieldName>Context</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>37559258-24f1-4c8c-b462-23ddf8de4e1e</name>
<entityName>AppointmentLink_entity</entityName>
......
<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.1">
<name>ObjectRelationType_entity</name>
<title>Relation type</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<icon>VAADIN:SPLIT</icon>
<titleProcess>%aditoprj%/entity/ObjectRelationType_entity/titleProcess.js</titleProcess>
......@@ -8,14 +9,6 @@
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
<dependencies>
<entityDependency>
<name>e66086ed-667b-4270-9ffb-ccb41e894ac3</name>
<entityName>ObjectRelation_entity</entityName>
<fieldName>ObjectRelationTypes</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
</entityProvider>
<entityField>
<name>UID</name>
......@@ -80,6 +73,8 @@
<name>DEST_OBJECT_TYPE</name>
<title>Context 2</title>
<consumer>Contexts</consumer>
<mandatoryProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/dest_object_type/mandatoryProcess.js</mandatoryProcess>
<stateProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/dest_object_type/stateProcess.js</stateProcess>
<displayValueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/dest_object_type/displayValueProcess.js</displayValueProcess>
</entityField>
<entityField>
......@@ -104,6 +99,8 @@
<entityField>
<name>DEST_RELATION_TITLE</name>
<title>Relation type 2</title>
<mandatoryProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/dest_relation_title/mandatoryProcess.js</mandatoryProcess>
<stateProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/dest_relation_title/stateProcess.js</stateProcess>
<displayValueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/dest_relation_title/displayValueProcess.js</displayValueProcess>
</entityField>
<entityConsumer>
......@@ -122,6 +119,13 @@
<onActionProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/removeusage/onActionProcess.js</onActionProcess>
<iconId>NEON:TRASH</iconId>
</entityActionField>
<entityField>
<name>Type2Enabled_proxy</name>
<title>Enable relation type 2</title>
<contentType>BOOLEAN</contentType>
<possibleItemsProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/type2enabled_proxy/possibleItemsProcess.js</possibleItemsProcess>
<valueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/type2enabled_proxy/valueProcess.js</valueProcess>
</entityField>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
......@@ -144,6 +148,7 @@
<element>SIDE.value</element>
<element>DEST_OBJECTRELATIONTYPEID.value</element>
<element>DEST_RELATION_TITLE.value</element>
<element>Type2Enabled_proxy.value</element>
</recordFields>
</jDitoRecordContainer>
</recordContainers>
......
......@@ -3,7 +3,7 @@ import("system.result");
import("system.neon");
import("system.vars");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$field.DEST_OBJECT_TYPE")) {
if(!vars.get("$field.DEST_OBJECT_TYPE")) {
result.string("");
} else if (vars.exists("$field.DEST_OBJECT_TYPE") && vars.get("$field.DEST_OBJECT_TYPE")) {
result.string(ContextUtils.getContext(vars.get("$field.DEST_OBJECT_TYPE"))[2]);
......
import("system.vars");
import("system.result");
result.string(vars.get("$field.objectTypeProxy"))
\ No newline at end of file
result.string(vars.getString("$field.Type2Enabled_proxy") == "1")
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.result");
import("system.neon");
logging.log("hui " + vars.get("$field.Type2Enabled_proxy"))
if (vars.getString("$field.Type2Enabled_proxy") == "0")
{
result.string(neon.COMPONENTSTATE_DISABLED);
}
else
{
result.string(neon.COMPONENTSTATE_EDITABLE);
}
\ No newline at end of file
import("system.vars");
import("system.result");
result.string(vars.get("$field.OBJECT1_TYPE"))
\ No newline at end of file
result.string(vars.getString("$field.Type2Enabled_proxy") == "1");
\ No newline at end of file
......@@ -2,5 +2,11 @@ import("system.vars");
import("system.result");
import("system.neon");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
result.string(vars.getString("$sys.date"));
\ No newline at end of file
if (vars.getString("$field.Type2Enabled_proxy") == "0")
{
result.string(neon.COMPONENTSTATE_DISABLED);
}
else
{
result.string(neon.COMPONENTSTATE_EDITABLE);
}
\ No newline at end of file
import("system.translate");
import("system.result");
result.object([
["1", translate.text("Yes")]
,["0", translate.text("No")]
]);
\ No newline at end of file
import("system.vars");
import("system.result");
result.string(vars.get("$field.OBJECT2_TYPE"))
\ No newline at end of file
if (!vars.get("$field.Type2Enabled_proxy"))
result.string(vars.get("$field.DIRECTION") == "same" ? 0 : 1);
\ No newline at end of file
......@@ -4,9 +4,9 @@ import("ObjectRelation_lib");
if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
{
result.object([ObjectRelationUtils.getRelationType(vars.get("$local.idvalues")[0])]);
result.object([ObjectRelationUtils.getRelationType(vars.get("$local.idvalues")[0], true)]);
}
else
{
result.object(ObjectRelationUtils.getPossibleRelationTypes(vars.get("$param.SourceObjectType_param"), true, vars.get("$param.OnlyFirstSide_param") == "1"));
result.object(ObjectRelationUtils.getPossibleRelationTypes(vars.get("$param.SourceObjectType_param"), true, vars.get("$param.OnlyFirstSide_param") == "1", undefined, true));
}
\ No newline at end of file
......@@ -22,8 +22,9 @@ db.insertData("AB_OBJECTRELATIONTYPE", [
vars.get("$field.HIERARCHY")
]);
if ((vars.get("$field.SOURCE_RELATION_TITLE") != vars.get("$field.DEST_RELATION_TITLE") || vars.get("$field.SOURCE_OBJECT_TYPE") != vars.get("$field.DEST_OBJECT_TYPE"))
&& vars.get("$field.DEST_OBJECT_TYPE") && vars.get("$field.DEST_RELATION_TITLE"))
if (vars.getString("$field.Type2Enabled_proxy") == "1"
&& (vars.get("$field.SOURCE_RELATION_TITLE") != vars.get("$field.DEST_RELATION_TITLE")
&& vars.get("$field.SOURCE_OBJECT_TYPE") != vars.get("$field.DEST_OBJECT_TYPE")))
{
db.insertData("AB_OBJECTRELATIONTYPE", [
"AB_OBJECTRELATIONTYPEID",
......
import("Entity_lib");
import("system.logging");
import("system.util");
import("Sql_lib");
import("system.db");
import("system.vars");
logging.log("---------------------------")
var usageCount = db.cell(SqlCondition.begin()
.andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1", "$field.UID")
.andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2", "$field.DEST_OBJECTRELATIONTYPEID")
......@@ -25,6 +28,8 @@ if (usageCount <= 0)
case "DEST":
type2Fields[fieldName.replace("DEST_", "")] = vars.get("$field." + fieldName);
break;
case "Type2Enabled":
break;
default:
type1Fields[fieldName] = vars.get("$field." + fieldName);
type2Fields[fieldName] = vars.get("$field." + fieldName);
......@@ -32,17 +37,23 @@ if (usageCount <= 0)
});
var updates = [];
var type1Cond = SqlCondition.begin().andPrepareVars("AB_OBJECTRELATIONTYPE.AB_OBJECTRELATIONTYPEID", "$field.UID").build("1=2");
var type2Cond = SqlCondition.begin().andPrepareVars("AB_OBJECTRELATIONTYPE.AB_OBJECTRELATIONTYPEID", "$field.DEST_OBJECTRELATIONTYPEID").build("1=2");
var type1Cond = SqlCondition.begin().andPrepare("AB_OBJECTRELATIONTYPE.RELATION_TYPE", vars.get("$field.RELATION_TYPE"))
.andPrepare("AB_OBJECTRELATIONTYPE.SIDE", "1").build("1=2");
var type2Cond = SqlCondition.begin().andPrepare("AB_OBJECTRELATIONTYPE.RELATION_TYPE", vars.get("$field.RELATION_TYPE"))
.andPrepare("AB_OBJECTRELATIONTYPE.SIDE", "2").build("1=2");
for (let field in type1Fields) {
updates.push(["AB_OBJECTRELATIONTYPE", [field], null, [type1Fields[field]], type1Cond]);
}
var type2Enabled = vars.getString("$field.Type2Enabled_proxy");
logging.log("en " + type2Enabled)
// delete, if type2 is empty -> convert it to a "same"-type
if ((vars.get("$field.SOURCE_RELATION_TITLE") == vars.get("$field.DEST_RELATION_TITLE") && vars.get("$field.SOURCE_OBJECT_TYPE") == vars.get("$field.DEST_OBJECT_TYPE"))
|| !vars.get("$field.DEST_OBJECT_TYPE") && !vars.get("$field.DEST_RELATION_TITLE"))
if (type2Enabled == "0" || ((vars.get("$field.SOURCE_RELATION_TITLE") == vars.get("$field.DEST_RELATION_TITLE") && vars.get("$field.SOURCE_OBJECT_TYPE") == vars.get("$field.DEST_OBJECT_TYPE"))
|| !vars.get("$field.DEST_OBJECT_TYPE") && !vars.get("$field.DEST_RELATION_TITLE")))
{
logging.log(vars.get("$field.DEST_OBJECTRELATIONTYPEID"))
db.deleteData("AB_OBJECTRELATIONTYPE", type2Cond);
}
else
......
<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.1">
<name>ObjectRelation_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<documentation>%aditoprj%/entity/ObjectRelation_entity/documentation.adoc</documentation>
<recordContainer>db</recordContainer>
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
<recordContainer>db</recordContainer>
<dependencies>
<entityDependency>
<name>6789c40b-d70b-4133-af1d-40cbf548d460</name>
<entityName>Organisation_entity</entityName>
<fieldName>ObjectRelations</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
</entityProvider>
<entityField>
<name>AB_OBJECTRELATIONTYPE1</name>
<title>Type 1</title>
<mandatory v="true" />
</entityField>
<entityField>
<name>OBJECT1_ROWID</name>
<title>Object 1</title>
<mandatory v="true" />
</entityField>
<entityField>
<name>AB_OBJECTRELATIONID</name>
<valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/ab_objectrelationid/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>OBJECT2_ROWID</name>
<title>Object 2</title>
<mandatory v="true" />
<titleProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/object2_rowid/titleProcess.js</titleProcess>
</entityField>
<entityField>
<name>AB_OBJECTRELATIONTYPE2</name>
<title>Type 2</title>
<mandatory v="true" />
</entityField>
<entityConsumer>
<name>Contexts</name>
<fieldType>DEPENDENCY_OUT</fieldType>
<dependency>
<name>dependency</name>
<entityName>Context_entity</entityName>
<fieldName>#PROVIDER</fieldName>
</dependency>
</entityConsumer>
<entityConsumer>
<name>Objects</name>
<fieldType>DEPENDENCY_OUT</fieldType>
<dependency>
<name>dependency</name>
<entityName>Object_entity</entityName>
<fieldName>AllObjects</fieldName>
</dependency>
<children>
<entityParameter>
<name>ObjectType_param</name>
<valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/objects/children/objecttype_param/valueProcess.js</valueProcess>
<triggerRecalculation v="true" />
</entityParameter>
</children>
</entityConsumer>
<entityProvider>
<name>ObjectRelations</name>
<fieldType>DEPENDENCY_IN</fieldType>
<targetContextField>objectTypeProxy</targetContextField>
<targetIdField>rowIdProxy</targetIdField>
<recordContainer>db</recordContainer>
<dependencies>
<entityDependency>
<name>30a7c954-3127-4ceb-9838-a0b7b55d0c8c</name>
<entityName>Person_entity</entityName>
<fieldName>ObjectRelations</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
<children>
<entityParameter>
<name>ObjectRowid_param</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
<entityParameter>
<name>ObjectType_param</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
</children>
</entityProvider>
<entityConsumer>
<name>ObjectRelationTypes</name>
<fieldType>DEPENDENCY_OUT</fieldType>
<dependency>
<name>dependency</name>
<entityName>ObjectRelationType_entity</entityName>
<fieldName>#PROVIDER</fieldName>
</dependency>
<children>
<entityParameter>
<name>SourceObjectType_param</name>
<valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/objectrelationtypes/children/sourceobjecttype_param/valueProcess.js</valueProcess>
<triggerRecalculation v="true" />
</entityParameter>
</children>
</entityConsumer>
<entityParameter>
<name>ObjectType_param</name>
<expose v="true" />
<triggerRecalculation v="true" />
<mandatory v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityParameter>
<name>ObjectRowid_param</name>
<expose v="true" />
<triggerRecalculation v="true" />
<mandatory v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityField>
<name>selectedObjectRelationTypeIdProxy</name>
<title>Relationtype</title>
<possibleItemsProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/selectedobjectrelationtypeidproxy/possibleItemsProcess.js</possibleItemsProcess>
<valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/selectedobjectrelationtypeidproxy/valueProcess.js</valueProcess>
<onValueChange>%aditoprj%/entity/ObjectRelation_entity/entityfields/selectedobjectrelationtypeidproxy/onValueChange.js</onValueChange>
</entityField>
<entityField>
<name>relationTypeProxy</name>
<title>Relationtype</title>
<valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/relationtypeproxy/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>rowIdProxy</name>
<title>Object</title>
<consumer>Objects</consumer>
<linkedContextProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/rowidproxy/linkedContextProcess.js</linkedContextProcess>
<valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/rowidproxy/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/rowidproxy/displayValueProcess.js</displayValueProcess>
<onValueChange>%aditoprj%/entity/ObjectRelation_entity/entityfields/rowidproxy/onValueChange.js</onValueChange>
</entityField>
<entityField>
<name>objectTypeProxy</name>
<title>Object type</title>
<valueProcess>%aditoprj%/entity/ObjectRelation_entity/entityfields/objecttypeproxy/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>mySide</name>
<description>Is always the side the current Object (from the parameters) is in the currently selected ObjectRelationType</description>
</entityField>
<entityField>
<name>OBJECT1_TYPE</name>
</entityField>
<entityField>
<name>OBJECT2_TYPE</name>
</entityField>
<entityField>
<name>INFO</name>
<title>Description</title>
</entityField>
</entityFields>
<recordContainers>
<dbRecordContainer>
<name>db</name>
<description>&lt;null value&gt;</description>
<alias>Data_alias</alias>
<fromClauseProcess>%aditoprj%/entity/ObjectRelation_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess>
<conditionProcess>%aditoprj%/entity/ObjectRelation_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
<linkInformation>
<linkInformation>
<name>e64669fe-3252-42b9-9b9b-56a2166d81b7</name>
<tableName>AB_OBJECTRELATION</tableName>
<primaryKey>AB_OBJECTRELATIONID</primaryKey>
<isUIDTable v="true" />
<readonly v="false" />
</linkInformation>
<linkInformation>
<name>2ff74f14-9e9c-458d-9100-1c2c9fb34b89</name>
<tableName>AB_OBJECTRELATIONTYPE</tableName>
<primaryKey>AB_OBJECTRELATIONTYPEID</primaryKey>
<isUIDTable v="false" />
<readonly v="true" />
</linkInformation>
</linkInformation>
<recordFieldMappings>
<dbRecordFieldMapping>
<name>AB_OBJECTRELATIONID.value</name>
<recordfield>AB_OBJECTRELATION.AB_OBJECTRELATIONID</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>OBJECT1_ROWID.value</name>
<recordfield>AB_OBJECTRELATION.OBJECT1_ROWID</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>OBJECT2_ROWID.value</name>
<recordfield>AB_OBJECTRELATION.OBJECT2_ROWID</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>AB_OBJECTRELATIONTYPE1.value</name>
<recordfield>AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>AB_OBJECTRELATIONTYPE2.value</name>
<recordfield>AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>OBJECT2_TYPE.value</name>
<expression>%aditoprj%/entity/ObjectRelation_entity/recordcontainers/db/recordfieldmappings/object2_type.value/expression.js</expression>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>OBJECT1_TYPE.value</name>
<expression>%aditoprj%/entity/ObjectRelation_entity/recordcontainers/db/recordfieldmappings/object1_type.value/expression.js</expression>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>INFO.value</name>
<recordfield>AB_OBJECTRELATION.INFO</recordfield>
</dbRecordFieldMapping>
</recordFieldMappings>
</dbRecordContainer>
</recordContainers>
</entity>
Object Relation
===============
:toc2: left
:numbered:
(how it works currently 13.03.2019)
== How the ObjectRelation_entity works ==
The entity works with the AB_OBJECTRELATION and AB_OBJECTRELATIONTYPE db-tables.
The AB_OBJECTRELATIONTYPE defines which relations are possible.
It always defines one "side" of the relation. So for each relation you always need two of them and both have to be from the same RELATION_TYPE.
So for example if you would like to have a relation between a child and parent you need these two types:
----
AB_OBJECTRELATIONTYPEID = UID_1
OBJECT_TYPE = Person
RELATION_TITLE = child of
RELATION_TYPE = TypeUID_1
SIDE = 1
and
AB_OBJECTRELATIONTYPEID = UID_2
OBJECT_TYPE = Person
RELATION_TITLE = parent of
RELATION_TYPE = TypeUID_1
SIDE = 2
----
Note that the RELATION_TYPE is the same.
If you create a new relation between two persons it looks like this:
----
AB_OBJECTRELATIONID = RelUID_1
OBJECT1_ROWID = UID_Lisa_Sommer
OBJECT2_ROWID = UID_Franz_Mueller
AB_OBJECTRELATIONTYPE1 = UID_1
AB_OBJECTRELATIONTYPE2 = UID_2
----
-> So:
* Most relationtypes consist of two separate types connected by the RELATION_TYPE-id
* Each type also has a SIDE, which defines, if it is for side 1 or side 2
* If both sides are from the same type, then there is only one OBJECTRELATIONTYPE with the side 1 and Objects use the same one.
The provider use the targetContext-feature to show the preview of the linked objects directly. (see targetContext-docu in the ohers/guide folder)
\ No newline at end of file
import("system.neon");
import("system.util");
import("system.vars");
import("system.result");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
result.string(util.getNewUUID());
\ No newline at end of file
import("system.vars");
import("system.result");
import("system.neon");
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
result.string(vars.getString("$sys.date"));
\ No newline at end of file
import("system.result");
result.string("ObjectRelationType");
\ No newline at end of file
import("system.translate");
import("system.vars");
import("system.result");
import("Context_lib");
result.string(vars.exists("$param.Object2RowidTitle_param") ? vars.get("$param.Object2RowidTitle_param") : "Object 2");
\ No newline at end of file
import("system.result");
result.string("tree");
\ No newline at end of file
import("system.vars");
import("system.result");
result.string(vars.get("$param.ObjectType_param"))
\ 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