Jelajahi Sumber

updated wfs describe p5:name if field name and ref name diffs

Piotr Labudda 9 tahun lalu
induk
melakukan
38550e6036

+ 1 - 0
SE/se-lib/Api/WfsData.php

@@ -58,6 +58,7 @@ class Api_WfsData extends ApiRouteBase {// TODO: extends Api_WfsBase which exten
 
 
 			$this->DBG("usr:" . $this->_apiUser->getID(), __LINE__, __FUNCTION__, __CLASS__);
 			$this->DBG("usr:" . $this->_apiUser->getID(), __LINE__, __FUNCTION__, __CLASS__);
 			$wfsServer = new $serverClass($userAcl);
 			$wfsServer = new $serverClass($userAcl);
+			$wfsServer->setLogger($this->_logger);
 			$wfsServer->setBaseUri($this->_apiBaseUri);
 			$wfsServer->setBaseUri($this->_apiBaseUri);
 			$wfsServer->run($request);
 			$wfsServer->run($request);
 			exit;// TODO:? return $document;
 			exit;// TODO:? return $document;

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

@@ -1495,6 +1495,9 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 									$elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:name", $fieldName);
 									$elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:name", $fieldName);
 								} else {
 								} else {
 									$elNode->setAttribute('ref', "{$tnsPrefix}:{$field['@ref']}");
 									$elNode->setAttribute('ref', "{$tnsPrefix}:{$field['@ref']}");
+									if ($fieldName != $field['@ref']) {
+										$elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:name", $fieldName);
+									}
 								}
 								}
 							} else {
 							} else {
 								throw new Exception("Error Processing simpleSchema - missing @type or @ref: '{$ssName}/{$fieldName}'");
 								throw new Exception("Error Processing simpleSchema - missing @type or @ref: '{$ssName}/{$fieldName}'");

+ 15 - 7
SE/se-lib/Api/Xsd.php

@@ -63,6 +63,7 @@ XMLEOF;
 			foreach ($tbls as $tblName => $ds) {
 			foreach ($tbls as $tblName => $ds) {
 				$xmlFields = array();
 				$xmlFields = array();
 				$tblFields = $ds->_col_types;
 				$tblFields = $ds->_col_types;
+				$xmlTableNamedSimpleTypes = array();
 				foreach ($tblFields as $fldName => $colType) {
 				foreach ($tblFields as $fldName => $colType) {
 					$minOccurs = 0;
 					$minOccurs = 0;
 					$maxOccurs = 1;
 					$maxOccurs = 1;
@@ -173,20 +174,26 @@ XMLEOF;
 					}
 					}
 
 
 					$xmlFld = '';
 					$xmlFld = '';
-					$xmlFld .= '<xs:element minOccurs="' . $minOccurs . '" maxOccurs="' . $maxOccurs . '" name="' . $fldName . '">';
-						$xmlFld .= "\n\t\t\t\t" . '<xs:simpleType>';
+					$xmlFieldTypeName = "{$tblName}__{$fldName}";
+					$xmlFld .= '<xs:element minOccurs="' . $minOccurs . '" maxOccurs="' . $maxOccurs . '" name="' . $fldName . '" type="' . "{$this->_dataSourceName}:{$xmlFieldTypeName}" . '">';
+					{
+						$xmlNamedSimpleType = '';
+						$xmlNamedSimpleType .= "\n" . '<xs:simpleType name="' . $xmlFieldTypeName . '">';
 						if (!empty($xsdRestrictions)) {
 						if (!empty($xsdRestrictions)) {
-							$xmlFld .= "\n\t\t\t\t\t" . '<xs:restriction base="xs:' . $xsdType . '">';
-								$xmlFld .= "\n\t\t\t\t\t\t" . implode("\n\t\t\t\t\t\t", $xsdRestrictions);
-							$xmlFld .= "\n\t\t\t\t\t" . '</xs:restriction>';
+							$xmlNamedSimpleType .= "\n\t" . '<xs:restriction base="xs:' . $xsdType . '">';
+								$xmlNamedSimpleType .= "\n\t\t" . implode("\n\t\t", $xsdRestrictions);
+							$xmlNamedSimpleType .= "\n\t" . '</xs:restriction>';
 						} else {
 						} else {
-							$xmlFld .= "\n\t\t\t\t\t" . '<xs:restriction base="xs:' . $xsdType . '"/>';
+							$xmlNamedSimpleType .= "\n\t" . '<xs:restriction base="xs:' . $xsdType . '"/>';
 						}
 						}
-						$xmlFld .= "\n\t\t\t\t" . '</xs:simpleType>';
+						$xmlNamedSimpleType .= "\n" . '</xs:simpleType>';
+						$xmlTableNamedSimpleTypes[] = $xmlNamedSimpleType;
+					}
 					$xmlFld .= "\n\t\t\t" . '</xs:element>';
 					$xmlFld .= "\n\t\t\t" . '</xs:element>';
 					$xmlFields[] = $xmlFld;
 					$xmlFields[] = $xmlFld;
 				}
 				}
 				$xmlFields = implode("\n\t\t\t", $xmlFields);
 				$xmlFields = implode("\n\t\t\t", $xmlFields);
+				$xmlTableNamedSimpleTypes = implode("\n", $xmlTableNamedSimpleTypes);
 				$xml .= <<<XMLEOF
 				$xml .= <<<XMLEOF
 
 
 
 
@@ -197,6 +204,7 @@ XMLEOF;
 			{$xmlFields}
 			{$xmlFields}
 		</xs:sequence>
 		</xs:sequence>
 	</xs:complexType>
 	</xs:complexType>
+	{$xmlTableNamedSimpleTypes}
 XMLEOF;
 XMLEOF;
 			}
 			}
 			$xml .= <<<XMLEOF
 			$xml .= <<<XMLEOF

