Commit 0c64a459 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

preparing test env

parent 0324a19b
......@@ -16,19 +16,48 @@ declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare namespace xhtml="http://www.w3.org/1999/xhtml";
declare
%test:setUp
function f-indexviewer:setup() {
if( xmldb:collection-available("/db/sade-projects/textgrid") )
then true()
else
(: read test config :)
let $testconfig := doc("tests.xml")
(: prepare the collections :)
let $prepare-collections :=
for $create in $testconfig//create/collection
return
xmldb:create-collection($create/@target, $create/@new)
(: prepare documents :)
let $prepare-documents :=
for $create in $testconfig//create/document
return
xmldb:store($create/@collection, $create/@name, $create/*)
let $prepare-documents-from-template :=
for $create in $testconfig//create/document-template
let $template := $create/template/*
return
for $data in $create//data
let $doc := doc( xmldb:store($create/@collection, $data/@name, $template) )
return
update insert $data/* into $doc//tei:body
return true()
};
(: Main cache function
: @return path to the cached document :)
declare
%test:name("cache")
%test:assertTrue
%test:pending (: throws NPE on non-initialized db. needs some data from the grid. :)
(: %test:pending (: throws NPE on non-initialized db. needs some data from the grid. :):)
function local:cache()
as xs:string {
{
let $set-option := util:declare-option("exist:output-size-limit", "2000000")
let $collection-uri := "/db/sade-projects/textgrid/data/xml/xhtml",
$resource := "index.xml"
let $agg := '253st.xml' (: TextGrid Aggregation containing all index files :)
let $uris := (doc('/db/sade-projects/textgrid/data/xml/agg/' || $agg)
//ore:aggregates/substring-after(@rdf:resource, 'textgrid:')
......@@ -36,7 +65,6 @@ let $uris := (doc('/db/sade-projects/textgrid/data/xml/agg/' || $agg)
let $lastMod := $uris ! xmldb:last-modified($f-indexproc:dataPath, . || '.xml')
return
if($uris = ()) then true() else
if(not(local:login($collection-uri)))
then error(QName("FONTANE", "INDEXVIEW1"), "unable to authenticate.")
else
......@@ -46,7 +74,7 @@ return
$collection-uri || "/" || $resource
else
(: create the cache :)
xmldb:store($collection-uri, $resource, <xhtml:div>{f-indexproc:register()}</xhtml:div>)
xmldb:store($collection-uri, $resource, <xhtml:div>{util:eval('f-indexproc:register()')}</xhtml:div>)
};
(: forces the creation of a new cache file
......@@ -104,19 +132,6 @@ return
else $node
};
declare function local:tab-content($index as document-node(), $active as xs:string)
as element(xhtml:div) {
let $indexContentNodes := $index/xhtml:div/xhtml:div
return
if($f-indexproc:getEntity)
then
let $id := generate-id($index//xhtml:li[@id = $f-indexproc:getEntity])
return
local:transform-entity($indexContentNodes[@id = $active]/*, $id)
else
$indexContentNodes[@id = $active]/*
};
declare function f-indexviewer:main($model as map()*, $node as node(), $index as xs:string) {
if ($f-indexproc:notebookParam)
then
......@@ -190,7 +205,7 @@ return
};
declare function local:login($col) {
if(false() = xmldb:login( $col, config:get('sade.user') , config:get("sade.password")))
then (xmldb:login( $col, "admin", ""))
if(false() = xmldb:login($col, config:get('sade.user'), config:get("sade.password")))
then (xmldb:login($col, "admin", ""))
else true()
};
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment