Skip to content

Commit

Permalink
Update collection support in catalogs
Browse files Browse the repository at this point in the history
  • Loading branch information
jjrom committed Nov 28, 2024
1 parent 18bedec commit 45a152f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
8 changes: 2 additions & 6 deletions app/resto/core/api/STACAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,7 @@ private function processPath($segments, $params = array())
$searchParams = array(
'q' => $catalogs[0]['id']
);

foreach (array_keys($params) as $key) {
if ($key !== 'segments') {
$searchParams[$key] = $params[$key];
Expand All @@ -1420,7 +1420,7 @@ private function processPath($segments, $params = array())
'type' => 'Catalog',
'links' => array_merge(
$this->getBaseLinks($segments),
( !empty($parentAndChilds['parent']['links']) ? array_merge($parentAndChilds['childs'], $parentAndChilds['parent']['links']) : $parentAndChilds['childs'] )
!empty($parentAndChilds['parent']['links']) ? array_merge($parentAndChilds['childs'], $parentAndChilds['parent']['links']) : $parentAndChilds['childs']
)
);

Expand Down Expand Up @@ -1605,7 +1605,6 @@ private function getParentAndChilds($catalogId, $params)
for ($i = 1, $ii = count($catalogs); $i < $ii; $i++) {
if ($catalogs[$i]['level'] === $parentAndChilds['parent']['level'] + 1) {
$element = array(
'id' => $catalogs[$i]['id'],
'rel' => 'child',
'type' => RestoUtil::$contentTypes['json'],
'href' => $this->context->core['baseUrl'] . ( str_starts_with($catalogs[$i]['id'], 'collections/') ? '/' : '/catalogs/') . join('/', array_map('rawurlencode', explode('/', $catalogs[$i]['id'])))
Expand All @@ -1619,9 +1618,6 @@ private function getParentAndChilds($catalogId, $params)
if ( isset($catalogs[$i]['description']) ) {
$element['description'] = $catalogs[$i]['description'];
}
if ( isset($catalogs[$i]['rtype']) ) {
$element['resto:type'] = $catalogs[$i]['rtype'];
}
$parentAndChilds['childs'][] = $element;
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/resto/core/dbfunctions/CatalogsFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ private function getCleanLinks($catalog, $context) {
*/
private function onTheFlyUpdateCountersWithCollection($catalogs)
{

$collectionsList = [];
for ($i = 0, $ii = count($catalogs); $i < $ii; $i++){
if ($catalogs[$i]['rtype'] === 'collection') {
Expand Down
6 changes: 3 additions & 3 deletions docs/COLLECTIONS_AND_CATALOGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ is to create an empty catalog then add its childs through the POST API

### Add a catalog with item

# The catalog dummyCatalogWithItem is posted under /catalogs/dummyCatalog/dummyCatalogChild1
# The catalog dummyCatalogWithItem is posted under /catalogs/dummyCatalogWithChilds/dummyCatalogChild1
# It references :
# * a local item that is added to catalog_feature table
# * an external item that is kept as referenced within the links column in catalog table

# First POST the item because it should exist before referencing it within the catalog
curl -X POST -d@examples/features/dummySargasse.json "http://admin:admin@localhost:5252/collections/DummyCollection/items"

curl -X POST -d@examples/catalogs/dummyCatalogWithItem.json "http://admin:admin@localhost:5252/catalogs/dummyCatalog/dummyCatalogChild1"
curl -X POST -d@examples/catalogs/dummyCatalogWithItem.json "http://admin:admin@localhost:5252/catalogs/dummyCatalogWithChilds/dummyCatalogChild1"

### Update a catalog

# Update a catalog - user with the "updateCatalog" right can update a catalog he owns

curl -X PUT -d@examples/catalogs/dummyCatalogWithItem_update.json "http://admin:admin@localhost:5252/catalogs/dummyCatalog/dummyCatalogChild1"
curl -X PUT -d@examples/catalogs/dummyCatalogWithItem_update.json "http://admin:admin@localhost:5252/catalogs/dummyCatalogWithChilds/dummyCatalogChild1"

### Update a catalog that has already childs

Expand Down

0 comments on commit 45a152f

Please sign in to comment.