diff --git a/controller.xql b/controller.xql index b246d25ae5fd3d67027508f2be35aeb24e02edbd..34fe5e414a0ece814971e9b750ad96dd4b0929d7 100644 --- a/controller.xql +++ b/controller.xql @@ -24,7 +24,7 @@ else if ($exist:path eq "/") then -else if (ends-with($exist:resource, ".html")) then +else if ( matches($exist:path, "/" || $project || "/" || $exist:resource) ) then (: the html page is run through view.xq to expand templates :) diff --git a/modules/textgrid/client.xqm b/modules/textgrid/client.xqm index 7921fcb87a5ac280d4c49328c891f8d2ae7ee0f5..098a99e3531d09c96949696766c5114b2c4e4636 100644 --- a/modules/textgrid/client.xqm +++ b/modules/textgrid/client.xqm @@ -16,6 +16,7 @@ declare namespace http="http://expath.org/ns/http-client"; declare namespace ore="http://www.openarchives.org/ore/terms/"; declare namespace rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; declare namespace sparql-results="http://www.w3.org/2005/sparql-results#"; +declare namespace test="http://exist-db.org/xquery/xqsuite"; declare namespace tgmd="http://textgrid.info/namespaces/metadata/core/2010"; declare namespace xhtml="http://www.w3.org/1999/xhtml"; @@ -66,10 +67,21 @@ declare function tgclient:getData($id as xs:string, $tgcrud-url as xs:string, $s }; -(:~ Returns a list of TextGrid items within a given aggregation - : @param tguri – the URI of any tg.aggregation :) -declare function tgclient:getAggregatedUris($tguri as xs:string, $rdfstore as xs:string) as item()* { - let $query := concat("PREFIX ore: PREFIX tg: SELECT ?s WHERE { <",$tguri,"> (ore:aggregates/tg:isBaseUriOf|ore:aggregates)* ?s. }") +(:~ Returns a list of TextGrid items within a given aggregation, but only the + latest revision of an object. + : @param tguri – the URI of any tg.aggregation + : @param rdfstore – url to the triple store + : @return sequence of strings (textgrid URIs) or empty sequence + :) +declare + %test:name("sqarql query") + %test:args("textgrid:vv6f.0", "https://textgridlab.org/1.0/triplestore/textgrid-public") + %test:assertExists + %test:assertEquals("textgrid:vv6f.0", "textgrid:vv6g.0", "textgrid:vvc3.0") + %test:assertXPath("count($result) eq 3") +function tgclient:getAggregatedUris($tguri as xs:string, $rdfstore as xs:string) +as xs:string* { + let $query := concat("PREFIX ore: PREFIX tg: SELECT ?s WHERE { <",$tguri,"> (ore:aggregates/tg:isBaseUriOf|ore:aggregates)* ?s. FILTER not exists { ?s tg:isDeleted true } . }") let $uris := tgclient:sparql($query, $rdfstore) (: let $uris := $uris//sparql-results:uri/string() :) for $uri in distinct-values( $uris//sparql-results:uri/substring-before(.,'.')) @@ -92,8 +104,9 @@ declare function tgclient:remove-prefix($tguri as xs:string) as xs:string { : @result the resulting MetadataContainerType :) declare function tgclient:createData($config as map(*), $title, $format, $data) as node() { -let $sessionId := () -let $projectId := () +let $sessionId := $config("sid") +let $projectId := $config("pid") +let $tgcrudURL := $config("tgcrudURL") let $url := $tgcrudURL || "?sessionId=" || $sessionId || "&projectId=" || $projectId @@ -220,3 +233,23 @@ let $soapElement := local:soapElement("tgAssignedProjects", $sid, 0< return local:tgAuth-call($authUrl, $soapHeader, $soapElement) }; + +(:~ + : Creates an aggregation, either empty or filled with the provided textgrid-URIs + : @param $config – a map containing static parameters "pid", "sid" and "tgCrudUrl" + : @param $title – the name of the aggregation + : @param $uris – a sequence of textgrid URIs +:) +declare function tgclient:createAggregation($config as map(*), $title as xs:string, $uris as xs:string+) +as element(tgmd:MetadataContainerType) { +let $data := (: rdf:Description/@rdf:about will be set by the CRUD :) + document { + + + {for $uri in $uris + return } + + } +return + tgclient:createData($config, $title, "text/tg.aggregation+xml", $data) +};