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

add objects for readable indices of the arrays

parent 956aa8e8
No related branches found
No related tags found
No related merge requests found
......@@ -26,13 +26,13 @@ var ENTRY_DATA = {
objectType: 2,
relationTitle: 3,
info: 4,
onjectRelationTypeId: 5
objectRelationTypeId: 5
}
var UID = {
objectId: 0,
layer: 1,
onjectRelationTypeId: 2,
objectRelationTypeId: 2,
otherObjectType: 3,
relationTypeData: 4,
myObjectType: 5,
......@@ -40,8 +40,6 @@ var UID = {
hierarchy: 7
}
var tree = []
// uidParam: if only one row should be loaded
......@@ -60,12 +58,13 @@ if (uidParam)
// load one by uid.
// Basically the data to return is also encoded in the uid itself -> no extra data loading is needed.
let uid = JSON.parse(uidParam);
let isObjectRelationNode = uid != null && typeof uid[2] == "string";
// if objectRelationTypeId is a string it is a relation node and no Grouping
let isObjectRelationNode = uid != null && typeof uid[UID.objectRelationTypeId] == "string";
if (isObjectRelationNode)
{
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], relationTypeData[12], relationTypeData[4]);
let relationTypeData = ObjectRelationUtils.getRelationType(uid[UID.objectRelationTypeId]);
_insertEntry(tree, _getEntryData(uid[UID.objectId], relationTypeData[3], relationTypeData[7], relationTypeData[8], undefined, false, uid[UID.objectRelationId]), "", 0, uid[UID.otherObjectType], relationTypeData[10], relationTypeData[12], relationTypeData[4]);
}
}
else
......@@ -153,7 +152,8 @@ function _loadObjectRelationTree(pTree, pObjectId, pObjectType, pObjectRelationT
let uids = _insertEntry(parentTmpTree, [[currentObjectId, "", "", "", "", relationTypeData[7]]], pNodeId, pLayer, pObjectType, selectedRelationType, relationTypeData[12], true)
for (let i = 0; i < uids.length; i++)
{
_loadObjectRelationTree(childsTmpTree, uids[i][0], uids[i][3], relationTypeData[0], uids[i], pLayer+1, relationTypeData);
// recursive call
_loadObjectRelationTree(childsTmpTree, uids[i][UID.objectId], uids[i][UID.otherObjectType], relationTypeData[0], uids[i], pLayer+1, relationTypeData);
}
// only add parent if childs are available
......@@ -194,7 +194,7 @@ function _loadObjectRelationTree(pTree, pObjectId, pObjectType, pObjectRelationT
{
// if no relationType given, load from nodeId
if (!pRelationTypeData)
pRelationTypeData = pNodeId[2];
pRelationTypeData = pNodeId[UID.objectRelationTypeId];
// if it's only the id, load via function
if (typeof pRelationTypeData == "string")
......@@ -228,8 +228,9 @@ function _loadObjectRelationTree(pTree, pObjectId, pObjectType, pObjectRelationT
let uids = _insertEntry(pTree, myData, pNodeId, pLayer, destObjectType, relationTypeIdForNew, icon, hierarchy)
for (let i = 0; i < uids.length; i++)
{
_loadObjectRelationTree(pTree, uids[i][0], uids[i][3], pObjectRelationTypeId, uids[i], pLayer+1, pRelationTypeData);
{
// recursive call
_loadObjectRelationTree(pTree, uids[i][UID.objectId], uids[i][UID.otherObjectType], pObjectRelationTypeId, uids[i], pLayer+1, pRelationTypeData);
}
}
else
......@@ -238,10 +239,10 @@ function _loadObjectRelationTree(pTree, pObjectId, pObjectType, pObjectRelationT
var prevObjectId;
if (pNodeId[4] != undefined)
{
prevObjectId = pNodeId[4][0];
prevObjectId = pNodeId[UID.relationTypeData][0];
}
var entryData = _getEntryData(pNodeId[0], direction, relationType1, relationType2, prevObjectId, true);
var entryData = _getEntryData(pNodeId[UID.objectId], direction, relationType1, relationType2, prevObjectId, true);
if (direction == "same")
relationTypeIdForNew = thisRelationTypeId
......@@ -250,7 +251,7 @@ function _loadObjectRelationTree(pTree, pObjectId, pObjectType, pObjectRelationT
_insertEntry(pTree, entryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, icon, hierarchy, 0);
if (direction == "same")
{
var otherEntryData = _getEntryData(pNodeId[0], "normal", relationType1, relationType2, prevObjectId, true);
var otherEntryData = _getEntryData(pNodeId[UID.objectId], "normal", relationType1, relationType2, prevObjectId, true);
_insertEntry(pTree, otherEntryData, pNodeId, pLayer, destObjectType, thisRelationTypeId, icon, hierarchy, 1);
}
}
......@@ -313,7 +314,7 @@ function _getEntryData(pObjectId, pDirection, pRelationType1, pRelationType2, pP
join AB_OBJECTRELATIONTYPE on AB_OBJECTRELATIONTYPEID = AB_OBJECTRELATIONTYPE" + myNum + " and ","1=2", "", false));
// try again with other side for "same"
if (data.length == 0 && pDirection == "same" && !pNoRecursion || pObjectRelationId && data.length > 0 && !data[0][0])
if (data.length == 0 && pDirection == "same" && !pNoRecursion || pObjectRelationId && data.length > 0 && !data[0][ENTRY_DATA.objectId])
{
return _getEntryData(pObjectId, "normal", pRelationType1, pRelationType2, pPrevId, true, pObjectRelationId)
}
......@@ -351,14 +352,14 @@ function _insertEntry(pTree, pEntryData, pNodeId, pLayer, pObjectType, pNewRelat
var uids = [];
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][ENTRY_DATA.objectId]));
// TODO: Icon
var uid = [pEntryData[i][0], i, pEntryData[i][5], pObjectType, pNodeId, pEntryData[i][2], pEntryData[i][1], pHierarchy]
var uid = [pEntryData[i][ENTRY_DATA.objectId], i, pEntryData[i][ENTRY_DATA.objectRelationTypeId], pObjectType, pNodeId, pEntryData[i][ENTRY_DATA.objectType], pEntryData[i][ENTRY_DATA.objectRelationId], pHierarchy]
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], pNewRelationTypeId, pIcon]);
pTree.push([JSON.stringify(uid), display, JSON.stringify(pNodeId), expanded, pEntryData[i][ENTRY_DATA.objectId], pObjectType, pEntryData[i][ENTRY_DATA.info], pNewRelationTypeId, pIcon]);
}
return uids;
}
......
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