diff --git a/application/_____SYSTEM_APPLICATION_NEON/_____SYSTEM_APPLICATION_NEON.aod b/application/_____SYSTEM_APPLICATION_NEON/_____SYSTEM_APPLICATION_NEON.aod index 74af7250a3e212caebc7415ef0a2447d212b8248..2d715c6e5a0360e97f68cafd23bfc6179425aca6 100644 --- a/application/_____SYSTEM_APPLICATION_NEON/_____SYSTEM_APPLICATION_NEON.aod +++ b/application/_____SYSTEM_APPLICATION_NEON/_____SYSTEM_APPLICATION_NEON.aod @@ -33,6 +33,7 @@ <node name="KeywordEntry" kind="10077" /> <node name="KeywordAttribute" kind="10077" /> <node name="Employee" kind="10077" /> + <node name="ObjectRelationType" kind="10077" /> <node name="INTERNAL_ADMINISTRATOR" kind="159" /> </node> </node> diff --git a/entity/Context_entity/Context_entity.aod b/entity/Context_entity/Context_entity.aod index 6b92f784aa1b0eefdd87b1fe711183f4a0bbe562..df505cf73583fb1a97566a887270b53c34be8595 100644 --- a/entity/Context_entity/Context_entity.aod +++ b/entity/Context_entity/Context_entity.aod @@ -41,6 +41,14 @@ <entityProvider> <name>Context</name> <fieldType>DEPENDENCY_IN</fieldType> + <dependencies> + <entityDependency> + <name>dab09827-2eeb-403d-a070-ba805d2640ee</name> + <entityName>ObjectRelationType_entity</entityName> + <fieldName>Contexts</fieldName> + <isConsumer v="false" /> + </entityDependency> + </dependencies> <children> <entityParameter> <name>excludeContexts_param</name> diff --git a/entity/ObjectRelationType_entity/ObjectRelationType_entity.aod b/entity/ObjectRelationType_entity/ObjectRelationType_entity.aod index 7569f2f522cda9dfe237cdd8af2d3594c8a505ea..ad564c0c7354b4692adc0ef11ff6983f5ebd06d2 100644 --- a/entity/ObjectRelationType_entity/ObjectRelationType_entity.aod +++ b/entity/ObjectRelationType_entity/ObjectRelationType_entity.aod @@ -2,6 +2,7 @@ <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> <majorModelMode>DISTRIBUTED</majorModelMode> + <icon>VAADIN:SPLIT</icon> <titleProcess>%aditoprj%/entity/ObjectRelationType_entity/titleProcess.js</titleProcess> <recordContainer>jdito</recordContainer> <entityFields> @@ -21,7 +22,10 @@ <valueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/uid/valueProcess.js</valueProcess> </entityField> <entityField> - <name>RELATION_TITLE</name> + <name>SOURCE_RELATION_TITLE</name> + <title>Relation type 1</title> + <mandatory v="true" /> + <displayValueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/source_relation_title/displayValueProcess.js</displayValueProcess> </entityField> <entityParameter> <name>SourceObjectType_param</name> @@ -46,17 +50,100 @@ <expose v="true" /> <triggerRecalculation v="true" /> </entityParameter> + <entityParameter> + <name>OnlyFirstSide_param</name> + <valueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/objectrelationtypes/children/onlyfirstside_param/valueProcess.js</valueProcess> + <expose v="false" /> + </entityParameter> </children> </entityProvider> + <entityParameter> + <name>OnlyFirstSide_param</name> + <valueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/onlyfirstside_param/valueProcess.js</valueProcess> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> + <entityField> + <name>RELATION_TYPE</name> + </entityField> + <entityField> + <name>DIRECTION</name> + </entityField> + <entityField> + <name>HIERARCHY</name> + <title>Hierarchy</title> + <contentType>BOOLEAN</contentType> + <possibleItemsProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/hierarchy/possibleItemsProcess.js</possibleItemsProcess> + <valueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/hierarchy/valueProcess.js</valueProcess> + </entityField> + <entityField> + <name>DEST_OBJECT_TYPE</name> + <title>Context 2</title> + <consumer>Contexts</consumer> + <displayValueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/dest_object_type/displayValueProcess.js</displayValueProcess> + </entityField> + <entityField> + <name>SOURCE_OBJECT_TYPE</name> + <title>Context 1</title> + <consumer>Contexts</consumer> + <mandatory v="true" /> + <displayValueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/source_object_type/displayValueProcess.js</displayValueProcess> + </entityField> + <entityField> + <name>AB_OBJECTRELATIONTYPE1</name> + </entityField> + <entityField> + <name>AB_OBJECTRELATIONTYPE2</name> + </entityField> + <entityField> + <name>SIDE</name> + </entityField> + <entityField> + <name>DEST_OBJECTRELATIONTYPEID</name> + </entityField> + <entityField> + <name>DEST_RELATION_TITLE</name> + <title>Relation type 2</title> + <displayValueProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/dest_relation_title/displayValueProcess.js</displayValueProcess> + </entityField> + <entityConsumer> + <name>Contexts</name> + <fieldType>DEPENDENCY_OUT</fieldType> + <dependency> + <name>dependency</name> + <entityName>Context_entity</entityName> + <fieldName>Context</fieldName> + </dependency> + </entityConsumer> + <entityActionField> + <name>removeUsage</name> + <fieldType>ACTION</fieldType> + <title>Delete all usage</title> + <onActionProcess>%aditoprj%/entity/ObjectRelationType_entity/entityfields/removeusage/onActionProcess.js</onActionProcess> + <iconId>NEON:TRASH</iconId> + </entityActionField> </entityFields> <recordContainers> <jDitoRecordContainer> <name>jdito</name> <jDitoRecordAlias>Data_alias</jDitoRecordAlias> <contentProcess>%aditoprj%/entity/ObjectRelationType_entity/recordcontainers/jdito/contentProcess.js</contentProcess> + <onInsert>%aditoprj%/entity/ObjectRelationType_entity/recordcontainers/jdito/onInsert.js</onInsert> + <onUpdate>%aditoprj%/entity/ObjectRelationType_entity/recordcontainers/jdito/onUpdate.js</onUpdate> + <onDelete>%aditoprj%/entity/ObjectRelationType_entity/recordcontainers/jdito/onDelete.js</onDelete> <recordFields> <element>UID.value</element> - <element>RELATION_TITLE.value</element> + <element>SOURCE_RELATION_TITLE.value</element> + <element>RELATION_TYPE.value</element> + <element>DIRECTION.value</element> + <element>HIERARCHY.value</element> + <element>DEST_OBJECT_TYPE.value</element> + <element>SOURCE_OBJECT_TYPE.value</element> + <element>AB_OBJECTRELATIONTYPE1.value</element> + <element>AB_OBJECTRELATIONTYPE2.value</element> + <element>SIDE.value</element> + <element>DEST_OBJECTRELATIONTYPEID.value</element> + <element>DEST_RELATION_TITLE.value</element> </recordFields> </jDitoRecordContainer> </recordContainers> diff --git a/entity/ObjectRelationType_entity/entityfields/dest_object_type/displayValueProcess.js b/entity/ObjectRelationType_entity/entityfields/dest_object_type/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..4cee3b90ca1fb124959d0d75bdbbed6a728fac65 --- /dev/null +++ b/entity/ObjectRelationType_entity/entityfields/dest_object_type/displayValueProcess.js @@ -0,0 +1,10 @@ +import("Context_lib"); +import("system.result"); +import("system.neon"); +import("system.vars"); + +if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !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]); +} \ No newline at end of file diff --git a/entity/ObjectRelationType_entity/entityfields/dest_relation_title/displayValueProcess.js b/entity/ObjectRelationType_entity/entityfields/dest_relation_title/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..6aecb834c55c3c2d2bd7ec41df700ab39b7ae933 --- /dev/null +++ b/entity/ObjectRelationType_entity/entityfields/dest_relation_title/displayValueProcess.js @@ -0,0 +1,5 @@ +import("system.result"); +import("system.vars"); +import("system.translate"); + +result.string(translate.text(vars.get("$field.DEST_RELATION_TITLE"))); \ No newline at end of file diff --git a/entity/ObjectRelationType_entity/entityfields/hierarchy/possibleItemsProcess.js b/entity/ObjectRelationType_entity/entityfields/hierarchy/possibleItemsProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..b88d5392d1a40aa827f90e9dfcdd26303c4b1baa --- /dev/null +++ b/entity/ObjectRelationType_entity/entityfields/hierarchy/possibleItemsProcess.js @@ -0,0 +1,7 @@ +import("system.translate"); +import("system.result"); + +result.object([ + ["1", translate.text("Yes")] + ,["0", translate.text("No")] +]); \ No newline at end of file diff --git a/entity/ObjectRelationType_entity/entityfields/hierarchy/valueProcess.js b/entity/ObjectRelationType_entity/entityfields/hierarchy/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..b3028ee4f3a3271d9a6603e8d52faf656a4fa484 --- /dev/null +++ b/entity/ObjectRelationType_entity/entityfields/hierarchy/valueProcess.js @@ -0,0 +1,8 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) +{ + result.string("0") +} \ No newline at end of file diff --git a/entity/ObjectRelationType_entity/entityfields/objectrelationtypes/children/onlyfirstside_param/valueProcess.js b/entity/ObjectRelationType_entity/entityfields/objectrelationtypes/children/onlyfirstside_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..755662df1632264e94e6a4d766bb65ead50a553d --- /dev/null +++ b/entity/ObjectRelationType_entity/entityfields/objectrelationtypes/children/onlyfirstside_param/valueProcess.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string("0") \ No newline at end of file diff --git a/entity/ObjectRelationType_entity/entityfields/onlyfirstside_param/valueProcess.js b/entity/ObjectRelationType_entity/entityfields/onlyfirstside_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..985b9f8612b5b61cb0d132b3fa7aec6412d4439a --- /dev/null +++ b/entity/ObjectRelationType_entity/entityfields/onlyfirstside_param/valueProcess.js @@ -0,0 +1,2 @@ +import("system.result"); +result.string("1"); \ No newline at end of file diff --git a/entity/ObjectRelationType_entity/entityfields/removeusage/onActionProcess.js b/entity/ObjectRelationType_entity/entityfields/removeusage/onActionProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..7de1f5f6cb2dc53d15d82fdf758c2dd93880f2a6 --- /dev/null +++ b/entity/ObjectRelationType_entity/entityfields/removeusage/onActionProcess.js @@ -0,0 +1,14 @@ +import("system.translate"); +import("system.question"); +import("system.vars"); +import("system.db"); +import("Sql_lib"); + +if (vars.get("$field.UID") && vars.get("$field.DEST_OBJECTRELATIONTYPEID")) +{ + db.deleteData("AB_OBJECTRELATION", SqlCondition.begin() + .andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1", "$field.UID") + .andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2", "$field.DEST_OBJECTRELATIONTYPEID").build("1=2")); + question.showMessage(translate.withArguments("Deleted all usages of \"%0\".", [translate.text(vars.get("$field.SOURCE_RELATION_TITLE")) + " -> " + translate.text(vars.get("$field.DEST_RELATION_TITLE"))]), question.INFORMATION, translate.text("Successful")) +} + diff --git a/entity/ObjectRelationType_entity/entityfields/source_object_type/displayValueProcess.js b/entity/ObjectRelationType_entity/entityfields/source_object_type/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..762ebccbcb1e905fa528f7557056c0be29e32682 --- /dev/null +++ b/entity/ObjectRelationType_entity/entityfields/source_object_type/displayValueProcess.js @@ -0,0 +1,10 @@ +import("Context_lib"); +import("system.result"); +import("system.neon"); +import("system.vars"); + +if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && !vars.get("$field.SOURCE_OBJECT_TYPE")) { + result.string(""); +} else if (vars.exists("$field.SOURCE_OBJECT_TYPE") && vars.get("$field.SOURCE_OBJECT_TYPE")) { + result.string(ContextUtils.getContext(vars.get("$field.SOURCE_OBJECT_TYPE"))[2]); +} \ No newline at end of file diff --git a/entity/ObjectRelationType_entity/entityfields/source_relation_title/displayValueProcess.js b/entity/ObjectRelationType_entity/entityfields/source_relation_title/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..abba412e0e44eccb7125811e68858e85db985847 --- /dev/null +++ b/entity/ObjectRelationType_entity/entityfields/source_relation_title/displayValueProcess.js @@ -0,0 +1,5 @@ +import("system.result"); +import("system.vars"); +import("system.translate"); + +result.string(translate.text(vars.get("$field.SOURCE_RELATION_TITLE"))); \ No newline at end of file diff --git a/entity/ObjectRelationType_entity/recordcontainers/jdito/contentProcess.js b/entity/ObjectRelationType_entity/recordcontainers/jdito/contentProcess.js index 23e43cb44c7bc9f62000e8d7c77f7f8b24cc0a22..698419fadb815a40dc6bea058c6e873183f6881f 100644 --- a/entity/ObjectRelationType_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/ObjectRelationType_entity/recordcontainers/jdito/contentProcess.js @@ -1,6 +1,12 @@ -import("system.logging"); import("system.result"); import("system.vars"); import("ObjectRelation_lib"); -result.object(ObjectRelationUtils.getPossibleRelationTypes(vars.get("$param.SourceObjectType_param"))); \ No newline at end of file +if (vars.exists("$local.idvalues") && vars.get("$local.idvalues")) +{ + result.object([ObjectRelationUtils.getRelationType(vars.get("$local.idvalues")[0])]); +} +else +{ + result.object(ObjectRelationUtils.getPossibleRelationTypes(vars.get("$param.SourceObjectType_param"), true, vars.get("$param.OnlyFirstSide_param") == "1")); +} \ No newline at end of file diff --git a/entity/ObjectRelationType_entity/recordcontainers/jdito/onDelete.js b/entity/ObjectRelationType_entity/recordcontainers/jdito/onDelete.js new file mode 100644 index 0000000000000000000000000000000000000000..78bb374858de35e55f8003509b94d9bcc861e735 --- /dev/null +++ b/entity/ObjectRelationType_entity/recordcontainers/jdito/onDelete.js @@ -0,0 +1,23 @@ +import("system.logging"); +import("system.vars"); +import("system.db"); +import("system.translate"); +import("system.question"); +import("Sql_lib"); + +var usageCount = db.cell(SqlCondition.begin() + .andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1", "$field.UID") + .andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2", "$field.DEST_OBJECTRELATIONTYPEID") + .buildSql("select count(*) from AB_OBJECTRELATION", "1=2")) + +if (usageCount <= 0) +{ + db.deleteData("AB_OBJECTRELATIONTYPE", SqlCondition.begin() + .andPrepareVars("AB_OBJECTRELATIONTYPE.RELATION_TYPE", "$field.RELATION_TYPE") + .build("1=2")); +} +else +{ + // TODO: server hängt bei question.showMessage + //question.showMessage(translate.withArguments("There are still %0 relations using the type %1.", [usageCount, translate.text(vars.get("$field.SOURCE_RELATION_TITLE")) + " -> " + translate.text(vars.get("$field.DEST_RELATION_TITLE"))]), question.WARNING, translate.text("Cannot remove relation type")) +} \ No newline at end of file diff --git a/entity/ObjectRelationType_entity/recordcontainers/jdito/onInsert.js b/entity/ObjectRelationType_entity/recordcontainers/jdito/onInsert.js new file mode 100644 index 0000000000000000000000000000000000000000..b9f87162f4bbcf88c0a2b17e83a581a51d7c9572 --- /dev/null +++ b/entity/ObjectRelationType_entity/recordcontainers/jdito/onInsert.js @@ -0,0 +1,43 @@ +import("system.util"); +import("ObjectRelation_lib"); +import("system.vars"); +import("system.db"); +import("system.util"); + +var newRelationType = util.getNewUUID(); + +db.insertData("AB_OBJECTRELATIONTYPE", [ + "AB_OBJECTRELATIONTYPEID", + "OBJECT_TYPE", + "RELATION_TITLE", + "RELATION_TYPE", + "SIDE", + "HIERARCHY" +], null, [ + util.getNewUUID(), + vars.get("$field.SOURCE_OBJECT_TYPE"), + vars.get("$field.SOURCE_RELATION_TITLE"), + newRelationType, + 1, + 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")) +{ + db.insertData("AB_OBJECTRELATIONTYPE", [ + "AB_OBJECTRELATIONTYPEID", + "OBJECT_TYPE", + "RELATION_TITLE", + "RELATION_TYPE", + "SIDE", + "HIERARCHY" + ], null, [ + util.getNewUUID(), + vars.get("$field.DEST_OBJECT_TYPE"), + vars.get("$field.DEST_RELATION_TITLE"), + newRelationType, + 2, + vars.get("$field.HIERARCHY") + ]); +} \ No newline at end of file diff --git a/entity/ObjectRelationType_entity/recordcontainers/jdito/onUpdate.js b/entity/ObjectRelationType_entity/recordcontainers/jdito/onUpdate.js new file mode 100644 index 0000000000000000000000000000000000000000..4df0c2df9ece10a5c2e64a8506ac0f0597a0e174 --- /dev/null +++ b/entity/ObjectRelationType_entity/recordcontainers/jdito/onUpdate.js @@ -0,0 +1,88 @@ +import("system.util"); +import("Sql_lib"); +import("system.db"); +import("system.vars"); + +var usageCount = db.cell(SqlCondition.begin() + .andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1", "$field.UID") + .andPrepareVars("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2", "$field.DEST_OBJECTRELATIONTYPEID") + .buildSql("select count(*) from AB_OBJECTRELATION", "1=2")) + +if (usageCount <= 0) +{ + var type1Fields = {}; + var type2Fields = {}; + + vars.get("local.changed").forEach(function(pChange) + { + var fieldName = pChange.split(".")[0]; + + switch (pChange.split("_")[0]) + { + case "SOURCE": + type1Fields[fieldName.replace("SOURCE_", "")] = vars.get("$field." + fieldName); + break; + case "DEST": + type2Fields[fieldName.replace("DEST_", "")] = vars.get("$field." + fieldName); + break; + default: + type1Fields[fieldName] = vars.get("$field." + fieldName); + type2Fields[fieldName] = vars.get("$field." + fieldName); + } + }); + + 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"); + + for (let field in type1Fields) { + updates.push(["AB_OBJECTRELATIONTYPE", [field], null, [type1Fields[field]], type1Cond]); + } + + // 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")) + { + db.deleteData("AB_OBJECTRELATIONTYPE", type2Cond); + } + else + { // update if already existing + if (vars.get("$field.DIRECTION") != "same") + { + for (let field in type2Fields) { + updates.push(["AB_OBJECTRELATIONTYPE", [field], null, [type2Fields[field]], type2Cond]); + } + } + else + { // insert if it was "same" before + 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")) + { + db.insertData("AB_OBJECTRELATIONTYPE", [ + "AB_OBJECTRELATIONTYPEID", + "OBJECT_TYPE", + "RELATION_TITLE", + "RELATION_TYPE", + "SIDE", + "HIERARCHY" + ], null, [ + util.getNewUUID(), + vars.get("$field.DEST_OBJECT_TYPE"), + vars.get("$field.DEST_RELATION_TITLE"), + vars.get("$field.RELATION_TYPE"), + 2, + vars.get("$field.HIERARCHY") + ]); + + } + } + } + + db.updates(updates); +} +else +{ + // TODO: server hängt bei question.showMessage + //question.showMessage(translate.withArguments("There are still %0 relations using the type %1.", [usageCount, translate.text(vars.get("$field.SOURCE_RELATION_TITLE")) + " -> " + translate.text(vars.get("$field.DEST_RELATION_TITLE"))]), question.WARNING, translate.text("Cannot remove relation type")) +} + diff --git a/entity/ObjectRelationType_entity/titleProcess.js b/entity/ObjectRelationType_entity/titleProcess.js index 71a9111fb455f300d19637ad0dac20645516bac6..dbc0c500302fcbb7dfe706e35445f9f01952daa5 100644 --- a/entity/ObjectRelationType_entity/titleProcess.js +++ b/entity/ObjectRelationType_entity/titleProcess.js @@ -2,4 +2,11 @@ import("system.translate"); import("system.vars"); import("system.result"); -result.string(translate.text(vars.get("$field.RELATION_TITLE"))) \ No newline at end of file +if (vars.exists("$param.OnlyFirstSide_param") && vars.get("$param.OnlyFirstSide_param") == "1" && vars.get("$field.DIRECTION") != "same") +{ + result.string(translate.text(vars.get("$field.SOURCE_RELATION_TITLE")) + " -> " + translate.text(vars.get("$field.DEST_RELATION_TITLE"))); +} +else +{ + result.string(translate.text(vars.get("$field.SOURCE_RELATION_TITLE"))); +} \ No newline at end of file diff --git a/entity/ObjectTree_entity/ObjectTree_entity.aod b/entity/ObjectTree_entity/ObjectTree_entity.aod index d940f4a75f04936b121339950f8a4078b5d40c0d..78ee2dcbcd62f54fb31db4eb1250d354f369a99f 100644 --- a/entity/ObjectTree_entity/ObjectTree_entity.aod +++ b/entity/ObjectTree_entity/ObjectTree_entity.aod @@ -1,7 +1,7 @@ <?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>ObjectTree_entity</name> - <title>Object tree</title> + <title>Object relation</title> <majorModelMode>DISTRIBUTED</majorModelMode> <recordContainer>jdito</recordContainer> <entityFields> @@ -108,6 +108,7 @@ <title>Relation</title> <consumer>Objects</consumer> <linkedContextProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/target_id/linkedContextProcess.js</linkedContextProcess> + <mandatory v="true" /> <searchable v="false" /> <stateProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/target_id/stateProcess.js</stateProcess> <displayValueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/target_id/displayValueProcess.js</displayValueProcess> @@ -127,6 +128,7 @@ <name>OBJECTRELATIONTYPEID</name> <title>Relationtype</title> <consumer>ObjectRelationTypes</consumer> + <mandatory v="true" /> <stateProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/stateProcess.js</stateProcess> <valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/displayValueProcess.js</displayValueProcess> @@ -167,9 +169,8 @@ <name>edit</name> <fieldType>ACTION</fieldType> <onActionProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/alter/children/edit/onActionProcess.js</onActionProcess> + <isSelectionAction v="true" /> <iconId>NEON:PENCIL</iconId> - <state>DISABLED</state> - <stateProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/alter/children/edit/stateProcess.js</stateProcess> </entityActionField> </children> </entityActionGroup> diff --git a/entity/ObjectTree_entity/entityfields/alter/children/edit/stateProcess.js b/entity/ObjectTree_entity/entityfields/alter/children/edit/stateProcess.js deleted file mode 100644 index 60b83bbcbd21fecc83049a4f8909cfd74837fb33..0000000000000000000000000000000000000000 --- a/entity/ObjectTree_entity/entityfields/alter/children/edit/stateProcess.js +++ /dev/null @@ -1,30 +0,0 @@ -import("system.logging"); -import("system.result"); -import("system.neon"); -import("system.vars"); -logging.log("aaaaaaaaaaaaa " + vars.get("$sys.selection")) -logging.log("aaaaaaaaaaaaa " + vars.get("$sys." + "viewmode")) -if (vars.get("$sys." + "viewmode") == neon.FRAME_VIEWMODE_COMPONENT) -if (vars.exists("$sys." + "selection") && vars.get("$sys." + "selection")) -{ - var selectedRows = JSON.parse(vars.get("$sys." + "selection")); - var isObjectRelationNode = false; - if (selectedRows.length > 0) - { - logging.log(selectedRows.toSource()) - var uid = JSON.parse(selectedRows[0]); - logging.log(uid.toSource()) - isObjectRelationNode = typeof uid[2] == "string"; - } - logging.log(isObjectRelationNode) - if (isObjectRelationNode) - { - result.string(neon.COMPONENTSTATE_EDITABLE) - } - else - { - result.string(neon.COMPONENTSTATE_DISABLED) - } -} -else - result.string(neon.COMPONENTSTATE_DISABLED) \ No newline at end of file diff --git a/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js b/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js index 70b8263604a7974af3221512a62910e4578da340..565597b0b451171e4b92810f6e25092471050650 100644 --- a/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js @@ -30,8 +30,6 @@ if (uidParam) _insertEntry(tree, _getEntryData(uid[0], relationTypeData[3], relationTypeData[7], relationTypeData[8], undefined, false, uid[6]), "", 0, uid[3], relationTypeData[10]); } - /* else - tree = [["", "", "", "", "", "", "", ""]]*/ } else { @@ -163,17 +161,12 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, if (direction == "same") relationTypeIdForNew = thisRelationTypeId - // add both sides. Only one will succeed, because the prevObjectId will be filtered and it will just return [] - let uids = _insertEntry(tree, entryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, 0); + // add both sides. Only one will succeed, because the prevObjectId will be filtered + _insertEntry(tree, entryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, 0); if (direction == "same") { var otherEntryData = _getEntryData(pNodeId[0], "normal", relationType1, relationType2, prevObjectId, true); - uids = uids.concat(_insertEntry(tree, otherEntryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, 1)); - } - - for (let i = 0; i < uids.length; i++) - { - _loadObjectRelationTree(uids[i][0], uids[i][3], pObjectRelationTypeId, uids[i], pLayer+1, pRelationTypeData); + uids.concat(_insertEntry(tree, otherEntryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, 1)); } } } diff --git a/entity/Object_entity/recordcontainers/jdito/contentProcess.js b/entity/Object_entity/recordcontainers/jdito/contentProcess.js index 4497cff4006889629e44c87348ca9169084ad09b..cc897167253658a76227405133616de5a988b233 100644 --- a/entity/Object_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Object_entity/recordcontainers/jdito/contentProcess.js @@ -1,3 +1,4 @@ +import("system.logging"); import("system.db"); import("system.vars"); import("system.result"); @@ -10,6 +11,9 @@ if (vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param" if (vars.exists("$param.ExcludedObjectIds_param") && vars.get("$param.ExcludedObjectIds_param")) excludedIds = JSON.parse(vars.get("$param.ExcludedObjectIds_param")); + logging.log("aa22aa" + vars.get("$param.ExcludedObjectIds_param").toSource()) + logging.log("aa22aa" + vars.get("$param.ObjectType_param").toSource()) + result.object(db.table(ContextUtils.getContextDataSql(vars.get("$param.ObjectType_param"), undefined, false, undefined, false, excludedIds))) } else diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index bbbd5c1c673c453915abee455e018c9e2605a10c..6e444797931037109e109f8c9694e4b6914eb1ae 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -564,7 +564,7 @@ </entityParameter> <entityConsumer> <name>ObjectTrees</name> - <title>Relation tree</title> + <title>Object relation</title> <fieldType>DEPENDENCY_OUT</fieldType> <dependency> <name>dependency</name> diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod index 2e33f29ccd7b0228e1b8f5302e0b81ff05522101..eb5d2f205c8ab918c884b8f2ebd5eed59e2db9bb 100644 --- a/entity/Person_entity/Person_entity.aod +++ b/entity/Person_entity/Person_entity.aod @@ -637,7 +637,7 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact </entityConsumer> <entityConsumer> <name>ObjectTrees</name> - <title>Relation tree</title> + <title>Object relation</title> <fieldType>DEPENDENCY_OUT</fieldType> <dependency> <name>dependency</name> diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod index db5e07b9e3594eb3216894572c5d445139345adf..bc40627b52c39d972ed1a70c08ce657d7771a15b 100644 --- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod +++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod @@ -2742,9 +2742,60 @@ <entry> <key>Salesproject phases</key> </entry> + <entry> + <key>Object type 1</key> + </entry> + <entry> + <key>Object type 2</key> + </entry> + <entry> + <key>Objectrelation type</key> + </entry> <entry> <key>Key figures</key> </entry> + <entry> + <key>Delete all usage</key> + </entry> + <entry> + <key>Deleted all usages of \"%0\".</key> + </entry> + <entry> + <key>promotion target ofc</key> + </entry> + <entry> + <key>Successful</key> + </entry> + <entry> + <key>Relation type 1</key> + </entry> + <entry> + <key>Relation type 2</key> + </entry> + <entry> + <key>Relation type</key> + </entry> + <entry> + <key>Context 1</key> + </entry> + <entry> + <key>Context 2</key> + </entry> + <entry> + <key>Title 1</key> + </entry> + <entry> + <key>Title 2</key> + </entry> + <entry> + <key>Hierarchy</key> + </entry> + <entry> + <key>Object relation</key> + </entry> + <entry> + <key>Type 2 enabled</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> <sqlModels> diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index e520e492190ea77c1f2f5078029567c3c951e273..735158662360baa2d5c7304604c3348859dfeaa8 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -3250,6 +3250,7 @@ </entry> <entry> <key>Object tree</key> + <value>Beziehungen</value> </entry> <entry> <key>&Aufg / Term (%0/%1)</key> @@ -3539,6 +3540,108 @@ <entry> <key>Salesproject Phases</key> </entry> + <entry> + <key>Salesproject Phases</key> + </entry> + <entry> + <key>Key figures</key> + </entry> + <entry> + <key>Objectrelation type</key> + <value>Beziehungstyp</value> + </entry> + <entry> + <key>Kennzahlen</key> + </entry> + <entry> + <key>Count</key> + </entry> + <entry> + <key>Forecast actual year </key> + </entry> + <entry> + <key>Chart</key> + </entry> + <entry> + <key>Salesproject Charts</key> + </entry> + <entry> + <key>Relation</key> + </entry> + <entry> + <key>Zeigt wie viele Vertriebsprojekte in den einzelnen Vertriebsphasen sind. </key> + </entry> + <entry> + <key>test1eee</key> + </entry> + <entry> + <key>Object type 1</key> + <value>Typ 1</value> + </entry> + <entry> + <key>Object type 2</key> + <value>Typ 2</value> + </entry> + <entry> + <key>test2</key> + </entry> + <entry> + <key>Title 1</key> + <value>Titel 1</value> + </entry> + <entry> + <key>Title 2</key> + <value>Titel 2</value> + </entry> + <entry> + <key>Hierarchy</key> + <value>Hierarchie</value> + </entry> + <entry> + <key>Object relation</key> + <value>Beziehungen</value> + </entry> + <entry> + <key>Type 2 enabled</key> + <value>Typ 2 aktiviert</value> + </entry> + <entry> + <key>Relation type 1</key> + <value>Beziehungsart 1</value> + </entry> + <entry> + <key>Relation type 2</key> + <value>Beziehungsart 2</value> + </entry> + <entry> + <key>Relation type</key> + <value>Beziehungstyp</value> + </entry> + <entry> + <key>Context 1</key> + <value>Kontext 1</value> + </entry> + <entry> + <key>Context 2</key> + <value>Kontext2</value> + </entry> + <entry> + <key>Tochter</key> + </entry> + <entry> + <key>Delete all usage</key> + <value>Lösche jede Verwendung</value> + </entry> + <entry> + <key>Deleted all usages of \"%0\".</key> + <value>Jede Verwendung von \"%0\" wurde gelöscht.</value> + </entry> + <entry> + <key>promotion target ofc</key> + </entry> + <entry> + <key>Successful</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod index 0cd508f221c0b3df5c5c887b557e9ee01a7d1366..698a13751f1a5437735a6ed2aff5d8a440bd1bc4 100644 --- a/language/_____LANGUAGE_en/_____LANGUAGE_en.aod +++ b/language/_____LANGUAGE_en/_____LANGUAGE_en.aod @@ -2776,6 +2776,54 @@ <entry> <key>Key figures</key> </entry> + <entry> + <key>Relation</key> + </entry> + <entry> + <key>Object type 1</key> + </entry> + <entry> + <key>Object type 2</key> + </entry> + <entry> + <key>Title 1</key> + </entry> + <entry> + <key>Title 2</key> + </entry> + <entry> + <key>Hierarchy</key> + </entry> + <entry> + <key>Object relation</key> + </entry> + <entry> + <key>Relation type 1</key> + </entry> + <entry> + <key>Relation type 2</key> + </entry> + <entry> + <key>Relation type</key> + </entry> + <entry> + <key>Context 1</key> + </entry> + <entry> + <key>Context 2</key> + </entry> + <entry> + <key>Delete all usage</key> + </entry> + <entry> + <key>Deleted all usages of \"%0\".</key> + </entry> + <entry> + <key>promotion target ofc</key> + </entry> + <entry> + <key>Successful</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> </language> diff --git a/neonContext/ObjectRelationType/ObjectRelationType.aod b/neonContext/ObjectRelationType/ObjectRelationType.aod index f3285ed72a72b2f7e2d2c18ddc921ce671c1717c..5e82a5275611386b972a0109437cf5a6a97dbf9d 100644 --- a/neonContext/ObjectRelationType/ObjectRelationType.aod +++ b/neonContext/ObjectRelationType/ObjectRelationType.aod @@ -1,6 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> <neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0"> <name>ObjectRelationType</name> + <title>Relation type</title> <majorModelMode>DISTRIBUTED</majorModelMode> + <filterview>ObjectRelationTypeFilter_view</filterview> + <editview>ObjectRelationTypeEdit_view</editview> + <preview>ObjectRelationTypePreview_view</preview> <entity>ObjectRelationType_entity</entity> + <references> + <neonViewReference> + <name>3bee0408-8a9b-4188-8ebf-0b9671bbf436</name> + <view>ObjectRelationTypeFilter_view</view> + </neonViewReference> + <neonViewReference> + <name>afb5b3c7-fb34-4511-8b72-34808d64e226</name> + <view>ObjectRelationTypeEdit_view</view> + </neonViewReference> + <neonViewReference> + <name>b4cb3fc0-03ed-48d5-bd0c-725623865bc3</name> + <view>ObjectRelationTypePreview_view</view> + </neonViewReference> + </references> </neonContext> diff --git a/neonView/ObjectRelationTypeEdit_view/ObjectRelationTypeEdit_view.aod b/neonView/ObjectRelationTypeEdit_view/ObjectRelationTypeEdit_view.aod new file mode 100644 index 0000000000000000000000000000000000000000..03950156117d7a1eb4f37b9efb67b833453a8c7b --- /dev/null +++ b/neonView/ObjectRelationTypeEdit_view/ObjectRelationTypeEdit_view.aod @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.1"> + <name>ObjectRelationTypeEdit_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <boxLayout> + <name>layout</name> + </boxLayout> + </layout> + <children> + <genericViewTemplate> + <name>Info</name> + <editMode v="true" /> + <entityField>#ENTITY</entityField> + <fields> + <entityFieldLink> + <name>adb2c427-89fd-4f8d-abae-39c8273c9916</name> + <entityField>SOURCE_RELATION_TITLE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>ffaf9de0-6866-4d0a-80af-42b57169d83e</name> + <entityField>SOURCE_OBJECT_TYPE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>0fd227e4-2896-4ce3-b699-8e5ce82a2862</name> + <entityField>DEST_RELATION_TITLE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>e7578539-f60d-4136-af56-9fd587ed34ec</name> + <entityField>DEST_OBJECT_TYPE</entityField> + </entityFieldLink> + <entityFieldLink> + <name>945f613e-ce96-419d-8a71-f3196e41e444</name> + <entityField>HIERARCHY</entityField> + </entityFieldLink> + </fields> + </genericViewTemplate> + </children> +</neonView> diff --git a/neonView/ObjectRelationTypeFilter_view/ObjectRelationTypeFilter_view.aod b/neonView/ObjectRelationTypeFilter_view/ObjectRelationTypeFilter_view.aod new file mode 100644 index 0000000000000000000000000000000000000000..474bfcaaf5f51ab1861982ad275bc228d867326e --- /dev/null +++ b/neonView/ObjectRelationTypeFilter_view/ObjectRelationTypeFilter_view.aod @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.1"> + <name>ObjectRelationTypeFilter_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <boxLayout> + <name>layout</name> + </boxLayout> + </layout> + <children> + <tableViewTemplate> + <name>RelationTypes</name> + <entityField>#ENTITY</entityField> + <columns> + <neonTableColumn> + <name>e526e3fb-2776-42f9-b75e-67a5dc7bde9d</name> + <entityField>SOURCE_RELATION_TITLE</entityField> + </neonTableColumn> + <neonTableColumn> + <name>89ee84eb-b50b-47e4-863c-7537c8a2c1d0</name> + <entityField>SOURCE_OBJECT_TYPE</entityField> + </neonTableColumn> + <neonTableColumn> + <name>2230c73a-f5d9-44bb-bcfa-67d42a24881b</name> + <entityField>DEST_RELATION_TITLE</entityField> + </neonTableColumn> + <neonTableColumn> + <name>755d8ce7-3995-457c-b5f2-39f5aae361f6</name> + <entityField>DEST_OBJECT_TYPE</entityField> + </neonTableColumn> + <neonTableColumn> + <name>3e9e27c1-e971-4431-9f47-1d8fe436be76</name> + <entityField>HIERARCHY</entityField> + </neonTableColumn> + </columns> + </tableViewTemplate> + </children> +</neonView> diff --git a/neonView/ObjectRelationTypePreview_view/ObjectRelationTypePreview_view.aod b/neonView/ObjectRelationTypePreview_view/ObjectRelationTypePreview_view.aod new file mode 100644 index 0000000000000000000000000000000000000000..0b02d9141e2ecf589fc746a1b7ad2547da75ed6b --- /dev/null +++ b/neonView/ObjectRelationTypePreview_view/ObjectRelationTypePreview_view.aod @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.1"> + <name>ObjectRelationTypePreview_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <boxLayout> + <name>layout</name> + </boxLayout> + </layout> + <children> + <cardViewTemplate> + <name>header</name> + <titleField>SOURCE_RELATION_TITLE</titleField> + <entityField>#ENTITY</entityField> + </cardViewTemplate> + </children> +</neonView> diff --git a/neonView/OrganisationMain_view/OrganisationMain_view.aod b/neonView/OrganisationMain_view/OrganisationMain_view.aod index 33c7ef256855c1d91ec0170016f587594724fe36..af17888c14a947777afbc2d620121e72bba2695e 100644 --- a/neonView/OrganisationMain_view/OrganisationMain_view.aod +++ b/neonView/OrganisationMain_view/OrganisationMain_view.aod @@ -45,11 +45,6 @@ <entityField>Documents</entityField> <view>DocumentFilter_view</view> </neonViewReference> - <neonViewReference> - <name>ab7d3db4-af9d-4903-b28a-6347f2512a54</name> - <entityField>ObjectRelations</entityField> - <view>ObjectRelationFilter_view</view> - </neonViewReference> <neonViewReference> <name>c82aff98-ede5-4d9e-a902-89f71ed7dbb0</name> <entityField>ObjectTrees</entityField> diff --git a/neonView/PersonMain_view/PersonMain_view.aod b/neonView/PersonMain_view/PersonMain_view.aod index 81c60ecc29cb6d4929fc9e8d777ce5efc4887a91..6720704e06d6404674dfcbb9408080701567e088 100644 --- a/neonView/PersonMain_view/PersonMain_view.aod +++ b/neonView/PersonMain_view/PersonMain_view.aod @@ -34,11 +34,6 @@ <entityField>Documents</entityField> <view>DocumentFilter_view</view> </neonViewReference> - <neonViewReference> - <name>a713a58e-eae0-4657-9cb0-ffffbd41d4ab</name> - <entityField>ObjectRelations</entityField> - <view>ObjectRelationFilter_view</view> - </neonViewReference> <neonViewReference> <name>cb8ff3df-772b-4c12-8814-f9101295b1ba</name> <entityField>ObjectTrees</entityField> diff --git a/process/ObjectRelation_lib/process.js b/process/ObjectRelation_lib/process.js index f44bc3ead9245e888330ea4bbbac35e3f80db11e..710f0c64e95ef07b4835a417bb2f5a216ee9d4ae 100644 --- a/process/ObjectRelation_lib/process.js +++ b/process/ObjectRelation_lib/process.js @@ -13,59 +13,81 @@ function ObjectRelationUtils() {} * Get all possible relationTypes by a objectType. (objectrelationtypeId and title) * Normally it only returns the id and title. If you set pFullInfo to true, you will get additional information, too. * - * @param {String} pObjectType the object type to load the relation types for.] - * @param {Boolean} [pFullInfo=false] return also RELATION_TYPE, direction (normal, reverse, same), hierarchy, OBJECT_TYPE dest, OBJECT_TYPE source, objectrelationtypeId1, objectrelationtypeId2, side, objectrelationtypeId + * @param {String} [pObjectType=undefined] the object type to load the relation types for.] + * @param {Boolean} [pFullInfo=false] return also RELATION_TYPE, direction (normal, reverse, same), hierarchy, OBJECT_TYPE dest, OBJECT_TYPE source, objectrelationtypeId1, objectrelationtypeId2, side, objectrelationtypeId, other title * * @return {String[][]} */ -ObjectRelationUtils.getPossibleRelationTypes = function(pObjectType, pFullInfo) +ObjectRelationUtils.getPossibleRelationTypes = function(pObjectType, pFullInfo, pOnlyFirstSide, pRelationTypeId) { var sql = " from AB_OBJECTRELATIONTYPE main \n\ - left join AB_OBJECTRELATIONTYPE type2 on (type2.AB_OBJECTRELATIONTYPEID <> main.AB_OBJECTRELATIONTYPEID and type2.RELATION_TYPE = main.RELATION_TYPE) \n\ - where case when type2.OBJECT_TYPE is null then main.OBJECT_TYPE else type2.OBJECT_TYPE end = ? " + left join AB_OBJECTRELATIONTYPE type2 on (type2.AB_OBJECTRELATIONTYPEID <> main.AB_OBJECTRELATIONTYPEID and type2.RELATION_TYPE = main.RELATION_TYPE) "; + var cond = ""; - // only id and title: - if (pFullInfo == undefined || pFullInfo == false) + var params = []; + + if (pObjectType) + { + cond = "where case when type2.OBJECT_TYPE is null then main.OBJECT_TYPE else type2.OBJECT_TYPE end = ? " + params.push([pObjectType, db.getColumnTypes("AB_OBJECTRELATIONTYPE", ["OBJECT_TYPE"])[0]]); + } + + if (pRelationTypeId) { - pFullInfo = []; + if (!cond) + cond = "where "; + else + cond += " and "; - return (db.table( - ["select main.AB_OBJECTRELATIONTYPEID, main.RELATION_TITLE" + sql, - [ - [pObjectType, db.getColumnTypes("AB_OBJECTRELATIONTYPE", ["OBJECT_TYPE"])[0]] - ] - ])); + cond += " main.AB_OBJECTRELATIONTYPEID = ? "; + params.push([pRelationTypeId, db.getColumnTypes("AB_OBJECTRELATIONTYPE", ["AB_OBJECTRELATIONTYPEID"])[0]]); + } + + if (pOnlyFirstSide == "1") + { + if (!cond) + cond = "where "; + else + cond += " and "; + cond += " main.SIDE = 1 " } - // full info: - var relationTypes = (db.table( - ["select main.AB_OBJECTRELATIONTYPEID, main.RELATION_TITLE, main.RELATION_TYPE, \n\ + sql += cond; + + // only id and title: + if (pFullInfo == undefined || pFullInfo == false) + { + sql = "select main.AB_OBJECTRELATIONTYPEID, main.RELATION_TITLE" + sql; + } + else + { + sql = "select main.AB_OBJECTRELATIONTYPEID, main.RELATION_TITLE, main.RELATION_TYPE, \n\ case when type2.AB_OBJECTRELATIONTYPEID is null then 'same' \n\ when main.SIDE = 1 then 'normal'\n\ else 'reverse'\n\ end direction,\n\ main.HIERARCHY, \n\ - type2.OBJECT_TYPE objectType, \n\ - main.OBJECT_TYPE objectType, \n\ + type2.OBJECT_TYPE destObjectType, \n\ + main.OBJECT_TYPE sourceObjectType, \n\ -- typeId of Object2\n\ case when main.SIDE = 1 then main.AB_OBJECTRELATIONTYPEID\n\ else type2.AB_OBJECTRELATIONTYPEID end objectrelationtypeId1,\n\ -- typeId of Object1\n\ case when type2.AB_OBJECTRELATIONTYPEID is null or main.SIDE = 2 then main.AB_OBJECTRELATIONTYPEID\n\ else type2.AB_OBJECTRELATIONTYPEID end objectrelationtypeId2, \n\ - main.SIDE, case when type2.AB_OBJECTRELATIONTYPEID is null then main.AB_OBJECTRELATIONTYPEID else type2.AB_OBJECTRELATIONTYPEID end" + sql, - [ - [pObjectType, db.getColumnTypes("AB_OBJECTRELATIONTYPE", ["OBJECT_TYPE"])[0]] - ] - ])); - - return relationTypes; + main.SIDE,\n\ + case when type2.AB_OBJECTRELATIONTYPEID is null then main.AB_OBJECTRELATIONTYPEID else type2.AB_OBJECTRELATIONTYPEID end,\n\ + type2.RELATION_TITLE" + sql; + } + + // full info: + return (db.table([sql, params])); } /** * Get relationType by a RelationTypeId. - * returns the objectrelationtypeId, title, RELATION_TYPE, direction (normal, reverse, same), hierarchy, OBJECT_TYPE dest, OBJECT_TYPE source, objectrelationtypeId1, objectrelationtypeId2, side,objectrelationtypeId + * returns the objectrelationtypeId, title, RELATION_TYPE, direction (normal, reverse, same), hierarchy, OBJECT_TYPE dest, OBJECT_TYPE source, objectrelationtypeId1, objectrelationtypeId2, side,objectrelationtypeId, other title * * @param {String} pRelationTypeId the RelationTypeId to load the full relation type for. * @@ -73,32 +95,9 @@ ObjectRelationUtils.getPossibleRelationTypes = function(pObjectType, pFullInfo) */ ObjectRelationUtils.getRelationType = function(pRelationTypeId) { - // TODO: funktionen evtl. zusammenfassen - var sql = " from AB_OBJECTRELATIONTYPE main \n\ - left join AB_OBJECTRELATIONTYPE type2 on (type2.AB_OBJECTRELATIONTYPEID <> main.AB_OBJECTRELATIONTYPEID and type2.RELATION_TYPE = main.RELATION_TYPE) \n\ - where main.AB_OBJECTRELATIONTYPEID = ?" - - // full info: - var relationType = (db.array(db.ROW, - ["select main.AB_OBJECTRELATIONTYPEID, main.RELATION_TITLE, main.RELATION_TYPE, \n\ - case when type2.AB_OBJECTRELATIONTYPEID is null then 'same' \n\ - when main.SIDE = 1 then 'normal'\n\ - else 'reverse'\n\ - end direction,\n\ - main.HIERARCHY, \n\ - type2.OBJECT_TYPE objectType, \n\ - main.OBJECT_TYPE objectType, \n\ - -- typeId of Object2\n\ - case when main.SIDE = 1 then main.AB_OBJECTRELATIONTYPEID\n\ - else type2.AB_OBJECTRELATIONTYPEID end objectrelationtypeId1,\n\ - -- typeId of Object1\n\ - case when type2.AB_OBJECTRELATIONTYPEID is null or main.SIDE = 2 then main.AB_OBJECTRELATIONTYPEID\n\ - else type2.AB_OBJECTRELATIONTYPEID end objectrelationtypeId2, \n\ - main.SIDE, case when type2.AB_OBJECTRELATIONTYPEID is null then main.AB_OBJECTRELATIONTYPEID else type2.AB_OBJECTRELATIONTYPEID end" + sql, - [ - [pRelationTypeId, db.getColumnTypes("AB_OBJECTRELATIONTYPE", ["AB_OBJECTRELATIONTYPEID"])[0]], - ] - ])); - - return relationType; + var data = ObjectRelationUtils.getPossibleRelationTypes(undefined, true, false, pRelationTypeId); + if (data.length > 0) + return data[0]; + else + return []; } \ No newline at end of file