Bläddra i källkod

added support for resolve, resolveDepth in GetFeature PropertyName, added test cases in Panel wfs js

Piotr Labudda 8 år sedan
förälder
incheckning
6a3cd60173

+ 17 - 1
SE/se-lib/Api/Wfs/GetFeature.php

@@ -23,7 +23,7 @@ class Api_Wfs_GetFeature {
 		if (empty($ogcPropertyList)) {
 			$ogcPropertyList = array_values($acl->getFieldListByIdZasob());
 			$ogcPropertyList = array_filter($ogcPropertyList, function ($fieldName) use ($acl) {
-				return $acl->canReadField($fieldName); // TODO: || $acl->canReadObjectField();
+				return $acl->canReadField($fieldName);
 			});
 		}
 
@@ -38,6 +38,22 @@ class Api_Wfs_GetFeature {
 			},
 			[]
 		);
+		if (!empty($nestedFields)) {
+			if (array_key_exists('*', $nestedFields)) {
+				$nestedParts = $nestedFields['*'];
+				unset($nestedFields['*']);
+				DBG::log($nestedParts, 'array', "convertOgcPropsRecurse: TODO: '*' in \$nestedFields - \$nestedParts");
+				$canReadRefs = array_values($acl->getFieldListByIdZasob());
+				$canReadRefs = array_filter($canReadRefs, function ($fieldName) use ($acl) {
+					return (false !== strpos($fieldName, ":") && $acl->canReadField($fieldName));
+				});
+				foreach ($canReadRefs as $refField) {
+					foreach ($nestedParts as $nestedPart) {
+						$nestedFields[ $refField ][] = $nestedPart;
+					}
+				}
+			}
+		}
 		if (!empty($nestedFields)) {
 			$aclFields = array_unique(array_merge($aclFields, array_keys($nestedFields)));
 		}

+ 13 - 1
SE/se-lib/Api/WfsServerBase.php

@@ -1338,6 +1338,9 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 		if (empty($requestOgcFilter)) return '';
 		$requestXml = new DOMDocument();
 		$requestXml->loadXml($requestOgcFilter);
+		$rootNode = $requestXml->documentElement;
+		// if ($rootNode->getAttribute('resolve'))
+		DBG::log([$rootNode->getAttribute('resolve'), $rootNode->getAttribute('resolveDepth')], 'array', "TODO: use wfs:GetFeature @resolve, @resolveDepth");
 		$nodesQuery = [];
 		foreach ($requestXml->getElementsByTagNameNS('http://www.opengis.net/wfs', 'Query') as $element) {
 			DBG::log($element->nodeName, 'array', "main loop - wfs:Query");
@@ -1368,7 +1371,16 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 			$tagsWfsPropertyName = [];
 			foreach ($requestXml->getElementsByTagNameNS('http://www.opengis.net/wfs', 'PropertyName') as $element) {
 				// DBG::log($element->nodeValue, 'array', "loop wfs:PropertyName (1 * wfs:Query)");
-				$tagsWfsPropertyName[] = $element->nodeValue;
+				if ($element->getAttribute('resolve')) DBG::log([$element->getAttribute('resolve'), $element->getAttribute('resolveDepth'), $element->getAttribute('resolvePath')], 'array', "TODO: use wfs:PropertyName @resolve, @resolveDepth, @resolvePath");
+				$value = $element->nodeValue;
+				if (in_array($element->getAttribute('resolve'), ['all', 'local', 'remote'])) {
+					$depth = $element->getAttribute('resolveDepth');
+					if ('*' !== substr($value, -1)) { // TODO: propertyName is not regex
+						if ('*' === $depth) $value .= "/**"; // TODO: resolveDepth="*" - resolve all
+						else if ((int)$depth > 0) $value .= str_repeat("/*", $depth);
+					}
+				}
+				$tagsWfsPropertyName[] = $value;
 			}
 			DBG::log($tagsWfsPropertyName, 'array', "\$tagsWfsPropertyName (1 * wfs:Query)");
 			return array_filter([

+ 28 - 0
SE/se-lib/Route/WfsJsRequestPanel.php

@@ -35,6 +35,34 @@ class Route_WfsJsRequestPanel extends RouteBase {
 				"	<wfs:PropertyName>DESC</wfs:PropertyName>",
 				"	<wfs:PropertyName>default_db__x3A__CRM_PROCES:PROCES</wfs:PropertyName>",
 			];
+			$listExampleProp['lvl2-by-@-1'] = [
+				"	<wfs:PropertyName>ID</wfs:PropertyName>",
+				"	<wfs:PropertyName>PARENT_ID</wfs:PropertyName>",
+				"	<wfs:PropertyName>TYPE</wfs:PropertyName>",
+				"	<wfs:PropertyName>DESC</wfs:PropertyName>",
+				"	<wfs:PropertyName resolve=\"all\" resolveDepth=\"1\">default_db__x3A__CRM_PROCES:PROCES</wfs:PropertyName>",
+			];
+			$listExampleProp['lvl2-by-@-2'] = [
+				"	<wfs:PropertyName>ID</wfs:PropertyName>",
+				"	<wfs:PropertyName>PARENT_ID</wfs:PropertyName>",
+				"	<wfs:PropertyName>TYPE</wfs:PropertyName>",
+				"	<wfs:PropertyName>DESC</wfs:PropertyName>",
+				"	<wfs:PropertyName resolve=\"all\" resolveDepth=\"2\">default_db__x3A__CRM_PROCES:PROCES</wfs:PropertyName>",
+			];
+			$listExampleProp['lvl2-by-@-3'] = [
+				"	<wfs:PropertyName>ID</wfs:PropertyName>",
+				"	<wfs:PropertyName>PARENT_ID</wfs:PropertyName>",
+				"	<wfs:PropertyName>TYPE</wfs:PropertyName>",
+				"	<wfs:PropertyName>DESC</wfs:PropertyName>",
+				"	<wfs:PropertyName resolve=\"all\" resolveDepth=\"3\">default_db__x3A__CRM_PROCES:PROCES</wfs:PropertyName>",
+			];
+			$listExampleProp['lvl2-by-@-*'] = [
+				"	<wfs:PropertyName>ID</wfs:PropertyName>",
+				"	<wfs:PropertyName>PARENT_ID</wfs:PropertyName>",
+				"	<wfs:PropertyName>TYPE</wfs:PropertyName>",
+				"	<wfs:PropertyName>DESC</wfs:PropertyName>",
+				"	<wfs:PropertyName resolve=\"all\" resolveDepth=\"*\">default_db__x3A__CRM_PROCES:PROCES</wfs:PropertyName>",
+			];
 			$listExampleProp['lvl2'] = [
 				"	<wfs:PropertyName>ID</wfs:PropertyName>",
 				"	<wfs:PropertyName>PARENT_ID</wfs:PropertyName>",