Explorar o código

added p5:primaryKey attribute for GetFeature

Piotr Labudda %!s(int64=8) %!d(string=hai) anos
pai
achega
6f85c9aaff

+ 3 - 0
SE/se-lib/AclQueryBuilder.php

@@ -161,6 +161,9 @@ class AclQueryBuilder {
 		$sqlPk = 'ID';
 		if ($this->from instanceof Core_AclBase) $sqlPk = $this->from->getSqlPrimaryKeyField();
 		if ('*' === $select) return "{$this->_fromPrefix}.*";
+		if ('@primaryKey' === $select) {
+			return "{$this->_fromPrefix}.{$sqlPk} as `@primaryKey`";
+		}
 		if ('@instances' === $select) {
 			if (!($this->from instanceof Core_AclBase)) throw new Exception("select @instances allowed only for Acl object");
 			$instanceTable = ACL::getInstanceTable($this->from->getNamespace());

+ 4 - 4
SE/se-lib/AclQueryFeatures.php

@@ -502,7 +502,7 @@ class AclQueryFeatures {
 
 		$items = $this->fetchRowsRefs(
 			$this->getQuery()
-				->select($select)
+				->select(array_merge(['@primaryKey'], $select))
 				->limit($limit)
 				->offset($offset)
 				->orderBy($sortBy)
@@ -566,9 +566,9 @@ class AclQueryFeatures {
 			}
 		}
 
-		$primaryKey = $this->getAclSqlPrimaryKeyField();
-		if (!in_array($primaryKey, $this->_selectLocalFields)) {
-			$this->_selectLocalFields[] = $primaryKey;
+		$primaryKeyField = $this->getAclSqlPrimaryKeyField();
+		if (!in_array($primaryKeyField, $this->_selectLocalFields)) {
+			$this->_selectLocalFields[] = $primaryKeyField;
 		}
 
 		// TODO: always add A_ADM_COMPANY, A_CLASSIFIED, L_APPOITMENT_USER ?

+ 2 - 0
SE/se-lib/Api/Wfs/GetFeature.php

@@ -349,6 +349,7 @@ class Api_Wfs_GetFeature {
 					$xmlWriter->writeAttribute("p5:allow_write", "true");
 				}
 				$xmlWriter->writeAttribute('xlink:href', $xlink);
+				$xmlWriter->writeAttribute('p5:primaryKey', substr($xlink, strrpos($xlink, '.') + 1));
 			$xmlWriter->endElement();// {$itemPrefix}:{$fldName}
 			return;
 		}
@@ -392,6 +393,7 @@ class Api_Wfs_GetFeature {
 		foreach ($attrs as $name => $value) {
 			$xmlWriter->writeAttribute($name, $value);
 		}
+		if (!empty($item['@primaryKey'])) $xmlWriter->writeAttribute('p5:primaryKey', $item['@primaryKey']);
 
 		// $fldList = $acl->getRealFieldListByIdZasob();
 		$fldList = $acl->getFieldListByIdZasob();