Просмотр исходного кода

added instance in DescribeFeatureTypeAdvanced

Piotr Labudda 9 лет назад
Родитель
Сommit
fa5c7f954e
2 измененных файлов с 54 добавлено и 5 удалено
  1. 8 5
      SE/se-lib/Api/WfsDataServer.php
  2. 46 0
      SE/se-lib/Api/WfsServerBase.php

+ 8 - 5
SE/se-lib/Api/WfsDataServer.php

@@ -309,8 +309,8 @@ class Api_WfsDataServer extends Api_WfsServerBase {
 	}
 
 	public function describeFeatureTypeAdvancedAction() {
-		$type = V::get('TYPENAME', '', $_REQUEST);
-		if (empty($type)) {
+		$typeName = V::geti('TYPENAME', '', $_REQUEST);
+		if (empty($typeName)) {
 			$reqContent = Request::getRequestBody();
 			if (!empty($reqContent)) {
 				return $this->_parseDescribeFeatureTypeRequest($reqContent, $simple = false);
@@ -319,9 +319,12 @@ class Api_WfsDataServer extends Api_WfsServerBase {
 			}
 			//throw new HttpException("Wrong param TYPENAME", 400);
 		}
-		$typeEx = explode(':', $type);
-		if (count($typeEx) != 2) throw new HttpException("Wrong param TYPENAME", 400);
-		return $this->_getDescribeFeatureType($typeEx[0], $typeEx[1], $simple = false);
+		if (false === strpos($typeName, ':')) throw new HttpException("Wrong param TYPENAME", 400);
+		list($nsPrefix, $name) = explode(':', $typeName);
+		if ('/@instance' == strtolower(substr($name, -1 * strlen('/@instance')))) {
+			return $this->_describeInstanceAttributeTable($nsPrefix, substr($name, 0, -1 * strlen('/@instance')));
+		}
+		return $this->_getDescribeFeatureType($nsPrefix, $name, $simple = false);
 	}
 
 	public function getCapabilitiesAction() {

+ 46 - 0
SE/se-lib/Api/WfsServerBase.php

@@ -1227,6 +1227,52 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 		return $reqXml->schemaValidateSource($validateConvertedTransactionXsdString);
 	}
 
+	public function _describeInstanceAttributeTable($nsPrefix, $name) {
+		$acl = $this->getAclFromTypeName("{$nsPrefix}:{$name}");
+
+		$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('xsd:schema');
+		$xmlWriter->writeAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
+		$xmlWriter->writeAttribute('xmlns:gml', 'http://www.opengis.net/gml');
+		foreach (Api_WfsNs::getNsList() as $uri => $prefix) {
+			$xmlWriter->writeAttribute("xmlns:{$prefix}", $uri);
+		}
+		$xmlWriter->writeAttribute('elementFormDefault', 'qualified');
+
+		$xsdInstanceType = $acl->getName() . "_instanceType";
+		$xsdPrimaryKey = "xsd:string";// TODO: get from $acl
+		$xmlWriter->h('xsd:element', ['name'=>"instance"], [
+			[ 'xsd:complexType', [
+				[ 'xsd:sequence', [
+					[ 'xsd:element', ['name'=>"primaryKey", 'type'=>$xsdPrimaryKey], null ],
+					[ 'xsd:element', ['name'=>"instance", 'type'=>$xsdInstanceType], null ],
+					[ 'xsd:element', ['name'=>"type", 'type'=>"xsd:string"], null ],// TODO: instance, derived
+					[ 'xsd:element', ['name'=>"create_author", 'type'=>"xsd:string"], null ],
+					[ 'xsd:element', ['name'=>"create_date", 'type'=>"xsd:dateTime"], null ],
+					[ 'xsd:element', ['name'=>"update_author", 'type'=>"xsd:string"], null ],
+					[ 'xsd:element', ['name'=>"updage_date", 'type'=>"xsd:dateTime"], null ],
+				] ]
+			] ]
+		]);
+		$instanceList = [];
+		$instanceList[] = [ 'xsd:enumeration', ['value'=>$acl->getName()], null ];
+		if (method_exists($acl, 'getInstanceList')) {
+			foreach ($acl->getInstanceList() as $instanceName) {
+				$instanceList[] = [ 'xsd:enumeration', ['value'=>$instanceName], null ];
+			}
+		}
+		$xmlWriter->h('xsd:simpleType', ['name'=>$xsdInstanceType], [
+			[ 'xsd:restriction', ['base'=>"xsd:string"], $instanceList],
+		]);
+		$xmlWriter->endElement();// xsd:schema
+		$xmlWriter->endDocument();
+		exit;
+	}
+
 	public function _getDescribeFeatureType($nsPrefix, $type, $simple = true) {
 		return $this->_getDescribeFeatureTypes(array(array($nsPrefix, $type)), $simple);
 	}