浏览代码

fixed wfs field type xsd:dateTime to string with regexp

Piotr Labudda 9 年之前
父节点
当前提交
c129496dc0
共有 1 个文件被更改,包括 22 次插入27 次删除
  1. 22 27
      SE/se-lib/Api/WfsServerBase.php

+ 22 - 27
SE/se-lib/Api/WfsServerBase.php

@@ -755,7 +755,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $convertedTransaction:';print_r($convertedTran
 		$changesList = array();
 		if (!empty($itemPatchs)) {
 			foreach ($itemPatchs as $itemPatchInfo) {
-				if($DBG){echo "itemPatchInfo['itemPatch']:\n";print_r($itemPatchInfo['itemPatch']);}
+				if($DBG){echo "L." . __LINE__ . " itemPatchInfo['itemPatch']:\n";print_r($itemPatchInfo['itemPatch']);}
 				$acl = $this->getAclFromTypeName($itemPatchInfo['typeName']);
 				if ('Delete' == $itemPatchInfo['tag']) {
 					$itemPatch = array();
@@ -777,7 +777,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $convertedTransaction:';print_r($convertedTran
 					}
 				}
 
-				if($DBG){echo "TODO '" . ($itemPatchInfo['tag'])? 'Insert' : 'Update' . "' itemPatch:\n";print_r($itemPatch);}
+				if($DBG){echo "L." . __LINE__ . " TODO '" . ($itemPatchInfo['tag'])? 'Insert' : 'Update' . "' itemPatch:\n";print_r($itemPatch);}
 				if ('Insert' == $itemPatchInfo['tag'] && empty($itemPatch[$acl->getPrimaryKeyField()])) {
 					$newId = $acl->addItem($itemPatch);
 					$changesList[$newId] = array('Status'=>(($newId > 0)? 'SUCCESS' : 'FAILED'), 'Message'=>"created {$newId}.");
@@ -1115,11 +1115,14 @@ if($DBG){echo 'L.' . __LINE__ . ' sourceNsList:';print_r($sourceNsList);echo "\n
 				$updateTypeNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:complexType');
 				$rootNode->appendChild($updateTypeNode);
 				$updateTypeNode->setAttribute('name', $updateElementType);
+				{
 					$seqNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:all');
 					$updateTypeNode->appendChild($seqNode);
-
+					{
 						$pKeyField = $acl->getPrimaryKeyField();
 						$fldList = $this->_getFieldListFromAcl($acl);
+
+						// fields without geometry fields
 						foreach ($fldList as $fldName) {
 							if ($acl->isGeomField($fldName)) continue;
 
@@ -1145,37 +1148,25 @@ if($DBG){echo 'L.' . __LINE__ . ' sourceNsList:';print_r($sourceNsList);echo "\n
 								$fldType = 'xsd:date';
 							}
 							else if ($acl->isDateTimeField($fldName)) {
-								$fldType = 'xsd:dateTime';
-							}
-							else if ($acl->isGeomField($fldName)) {
-								//$fldType = 'gml:GeometryPropertyType';
-								// TODO: use geom types from gml to wkt
-								// TODO: pattern wg atrybutów gml:coordinates decimal="." cs="," ts=" "
-								$patternWkt = '';// TODO: error if empty - unsupported geom type
-								$patternNum = '\-?\d+\.?\d*';
-								$patternPoint = $patternNum . ',' . $patternNum;
-								$patternPoints = '(' . $patternPoint . ')( ' . $patternPoint . ')+';
-
-								$geomType = $acl->getGeomFieldType($fldName);
-								if ('polygon' == $geomType) {
-									// [a-zA-Z]+\(\((\-?\d+\.?\d*,\-?\d+\.?\d*)( (\-?\d+\.?\d*,\-?\d+\.?\d*))+\)\)
-									$patternWkt = '[a-zA-Z]+\(\(' . $patternPoints . '\)\)';
-								} else if ('linestring' == $geomType) {
-									// [a-zA-Z]+\((\-?\d+\.?\d*,\-?\d+\.?\d*)( (\-?\d+\.?\d*,\-?\d+\.?\d*))+\)
-									$patternWkt = '[a-zA-Z]+\(' . $patternPoints . '\)';
-								} else if ('point' == $geomType) {
-									// [a-zA-Z]+\(\-?\d\.?\d*,\-?\d\.?\d*\)
-									$patternWkt = '[a-zA-Z]+\(' . $patternPoint . '\)';
-								}
-
+								// $fldType = 'xsd:dateTime';
+								$fldType = null;// 'xsd:string';
+								$patternDataTime = "(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})(:(\d{2}))?";
+								// <xsd:element name="..." minOccurs="0" nillable="true">
+		            //     <xsd:simpleType>
+		            //         <xsd:restriction base="xsd:string">
+		            //             <xsd:pattern value="[a-zA-Z]+\(\((\-?\d+\.?\d*,\-?\d+\.?\d*)( \-?\d+\.?\d*,\-?\d+\.?\d*)+\)\)"/>
+		            //         </xsd:restriction>
+		            //     </xsd:simpleType>
+		            // </xsd:element>
 								$simpleTypeNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:simpleType');
 								$restrictionNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:restriction');
 								$patternNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:pattern');
 								$restrictionNode->setAttribute('base', 'xsd:string');
-								$patternNode->setAttribute('value', $patternWkt);
+								$patternNode->setAttribute('value', $patternDataTime);
 								$restrictionNode->appendChild($patternNode);
 								$simpleTypeNode->appendChild($restrictionNode);
 								$elNode->appendChild($simpleTypeNode);
+								// continue;// TODO: ? below added nillable = true, minOccurs = 0, type = $fldType
 							}
 							else {
 								$fldType = 'xsd:string';
@@ -1184,6 +1175,8 @@ if($DBG){echo 'L.' . __LINE__ . ' sourceNsList:';print_r($sourceNsList);echo "\n
 							$elNode->setAttribute('nillable', 'true');
 							$elNode->setAttribute('minOccurs', '0');
 						}
+
+						// only geometry fields
 						foreach ($fldList as $fldName) {
 							if (!$acl->isGeomField($fldName)) continue;
 
@@ -1230,6 +1223,8 @@ if($DBG){echo 'L.' . __LINE__ . ' sourceNsList:';print_r($sourceNsList);echo "\n
 							$elNode->setAttribute('nillable', 'true');
 							$elNode->setAttribute('minOccurs', '0');
 						}
+					}
+				}
 
 				$attrNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:attribute');
 				$updateTypeNode->appendChild($attrNode);