+ 2 - 0
SE/se-lib/OBJ.php

@@ -123,6 +123,8 @@ IF $changed :
       , c.`{$fld}` - l.`{$fld}` ...
       , c.`{$fld}` - l.`{$fld}` ...
     where c.`#PRIMARY_KEY` = {$pk} and l.`ID` = {$version} and l.`#PRIMARY_KEY` = {$pk}
     where c.`#PRIMARY_KEY` = {$pk} and l.`ID` = {$version} and l.`#PRIMARY_KEY` = {$pk}
 
 
+# TODO: function to import data from _HIST table
+
 # TODO: #REF
 # TODO: #REF
   # TODO: update #REF should update #VERSION
   # TODO: update #REF should update #VERSION
     # TODO: #REF sctruct hould have #VERIFIED fields for both sides of relation - eg. change instance of some obj may break #REF from another obj
     # TODO: #REF sctruct hould have #VERIFIED fields for both sides of relation - eg. change instance of some obj may break #REF from another obj

+ 93 - 0
SE/se-lib/Route/Storage.php

@@ -753,6 +753,25 @@ jQuery(document).on('p5UIBtnAjax:Storage:addCellToZasoby:ajaxLoaded', function(e
 	jQuery.notify(payload.msg, payload.type);
 	jQuery.notify(payload.msg, payload.type);
 });
 });
 </script>
 </script>
