Parcourir la source

+ XML outputFormat in BiAuditGraph

Piotr Labudda il y a 7 ans
Parent
commit
127187271a
1 fichiers modifiés avec 42 ajouts et 1 suppressions
  1. 42 1
      SE/se-lib/Route/UrlAction/BiAuditGraph.php

+ 42 - 1
SE/se-lib/Route/UrlAction/BiAuditGraph.php

@@ -2,6 +2,7 @@
 
 Lib::loadClass('Api_WfsNs');
 Lib::loadClass('Response');
+Lib::loadClass('Core_XmlWriter');
 
 class Route_UrlAction_BiAuditGraph extends RouteBase {
 
@@ -277,7 +278,47 @@ class Route_UrlAction_BiAuditGraph extends RouteBase {
 		die();
 	}
 	function sendXmlStats($raportId, $stats) {
-		print_r($stats);
+		header('Content-type: application/xml; charset=utf-8');
+		$xmlWriter = new Core_XmlWriter();
+		if (!$xmlWriter) throw new HttpException("Error no XMLWriter", 404);
+		$xmlWriter->openUri('php://output');
+		$xmlWriter->setIndent(true);
+		$xmlWriter->startDocument('1.0','UTF-8');
+		$xmlWriter->startElement('p5:reportGraph');
+		// $xmlWriter->writeAttribute('xml:lang', "en-GB");
+		$xmlWriter->writeAttribute('xmlns:p5', Api_WfsNs::getBaseWfsUri());
+		$xmlWriter->writeAttribute('xmlns:xlink', "http://www.w3.org/1999/xlink");
+		$xmlWriter->writeAttribute('xmlns:wps', "http://www.opengis.net/wps/1.0.0");
+		$xmlWriter->writeAttribute('xmlns:ows', "http://www.opengis.net/ows/1.1");
+		$xmlWriter->writeAttribute('xmlns:ogc', "http://www.opengis.net/ogc");
+		$xmlWriter->writeAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
+		$xmlWriter->writeAttribute('id', $raportId);
+		$xmlWriter->h('p5:nodes', [], array_map(function ($node) {
+			return [
+				'p5:node', [
+					'objectName' => $node['@object'],
+					'primaryKey' => $node['@primaryKey'],
+					'label' => $node['@label'],
+				], []
+			];
+		}, $stats['nodes']) );
+		$xmlWriter->h('p5:edges', [], array_map(function ($node) {
+			return [
+				'p5:edge', [
+					'source' => $node['source'],
+					'target' => $node['target'],
+					'pathId' => $node['pathId'],
+				], []
+			];
+		}, $stats['edges']) );
+		// [edges] => Array:
+		//         [0] => Array:
+		//             [source] => BI_audit_KRS_person.747000
+		//             [target] => BI_audit_MSIG_person.856408
+		//             [pathId] => 396191
+		$xmlWriter->endElement(); // root
+		$xmlWriter->endDocument();
+		exit;
 	}
 	function sendHtmlStats($raportId, $stats) {
 		UI::gora();