|
@@ -326,8 +326,13 @@ class Core_AclBase {
|
|
|
if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " F.".__FUNCTION__." validate fields loop({$idx}) loop({$fieldName}) \$fieldType({$fieldType})"."\n";}
|
|
if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " F.".__FUNCTION__." validate fields loop({$idx}) loop({$fieldName}) \$fieldType({$fieldType})"."\n";}
|
|
|
if ('gml:' == substr($fieldType, 0, 4)) {
|
|
if ('gml:' == substr($fieldType, 0, 4)) {
|
|
|
$tagValue['value'] = $this->convertGmlTagsToWkt($fieldType, $tagValue['tags']);
|
|
$tagValue['value'] = $this->convertGmlTagsToWkt($fieldType, $tagValue['tags']);
|
|
|
|
|
+ } else if ('ref:' == substr($fieldType, 0, 4)) {
|
|
|
|
|
+ if (1 == count($tagValue['tags'])) {
|
|
|
|
|
+ $tagValue['value'] = $tagValue['tags'][0]['attributes']['xlink:href'];// https://biuro.biall-net.pl/wfs/default_objects#AccessGroupRead.27
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new Exception("Error Processing Update Request - wrong Value tag format for field '{$fieldName}' (Update/Property[{$idx}])");
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- // TODO: return $fields[$fieldName][] = array('type'=>'open', 'typeName'=>$fieldType, 'tags'=>...
|
|
|
|
|
throw new Exception("Error Processing Update Request - wrong Value tag format for field '{$fieldName}' (Update/Property[{$idx}])");
|
|
throw new Exception("Error Processing Update Request - wrong Value tag format for field '{$fieldName}' (Update/Property[{$idx}])");
|
|
|
}
|
|
}
|
|
|
} else if ('complete' == $tagValue['type']) {
|
|
} else if ('complete' == $tagValue['type']) {
|
|
@@ -626,6 +631,15 @@ class Core_AclBase {
|
|
|
");
|
|
");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function _cleanRefs($childName, $pk) {// TODO: $idTransaction
|
|
|
|
|
+ $refTable = $this->createRefTable($childName);
|
|
|
|
|
+ $sqlPk = DB::getPDO()->quote($pk, PDO::PARAM_STR);
|
|
|
|
|
+ DB::getPDO()->exec("
|
|
|
|
|
+ update `{$refTable}` set `A_STATUS` = 'DELETED'
|
|
|
|
|
+ where `PRIMARY_KEY` = {$sqlPk}
|
|
|
|
|
+ ");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public function createRefTable($childName) {// TODO: $idTransaction
|
|
public function createRefTable($childName) {// TODO: $idTransaction
|
|
|
static $cacheRefTables = array();
|
|
static $cacheRefTables = array();
|
|
|
$objectName = $this->getName();
|
|
$objectName = $this->getName();
|
|
@@ -635,11 +649,23 @@ class Core_AclBase {
|
|
|
CREATE TABLE IF NOT EXISTS `{$refTable}` (
|
|
CREATE TABLE IF NOT EXISTS `{$refTable}` (
|
|
|
`PRIMARY_KEY` int(11) NOT NULL,
|
|
`PRIMARY_KEY` int(11) NOT NULL,
|
|
|
`REMOTE_PRIMARY_KEY` int(11) NOT NULL,
|
|
`REMOTE_PRIMARY_KEY` int(11) NOT NULL,
|
|
|
|
|
+ `A_STATUS` enum('WAITING', 'NORMAL', 'DELETED') NOT NULL DEFAULT 'WAITING',
|
|
|
|
|
+ `A_RECORD_UPDATE_DATE` timestamp ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
-- TODO `TRANACTION_ID` int(11) NOT NULL
|
|
-- TODO `TRANACTION_ID` int(11) NOT NULL
|
|
|
KEY `PRIMARY_KEY` (`PRIMARY_KEY`),
|
|
KEY `PRIMARY_KEY` (`PRIMARY_KEY`),
|
|
|
KEY `REMOTE_PRIMARY_KEY` (`REMOTE_PRIMARY_KEY`)
|
|
KEY `REMOTE_PRIMARY_KEY` (`REMOTE_PRIMARY_KEY`)
|
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin2;
|
|
) ENGINE=MyISAM DEFAULT CHARSET=latin2;
|
|
|
");
|
|
");
|
|
|
|
|
+ try {
|
|
|
|
|
+ DB::getPDO()->exec(" ALTER TABLE `{$refTable}` ADD `A_STATUS` enum('WAITING', 'NORMAL', 'DELETED') NOT NULL DEFAULT 'WAITING' ");
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ // echo 'C.'.get_class($this).' L.' . __LINE__ . " Error:";print_r($e->getMessage());echo "\n";
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ DB::getPDO()->exec(" ALTER TABLE `{$refTable}` ADD `A_RECORD_UPDATE_DATE` timestamp ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ");
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ // echo 'C.'.get_class($this).' L.' . __LINE__ . " Error:";print_r($e->getMessage());echo "\n";
|
|
|
|
|
+ }
|
|
|
$cacheRefTables[] = $refTable;
|
|
$cacheRefTables[] = $refTable;
|
|
|
return $refTable;
|
|
return $refTable;
|
|
|
}
|
|
}
|
|
@@ -653,18 +679,54 @@ class Core_AclBase {
|
|
|
if (empty($action['fields'])) throw new Exception("Error Processing Request - missing Property for type '{$action['typeName']}'", 500);
|
|
if (empty($action['fields'])) throw new Exception("Error Processing Request - missing Property for type '{$action['typeName']}'", 500);
|
|
|
// TODO: check acl user to update record ID = $action['Filter']
|
|
// TODO: check acl user to update record ID = $action['Filter']
|
|
|
$itemPatch = array();
|
|
$itemPatch = array();
|
|
|
|
|
+ $refPatch = array();
|
|
|
foreach ($action['fields'] as $fieldName => $childFields) {
|
|
foreach ($action['fields'] as $fieldName => $childFields) {
|
|
|
|
|
+ $fieldType = $this->getXsdFieldType($fieldName);
|
|
|
|
|
+if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " \$fieldType:";print_r($fieldType);echo "\n";}// ref:default_objects:AccessGroupRead
|
|
|
foreach ($childFields as $idx => $field) {
|
|
foreach ($childFields as $idx => $field) {
|
|
|
if ('complete' != $field['type']) continue;// skip child nodes, REF
|
|
if ('complete' != $field['type']) continue;// skip child nodes, REF
|
|
|
$value = $field['value'];
|
|
$value = $field['value'];
|
|
|
if ($this->isGeomField($fieldName)) $value = "GeomFromText('{$value}')";
|
|
if ($this->isGeomField($fieldName)) $value = "GeomFromText('{$value}')";
|
|
|
- $itemPatch[$fieldName] = $value;
|
|
|
|
|
|
|
+ if ('ref:' == substr($fieldType, 0, 4)) {
|
|
|
|
|
+ $refPatch[$fieldName][$idx] = $value;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $itemPatch[$fieldName] = $value;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $id = $itemPatch[$this->getPrimaryKeyField()] = $action['Filter'];
|
|
|
|
|
+ if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " updateXml action \$itemPatch({$id}):";print_r($itemPatch);echo "\n";}
|
|
|
|
|
+ if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " updateXml action \$refPatch:";print_r($refPatch);echo "\n";}
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach ($refPatch as $fieldName => $childValues) {
|
|
|
|
|
+ $this->_cleanRefs($fieldName, $id);
|
|
|
|
|
+ foreach ($childValues as $idx => $value) {
|
|
|
|
|
+ list($nsUrl, $featureId) = explode('#', $value, 2);// https://biuro.biall-net.pl/wfs/default_objects#AccessGroupRead.27
|
|
|
|
|
+ list($featureName, $primaryKey) = explode('.', $featureId, 2);
|
|
|
|
|
+if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " \$featureId: ";print_r($featureId);echo "\n";}// AccessGroupRead.27
|
|
|
|
|
+if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " \$featureName: ";print_r($featureName);echo "\n";}// AccessGroupRead
|
|
|
|
|
+if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " \$primaryKey: ";print_r($primaryKey);echo "\n";}// 27
|
|
|
|
|
+if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " \$nsUrl: ";print_r($nsUrl);echo "\n";}// https://biuro.biall-net.pl/wfs/default_objects
|
|
|
|
|
+ $refAcl = Core_AclHelper::getAclByNamespace("{$nsUrl}/{$featureName}");
|
|
|
|
|
+if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " \$refAcl: ";print_r($refAcl);echo "\n";}
|
|
|
|
|
+ $remoteItem = $refAcl->getItem($primaryKey);
|
|
|
|
|
+ if (!$remoteItem) throw new Exception("Brak dostępu do obiektu: {$value}");
|
|
|
|
|
+if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " \$remoteItem: ";print_r($remoteItem);echo "\n";}
|
|
|
|
|
+ // TODO: validate
|
|
|
|
|
+ $this->_insertRef($fieldName, $id, $primaryKey);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- $itemPatch[$this->getPrimaryKeyField()] = $action['Filter'];
|
|
|
|
|
- if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " updateXml action \$itemPatch:";print_r($itemPatch);echo "\n";}
|
|
|
|
|
|
|
+
|
|
|
|
|
+if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " updateXml action \$refPatch:";print_r($refPatch);echo "\n";}
|
|
|
|
|
+if($DBG){echo 'C.'.get_class($this).' L.' . __LINE__ . " updateXml action \$itemPatch:";print_r($itemPatch);echo "\n";}
|
|
|
|
|
+if($DBG){die();}
|
|
|
|
|
+
|
|
|
$affected = $this->updateItem($itemPatch);
|
|
$affected = $this->updateItem($itemPatch);
|
|
|
|
|
+
|
|
|
// TODO: update/insert child nodes, REF
|
|
// TODO: update/insert child nodes, REF
|
|
|
|
|
+
|
|
|
return $affected;
|
|
return $affected;
|
|
|
}
|
|
}
|
|
|
|
|
|