|
@@ -595,13 +595,6 @@ class AclQueryFeatures {
|
|
|
}, $rows));
|
|
}, $rows));
|
|
|
DBG::log($this->_foundFeatures, 'array', "_foundFeatures");
|
|
DBG::log($this->_foundFeatures, 'array', "_foundFeatures");
|
|
|
return array_map([ $this, 'fetchRowRefs' ], $rows);
|
|
return array_map([ $this, 'fetchRowRefs' ], $rows);
|
|
|
- // if (!empty($rows) && !empty($rows[0])) {
|
|
|
|
|
- // $rows[0]['default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK'] = [
|
|
|
|
|
- // [ 'xlink' => 'default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK.999' ],
|
|
|
|
|
- // [ 'xlink' => 'default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIK.998' ],
|
|
|
|
|
- // ];
|
|
|
|
|
- // }
|
|
|
|
|
- return $rows;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function fetchRowRefs($row) {
|
|
public function fetchRowRefs($row) {
|
|
@@ -610,11 +603,10 @@ class AclQueryFeatures {
|
|
|
$primaryKey = $row[$sqlPk];
|
|
$primaryKey = $row[$sqlPk];
|
|
|
DBG::log($row, 'array', "DBG primaryKey '{$primaryKey}'");
|
|
DBG::log($row, 'array', "DBG primaryKey '{$primaryKey}'");
|
|
|
if (!$primaryKey) throw new Exception("Missing primaryKey");
|
|
if (!$primaryKey) throw new Exception("Missing primaryKey");
|
|
|
|
|
+ $defaultRefLimit = 10; // TODO: get from $this->_params and pass to nested buildQuery
|
|
|
|
|
+ $refLimitPlus1 = $defaultRefLimit + 1;
|
|
|
foreach ($this->getSelectRemote() as $fieldName => $cols) {
|
|
foreach ($this->getSelectRemote() as $fieldName => $cols) {
|
|
|
DBG::log($cols, 'array', "add select remote '{$fieldName}' \$cols");
|
|
DBG::log($cols, 'array', "add select remote '{$fieldName}' \$cols");
|
|
|
-
|
|
|
|
|
- $refLimit = 10; // TODO: get from $this->_params and pass to nested buildQuery
|
|
|
|
|
- $refLimitPlus1 = $refLimit + 1;
|
|
|
|
|
$xsdType = $this->_acl->getXsdFieldType($fieldName);
|
|
$xsdType = $this->_acl->getXsdFieldType($fieldName);
|
|
|
if ('ref:' === substr($xsdType, 0, 4) && empty($cols)) {
|
|
if ('ref:' === substr($xsdType, 0, 4) && empty($cols)) {
|
|
|
DBG::log("add remote xlink's '{$fieldName}' \$items[{$primaryKey}] ...");
|
|
DBG::log("add remote xlink's '{$fieldName}' \$items[{$primaryKey}] ...");
|
|
@@ -635,32 +627,49 @@ class AclQueryFeatures {
|
|
|
'xlink' => "{$ns['url']}#{$ns['name']}.{$refInfo['REMOTE_PRIMARY_KEY']}",
|
|
'xlink' => "{$ns['url']}#{$ns['name']}.{$refInfo['REMOTE_PRIMARY_KEY']}",
|
|
|
];
|
|
];
|
|
|
}, $xlinks);
|
|
}, $xlinks);
|
|
|
- if (count($xlinks) > $refLimit) DBG::log('TODO: xlink FETCH MORE DATA...');
|
|
|
|
|
- if (count($xlinks) > $refLimit) $row[$fieldName][] = [ 'p5:links' => [
|
|
|
|
|
|
|
+ if (count($xlinks) > $defaultRefLimit) DBG::log('TODO: xlink FETCH MORE DATA...');
|
|
|
|
|
+ if (count($xlinks) > $defaultRefLimit) $row[$fieldName][] = [ 'p5:links' => [
|
|
|
'p5:next' => [
|
|
'p5:next' => [
|
|
|
'@typeName' => $fieldName,
|
|
'@typeName' => $fieldName,
|
|
|
'@backRefNS' => $this->_acl->getNamespace(),
|
|
'@backRefNS' => $this->_acl->getNamespace(),
|
|
|
'@backRefPK' => $primaryKey,
|
|
'@backRefPK' => $primaryKey,
|
|
|
- '@startIndex' => $refLimit,
|
|
|
|
|
- 'value' => Request::getScriptUri() . "?SERVICE=WFS&VERSION=1.0.0&TYPENAME={$fieldName}&REQUEST=GetFeature&backRefNS=".$this->_acl->getNamespace()."&backRefPK={$primaryKey}&backRefField={$fieldName}&startIndex={$refLimit}",
|
|
|
|
|
|
|
+ '@startIndex' => $defaultRefLimit,
|
|
|
|
|
+ 'value' => Request::getScriptUri() . "?SERVICE=WFS&VERSION=1.0.0&TYPENAME={$fieldName}&REQUEST=GetFeature&backRefNS=".$this->_acl->getNamespace()."&backRefPK={$primaryKey}&backRefField={$fieldName}&startIndex={$defaultRefLimit}",
|
|
|
],
|
|
],
|
|
|
] ];
|
|
] ];
|
|
|
DBG::log($row[$fieldName], 'array', "remote xlinks for \$items[{$primaryKey}][{$fieldName}]");
|
|
DBG::log($row[$fieldName], 'array', "remote xlinks for \$items[{$primaryKey}][{$fieldName}]");
|
|
|
}
|
|
}
|
|
|
} else if ('ref:' === substr($xsdType, 0, 4) && !empty($cols)) {
|
|
} else if ('ref:' === substr($xsdType, 0, 4) && !empty($cols)) {
|
|
|
$refAcl = ACL::getAclByTypeName($fieldName);
|
|
$refAcl = ACL::getAclByTypeName($fieldName);
|
|
|
- $items = $refAcl->buildQuery([
|
|
|
|
|
|
|
+ $refQuery = $refAcl->buildQuery([
|
|
|
'cols' => $cols,
|
|
'cols' => $cols,
|
|
|
'__backRef' => [
|
|
'__backRef' => [
|
|
|
'namespace' => $this->_acl->getNamespace(),
|
|
'namespace' => $this->_acl->getNamespace(),
|
|
|
'primaryKey' => $primaryKey,
|
|
'primaryKey' => $primaryKey,
|
|
|
'fieldName' => $fieldName,
|
|
'fieldName' => $fieldName,
|
|
|
],
|
|
],
|
|
|
|
|
+ 'limit' => $refLimitPlus1,
|
|
|
'skipFeaturesAsXlink' => $this->_foundFeatures
|
|
'skipFeaturesAsXlink' => $this->_foundFeatures
|
|
|
- // TODO: add $refLimit + 1
|
|
|
|
|
- ])->getItems();
|
|
|
|
|
- // TODO: if (count($items) > $refLimit) // TODO: add item for GUI - has more data + wfs link to fetch more (offset)
|
|
|
|
|
- DBG::log($items, 'array', "add remote items '{$fieldName}' \$items");
|
|
|
|
|
|
|
+ // TODO: add $defaultRefLimit + 1
|
|
|
|
|
+ ]);
|
|
|
|
|
+ $totalRefs = $refQuery->getTotal();
|
|
|
|
|
+ $items = $refQuery->getItems([ 'limit' => $defaultRefLimit ]);
|
|
|
|
|
+ // TODO: if (count($items) > $defaultRefLimit) // TODO: add item for GUI - has more data + wfs link to fetch more (offset)
|
|
|
|
|
+ DBG::log($items, 'array', "add remote items '{$fieldName}' \$items[{$primaryKey}][{$fieldName}] total({$totalRefs})");
|
|
|
|
|
+ if ($totalRefs > $defaultRefLimit) {
|
|
|
|
|
+ DBG::log('TODO: resolve recurse fetch more data link');
|
|
|
|
|
+ array_pop($items); // remove last item
|
|
|
|
|
+ $items[] = [ 'p5:links' => [
|
|
|
|
|
+ 'p5:next' => [
|
|
|
|
|
+ '@typeName' => $fieldName,
|
|
|
|
|
+ '@backRefNS' => $this->_acl->getNamespace(),
|
|
|
|
|
+ '@backRefPK' => $primaryKey,
|
|
|
|
|
+ '@startIndex' => $defaultRefLimit,
|
|
|
|
|
+ 'value' => Request::getScriptUri() . "?SERVICE=WFS&VERSION=1.0.0&TYPENAME={$fieldName}&REQUEST=GetFeature&backRefNS=".$this->_acl->getNamespace()."&backRefPK={$primaryKey}&backRefField={$fieldName}&startIndex={$defaultRefLimit}",
|
|
|
|
|
+ ],
|
|
|
|
|
+ ] ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$refNs = $refAcl->getNamespace();
|
|
$refNs = $refAcl->getNamespace();
|
|
|
$refPk = $refAcl->getPrimaryKeyField();
|
|
$refPk = $refAcl->getPrimaryKeyField();
|
|
|
$this__hasFeatureId = [ $this, 'hasFeatureId' ];
|
|
$this__hasFeatureId = [ $this, 'hasFeatureId' ];
|
|
@@ -690,7 +699,7 @@ class AclQueryFeatures {
|
|
|
}
|
|
}
|
|
|
public function addFeatureId($featureId) {
|
|
public function addFeatureId($featureId) {
|
|
|
$this->_foundFeatures[] = $featureId;
|
|
$this->_foundFeatures[] = $featureId;
|
|
|
- DBG::log($this->_foundFeatures, 'array', "TODO: addFeatureId({$featureId})");
|
|
|
|
|
|
|
+ DBG::log($this->_foundFeatures, 'array', "addFeatureId({$featureId})");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function getAclSqlPrimaryKeyField() {
|
|
public function getAclSqlPrimaryKeyField() {
|