From 9bbe54c550212c1a6fe74604703c407be49d08fb Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Fri, 5 Apr 2019 14:33:09 +0200 Subject: [PATCH] object relation tree inserts / deletes --- aliasDefinition/Data_alias/Data_alias.aod | 62 ++++++++++++++++++ .../recordcontainers/jdito/contentProcess.js | 3 +- .../ObjectTree_entity/ObjectTree_entity.aod | 63 ++++++++++++++++--- .../alter/children/insert/onActionProcess.js | 42 +++++++++++++ .../displayValueProcess.js | 9 +++ .../objectrelationtypeid/onValueChange.js | 38 +++++++++++ .../objectrelationtypeid/stateProcess.js | 12 ++++ .../objectrelationtypeid/valueProcess.js | 8 +++ .../children/objecttype_param/valueProcess.js | 5 ++ .../entityfields/parent_id/valueProcess.js | 9 +++ .../entityfields/selector/onValueChange.js | 3 - .../target_context/valueProcess.js | 9 +++ .../recordcontainers/jdito/contentProcess.js | 45 ++++++++----- .../recordcontainers/jdito/onDelete.js | 21 +++++++ .../recordcontainers/jdito/onInsert.js | 47 ++++++++++++++ entity/Object_entity/Object_entity.aod | 6 ++ neonContext/ObjectTree/ObjectTree.aod | 8 ++- .../ObjectTreeEdit_view.aod | 31 +++++++++ .../ObjectTreeFilter_view.aod} | 4 +- .../OrganisationMain_view.aod | 2 +- neonView/PersonMain_view/PersonMain_view.aod | 2 +- .../Data_alias/basic/2019.2/changelog.xml | 13 ++++ process/ObjectRelation_lib/process.js | 8 +-- 23 files changed, 415 insertions(+), 35 deletions(-) create mode 100644 entity/ObjectTree_entity/entityfields/alter/children/insert/onActionProcess.js create mode 100644 entity/ObjectTree_entity/entityfields/objectrelationtypeid/displayValueProcess.js create mode 100644 entity/ObjectTree_entity/entityfields/objectrelationtypeid/onValueChange.js create mode 100644 entity/ObjectTree_entity/entityfields/objectrelationtypeid/stateProcess.js create mode 100644 entity/ObjectTree_entity/entityfields/objectrelationtypeid/valueProcess.js create mode 100644 entity/ObjectTree_entity/entityfields/objects/children/objecttype_param/valueProcess.js create mode 100644 entity/ObjectTree_entity/entityfields/parent_id/valueProcess.js delete mode 100644 entity/ObjectTree_entity/entityfields/selector/onValueChange.js create mode 100644 entity/ObjectTree_entity/entityfields/target_context/valueProcess.js create mode 100644 entity/ObjectTree_entity/recordcontainers/jdito/onDelete.js create mode 100644 entity/ObjectTree_entity/recordcontainers/jdito/onInsert.js create mode 100644 neonView/ObjectTreeEdit_view/ObjectTreeEdit_view.aod rename neonView/{ObjectTree_view/ObjectTree_view.aod => ObjectTreeFilter_view/ObjectTreeFilter_view.aod} (85%) diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod index 89e097db343..fdfdb64c21b 100644 --- a/aliasDefinition/Data_alias/Data_alias.aod +++ b/aliasDefinition/Data_alias/Data_alias.aod @@ -5954,6 +5954,68 @@ </entityFieldDb> </entityFields> </entityDb> + <entityDb> + <name>TEST</name> + <dbName></dbName> + <idColumn>TESTID</idColumn> + <idGeneratorType v="0" /> + <idGeneratorInterval v="1" /> + <documentation></documentation> + <title></title> + <description></description> + <auditSyncConfig> + <name>auditSyncConfig</name> + <auditMode v="0" /> + <syncActive v="false" /> + <syncComplete v="true" /> + <syncDirection v="1" /> + <syncIds></syncIds> + </auditSyncConfig> + <entityFields> + <entityFieldDb> + <name>TEST2</name> + <dbName></dbName> + <primaryKey v="false" /> + <columnType v="12" /> + <size v="36" /> + <scale v="0" /> + <notNull v="false" /> + <isUnique v="false" /> + <index v="false" /> + <documentation></documentation> + <title></title> + <description></description> + </entityFieldDb> + <entityFieldDb> + <name>TESTID</name> + <dbName></dbName> + <primaryKey v="true" /> + <columnType v="1" /> + <size v="36" /> + <scale v="0" /> + <notNull v="true" /> + <isUnique v="true" /> + <index v="false" /> + <documentation></documentation> + <title></title> + <description></description> + </entityFieldDb> + <entityFieldDb> + <name>TEST1</name> + <dbName></dbName> + <primaryKey v="false" /> + <columnType v="12" /> + <size v="36" /> + <scale v="0" /> + <notNull v="false" /> + <isUnique v="false" /> + <index v="false" /> + <documentation></documentation> + <title></title> + <description></description> + </entityFieldDb> + </entityFields> + </entityDb> </entities> </entityGroup> </aliasDefDb> diff --git a/entity/Document_entity/recordcontainers/jdito/contentProcess.js b/entity/Document_entity/recordcontainers/jdito/contentProcess.js index 6682c389f91..ccee9b0372c 100644 --- a/entity/Document_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Document_entity/recordcontainers/jdito/contentProcess.js @@ -1,3 +1,4 @@ +import("system.logging"); import("system.vars"); import("system.result"); import("system.db"); @@ -16,7 +17,7 @@ if(vars.exists("$param.AssignmentTable_param") && if(vars.exists("$param.Keyword_param")) { keyword = vars.get("$param.Keyword_param"); } - + // Check if multiple Documents are selected if(vars.exists("$local.idvalues") && vars.get("$local.idvalues")) metadata = db.getBinaryMetadataForIds(vars.get("$local.idvalues"), true, alias) diff --git a/entity/ObjectTree_entity/ObjectTree_entity.aod b/entity/ObjectTree_entity/ObjectTree_entity.aod index 02de3b4ff64..1dff17cb99f 100644 --- a/entity/ObjectTree_entity/ObjectTree_entity.aod +++ b/entity/ObjectTree_entity/ObjectTree_entity.aod @@ -38,6 +38,10 @@ <expose v="true" /> <mandatory v="true" /> </entityParameter> + <entityParameter> + <name>RelationType_param</name> + <expose v="false" /> + </entityParameter> </children> </entityProvider> <entityParameter> @@ -53,6 +57,7 @@ <entityField> <name>PARENT_ID</name> <searchable v="false" /> + <valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/parent_id/valueProcess.js</valueProcess> </entityField> <entityField> <name>TITLE</name> @@ -63,14 +68,6 @@ <searchable v="false" /> <valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/icon/valueProcess.js</valueProcess> </entityField> - <entityField> - <name>Selector</name> - <title>Relationtype</title> - <consumer>ObjectRelationTypes</consumer> - <searchable v="true" /> - <state>EDITABLE</state> - <onValueChange>%aditoprj%/entity/ObjectTree_entity/entityfields/selector/onValueChange.js</onValueChange> - </entityField> <entityConsumer> <name>ObjectRelationTypes</name> <fieldType>DEPENDENCY_OUT</fieldType> @@ -102,22 +99,70 @@ </entityField> <entityField> <name>TARGET_ID</name> + <consumer>Objects</consumer> <searchable v="false" /> </entityField> <entityField> <name>TARGET_CONTEXT</name> <searchable v="false" /> + <valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/target_context/valueProcess.js</valueProcess> </entityField> <entityField> <name>INFO</name> <title>Description</title> + <searchable v="false" /> </entityField> + <entityField> + <name>OBJECTRELATIONTYPEID</name> + <title>Relationtype</title> + <consumer>ObjectRelationTypes</consumer> + <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> + <onValueChange>%aditoprj%/entity/ObjectTree_entity/entityfields/objectrelationtypeid/onValueChange.js</onValueChange> + </entityField> + <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> + <title></title> + <valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/objects/children/objecttype_param/valueProcess.js</valueProcess> + <triggerRecalculation v="true" /> + </entityParameter> + </children> + </entityConsumer> + <entityActionGroup> + <name>alter</name> + <children> + <entityActionField> + <name>insert</name> + <fieldType>ACTION</fieldType> + <onActionProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/alter/children/insert/onActionProcess.js</onActionProcess> + <isSelectionAction v="true" /> + <iconId>VAADIN:FILE_TREE_SMALL</iconId> + </entityActionField> + </children> + </entityActionGroup> + <entityParameter> + <name>RelationType_param</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> </entityFields> <recordContainers> <jDitoRecordContainer> <name>jdito</name> <jDitoRecordAlias>Data_alias</jDitoRecordAlias> <contentProcess>%aditoprj%/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js</contentProcess> + <onInsert>%aditoprj%/entity/ObjectTree_entity/recordcontainers/jdito/onInsert.js</onInsert> + <onDelete>%aditoprj%/entity/ObjectTree_entity/recordcontainers/jdito/onDelete.js</onDelete> <recordFields> <element>UID.value</element> <element>TITLE.value</element> @@ -126,7 +171,7 @@ <element>TARGET_ID.value</element> <element>TARGET_CONTEXT.value</element> <element>INFO.value</element> - <element>Selector.value</element> + <element>OBJECTRELATIONTYPEID.value</element> </recordFields> </jDitoRecordContainer> </recordContainers> diff --git a/entity/ObjectTree_entity/entityfields/alter/children/insert/onActionProcess.js b/entity/ObjectTree_entity/entityfields/alter/children/insert/onActionProcess.js new file mode 100644 index 00000000000..571d8ca4e31 --- /dev/null +++ b/entity/ObjectTree_entity/entityfields/alter/children/insert/onActionProcess.js @@ -0,0 +1,42 @@ +import("ObjectRelation_lib"); +import("system.logging"); +import("system.neon"); +import("system.vars"); + +if (vars.exists("$local.rows") && vars.get("$local.rows")) +{ + var selectedRows = JSON.parse(vars.get("$local.rows")); + var uid = JSON.parse(selectedRows[0]["#LOOKUPID"]); + var isObjectRelationNode = typeof uid[2] == "string"; + + logging.log(JSON.parse(selectedRows[0]["#LOOKUPID"]).toSource()) + logging.log(vars.getString("$param.ObjectId_param")) + logging.log(isObjectRelationNode) + + var parentId; + var parentObjectType; + var relationType; + + if (isObjectRelationNode) + { + parentId = uid[0]; + parentObjectType = uid[3]; + // get relationTypeId from the other side + //relationType = ObjectRelationUtils.getRelationType(uid[2])[10]; + } + else + { + parentId = vars.getString("$param.ObjectId_param"); + parentObjectType = vars.getString("$param.ObjectType_param"); + //relationType = uid[2][0]; + } + + var params = { + "ObjectId_param" : parentId, + "ObjectType_param" : parentObjectType, + "RelationType_param" : vars.get("$field.OBJECTRELATIONTYPEID") + }; + + logging.log(params.toSource()) + neon.openContext("ObjectTree", "ObjectTreeEdit_view", null, neon.OPERATINGSTATE_NEW, params); +} \ No newline at end of file diff --git a/entity/ObjectTree_entity/entityfields/objectrelationtypeid/displayValueProcess.js b/entity/ObjectTree_entity/entityfields/objectrelationtypeid/displayValueProcess.js new file mode 100644 index 00000000000..83a799bf342 --- /dev/null +++ b/entity/ObjectTree_entity/entityfields/objectrelationtypeid/displayValueProcess.js @@ -0,0 +1,9 @@ +import("system.translate"); +import("system.result"); +import("system.vars"); +import("ObjectRelation_lib"); + +if (vars.get("$field.OBJECTRELATIONTYPEID")) +{ + result.string(translate.text(ObjectRelationUtils.getRelationType(vars.get("$field.OBJECTRELATIONTYPEID"))[1])); +} diff --git a/entity/ObjectTree_entity/entityfields/objectrelationtypeid/onValueChange.js b/entity/ObjectTree_entity/entityfields/objectrelationtypeid/onValueChange.js new file mode 100644 index 00000000000..9264282cd7b --- /dev/null +++ b/entity/ObjectTree_entity/entityfields/objectrelationtypeid/onValueChange.js @@ -0,0 +1,38 @@ +import("system.vars"); +import("system.db"); +import("system.result"); +import("system.neon"); +import("Sql_lib"); +import("Entity_lib"); + +var selectedObjectRelationTypeId = vars.exists("$field.selectedObjectRelationTypeIdProxy") ? vars.get("$field.selectedObjectRelationTypeIdProxy") : ""; +selectedObjectRelationTypeId = ProcessHandlingUtils.getOnValidationValue(selectedObjectRelationTypeId); + +var relationTypeData = db.array(db.ROW, SqlCondition.begin() + .andPrepare("AB_OBJECTRELATIONTYPE.AB_OBJECTRELATIONTYPEID", selectedObjectRelationTypeId) + .buildSql("select AB_OBJECTRELATIONTYPEID, OBJECT_TYPE, RELATION_TITLE, RELATION_TYPE, SIDE from AB_OBJECTRELATIONTYPE", "1=2")); + +if (relationTypeData[0]) +{ + var otherRelationTypeData = db.array(db.ROW, SqlCondition.begin() + .andPrepare("AB_OBJECTRELATIONTYPE.RELATION_TYPE", relationTypeData[3]) + .andPrepare("AB_OBJECTRELATIONTYPE.SIDE", (relationTypeData[4] == "1" ? "2" : "1")) + .buildSql("select AB_OBJECTRELATIONTYPEID, OBJECT_TYPE, RELATION_TITLE, RELATION_TYPE, SIDE from AB_OBJECTRELATIONTYPE", "1=2")) + if (!otherRelationTypeData[0]) + { + otherRelationTypeData = relationTypeData; + } + + if (relationTypeData[4] == "2") + { + //neon.setFieldValue("$field.AB_OBJECTRELATIONTYPE2", relationTypeData[0]); + //neon.setFieldValue("$field.AB_OBJECTRELATIONTYPE1", otherRelationTypeData[0]); + } + else if (relationTypeData[4] == "1") + { + //neon.setFieldValue("$field.AB_OBJECTRELATIONTYPE1", relationTypeData[0]); + //neon.setFieldValue("$field.AB_OBJECTRELATIONTYPE2", otherRelationTypeData[0]); + } + + // neon.setFieldValue("$field.MySide", otherRelationTypeData[4]); +} diff --git a/entity/ObjectTree_entity/entityfields/objectrelationtypeid/stateProcess.js b/entity/ObjectTree_entity/entityfields/objectrelationtypeid/stateProcess.js new file mode 100644 index 00000000000..7c27f2f690b --- /dev/null +++ b/entity/ObjectTree_entity/entityfields/objectrelationtypeid/stateProcess.js @@ -0,0 +1,12 @@ +import("system.result"); +import("system.vars"); +import("system.neon"); + +if (vars.exists("$param.RelationType_param") && vars.get("$param.RelationType_param")) +{ + result.string(neon.COMPONENTSTATE_DISABLED); +} +else +{ + result.string(neon.COMPONENTSTATE_AUTO); +} \ No newline at end of file diff --git a/entity/ObjectTree_entity/entityfields/objectrelationtypeid/valueProcess.js b/entity/ObjectTree_entity/entityfields/objectrelationtypeid/valueProcess.js new file mode 100644 index 00000000000..6dad72dac58 --- /dev/null +++ b/entity/ObjectTree_entity/entityfields/objectrelationtypeid/valueProcess.js @@ -0,0 +1,8 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.RelationType_param") && vars.get("$param.RelationType_param")) +{ + result.string(vars.get("$param.RelationType_param")) +} \ No newline at end of file diff --git a/entity/ObjectTree_entity/entityfields/objects/children/objecttype_param/valueProcess.js b/entity/ObjectTree_entity/entityfields/objects/children/objecttype_param/valueProcess.js new file mode 100644 index 00000000000..85f399b856a --- /dev/null +++ b/entity/ObjectTree_entity/entityfields/objects/children/objecttype_param/valueProcess.js @@ -0,0 +1,5 @@ +import("system.logging"); +import("system.vars"); +import("system.result"); +logging.log(vars.get("$field.TARGET_CONTEXT")) +result.string(vars.get("$field.TARGET_CONTEXT")); \ No newline at end of file diff --git a/entity/ObjectTree_entity/entityfields/parent_id/valueProcess.js b/entity/ObjectTree_entity/entityfields/parent_id/valueProcess.js new file mode 100644 index 00000000000..7eed476d464 --- /dev/null +++ b/entity/ObjectTree_entity/entityfields/parent_id/valueProcess.js @@ -0,0 +1,9 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); +import("ObjectRelation_lib"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.ObjectId_param") && vars.get("$param.ObjectId_param")) +{ + result.string(vars.get("$param.ObjectId_param")); +} \ No newline at end of file diff --git a/entity/ObjectTree_entity/entityfields/selector/onValueChange.js b/entity/ObjectTree_entity/entityfields/selector/onValueChange.js deleted file mode 100644 index 821651c14e6..00000000000 --- a/entity/ObjectTree_entity/entityfields/selector/onValueChange.js +++ /dev/null @@ -1,3 +0,0 @@ -import("system.neon"); - -neon.refresh() \ No newline at end of file diff --git a/entity/ObjectTree_entity/entityfields/target_context/valueProcess.js b/entity/ObjectTree_entity/entityfields/target_context/valueProcess.js new file mode 100644 index 00000000000..700dc7461b5 --- /dev/null +++ b/entity/ObjectTree_entity/entityfields/target_context/valueProcess.js @@ -0,0 +1,9 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); +import("ObjectRelation_lib"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT) +{ + result.string(ObjectRelationUtils.getRelationType(vars.get("$field.OBJECTRELATIONTYPEID"))[6]); +} \ 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 2496696dde7..ddabafed1e7 100644 --- a/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js @@ -1,3 +1,4 @@ +import("system.logging"); import("system.db"); import("system.translate"); import("system.result"); @@ -5,7 +6,6 @@ import("system.vars"); import("ObjectRelation_lib"); import("Context_lib"); import("Sql_lib"); -import("system.tools"); var tree = [] var filter = JSON.parse(vars.get("$local.filter")) @@ -54,7 +54,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, currentObjectId = _getRootID(currentObjectId, relationTypeData); } - let uids = _insertEntry(tree, [[currentObjectId, "", "", "", "", ""]], pNodeId, pLayer, pObjectType) + let uids = _insertEntry(tree, [[currentObjectId, "", "", "", "", relationTypeData[7]]], pNodeId, pLayer, pObjectType, selectedRelationType) for (let i = 0; i < uids.length; i++) { _loadObjectRelationTree(uids[i][0], uids[i][3], relationTypeData[0], uids[i], pLayer+1, relationTypeData); @@ -75,7 +75,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, // TODO: Icons, BINDATA // var icon = getIcon... let uid = [currentObjectId, i, relationTypes[i]]; - tree.push([JSON.stringify(uid), translate.text(relationTypes[i][1]), JSON.stringify(pNodeId), true, null, null, "", ""]); + tree.push([JSON.stringify(uid), translate.text(relationTypes[i][1]), JSON.stringify(pNodeId), true, null, null, "", relationTypes[i][0]]); _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, uid, pLayer+1, relationTypeData); } @@ -87,18 +87,31 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, // if no relationType given, load from nodeId if (!pRelationTypeData) pRelationTypeData = pNodeId[2]; - + logging.log("aaa " + pRelationTypeData.toSource()) + var thisRelationTypeId = pRelationTypeData[0]; + var otherRelationTypeId = pRelationTypeData[10]; var hierarchy = pRelationTypeData[4]; var destObjectType = pRelationTypeData[6]; var relationType1 = pRelationTypeData[7]; var relationType2 = pRelationTypeData[8]; var direction = pRelationTypeData[3]; + var relationTypeIdForNew = otherRelationTypeId; + if (hierarchy == "1") { var myData = _getEntryData(pNodeId[0], direction, relationType1, relationType2) - let uids = _insertEntry(tree, myData, pNodeId, pLayer, destObjectType) + + + // if hierarchy and selected RelationType -> use the selected one + if (selectedRelationType) + relationTypeIdForNew = selectedRelationType + else + relationTypeIdForNew = thisRelationTypeId; + + + let uids = _insertEntry(tree, myData, pNodeId, pLayer, destObjectType, relationTypeIdForNew) for (let i = 0; i < uids.length; i++) { _loadObjectRelationTree(uids[i][0], uids[i][3], pObjectRelationTypeId, uids[i], pLayer+1, pRelationTypeData); @@ -115,12 +128,15 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, var entryData = _getEntryData(pNodeId[0], direction, relationType1, relationType2, prevObjectId, true); + 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, 0); + let uids = _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, 1)); + uids = uids.concat(_insertEntry(tree, otherEntryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, 1)); } for (let i = 0; i < uids.length; i++) @@ -134,7 +150,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, /** * load data for a relation. - * OBJECT_ROWID, AB_OBJECTRELATIONID, OBJECT_TYPE, RELATION_TITLE + * OBJECT_ROWID, AB_OBJECTRELATIONID, OBJECT_TYPE, RELATION_TITLE, AB_OBJECTRELATIONTYPEID * * @param {String} pObjectId * @param {String} pDirection @@ -181,7 +197,7 @@ function _getEntryData(pObjectId, pDirection, pRelationType1, pRelationType2, pP // var image = getImageObject("Beziehung"); var data = db.table(cond.buildSql( - "select OBJECT" + otherNum + "_ROWID, AB_OBJECTRELATIONID, OBJECT_TYPE, RELATION_TITLE, INFO \n\ + "select OBJECT" + otherNum + "_ROWID, AB_OBJECTRELATIONID, OBJECT_TYPE, RELATION_TITLE, INFO, AB_OBJECTRELATIONTYPEID \n\ from AB_OBJECTRELATION \n\ join AB_OBJECTRELATIONTYPE on AB_OBJECTRELATIONTYPEID = AB_OBJECTRELATIONTYPE" + myNum + " and ","1=2", "", false)); @@ -209,11 +225,12 @@ function _getRelationTypes(pObjectType) * @param {Array[][]} pNodeId id of the parent * @param {Integer} pLayer layernumber * @param {String} pObjectType + * @param {String} pNewRelationTypeId the RelationType, a new relation should have, if this node is selected. * @param {Integer} [pNum=undefined] optional number added to the key. Needed, if the key would not be unique. * - * @return {Array[][]} the uids of the inserted data. Consists of [ObjectId, pEntryData-Index, ""(not needed anymore), pObjectType, pNodeId, objectrelationid, objecttype + * @return {Array[][]} the uids of the inserted data. Consists of [ObjectId, pEntryData-Index, AB_OBJECTRELATIONTYPEID, pObjectType, pNodeId, objectrelationid, objecttype */ -function _insertEntry(pTree, pEntryData, pNodeId, pLayer, pObjectType, pNum) +function _insertEntry(pTree, pEntryData, pNodeId, pLayer, pObjectType, pNewRelationTypeId, pNum) { var expanded = true; if (pLayer > 10) expanded = false; @@ -222,12 +239,12 @@ function _insertEntry(pTree, pEntryData, pNodeId, pLayer, pObjectType, pNum) for(let i = 0; i < pEntryData.length; i++) { var display = db.cell(ContextUtils.getNameSql(pObjectType, pEntryData[i][0])); - // TODO: Icon - var uid = [pEntryData[i][0], i, "", pObjectType, pNodeId, pEntryData[i][2], pEntryData[i][1]] + // TODO: Icon + var uid = [pEntryData[i][0], i, pEntryData[i][5], pObjectType, pNodeId, pEntryData[i][2], pEntryData[i][1]] if (pNum) uid.push(pNum); uids.push(uid); - pTree.push([JSON.stringify(uid), display, JSON.stringify(pNodeId), expanded, pEntryData[i][0], pObjectType, pEntryData[i][4], ""]); + pTree.push([JSON.stringify(uid), display, JSON.stringify(pNodeId), expanded, pEntryData[i][0], pObjectType, pEntryData[i][4], pNewRelationTypeId]); } return uids; } diff --git a/entity/ObjectTree_entity/recordcontainers/jdito/onDelete.js b/entity/ObjectTree_entity/recordcontainers/jdito/onDelete.js new file mode 100644 index 00000000000..86e11604e1a --- /dev/null +++ b/entity/ObjectTree_entity/recordcontainers/jdito/onDelete.js @@ -0,0 +1,21 @@ +import("system.logging"); +import("system.vars"); +import("system.neon"); +import("system.db"); +import("Sql_lib"); + + +var uid = JSON.parse(vars.get("$field.UID")); +var isObjectRelationNode = typeof uid[2] == "string"; + +if (isObjectRelationNode) +{ + var objectRelationId = uid[6]; + logging.log("delete: " + objectRelationId) + db.deleteData("AB_OBJECTRELATION", SqlCondition.begin() + .andPrepareIfSet("AB_OBJECTRELATION.AB_OBJECTRELATIONID", objectRelationId) + .build("1=2")); + + // Refresh otherwise the children of the deleted node would be moved to the root. + neon.refresh(); +} diff --git a/entity/ObjectTree_entity/recordcontainers/jdito/onInsert.js b/entity/ObjectTree_entity/recordcontainers/jdito/onInsert.js new file mode 100644 index 00000000000..9be46d3b15a --- /dev/null +++ b/entity/ObjectTree_entity/recordcontainers/jdito/onInsert.js @@ -0,0 +1,47 @@ +import("system.util"); +import("ObjectRelation_lib"); +import("system.vars"); +import("system.db"); + +selectedObjectRelationTypeId = vars.get("$field.OBJECTRELATIONTYPEID"); +if (selectedObjectRelationTypeId) +{ + relationTypeData = ObjectRelationUtils.getRelationType(selectedObjectRelationTypeId) + if (relationTypeData[0]) + { + var relationType1 = relationTypeData[7]; + var relationType2 = relationTypeData[8]; + var side = relationTypeData[9]; + var objectId1; + var objectId2; + var info = vars.get("$field.INFO"); + + + if (side == "1") + { + objectId1 = vars.get("$field.TARGET_ID"); + objectId2 = vars.get("$field.PARENT_ID"); + } + else + { + objectId1 = vars.get("$field.PARENT_ID"); + objectId2 = vars.get("$field.TARGET_ID"); + } + + db.insertData("AB_OBJECTRELATION", [ + "AB_OBJECTRELATIONID", + "OBJECT1_ROWID", + "OBJECT2_ROWID", + "AB_OBJECTRELATIONTYPE1", + "AB_OBJECTRELATIONTYPE2", + "INFO" + ], null, [ + util.getNewUUID(), + objectId1, + objectId2, + relationType1, + relationType2, + info + ]); + } +} \ No newline at end of file diff --git a/entity/Object_entity/Object_entity.aod b/entity/Object_entity/Object_entity.aod index 62d80564faf..7dedc47f217 100644 --- a/entity/Object_entity/Object_entity.aod +++ b/entity/Object_entity/Object_entity.aod @@ -86,6 +86,12 @@ <fieldName>Objects</fieldName> <isConsumer v="false" /> </entityDependency> + <entityDependency> + <name>e55777a1-7dfc-46b3-b0e3-318eeecf018e</name> + <entityName>ObjectTree_entity</entityName> + <fieldName>Objects</fieldName> + <isConsumer v="false" /> + </entityDependency> </dependencies> <children> <entityParameter> diff --git a/neonContext/ObjectTree/ObjectTree.aod b/neonContext/ObjectTree/ObjectTree.aod index b7ae46a2ca9..a8f24a44156 100644 --- a/neonContext/ObjectTree/ObjectTree.aod +++ b/neonContext/ObjectTree/ObjectTree.aod @@ -2,11 +2,17 @@ <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>ObjectTree</name> <majorModelMode>DISTRIBUTED</majorModelMode> + <filterview>ObjectTreeFilter_view</filterview> + <editview>ObjectTreeEdit_view</editview> <entity>ObjectTree_entity</entity> <references> <neonViewReference> <name>0c9fc36e-e3f7-4198-b675-5d9ddb177611</name> - <view>ObjectTree_view</view> + <view>ObjectTreeFilter_view</view> + </neonViewReference> + <neonViewReference> + <name>1122516a-5f1c-4f08-9995-02acaee2a0cd</name> + <view>ObjectTreeEdit_view</view> </neonViewReference> </references> </neonContext> diff --git a/neonView/ObjectTreeEdit_view/ObjectTreeEdit_view.aod b/neonView/ObjectTreeEdit_view/ObjectTreeEdit_view.aod new file mode 100644 index 00000000000..472f2ae6756 --- /dev/null +++ b/neonView/ObjectTreeEdit_view/ObjectTreeEdit_view.aod @@ -0,0 +1,31 @@ +<?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>ObjectTreeEdit_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <boxLayout> + <name>layout</name> + </boxLayout> + </layout> + <children> + <genericViewTemplate> + <name>Edit</name> + <editMode v="true" /> + <entityField>#ENTITY</entityField> + <fields> + <entityFieldLink> + <name>fd656c16-ef80-479f-a106-4741fb86c95f</name> + <entityField>OBJECTRELATIONTYPEID</entityField> + </entityFieldLink> + <entityFieldLink> + <name>81ec0bf6-132c-4046-b770-f65da3cd4b6e</name> + <entityField>TARGET_ID</entityField> + </entityFieldLink> + <entityFieldLink> + <name>04579da5-0609-4a43-97dd-9e773ec1a29b</name> + <entityField>INFO</entityField> + </entityFieldLink> + </fields> + </genericViewTemplate> + </children> +</neonView> diff --git a/neonView/ObjectTree_view/ObjectTree_view.aod b/neonView/ObjectTreeFilter_view/ObjectTreeFilter_view.aod similarity index 85% rename from neonView/ObjectTree_view/ObjectTree_view.aod rename to neonView/ObjectTreeFilter_view/ObjectTreeFilter_view.aod index 2917cacd091..36498203200 100644 --- a/neonView/ObjectTree_view/ObjectTree_view.aod +++ b/neonView/ObjectTreeFilter_view/ObjectTreeFilter_view.aod @@ -1,6 +1,6 @@ <?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>ObjectTree_view</name> + <name>ObjectTreeFilter_view</name> <majorModelMode>DISTRIBUTED</majorModelMode> <filterable v="true" /> <layout> @@ -12,10 +12,12 @@ <treeViewTemplate> <name>ObjectRelations</name> <parentField>PARENT_ID</parentField> + <favoriteActionGroup1>alter</favoriteActionGroup1> <nodeExpandedField>EXPANDED</nodeExpandedField> <titleField>TITLE</titleField> <descriptionField>INFO</descriptionField> <iconField>ICON</iconField> + <hideContentSearch v="true" /> <entityField>#ENTITY</entityField> </treeViewTemplate> </children> diff --git a/neonView/OrganisationMain_view/OrganisationMain_view.aod b/neonView/OrganisationMain_view/OrganisationMain_view.aod index b8cddb7e650..33c7ef25685 100644 --- a/neonView/OrganisationMain_view/OrganisationMain_view.aod +++ b/neonView/OrganisationMain_view/OrganisationMain_view.aod @@ -53,7 +53,7 @@ <neonViewReference> <name>c82aff98-ede5-4d9e-a902-89f71ed7dbb0</name> <entityField>ObjectTrees</entityField> - <view>ObjectTree_view</view> + <view>ObjectTreeFilter_view</view> </neonViewReference> <neonViewReference> <name>39c98ccb-7f77-4df0-818f-1f302f69fec4</name> diff --git a/neonView/PersonMain_view/PersonMain_view.aod b/neonView/PersonMain_view/PersonMain_view.aod index 25df37d62a0..81c60ecc29c 100644 --- a/neonView/PersonMain_view/PersonMain_view.aod +++ b/neonView/PersonMain_view/PersonMain_view.aod @@ -42,7 +42,7 @@ <neonViewReference> <name>cb8ff3df-772b-4c12-8814-f9101295b1ba</name> <entityField>ObjectTrees</entityField> - <view>ObjectTree_view</view> + <view>ObjectTreeFilter_view</view> </neonViewReference> <neonViewReference> <name>be48c6fe-1837-4c40-aef1-130fc1a5c544</name> diff --git a/others/db_changes/Data_alias/basic/2019.2/changelog.xml b/others/db_changes/Data_alias/basic/2019.2/changelog.xml index 4c52dd94a3d..11919373ef9 100644 --- a/others/db_changes/Data_alias/basic/2019.2/changelog.xml +++ b/others/db_changes/Data_alias/basic/2019.2/changelog.xml @@ -129,4 +129,17 @@ <include relativeToChangelogFile="true" file="indicesRefactor/Keyword.xml"/> <include relativeToChangelogFile="true" file="indicesRefactor/Activity.xml"/> <include relativeToChangelogFile="true" file="indicesRefactor/Task.xml"/> + + + + <changeSet author="j.hoermann" id="1df96464-abff-4a3c-b52c-759d073a9a7a"> + <createTable tableName="TEST"> + <column name="TESTID" type="CHAR(36)"> + <constraints primaryKey="true" primaryKeyName="PK_TEST_TESTID"/> + </column> + <column name="TEST1" type="VARCHAR(36)"/> + <column name="TEST2" type="VARCHAR(36)"/> + </createTable> + </changeSet> + </databaseChangeLog> diff --git a/process/ObjectRelation_lib/process.js b/process/ObjectRelation_lib/process.js index 2457c50902f..1010f1a6586 100644 --- a/process/ObjectRelation_lib/process.js +++ b/process/ObjectRelation_lib/process.js @@ -14,7 +14,7 @@ function ObjectRelationUtils() {} * 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 + * @param {Boolean} [pFullInfo=false] return also RELATION_TYPE, direction (normal, reverse, same), hierarchy, OBJECT_TYPE dest, OBJECT_TYPE source, objectrelationtypeId1, objectrelationtypeId2, side, otherSide-RELATION_TYPE * * @return {String[][]} */ @@ -54,7 +54,7 @@ ObjectRelationUtils.getPossibleRelationTypes = function(pObjectType, pFullInfo) -- 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" + sql, + main.SIDE, type2.AB_OBJECTRELATIONTYPEID" + sql, [ [pObjectType, db.getColumnTypes("AB_OBJECTRELATIONTYPE", ["OBJECT_TYPE"])[0]] ] @@ -65,7 +65,7 @@ ObjectRelationUtils.getPossibleRelationTypes = function(pObjectType, pFullInfo) /** * Get all possible relationTypes by a objectType. - * returns the id, title, RELATION_TYPE, direction (normal, reverse, same), hierarchy, OBJECT_TYPE dest, OBJECT_TYPE source, objectrelationtypeId1, objectrelationtypeId2, side + * returns the id, title, RELATION_TYPE, direction (normal, reverse, same), hierarchy, OBJECT_TYPE dest, OBJECT_TYPE source, objectrelationtypeId1, objectrelationtypeId2, side, otherSide-RELATION_TYPE * * @param {String} pObjectTypeId the object type to load the relation types for.] * @@ -94,7 +94,7 @@ ObjectRelationUtils.getRelationType = function(pObjectTypeId) -- 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" + sql, + main.SIDE, type2.AB_OBJECTRELATIONTYPEID" + sql, [ [pObjectTypeId, db.getColumnTypes("AB_OBJECTRELATIONTYPE", ["AB_OBJECTRELATIONTYPEID"])[0]], ] -- GitLab