Bläddra i källkod

updated graph labels

Piotr Labudda 7 år sedan
förälder
incheckning
b92c86787a
1 ändrade filer med 45 tillägg och 96 borttagningar
  1. 45 96
      tools/Bocian.php.view.js

+ 45 - 96
tools/Bocian.php.view.js

@@ -1785,6 +1785,21 @@ function graphFetchData(node, nameSection) {
 		ogcFilterFields: ogcFilterFields,
 	});
 
+	function refFieldsOnPathToList(typeName, fields) {
+		var fields = fields || []
+		var flatList = []
+		var refPathBase = [
+			'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'
+		]
+		flatList.push(refPathBase.concat(typeName).join('/'))
+		fields.forEach(function (fieldName) {
+			flatList.push(refPathBase.concat(typeName, fieldName).join('/'))
+		})
+		return flatList;
+	}
+
 	p5WFS_GetFeature('default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY',
 		Object.assign({
 			sortBy: 'ID+D',
@@ -1797,57 +1812,14 @@ function graphFetchData(node, nameSection) {
 				'ID',
 				'imiona',
 				'nazwisko',
-				'miejscowosc',
+				'miejscowosc'
+			].concat(refFieldsOnPathToList('default_db__x3A__BI_audit_KRS:BI_audit_KRS', [ 'ID', 'nazwa', 'krs', 'S_miejscowosc' ]))
+			.concat(refFieldsOnPathToList('default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI', [ 'ID', 'Pelna_nazwa_kontrahenta' ]))
+			.concat(refFieldsOnPathToList('default_db__x3A__BI_audit_MSIG:BI_audit_MSIG', [ 'ID', 'nazwa' ]))
+			.concat(refFieldsOnPathToList('default_db__x3A__BI_audit_CEIDG:BI_audit_CEIDG', [ 'ID', 'nazwisko', 'firma' ]))
+			.concat([
 				// '*',
 				// 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy/*',
-				[
-					'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_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI'
-				].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'
-				].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',
-					'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
-					'default_db__x3A__BI_audit_MSIG:BI_audit_MSIG'
-				].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_CEIDG:BI_audit_CEIDG'
-				].join('/'),
 				[
 					'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
 					'ID'
@@ -1863,7 +1835,7 @@ function graphFetchData(node, nameSection) {
 					'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object',
 					'ID'
 				].join('/')
-			].map(function (fieldName) {
+			]).map(function (fieldName) {
 				return '<wfs:PropertyName>' + fieldName + '</wfs:PropertyName>';
 			}).join('\n') + '\n' +
 			( ogcFilterFields ? ogcFilterFields : '' ) +
@@ -2056,36 +2028,24 @@ function parseResponseRec(_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
 
 		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_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY" === typeName) {
-			nodeObject = dataMakeNode({
-				typeName: typeName,
-				primaryKey: (json['ID']) ? json['ID'] : null, // TODO: get primaryKey from object
-				row: json
-			})
-			_todoGraphData[level].nodes.push(nodeObject)
-			if (parentNodeId) {
-				_todoGraphData[level].edges.push(dataMakeEdge(parentNodeId, nodeObject))
-			}
+		else if ("default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object" === typeName) {
+			// parseResponseRec__row_object(_todoGraphData, json, typeName, parentNodeId, level)
 			Object.keys(json).filter(function (fieldName) {
 				return (fieldName.indexOf(':') > -1)
 			})
 			.forEach(function (fieldName) {
 				var value = json[fieldName]
-				parseResponseRec(_todoGraphData, value, fieldName, nodeId, level + 1)
+				parseResponseRec(_todoGraphData, value, fieldName, parentNodeId, level + 1)
 			})
 		}
-		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
-		) {
+		else {
 			_todoGraphData[level].nodes.push(nodeObject)
 			if (parentNodeId) {
 				_todoGraphData[level].edges.push(dataMakeEdge(parentNodeId, nodeObject))
@@ -2098,15 +2058,6 @@ function parseResponseRec(_todoGraphData, json, typeName, parentNodeId, level) {
 				parseResponseRec(_todoGraphData, value, fieldName, nodeId, level + 1)
 			})
 		}
-		else {
-			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 if (p5Utils__isString(json)) {
 		if(DBG)console.log('TODO: Not implemented - parseResponseRec isString');
 	} else {
@@ -2166,26 +2117,6 @@ 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,
@@ -2349,6 +2280,24 @@ function graphAddNodeLabel(graphNode) {
 			label = (label) ? label : makeShortLabel(graphNode.id)
 			label = label + ' (pracownicy)'
 		} break;
+		case 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI': {
+			// <xs:assert id="KONTRAHENCI___d6e76526-1" test="@label = concat(substr(Pelna_nazwa_kontrahenta, 0, 20, '\n umów na kwotę ', @sum))"/>
+			if (graphNode.row) label = [graphNode.row.Pelna_nazwa_kontrahenta].filter(function (val) { return val; }).join(' ');
+			label = (label) ? label : makeShortLabel(graphNode.id)
+			label = label + ' (kontrahent)'
+		} break;
+		case 'default_db__x3A__BI_audit_CEIDG:BI_audit_CEIDG': {
+			// <xs:assert test="@label = concat(nazwisko, substring(firma, 1, 20))"/>
+			if (graphNode.row) label = [graphNode.row.nazwisko, graphNode.row.firma].filter(function (val) { return val; }).join(' ');
+			label = (label) ? label : makeShortLabel(graphNode.id)
+			label = label + ' (ceidg)'
+		} break;
+		case 'default_db__x3A__BI_audit_MSIG:BI_audit_MSIG': {
+			// <xs:assert test="@label = substring(nazwa, 1, 20)"/>
+			if (graphNode.row) label = [graphNode.row.nazwa].filter(function (val) { return val; }).join(' ');
+			label = (label) ? label : makeShortLabel(graphNode.id)
+			label = label + ' (msig)'
+		} break;
 	}
 	return Object.assign(graphNode, {
 		label: label,