Skip to content

Commit 0808532

Browse files
authored
Merge branch 'dev' into unit-tests
2 parents 6f22d5b + b04fe15 commit 0808532

File tree

5 files changed

+41
-9
lines changed

5 files changed

+41
-9
lines changed

repo/backend/update/add_collection.xqm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import module namespace functx = 'http://www.functx.com';
66
import module namespace G = "globals";
77
import module namespace utils_dots = "utils_dots";
88
import module namespace resources = "backend/resources_register_builder";
9+
declare namespace dc = "http://purl.org/dc/elements/1.1/";
910

1011
declare namespace dots = "https://github.com/chartes/dots/";
1112

@@ -35,10 +36,18 @@ declare updating function add_coll:handleAddition($dbName as xs:string, $resourc
3536
declare updating function add_coll:addCollToResourcesReg($dbName as xs:string, $resourceId as xs:string, $parentId as xs:string) {
3637
let $csv := resources:getCSV-map($dbName, "collection")
3738
let $resources_register := db:get($dbName, $G:resourcesRegister)//dots:member
39+
let $metadata := resources:getCollectionMetadata($dbName, $resourceId, $csv)
3840
return
3941
insert node
40-
<collection xmlns="https://github.com/chartes/dots/" dtsResourceId="{$resourceId}" totalChildren="0" parentIds="{$parentId}">{
41-
resources:getCollectionMetadata($dbName, $resourceId, $csv)
42+
<collection xmlns="https://github.com/chartes/dots/" dtsResourceId="{$resourceId}" totalChildren="0" parentIds="{$parent}">{
43+
if ($metadata/descendant-or-self::*:title)
44+
then
45+
$metadata
46+
else
47+
(
48+
<dc:title>{$resourceId}</dc:title>,
49+
$metadata
50+
)
4251
}</collection> as last into $resources_register
4352
};
4453

repo/globals.xqm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare default element namespace "https://github.com/chartes/dots/";
1717
(:~ Variable pour accéder aux feuilles de transformation XSLT :)
1818
(: "/srv/transform/" :)
1919
declare function G:linkToXsl() {
20-
let $specificLink := db:get($G:dots)//settings/linkXSL
20+
let $specificLink := db:get($G:dots)//settings/linkXSL[. != ""]
2121
return
2222
if ($specificLink != "")
2323
then if (ends-with($specificLink, "/")) then $specificLink else concat($specificLink, "/")

repo/resolver/utils.xqm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,9 @@ declare function utils:getMandatory(
672672
)
673673
let $uri := substring-before(request:uri(), "/api")
674674
let $resourceLink := if ($type = ("resource", "Resource")) then (
675-
<pair name="collection">{concat($uri, "/api/dts/collection?id=", $resourceId, "{&amp;nav}")}</pair>,
676-
<pair name="document">{concat($uri, "/api/dts/document?resource=", $resourceId, "{&amp;ref,start,end,tree,mediaType}")}</pair>,
677-
<pair name="navigation">{concat($uri, "/api/dts/navigation?resource=", $resourceId, "{&amp;ref,start,end,tree,down}")}</pair>,
675+
<pair name="collection">{concat($uri, "/api/dts/collection?id=", $resourceId, "{?nav}")}</pair>,
676+
<pair name="document">{concat($uri, "/api/dts/document?resource=", $resourceId, "{?ref,start,end,tree,mediaType}")}</pair>,
677+
<pair name="navigation">{concat($uri, "/api/dts/navigation?resource=", $resourceId, "{?ref,start,end,tree,down}")}</pair>,
678678
let $downloads := $resource/*:download
679679
where $downloads
680680
return

tests/project_create/project_registers_create_test.xq

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,35 @@ declare %unit:test function local:assertUniqueResourcesIdentifiers() {
6767
: @return Success if all fragment references are distinct.
6868
:)
6969
declare %unit:test function local:assertUniqueFragmentsIdentifiers() {
70-
let $ref := db:get($dbName, $G:fragmentsRegister)//dots:member/dots:fragment/@ref
70+
let $reg := db:get($dbName, $G:fragmentsRegister)
7171
return
72-
unit:assert(empty(duplicate-values($ref)))
72+
for $fragments in $reg//dots:fragment
73+
let $resourceId := $fragments/@resourceId
74+
group by $resourceId
75+
return
76+
let $ref :=
77+
for $fragment in $fragments
78+
let $ref := $fragment/@ref
79+
return normalize-space($ref)
80+
return
81+
unit:assert(empty(duplicate-values($ref)))
7382
};
7483

84+
(: let $reg := db:get("theater", "dots/fragments_register.xml")
85+
return
86+
for $fragments in $reg//*:fragment
87+
let $resourceId := $fragments/@resourceId
88+
group by $resourceId
89+
return
90+
<resource id="{$resourceId}">{
91+
let $ref :=
92+
for $fragment in $fragments
93+
let $ref := $fragment/@ref
94+
return normalize-space($ref)
95+
return
96+
duplicate-values($ref)
97+
}</resource> :)
98+
7599
(:~
76100
: This test verifies that the value of @totalChildren for each collection matches the number of members referring to it as a parent.
77101
: @return Success if the declared number of children equals the actual count.

webapp/WEB-INF/web.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
<url-pattern>/static/*</url-pattern>
5757
</servlet-mapping>
5858

59-
<!-- Set Access-Control-Allow-Origin: * -->
6059
<filter>
6160
<filter-name>cross-origin</filter-name>
6261
<filter-class>org.eclipse.jetty.ee9.servlets.CrossOriginFilter</filter-class>

0 commit comments

Comments
 (0)