|
@@ -493,8 +493,10 @@ class AclQueryFeatures {
|
|
|
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)) { // only xlink's
|
|
|
|
|
|
|
+ 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}] ...");
|
|
|
$refTable = ACL::getRefTable($this->_acl->getNamespace(), $fieldName);
|
|
$refTable = ACL::getRefTable($this->_acl->getNamespace(), $fieldName);
|
|
|
if (!$refTable) DBG::log("BUG: Missing refTable in add remote xlink's '{$fieldName}' \$items[{$primaryKey}]");
|
|
if (!$refTable) DBG::log("BUG: Missing refTable in add remote xlink's '{$fieldName}' \$items[{$primaryKey}]");
|
|
@@ -503,6 +505,7 @@ class AclQueryFeatures {
|
|
|
select r.REMOTE_PRIMARY_KEY
|
|
select r.REMOTE_PRIMARY_KEY
|
|
|
from `{$refTable}` r
|
|
from `{$refTable}` r
|
|
|
where r.PRIMARY_KEY = '{$primaryKey}'
|
|
where r.PRIMARY_KEY = '{$primaryKey}'
|
|
|
|
|
+ limit {$refLimitPlus1}
|
|
|
");
|
|
");
|
|
|
DBG::log($xlinks, 'array', "add remote xlink's for '{$fieldName}' \$items[{$primaryKey}]");
|
|
DBG::log($xlinks, 'array', "add remote xlink's for '{$fieldName}' \$items[{$primaryKey}]");
|
|
|
$row[$fieldName] = array_map(function ($refInfo) use ($fieldName) {
|
|
$row[$fieldName] = array_map(function ($refInfo) use ($fieldName) {
|
|
@@ -512,9 +515,19 @@ 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' => [
|
|
|
|
|
+ 'p5:next' => [
|
|
|
|
|
+ '@typeName' => $fieldName,
|
|
|
|
|
+ '@backRefNS' => $this->_acl->getNamespace(),
|
|
|
|
|
+ '@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}",
|
|
|
|
|
+ ],
|
|
|
|
|
+ ] ];
|
|
|
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)) { // cols
|
|
|
|
|
|
|
+ } else if ('ref:' === substr($xsdType, 0, 4) && !empty($cols)) {
|
|
|
$items = ACL::getAclByTypeName($fieldName)->buildQuery([
|
|
$items = ACL::getAclByTypeName($fieldName)->buildQuery([
|
|
|
'cols' => $cols,
|
|
'cols' => $cols,
|
|
|
'__backRef' => [
|
|
'__backRef' => [
|
|
@@ -522,7 +535,9 @@ class AclQueryFeatures {
|
|
|
'primaryKey' => $primaryKey,
|
|
'primaryKey' => $primaryKey,
|
|
|
'fieldName' => $fieldName,
|
|
'fieldName' => $fieldName,
|
|
|
]
|
|
]
|
|
|
|
|
+ // TODO: add $refLimit + 1
|
|
|
])->getItems();
|
|
])->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");
|
|
DBG::log($items, 'array', "add remote items '{$fieldName}' \$items");
|
|
|
$row[$fieldName] = $items;
|
|
$row[$fieldName] = $items;
|
|
|
} else { // TODO: field is not ref
|
|
} else { // TODO: field is not ref
|