|
@@ -1809,6 +1809,30 @@ function graphFetchData(node, nameSection) {
|
|
|
'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
'default_db__x3A__BI_audit_KRS:BI_audit_KRS'
|
|
|
].join('/'),
|
|
|
+ [
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
+ 'default_db__x3A__BI_audit_KRS:BI_audit_KRS/ID'
|
|
|
+ ].join('/'),
|
|
|
+ [
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
+ 'default_db__x3A__BI_audit_KRS:BI_audit_KRS/nazwa'
|
|
|
+ ].join('/'),
|
|
|
+ [
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
+ 'default_db__x3A__BI_audit_KRS:BI_audit_KRS/krs'
|
|
|
+ ].join('/'),
|
|
|
+ [
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
|
|
|
+ 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
+ 'default_db__x3A__BI_audit_KRS:BI_audit_KRS/S_miejscowosc'
|
|
|
+ ].join('/'),
|
|
|
[
|
|
|
'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
|
|
@@ -1823,12 +1847,12 @@ function graphFetchData(node, nameSection) {
|
|
|
].join('/'),
|
|
|
[
|
|
|
'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
- 'ID',
|
|
|
+ 'ID'
|
|
|
].join('/'),
|
|
|
[
|
|
|
'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
|
|
|
- 'ID',
|
|
|
+ 'ID'
|
|
|
].join('/'),
|
|
|
[
|
|
|
'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
@@ -2006,7 +2030,6 @@ function parseResponseRec(_todoGraphData, json, typeName, parentNodeId, level) {
|
|
|
var level = level || 0
|
|
|
var parentNodeId = parentNodeId || null
|
|
|
if(DBG)console.log('DBG::parseResponseRec', {json:json, typeName:typeName, parentNodeId:parentNodeId, isString: p5Utils__isString(json), isArray: p5Utils__isArray(json), isObject: p5Utils__isObject(json)});
|
|
|
- console.log('DBG::parseResponseRec', {json:json, typeName:typeName, parentNodeId:parentNodeId, isString: p5Utils__isString(json), isArray: p5Utils__isArray(json), isObject: p5Utils__isObject(json)});
|
|
|
if (p5Utils__isArray(json)) {
|
|
|
// TODO: create named group
|
|
|
var isXlinkList = (json.length > 0 && p5Utils__isString(json[0]))
|
|
@@ -2029,7 +2052,13 @@ function parseResponseRec(_todoGraphData, json, typeName, parentNodeId, level) {
|
|
|
})
|
|
|
var nodeId = nodeObject.id
|
|
|
|
|
|
- if ("default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object" !== typeName
|
|
|
+ if ("default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row" === typeName) {
|
|
|
+ parseResponseRec__row(_todoGraphData, json, typeName, parentNodeId, level)
|
|
|
+ }
|
|
|
+ else if ("default_db__x3A__BI_audit_KRS:BI_audit_KRS" === typeName) {
|
|
|
+ parseResponseRec__krs(_todoGraphData, json, typeName, parentNodeId, level)
|
|
|
+ }
|
|
|
+ else if ("default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object" !== typeName
|
|
|
&& "default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row" !== typeName
|
|
|
) {
|
|
|
_todoGraphData[level].nodes.push(nodeObject)
|
|
@@ -2043,45 +2072,6 @@ function parseResponseRec(_todoGraphData, json, typeName, parentNodeId, level) {
|
|
|
var value = json[fieldName]
|
|
|
parseResponseRec(_todoGraphData, value, fieldName, nodeId, level + 1)
|
|
|
})
|
|
|
- } else if ("default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row" === typeName) {
|
|
|
- // 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
|
|
|
- // 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
- // 'default_db__x3A__BI_audit_KRS:BI_audit_KRS' --> Kontrahenci
|
|
|
- var rowObjectChildrens = []
|
|
|
- var rowTN = 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row'
|
|
|
- var rowObjTN = 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object'
|
|
|
- // { row: row_obj: [ { ID, kontr: [ "http...kontr.ID" ] }, { ID, kontr: [ "http...krs.ID" ] } ], ... }
|
|
|
- var rowJson = json
|
|
|
- if (rowJson[rowObjTN] && rowJson[rowObjTN].length > 1) {
|
|
|
- var pathItems = []
|
|
|
- rowJson[rowObjTN].forEach(function (rowObjJson) {
|
|
|
- Object.keys(rowObjJson)
|
|
|
- .filter(function (rowObjFld) { return (-1 !== rowObjFld.indexOf(':')); })
|
|
|
- .filter(function (rowObjRefFld) { return (rowObjJson[rowObjRefFld] && rowObjJson[rowObjRefFld].length); })
|
|
|
- .forEach(function (rowObjRefFld) {
|
|
|
- pathItems.push([ rowObjRefFld, rowObjJson[rowObjRefFld][0] ])
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- // console.log('pathItems:', pathItems);
|
|
|
- var lastParentFid = null
|
|
|
- pathItems.reverse().forEach(function (pathItem) {
|
|
|
- var nodeObject = dataMakeXlinkNode({
|
|
|
- xlink: pathItem[1],
|
|
|
- typeName: pathItem[0]
|
|
|
- })
|
|
|
- // _todoGraphData[todoLevel].nodes.push(nodeObject) // already added below
|
|
|
- if (lastParentFid) _todoGraphData[level].edges.push(dataMakeEdge(lastParentFid, nodeObject))
|
|
|
- lastParentFid = nodeObject.id
|
|
|
- })
|
|
|
-
|
|
|
- Object.keys(json).filter(function (fieldName) {
|
|
|
- return (fieldName.indexOf(':') > -1)
|
|
|
- })
|
|
|
- .forEach(function (fieldName) {
|
|
|
- var value = json[fieldName]
|
|
|
- parseResponseRec(_todoGraphData, value, fieldName, parentNodeId, level + 1)
|
|
|
- })
|
|
|
} else {
|
|
|
Object.keys(json).filter(function (fieldName) {
|
|
|
return (fieldName.indexOf(':') > -1)
|
|
@@ -2150,6 +2140,80 @@ function parseResponseP5Link(_todoGraphData, json, typeName, parentNodeId, level
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function parseResponseRec__krs(_todoGraphData, json, typeName, parentNodeId, level) {
|
|
|
+ var nodeObject = dataMakeNode({
|
|
|
+ typeName: typeName,
|
|
|
+ primaryKey: (json['ID']) ? json['ID'] : null, // TODO: get primaryKey from object
|
|
|
+ row: json
|
|
|
+ })
|
|
|
+ var nodeId = nodeObject.id
|
|
|
+
|
|
|
+ _todoGraphData[level].nodes.push(nodeObject)
|
|
|
+ if (parentNodeId) {
|
|
|
+ _todoGraphData[level].edges.push(dataMakeEdge(parentNodeId, nodeObject))
|
|
|
+ }
|
|
|
+ Object.keys(json).filter(function (fieldName) {
|
|
|
+ return (fieldName.indexOf(':') > -1)
|
|
|
+ })
|
|
|
+ .forEach(function (fieldName) {
|
|
|
+ var value = json[fieldName]
|
|
|
+ parseResponseRec(_todoGraphData, value, fieldName, nodeId, level + 1)
|
|
|
+ })
|
|
|
+}
|
|
|
+function parseResponseRec__row(_todoGraphData, json, typeName, parentNodeId, level) {
|
|
|
+ var nodeObject = dataMakeNode({
|
|
|
+ typeName: typeName,
|
|
|
+ primaryKey: (json['ID']) ? json['ID'] : null, // TODO: get primaryKey from object
|
|
|
+ })
|
|
|
+ var nodeId = nodeObject.id
|
|
|
+
|
|
|
+ // 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row',
|
|
|
+ // 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
|
|
|
+ // 'default_db__x3A__BI_audit_KRS:BI_audit_KRS' --> Kontrahenci
|
|
|
+ var rowObjectChildrens = []
|
|
|
+ var rowTN = 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row'
|
|
|
+ var rowObjTN = 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object'
|
|
|
+ // { row: row_obj: [ { ID, kontr: [ "http...kontr.ID" ] }, { ID, kontr: [ "http...krs.ID" ] } ], ... }
|
|
|
+ var rowJson = json
|
|
|
+ if (rowJson[rowObjTN] && rowJson[rowObjTN].length > 1) {
|
|
|
+ var pathItems = []
|
|
|
+ rowJson[rowObjTN].forEach(function (rowObjJson) {
|
|
|
+ Object.keys(rowObjJson)
|
|
|
+ .filter(function (rowObjFld) { return (-1 !== rowObjFld.indexOf(':')); })
|
|
|
+ .filter(function (rowObjRefFld) { return (rowObjJson[rowObjRefFld] && rowObjJson[rowObjRefFld].length); })
|
|
|
+ .forEach(function (rowObjRefFld) {
|
|
|
+ pathItems.push([ rowObjRefFld, rowObjJson[rowObjRefFld][0] ])
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // console.log('node('+nodeId+') pathItems:', pathItems);
|
|
|
+ var lastParentFid = null
|
|
|
+ pathItems.reverse().forEach(function (pathItem) {
|
|
|
+ var nodeObject = ('string' === typeof pathItem[1])
|
|
|
+ ? dataMakeXlinkNode({
|
|
|
+ xlink: pathItem[1],
|
|
|
+ typeName: pathItem[0]
|
|
|
+ })
|
|
|
+ : dataMakeNode({
|
|
|
+ typeName: pathItem[0],
|
|
|
+ primaryKey: (pathItem[1]['ID']) ? pathItem[1]['ID'] : null,
|
|
|
+ row: pathItem[1]
|
|
|
+ })
|
|
|
+ ;
|
|
|
+ // _todoGraphData[todoLevel].nodes.push(nodeObject) // already added below
|
|
|
+ if (lastParentFid) _todoGraphData[level].edges.push(dataMakeEdge(lastParentFid, nodeObject))
|
|
|
+ lastParentFid = nodeObject.id
|
|
|
+ })
|
|
|
+
|
|
|
+ Object.keys(json).filter(function (fieldName) {
|
|
|
+ return (fieldName.indexOf(':') > -1)
|
|
|
+ })
|
|
|
+ .forEach(function (fieldName) {
|
|
|
+ var value = json[fieldName]
|
|
|
+ parseResponseRec(_todoGraphData, value, fieldName, parentNodeId, level + 1)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
function isP5LinkObject(json) {
|
|
|
if ( !('type' in json) || !json['type'] ) return false;
|
|
|
if ( !('value' in json) || !json['value'] ) return false;
|
|
@@ -2163,15 +2227,16 @@ function isP5LinkObject(json) {
|
|
|
function dataMakeNode(params) {
|
|
|
var objectName = params.typeName.substr(params.typeName.indexOf(':') + 1)
|
|
|
var nodeId = objectName + '.' + params.primaryKey // TODO: primaryKey?
|
|
|
- return {
|
|
|
+ var graphNode = {
|
|
|
id: nodeId,
|
|
|
- label: makeShortLabel(nodeId), // TODO: get from schema assert @label attribute
|
|
|
name: nodeId,
|
|
|
group: objectName,
|
|
|
_loaded: true,
|
|
|
typeName: params.typeName,
|
|
|
primaryKey: params.primaryKey // TODO: _primaryKey
|
|
|
}
|
|
|
+ if (params.row) graphNode.row = params.row
|
|
|
+ return graphAddNodeLabel(graphNode)
|
|
|
}
|
|
|
function dataMakeEdge(parentNodeId, nodeObject) {
|
|
|
return {
|
|
@@ -2184,15 +2249,15 @@ function dataMakeXlinkNode(params) {
|
|
|
var objectName = params.typeName.substr(params.typeName.indexOf(':') + 1)
|
|
|
var nodeId = params.xlink.substr(params.xlink.indexOf('#') + 1)
|
|
|
var primaryKey = nodeId.substr(nodeId.lastIndexOf('.') + 1)
|
|
|
- return {
|
|
|
+ var graphNode = {
|
|
|
id: nodeId,
|
|
|
- label: makeShortLabel(nodeId) + ' (+)',
|
|
|
name: nodeId,
|
|
|
group: objectName,
|
|
|
_loaded: false,
|
|
|
typeName: params.typeName,
|
|
|
primaryKey: primaryKey
|
|
|
}
|
|
|
+ return graphAddNodeLabel(graphNode)
|
|
|
}
|
|
|
|
|
|
function dataMakeFetchMoreNode(params) {
|
|
@@ -2228,11 +2293,35 @@ function dataMakeFetchMoreEdge(parentNodeId, fetchMoreNode) {
|
|
|
}
|
|
|
function makeShortLabel(label) { // TODO: shorter name
|
|
|
// BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object.1234567
|
|
|
+
|
|
|
if (label.length < 30) return label;
|
|
|
var exLabel = label.split('.')
|
|
|
if (exLabel.length !== 2) return label;
|
|
|
return exLabel[0].substr(0, 24) + '...' + exLabel[0].substr(-10) + '.' + exLabel[1];
|
|
|
}
|
|
|
+function graphAddNodeLabel(graphNode) {
|
|
|
+ // var graphNode = {
|
|
|
+ // id: nodeId,
|
|
|
+ // name: nodeId,
|
|
|
+ // group: objectName,
|
|
|
+ // _loaded: true,
|
|
|
+ // typeName: params.typeName,
|
|
|
+ // primaryKey: params.primaryKey // TODO: _primaryKey
|
|
|
+ // }
|
|
|
+ var label = graphNode.id // TODO: get from schema assert @label attribute
|
|
|
+ label = makeShortLabel(graphNode.id)
|
|
|
+ // <xs:assert test="@default_db__x3A__BI_audit_KRS:label = concat(nazwa, ' ', krs, ' ', S_miejscowosc)" id="I_audit_KRS___d6e76977-1">
|
|
|
+ switch (graphNode.typeName) {
|
|
|
+ case 'default_db__x3A__BI_audit_KRS:BI_audit_KRS': {
|
|
|
+ if (graphNode.row) label = graphNode.row.nazwa + ' ' + graphNode.row.krs + ' ' + graphNode.row.S_miejscowosc;
|
|
|
+ label = label + ' (krs)'
|
|
|
+ } break;
|
|
|
+ }
|
|
|
+ return Object.assign(graphNode, {
|
|
|
+ label: label,
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|