Skip to content

Commit

Permalink
get parent collection of a dracor corpus with param nav on the collec…
Browse files Browse the repository at this point in the history
…tion endpoint
  • Loading branch information
ingoboerner committed Apr 12, 2024
1 parent ffa089e commit 7c8cf47
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions modules/dts.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function ddts:entry-point() {
and adapt the URI templates accordingly
What happend to param level in the navigation endpoint?
:)
let $collection-template := $ddts:collections-base || "{?id}"
let $collection-template := $ddts:collections-base || "{?id,nav}"
let $document-template := $ddts:documents-base || "{?resource,ref}"
let $navigation-template := $ddts:navigation-base || "{?resource,ref}"

Expand Down Expand Up @@ -198,7 +198,11 @@ but in case of an error it is a sequence! :)
(: TODO: check if this corpus really exists :)
let $corpus := dutil:get-corpus($id)
return
if ($corpus/name() eq "teiCorpus") then local:corpus-to-collection($id)
if ($corpus/name() eq "teiCorpus") then
if ( $nav eq 'parents') then
local:corpus-to-collection-with-parent-as-member($id)
else
local:corpus-to-collection($id)
else
(
<rest:response>
Expand All @@ -207,11 +211,16 @@ but in case of an error it is a sequence! :)
"The requested resource '" || $id || "' is not available."
)
else if ( matches($id, concat("^", $ddts:base-uri, "/id/","[a-z]+$" ) ) ) then
(: A corpus requested with URI :)
(: A corpus = collection requested with URI as value of the id param :)
let $corpusname := local:uri-to-id($id)
let $corpus := dutil:get-corpus($corpusname)
return
if ($corpus/name() eq "teiCorpus") then local:corpus-to-collection($id)
if ($corpus/name() eq "teiCorpus") then

if ( $nav eq 'parents') then
local:corpus-to-collection-with-parent-as-member($id)
else
local:corpus-to-collection($id)
else
(
<rest:response>
Expand Down

0 comments on commit 7c8cf47

Please sign in to comment.