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

objectRelation tree - Update

parent c07eca45
No related branches found
No related tags found
No related merge requests found
Showing
with 191 additions and 56 deletions
......@@ -105,7 +105,6 @@
</entityProvider>
<entityParameter>
<name>ContactId_param</name>
<valueProcess>%aditoprj%/entity/Address_entity/entityfields/contactid_param/valueProcess.js</valueProcess>
<expose v="true" />
<mandatory v="true" />
<documentation>%aditoprj%/entity/Address_entity/entityfields/contactid_param/documentation.adoc</documentation>
......
......@@ -7,13 +7,13 @@ var condition = SqlCondition.begin()
.andPrepareVars("AB_ATTRIBUTE.AB_ATTRIBUTEID", "$field.UID")
.build("1=2");
db.deleteData("AB_ATTRIBUTE", conditon);
db.deleteData("AB_ATTRIBUTE", condition);
var attributeId = vars.get("$field.UID");
var childIds = AttributeUtil.getAllChildren(attributeId).concat(attributeId);
var condition = SqlCondition.begin()
condition = SqlCondition.begin()
.and("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID in ('" + childIds.join("','") + "')")
.build();
......
......@@ -11,8 +11,6 @@
<entityProvider>
<name>TreeProvider</name>
<fieldType>DEPENDENCY_IN</fieldType>
<targetContextField>TARGET_CONTEXT</targetContextField>
<targetIdField>TARGET_ID</targetIdField>
<dependencies>
<entityDependency>
<name>f4c0605f-3ccb-4ff1-b460-7268e8553857</name>
......@@ -42,6 +40,10 @@
<name>RelationType_param</name>
<expose v="false" />
</entityParameter>
<entityParameter>
<name>Uid_param</name>
<expose v="false" />
</entityParameter>
</children>
</entityProvider>
<entityParameter>
......@@ -61,10 +63,12 @@
</entityField>
<entityField>
<name>TITLE</name>
<title>Object</title>
<searchable v="false" />
</entityField>
<entityField>
<name>ICON</name>
<contentType>IMAGE</contentType>
<searchable v="false" />
<valueProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/icon/valueProcess.js</valueProcess>
</entityField>
......@@ -99,8 +103,12 @@
</entityField>
<entityField>
<name>TARGET_ID</name>
<title>Object</title>
<consumer>Objects</consumer>
<linkedContextProcess>%aditoprj%/entity/ObjectTree_entity/entityfields/target_id/linkedContextProcess.js</linkedContextProcess>
<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>
</entityField>
<entityField>
<name>TARGET_CONTEXT</name>
......@@ -110,6 +118,7 @@
<entityField>
<name>INFO</name>
<title>Description</title>
<contentType>LONG_TEXT</contentType>
<searchable v="false" />
</entityField>
<entityField>
......@@ -152,6 +161,13 @@
<isSelectionAction v="true" />
<iconId>VAADIN:FILE_TREE_SMALL</iconId>
</entityActionField>
<entityActionField>
<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>
</entityActionField>
</children>
</entityActionGroup>
<entityParameter>
......@@ -159,6 +175,11 @@
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityParameter>
<name>Uid_param</name>
<expose v="true" />
<description>Needed to load ONE Objectrelation together with ObjectId_param and ObjectType_param to determine the side</description>
</entityParameter>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
......@@ -166,6 +187,7 @@
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<contentProcess>%aditoprj%/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
<onInsert>%aditoprj%/entity/ObjectTree_entity/recordcontainers/jdito/onInsert.js</onInsert>
<onUpdate>%aditoprj%/entity/ObjectTree_entity/recordcontainers/jdito/onUpdate.js</onUpdate>
<onDelete>%aditoprj%/entity/ObjectTree_entity/recordcontainers/jdito/onDelete.js</onDelete>
<recordFields>
<element>UID.value</element>
......
import("ObjectRelation_lib");
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";
if (isObjectRelationNode)
{
var params = {
"Uid_param" : selectedRows[0]["#LOOKUPID"]
}
neon.openContext("ObjectTree", "ObjectTreeEdit_view", null, neon.OPERATINGSTATE_EDIT, params);
}
}
\ No newline at end of file
import("system.neon");
import("system.translate");
import("system.result");
import("system.vars");
......
......@@ -2,7 +2,7 @@ import("system.result");
import("system.vars");
import("system.neon");
if (vars.exists("$param.RelationType_param") && vars.get("$param.RelationType_param"))
if (vars.exists("$param.RelationType_param") && vars.get("$param.RelationType_param") || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
{
result.string(neon.COMPONENTSTATE_DISABLED);
}
......
import("system.db");
import("system.result");
import("system.neon");
import("system.vars");
import("Context_lib");
if (vars.get("$field.TARGET_ID") && vars.get("$field.TARGET_CONTEXT"))
{
result.string(db.cell(ContextUtils.getNameSql(vars.get("$field.TARGET_CONTEXT"), vars.get("$field.TARGET_ID"))));
}
\ No newline at end of file
import("system.vars");
import("system.result");
import("Context_lib");
if (vars.get("$field.TARGET_CONTEXT"))
{
result.string(ContextUtils.getContextName(vars.get("$field.TARGET_CONTEXT")));
}
import("system.result");
import("system.vars");
import("system.neon");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
{
result.string(neon.COMPONENTSTATE_DISABLED);
}
else
{
result.string(neon.COMPONENTSTATE_AUTO);
}
\ No newline at end of file
......@@ -7,23 +7,45 @@ import("Context_lib");
import("Sql_lib");
var tree = []
var filter = JSON.parse(vars.get("$local.filter"))
var selectedRelationType = null;
if (filter)
// uidParam: if only one row should be loaded
var uidParam;
if (vars.exists("$param.Uid_param") && vars.get("$param.Uid_param"))
{
if (filter.childs.length > 0)
uidParam = vars.get("$param.Uid_param");
}
else if(vars.exists("$local.idvalues") && vars.get("$local.idvalues") && vars.get("$local.idvalues").length > 0)
{
uidParam = vars.get("$local.idvalues")[0];
}
if (uidParam)
{
let uid = JSON.parse(uidParam);
let relationTypeData = ObjectRelationUtils.getRelationType(uid[2]);
_insertEntry(tree, _getEntryData(uid[0], relationTypeData[3], relationTypeData[7], relationTypeData[8], undefined, false, uid[6]), "", 0, uid[3], relationTypeData[10]);
}
else
{
var filter = JSON.parse(vars.get("$local.filter"))
var selectedRelationType = null;
if (filter)
{
selectedRelationType = filter.childs[0].value;
if (filter.childs.length > 0)
{
selectedRelationType = filter.childs[0].value;
}
}
}
var originalObjectId = vars.get("$param.ObjectId_param");
var originalObjectId = vars.get("$param.ObjectId_param");
_loadObjectRelationTree(originalObjectId, vars.get("$param.ObjectType_param"), selectedRelationType);
_loadObjectRelationTree(originalObjectId, vars.get("$param.ObjectType_param"), selectedRelationType);
}
result.object(tree);
function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, pNodeId, pLayer, pRelationTypeData)
function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, pNodeId, pLayer, pRelationTypeData, pObjectRelationId)
{
// prevent stack overflows
if (pLayer > 30)
......@@ -41,9 +63,14 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
{
if (pLayer == 0)
{
if (pObjectRelationTypeId)
// load only one ObjectRelation (e.g. for edit mode)
if (pObjectRelationId)
{
}
else if (pObjectRelationTypeId)
{
var relationTypeData = ObjectRelationUtils.getRelationType(pObjectRelationTypeId);
let relationTypeData = ObjectRelationUtils.getRelationType(pObjectRelationTypeId);
// if hirachy: get most top id else use the current currentObjectId
if (relationTypeData[4] == "1")
......@@ -76,7 +103,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
let uid = [currentObjectId, i, relationTypes[i]];
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, relationTypes[i]);
}
}
}
......@@ -154,12 +181,13 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId,
* @param {String} pDirection
* @param {String} pRelationType1
* @param {String} pRelationType2
* @param {String} pPrevId Id of the previous node to exclude it
* @param {String} [pPrevId=undefined] Id of the previous node to exclude it
* @param {Boolean} [pNoRecursion=false] if false: select for direction "same" the other direction, if result is empty.
* @param {Boolean} [pObjectRelationId=false] provide if only one special node is needed
*
* @return {[][]}
*/
function _getEntryData(pObjectId, pDirection, pRelationType1, pRelationType2, pPrevId, pNoRecursion)
function _getEntryData(pObjectId, pDirection, pRelationType1, pRelationType2, pPrevId, pNoRecursion, pObjectRelationId)
{
if (pRelationType1 == undefined || pRelationType2 == undefined)
return [];
......@@ -181,7 +209,8 @@ function _getEntryData(pObjectId, pDirection, pRelationType1, pRelationType2, pP
var cond = SqlCondition.begin()
.andPrepare("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1", pRelationType1)
.andPrepare("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2", pRelationType2)
.andPrepare("AB_OBJECTRELATION.OBJECT" + myNum + "_ROWID", pObjectId);
.andPrepare("AB_OBJECTRELATION.OBJECT" + myNum + "_ROWID", pObjectId)
.andPrepareIfSet("AB_OBJECTRELATION.AB_OBJECTRELATIONID", pObjectRelationId);
// exclude previous node
if (!pPrevId)
......@@ -193,17 +222,16 @@ function _getEntryData(pObjectId, pDirection, pRelationType1, pRelationType2, pP
// TODO: BINDATA?
// var image = getImageObject("Beziehung");
var data = db.table(cond.buildSql(
"select OBJECT" + otherNum + "_ROWID, AB_OBJECTRELATIONID, OBJECT_TYPE, RELATION_TITLE, INFO, AB_OBJECTRELATIONTYPEID \n\
"select OBJECT" + (pObjectRelationId ? myNum : 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));
if (data.length == 0 && pDirection == "same" && !pNoRecursion)
// try again with other side for "same"
if (data.length == 0 && pDirection == "same" && !pNoRecursion || pObjectRelationId && data.length > 0 && !data[0][0])
{
return _getEntryData(pObjectId, "normal", pRelationType1, pRelationType2, pPrevId, true)
return _getEntryData(pObjectId, "normal", pRelationType1, pRelationType2, pPrevId, true, pObjectRelationId)
}
// TODO: BINDATA?
//for ( var i = 0; i < data.length; i++) data[i][2] = image[data[i][2]] == undefined ? "" : image[data[i][2]];
return data;
......@@ -226,7 +254,7 @@ function _getRelationTypes(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, AB_OBJECTRELATIONTYPEID, pObjectType, pNodeId, objectrelationid, objecttype
* @return {Array[][]} the uids of the inserted data. Consists of [ObjectId, pEntryData-Index, AB_OBJECTRELATIONTYPEID, pObjectType (from param), pNodeId, objecttype (from entryId), objectrelationid]
*/
function _insertEntry(pTree, pEntryData, pNodeId, pLayer, pObjectType, pNewRelationTypeId, pNum)
{
......
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];
db.updateData("AB_OBJECTRELATION", ["INFO"], null, [vars.get("$field.INFO")],
SqlCondition.begin()
.andPrepareIfSet("AB_OBJECTRELATION.AB_OBJECTRELATIONID", objectRelationId)
.build("1=2"));
}
......@@ -9,12 +9,6 @@
<entityProvider>
<name>#PROVIDER</name>
<recordContainer>jdito</recordContainer>
<children>
<entityParameter>
<name>ObjectRowId_param</name>
<expose v="false" />
</entityParameter>
</children>
</entityProvider>
<entityField>
<name>UID</name>
......
......@@ -123,10 +123,6 @@
<fieldType>DEPENDENCY_IN</fieldType>
<recordContainer>db</recordContainer>
<children>
<entityParameter>
<name>ContactId_param</name>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>WithPrivate_param</name>
<expose v="true" />
......@@ -644,10 +640,6 @@
</entityDependency>
</dependencies>
<children>
<entityParameter>
<name>ContactId_param</name>
<expose v="false" />
</entityParameter>
<entityParameter>
<name>ExcludeOrganisationsByPersonId</name>
<title></title>
......@@ -709,10 +701,6 @@
<name>AttributeKeyId_param</name>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>ContactId_param</name>
<expose v="false" />
</entityParameter>
<entityParameter>
<name>ExcludeOrganisationsByPersonId</name>
<expose v="false" />
......
......@@ -4,6 +4,7 @@
<majorModelMode>DISTRIBUTED</majorModelMode>
<filterview>ObjectTreeFilter_view</filterview>
<editview>ObjectTreeEdit_view</editview>
<preview>ObjectTreePreview</preview>
<entity>ObjectTree_entity</entity>
<references>
<neonViewReference>
......@@ -14,5 +15,9 @@
<name>1122516a-5f1c-4f08-9995-02acaee2a0cd</name>
<view>ObjectTreeEdit_view</view>
</neonViewReference>
<neonViewReference>
<name>1caa61e2-0e59-47bd-a996-db49867e3908</name>
<view>ObjectTreePreview</view>
</neonViewReference>
</references>
</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>ObjectTreePreview</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<layout>
<boxLayout>
<name>layout</name>
</boxLayout>
</layout>
<children>
<genericViewTemplate>
<name>Info</name>
<showDrawer v="true" />
<drawerCaption>Info</drawerCaption>
<entityField>#ENTITY</entityField>
<fields>
<entityFieldLink>
<name>a7ff1a5c-1ea5-4904-a802-b3da55c07341</name>
<entityField>OBJECTRELATIONTYPEID</entityField>
</entityFieldLink>
<entityFieldLink>
<name>0b612a60-d882-4def-b569-7146e1b1ccb6</name>
<entityField>TARGET_ID</entityField>
</entityFieldLink>
<entityFieldLink>
<name>6ed4e675-b1f5-4790-97d1-d015f87f37e4</name>
<entityField>INFO</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
</children>
</neonView>
import("system.logging");
import("Sql_lib");
import("system.db");
/**
......@@ -10,11 +10,11 @@ import("system.db");
function ObjectRelationUtils() {}
/**
* Get all possible relationTypes by a objectType.
* 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, otherSide-RELATION_TYPE
* @param {Boolean} [pFullInfo=false] return also RELATION_TYPE, direction (normal, reverse, same), hierarchy, OBJECT_TYPE dest, OBJECT_TYPE source, objectrelationtypeId1, objectrelationtypeId2, side, objectrelationtypeId
*
* @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, type2.AB_OBJECTRELATIONTYPEID" + sql,
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]]
]
......@@ -64,14 +64,14 @@ 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, otherSide-RELATION_TYPE
* 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
*
* @param {String} pObjectTypeId the object type to load the relation types for.]
* @param {String} pRelationTypeId the RelationTypeId to load the full relation type for.
*
* @return {String[][]}
*/
ObjectRelationUtils.getRelationType = function(pObjectTypeId)
ObjectRelationUtils.getRelationType = function(pRelationTypeId)
{
// TODO: funktionen evtl. zusammenfassen
var sql = " from AB_OBJECTRELATIONTYPE main \n\
......@@ -94,9 +94,9 @@ 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, type2.AB_OBJECTRELATIONTYPEID" + sql,
main.SIDE, case when type2.AB_OBJECTRELATIONTYPEID is null then main.AB_OBJECTRELATIONTYPEID else type2.AB_OBJECTRELATIONTYPEID end" + sql,
[
[pObjectTypeId, db.getColumnTypes("AB_OBJECTRELATIONTYPE", ["AB_OBJECTRELATIONTYPEID"])[0]],
[pRelationTypeId, db.getColumnTypes("AB_OBJECTRELATIONTYPE", ["AB_OBJECTRELATIONTYPEID"])[0]],
]
]));
......
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