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

object relation tree inserts / deletes

parent 1d0eada0
No related branches found
No related tags found
No related merge requests found
Showing
with 397 additions and 30 deletions
...@@ -5954,6 +5954,68 @@ ...@@ -5954,6 +5954,68 @@
</entityFieldDb> </entityFieldDb>
</entityFields> </entityFields>
</entityDb> </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> </entities>
</entityGroup> </entityGroup>
</aliasDefDb> </aliasDefDb>
......
import("system.logging");
import("system.vars"); import("system.vars");
import("system.result"); import("system.result");
import("system.db"); import("system.db");
...@@ -16,7 +17,7 @@ if(vars.exists("$param.AssignmentTable_param") && ...@@ -16,7 +17,7 @@ if(vars.exists("$param.AssignmentTable_param") &&
if(vars.exists("$param.Keyword_param")) { if(vars.exists("$param.Keyword_param")) {
keyword = vars.get("$param.Keyword_param"); keyword = vars.get("$param.Keyword_param");
} }
// Check if multiple Documents are selected // Check if multiple Documents are selected
if(vars.exists("$local.idvalues") && vars.get("$local.idvalues")) if(vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
metadata = db.getBinaryMetadataForIds(vars.get("$local.idvalues"), true, alias) metadata = db.getBinaryMetadataForIds(vars.get("$local.idvalues"), true, alias)
......
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
<expose v="true" /> <expose v="true" />
<mandatory v="true" /> <mandatory v="true" />
</entityParameter> </entityParameter>
<entityParameter>
<name>RelationType_param</name>
<expose v="false" />
</entityParameter>
</children> </children>
</entityProvider> </entityProvider>
<entityParameter> <entityParameter>
...@@ -53,6 +57,7 @@ ...@@ -53,6 +57,7 @@
<entityField> <entityField>
<name>PARENT_ID</name> <name>PARENT_ID</name>
<searchable v="false" /> <searchable v="false" />
<valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/parent_id/valueProcess.js</valueProcess>
</entityField> </entityField>
<entityField> <entityField>
<name>TITLE</name> <name>TITLE</name>
...@@ -63,14 +68,6 @@ ...@@ -63,14 +68,6 @@
<searchable v="false" /> <searchable v="false" />
<valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/icon/valueProcess.js</valueProcess> <valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/icon/valueProcess.js</valueProcess>
</entityField> </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> <entityConsumer>
<name>ObjectRelationTypes</name> <name>ObjectRelationTypes</name>
<fieldType>DEPENDENCY_OUT</fieldType> <fieldType>DEPENDENCY_OUT</fieldType>
...@@ -102,22 +99,70 @@ ...@@ -102,22 +99,70 @@
</entityField> </entityField>
<entityField> <entityField>
<name>TARGET_ID</name> <name>TARGET_ID</name>
<consumer>Objects</consumer>
<searchable v="false" /> <searchable v="false" />
</entityField> </entityField>
<entityField> <entityField>
<name>TARGET_CONTEXT</name> <name>TARGET_CONTEXT</name>
<searchable v="false" /> <searchable v="false" />
<valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/target_context/valueProcess.js</valueProcess>
</entityField> </entityField>
<entityField> <entityField>
<name>INFO</name> <name>INFO</name>
<title>Description</title> <title>Description</title>
<searchable v="false" />
</entityField> </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> </entityFields>
<recordContainers> <recordContainers>
<jDitoRecordContainer> <jDitoRecordContainer>
<name>jdito</name> <name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias> <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<contentProcess>%aditoprj%/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js</contentProcess> <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> <recordFields>
<element>UID.value</element> <element>UID.value</element>
<element>TITLE.value</element> <element>TITLE.value</element>
...@@ -126,7 +171,7 @@ ...@@ -126,7 +171,7 @@
<element>TARGET_ID.value</element> <element>TARGET_ID.value</element>
<element>TARGET_CONTEXT.value</element> <element>TARGET_CONTEXT.value</element>
<element>INFO.value</element> <element>INFO.value</element>
<element>Selector.value</element> <element>OBJECTRELATIONTYPEID.value</element>
</recordFields> </recordFields>
</jDitoRecordContainer> </jDitoRecordContainer>
</recordContainers> </recordContainers>
......
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
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]));
}
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]);
}
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
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
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
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
import("system.neon");
neon.refresh()
\ No newline at end of file
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
import("system.logging");
import("system.db"); import("system.db");
import("system.translate"); import("system.translate");
import("system.result"); import("system.result");
...@@ -5,7 +6,6 @@ import("system.vars"); ...@@ -5,7 +6,6 @@ import("system.vars");
import("ObjectRelation_lib"); import("ObjectRelation_lib");
import("Context_lib"); import("Context_lib");
import("Sql_lib"); import("Sql_lib");
import("system.tools");
var tree = [] var tree = []
var filter = JSON.parse(vars.get("$local.filter")) var filter = JSON.parse(vars.get("$local.filter"))
...@@ -54,7 +54,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, ...@@ -54,7 +54,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
currentObjectId = _getRootID(currentObjectId, relationTypeData); 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++) for (let i = 0; i < uids.length; i++)
{ {
_loadObjectRelationTree(uids[i][0], uids[i][3], relationTypeData[0], uids[i], pLayer+1, relationTypeData); _loadObjectRelationTree(uids[i][0], uids[i][3], relationTypeData[0], uids[i], pLayer+1, relationTypeData);
...@@ -75,7 +75,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, ...@@ -75,7 +75,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
// TODO: Icons, BINDATA // TODO: Icons, BINDATA
// var icon = getIcon... // var icon = getIcon...
let uid = [currentObjectId, i, relationTypes[i]]; 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); _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, uid, pLayer+1, relationTypeData);
} }
...@@ -87,18 +87,31 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, ...@@ -87,18 +87,31 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
// if no relationType given, load from nodeId // if no relationType given, load from nodeId
if (!pRelationTypeData) if (!pRelationTypeData)
pRelationTypeData = pNodeId[2]; pRelationTypeData = pNodeId[2];
logging.log("aaa " + pRelationTypeData.toSource())
var thisRelationTypeId = pRelationTypeData[0];
var otherRelationTypeId = pRelationTypeData[10];
var hierarchy = pRelationTypeData[4]; var hierarchy = pRelationTypeData[4];
var destObjectType = pRelationTypeData[6]; var destObjectType = pRelationTypeData[6];
var relationType1 = pRelationTypeData[7]; var relationType1 = pRelationTypeData[7];
var relationType2 = pRelationTypeData[8]; var relationType2 = pRelationTypeData[8];
var direction = pRelationTypeData[3]; var direction = pRelationTypeData[3];
var relationTypeIdForNew = otherRelationTypeId;
if (hierarchy == "1") if (hierarchy == "1")
{ {
var myData = _getEntryData(pNodeId[0], direction, relationType1, relationType2) 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++) for (let i = 0; i < uids.length; i++)
{ {
_loadObjectRelationTree(uids[i][0], uids[i][3], pObjectRelationTypeId, uids[i], pLayer+1, pRelationTypeData); _loadObjectRelationTree(uids[i][0], uids[i][3], pObjectRelationTypeId, uids[i], pLayer+1, pRelationTypeData);
...@@ -115,12 +128,15 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, ...@@ -115,12 +128,15 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
var entryData = _getEntryData(pNodeId[0], direction, relationType1, relationType2, prevObjectId, true); 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 [] // 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") if (direction == "same")
{ {
var otherEntryData = _getEntryData(pNodeId[0], "normal", relationType1, relationType2, prevObjectId, true); 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++) for (let i = 0; i < uids.length; i++)
...@@ -134,7 +150,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, ...@@ -134,7 +150,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
/** /**
* load data for a relation. * 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} pObjectId
* @param {String} pDirection * @param {String} pDirection
...@@ -181,7 +197,7 @@ function _getEntryData(pObjectId, pDirection, pRelationType1, pRelationType2, pP ...@@ -181,7 +197,7 @@ function _getEntryData(pObjectId, pDirection, pRelationType1, pRelationType2, pP
// var image = getImageObject("Beziehung"); // var image = getImageObject("Beziehung");
var data = db.table(cond.buildSql( 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\ from AB_OBJECTRELATION \n\
join AB_OBJECTRELATIONTYPE on AB_OBJECTRELATIONTYPEID = AB_OBJECTRELATIONTYPE" + myNum + " and ","1=2", "", false)); join AB_OBJECTRELATIONTYPE on AB_OBJECTRELATIONTYPEID = AB_OBJECTRELATIONTYPE" + myNum + " and ","1=2", "", false));
...@@ -209,11 +225,12 @@ function _getRelationTypes(pObjectType) ...@@ -209,11 +225,12 @@ function _getRelationTypes(pObjectType)
* @param {Array[][]} pNodeId id of the parent * @param {Array[][]} pNodeId id of the parent
* @param {Integer} pLayer layernumber * @param {Integer} pLayer layernumber
* @param {String} pObjectType * @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. * @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; var expanded = true;
if (pLayer > 10) expanded = false; if (pLayer > 10) expanded = false;
...@@ -222,12 +239,12 @@ function _insertEntry(pTree, pEntryData, pNodeId, pLayer, pObjectType, pNum) ...@@ -222,12 +239,12 @@ function _insertEntry(pTree, pEntryData, pNodeId, pLayer, pObjectType, pNum)
for(let i = 0; i < pEntryData.length; i++) for(let i = 0; i < pEntryData.length; i++)
{ {
var display = db.cell(ContextUtils.getNameSql(pObjectType, pEntryData[i][0])); var display = db.cell(ContextUtils.getNameSql(pObjectType, pEntryData[i][0]));
// TODO: Icon // TODO: Icon
var uid = [pEntryData[i][0], i, "", pObjectType, pNodeId, pEntryData[i][2], pEntryData[i][1]] var uid = [pEntryData[i][0], i, pEntryData[i][5], pObjectType, pNodeId, pEntryData[i][2], pEntryData[i][1]]
if (pNum) if (pNum)
uid.push(pNum); uid.push(pNum);
uids.push(uid); 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; return uids;
} }
......
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();
}
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
...@@ -86,6 +86,12 @@ ...@@ -86,6 +86,12 @@
<fieldName>Objects</fieldName> <fieldName>Objects</fieldName>
<isConsumer v="false" /> <isConsumer v="false" />
</entityDependency> </entityDependency>
<entityDependency>
<name>e55777a1-7dfc-46b3-b0e3-318eeecf018e</name>
<entityName>ObjectTree_entity</entityName>
<fieldName>Objects</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies> </dependencies>
<children> <children>
<entityParameter> <entityParameter>
......
...@@ -2,11 +2,17 @@ ...@@ -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"> <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> <name>ObjectTree</name>
<majorModelMode>DISTRIBUTED</majorModelMode> <majorModelMode>DISTRIBUTED</majorModelMode>
<filterview>ObjectTreeFilter_view</filterview>
<editview>ObjectTreeEdit_view</editview>
<entity>ObjectTree_entity</entity> <entity>ObjectTree_entity</entity>
<references> <references>
<neonViewReference> <neonViewReference>
<name>0c9fc36e-e3f7-4198-b675-5d9ddb177611</name> <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> </neonViewReference>
</references> </references>
</neonContext> </neonContext>
<?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>
<?xml version="1.0" encoding="UTF-8"?> <?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"> <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> <majorModelMode>DISTRIBUTED</majorModelMode>
<filterable v="true" /> <filterable v="true" />
<layout> <layout>
...@@ -12,10 +12,12 @@ ...@@ -12,10 +12,12 @@
<treeViewTemplate> <treeViewTemplate>
<name>ObjectRelations</name> <name>ObjectRelations</name>
<parentField>PARENT_ID</parentField> <parentField>PARENT_ID</parentField>
<favoriteActionGroup1>alter</favoriteActionGroup1>
<nodeExpandedField>EXPANDED</nodeExpandedField> <nodeExpandedField>EXPANDED</nodeExpandedField>
<titleField>TITLE</titleField> <titleField>TITLE</titleField>
<descriptionField>INFO</descriptionField> <descriptionField>INFO</descriptionField>
<iconField>ICON</iconField> <iconField>ICON</iconField>
<hideContentSearch v="true" />
<entityField>#ENTITY</entityField> <entityField>#ENTITY</entityField>
</treeViewTemplate> </treeViewTemplate>
</children> </children>
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<neonViewReference> <neonViewReference>
<name>c82aff98-ede5-4d9e-a902-89f71ed7dbb0</name> <name>c82aff98-ede5-4d9e-a902-89f71ed7dbb0</name>
<entityField>ObjectTrees</entityField> <entityField>ObjectTrees</entityField>
<view>ObjectTree_view</view> <view>ObjectTreeFilter_view</view>
</neonViewReference> </neonViewReference>
<neonViewReference> <neonViewReference>
<name>39c98ccb-7f77-4df0-818f-1f302f69fec4</name> <name>39c98ccb-7f77-4df0-818f-1f302f69fec4</name>
......
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