+<?php
+
+			$ajaxAddZasobLink = Request::getPathUri() . "index.php?_route=Storage&_task=addGeomEtykietaCells&idStorage={$idStorage}&tblName={$tblName}";
+			$onClick = "return p5UI__ButtonAjax(this, 'p5UIBtnAjax:Storage:addGeomEtykietaCells', { href: '{$ajaxAddZasobLink}' })";
+			UI::tag('a', ['onclick'=>$onClick, 'class'=>"btn btn-xs btn-primary", 'href'=>"#"], "Dodaj komórki etykiet", true);
+			echo "<i>(<code>`etykieta_x`</code>, <code>`etykieta_y`</code>, <code>`etykieta_obrot`</code>)</i>";
+?>
+<script>
+jQuery(document).on('p5UIBtnAjax:Storage:addGeomEtykietaCells:ajaxLoaded', function(e, n, payload) {
+	console.log('event p5UIBtnAjax:Storage:addGeomEtykietaCells:ajaxLoaded', n, payload);
+	if ('success' == payload.type && payload.body && payload.body.id > 0) {
+		var cellUwagi$Node = jQuery(n).parents('td').next('td');
+		cellUwagi$Node.text(cellUwagi$Node.text().replace('!Zasob', ''))
+		jQuery(n).parents('td').text(payload.body.id);
+		jQuery(n).remove();
+	}
+	jQuery.notify(payload.msg, payload.type);
+});
+</script>
 <?php
 <?php
 		} catch (Exception $e) {
 		} catch (Exception $e) {
 			UI::alert('danger', "Error #" . $e->getCode() .  "|" . $e->getLine() .  ": " . $e->getMessage());
 			UI::alert('danger', "Error #" . $e->getCode() .  "|" . $e->getLine() .  ": " . $e->getMessage());
@@ -760,6 +779,80 @@ jQuery(document).on('p5UIBtnAjax:Storage:addCellToZasoby:ajaxLoaded', function(e
 		UI::dol();
 		UI::dol();
 	}
 	}
 
 
+	public function addGeomEtykietaCellsAction() {
+		Response::sendTryCatchJson(array($this, 'addGeomEtykietaCells'), $_REQUEST);
+	}
+	public function addGeomEtykietaCells($args) {
+		$return = [
+			'type' => 'error',
+			'msg' => 'todo: F.' . __FUNCTION__ . ' L.' . __LINE__,
+		];
+
+		$return['_DBG_request'] = $args;
+		// idStorage: "36"
+		// tblName: "test_geom_linestring"
+		$idStorage = V::get('idStorage', 0, $args, 'int');
+		if ($idStorage <= 0) throw new HttpException("Missing idStorage", 400);
+		$storage = DB::getStorage($idStorage);
+		$tblName = V::get('tblName', 0, $args, 'word');
+		if (empty($tblName)) throw new HttpException("Missing tblName", 400);
+
+		$tableStruct = $storage->getTableStruct($tblName);
+		$return['_DBG_$tableStruct'] = $tableStruct;
+
+		if ('mysql' == DB::getPDO($idStorage)->getType()) {
+			$dbName = DB::getPDO($idStorage)->getDatabaseName();
+			$fixedTableName = DB::getPDO($idStorage)->fetchValue("
+				select t.TABLE_NAME
+				from `information_schema`.`TABLES` t
+				where t.TABLE_SCHEMA = '{$dbName}'
+					and t.TABLE_NAME LIKE '{$tblName}'
+			");
+			$return['_DBG_sql_fix__$tblName'] = "
+				select t.TABLE_NAME
+				from `information_schema`.`TABLES` t
+				where t.TABLE_SCHEMA = '{$dbName}'
+					and t.TABLE_NAME LIKE '{$tblName}'
+			";
+			if (empty($fixedTableName)) return $return;
+			if (empty($fixedTableName)) throw new HttpException("Database Error", 500);
+			$return['_DBG_$fixedTableName'] = $fixedTableName;
+			$tblName = $fixedTableName;
+		}
+		$return['_DBG_$tableStruct'] = $tableStruct;
+
+		$return['_DBG_has_field__etykieta_x'] = (null != V::geti('etykieta_x', null, $tableStruct));
+		$return['_DBG_has_field__etykieta_y'] = (null != V::geti('etykieta_y', null, $tableStruct));
+		$return['_DBG_has_field__etykieta_obrot'] = (null != V::geti('etykieta_obrot', null, $tableStruct));
+
+		if (!V::geti('etykieta_x', null, $tableStruct)) {
+			try {
+				DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}_HIST` ADD `etykieta_x` varchar(16) DEFAULT 'N/S;'");
+			} catch (Exception $e) {
+				$return['__DBG_hist_errors__etykieta_x'] = $e->getMessage();
+			}
+			DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}` ADD `etykieta_x` decimal(16,10) DEFAULT NULL COMMENT 'przesuniecie etykiety elementu w GIS'");
+		}
+		if (!V::geti('etykieta_y', null, $tableStruct)) {
+			try {
+				DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}_HIST` ADD `etykieta_y` varchar(16) DEFAULT 'N/S;'");
+			} catch (Exception $e) {
+				$return['__DBG_hist_errors__etykieta_y'] = $e->getMessage();
+			}
+			DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}` ADD `etykieta_y` decimal(16,10) DEFAULT NULL COMMENT 'przesuniecie etykiety elementu w GIS'");
+		}
+		if (!V::geti('etykieta_obrot', null, $tableStruct)) {
+			try {
+				DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}_HIST` ADD `etykieta_obrot` varchar(16) DEFAULT 'N/S;'");
+			} catch (Exception $e) {
+				$return['__DBG_hist_errors__etykieta_obrot'] = $e->getMessage();
+			}
+			DB::getPDO($idStorage)->exec("ALTER TABLE `{$tblName}` ADD `etykieta_obrot` decimal(16,10) DEFAULT NULL");
+		}
+
+		return $return;
+	}
+
 	public function xsdAction() {
 	public function xsdAction() {
 		$idStorage = V::get('idStorage', 0, $_REQUEST, 'int');
 		$idStorage = V::get('idStorage', 0, $_REQUEST, 'int');
 		$storage = DB::getStorage($idStorage);
 		$storage = DB::getStorage($idStorage);

+ 1 - 0
SE/se-lib/Route/UrlAction.php

@@ -116,6 +116,7 @@ class Route_UrlAction extends RouteBase {// TODO: UrlActionBase
 				, zp.ALIAS_ID as param_in_to_cell_id
 				, zp.ALIAS_ID as param_in_to_cell_id
 				, zp.DESC as param_in_name
 				, zp.DESC as param_in_name
 				, param.`DESC` as link_param
 				, param.`DESC` as link_param
+				-- TODO find LINK_TARGET_SELF under za.ID - link target defined globally
 			from CRM_LISTA_ZASOBOW z
 			from CRM_LISTA_ZASOBOW z
 				join CRM_LISTA_ZASOBOW za on(za.ID = z.ALIAS_ID)
 				join CRM_LISTA_ZASOBOW za on(za.ID = z.ALIAS_ID)
 				left join CRM_LISTA_ZASOBOW zp on(zp.PARENT_ID = z.ID and zp.`TYPE` = 'PARAM_IN')
 				left join CRM_LISTA_ZASOBOW zp on(zp.PARENT_ID = z.ID and zp.`TYPE` = 'PARAM_IN')

+ 1 - 1
SE/wfs-data.php

@@ -46,7 +46,7 @@ IF(V::get('DBG','',$_GET)){echo'<pre style="max-height:200px;overflow:auto;borde
 $api = new Api();
 $api = new Api();
 $api->setUser($apiUser);
 $api->setUser($apiUser);
 $apiBaseUri = Request::getScriptUri();
 $apiBaseUri = Request::getScriptUri();
-$api->setBaseUri($apiBaseUri);
+$api->setBaseUri($apiBaseUri);// TODO: RMME - replaced with Api_WfsNs::getBaseWfsUri();
 try {
 try {
 	$api->execute($taskPath);
 	$api->execute($taskPath);
 }
 }