diff --git a/post-install.xql b/post-install.xql
index c03957f2..c943f039 100644
--- a/post-install.xql
+++ b/post-install.xql
@@ -99,6 +99,43 @@ declare function local:force-xml-mime-type-xbl() as xs:string* {
return if (exists($doc)) then xdb:store($forms-includes, $r, $doc, 'application/xml') else ()
};
+(:~
+ : Helper function to recursively create a collection hierarchy.
+ :)
+declare function local:mkcol-recursive($collection, $components) {
+ if (exists($components)) then
+ let $newColl := concat($collection, "/", $components[1])
+ return (
+ xdb:create-collection($collection, $components[1]),
+ local:mkcol-recursive($newColl, subsequence($components, 2))
+ )
+ else
+ ()
+};
+
+(:~
+ : Helper function to recursively create a collection hierarchy.
+ :)
+declare function local:mkcol($collection, $path) {
+ local:mkcol-recursive($collection, tokenize($path, "/"))
+};
+
+(:~
+ : Add default index configuration to the data collection provided in $config:data-root
+ : Indices are used for searching and filtering on the main list page,
+ : see https://github.com/Edirom/MerMEId/issues/112
+ :)
+declare function local:add-index-configuration() as item()* {
+ let $config-path := concat("/db/system/config", $config:data-root)
+ return
+ if(doc-available(concat($config-path, '/collection.xconf'))) then ()
+ else (
+ local:mkcol("/db/system/config", $config:data-root),
+ xdb:store-files-from-pattern($config-path, $dir, "*.xconf"),
+ xdb:reindex($config:data-root)
+ )
+};
+
(: set options provided as environment variables :)
local:set-options(),
local:force-xml-mime-type-xbl(),
@@ -107,6 +144,7 @@ if (local:first-run()) then
local:create-group(),
local:create-user(),
local:change-group(),
+ local:add-index-configuration(),
(: This has to be the last command otherwise the other commands will not be executed properly :)
local:set-admin-password()
)
diff --git a/pre-install.xql b/pre-install.xql
deleted file mode 100755
index 898eacc7..00000000
--- a/pre-install.xql
+++ /dev/null
@@ -1,32 +0,0 @@
-xquery version "1.0";
-
-import module namespace xdb="http://exist-db.org/xquery/xmldb";
-
-(: The following external variables are set by the repo:deploy function :)
-
-(: file path pointing to the exist installation directory :)
-declare variable $home external;
-(: path to the directory containing the unpacked .xar package :)
-declare variable $dir external;
-(: the target collection into which the app is deployed :)
-declare variable $target external;
-
-declare function local:mkcol-recursive($collection, $components) {
- if (exists($components)) then
- let $newColl := concat($collection, "/", $components[1])
- return (
- xdb:create-collection($collection, $components[1]),
- local:mkcol-recursive($newColl, subsequence($components, 2))
- )
- else
- ()
-};
-
-(: Helper function to recursively create a collection hierarchy. :)
-declare function local:mkcol($collection, $path) {
- local:mkcol-recursive($collection, tokenize($path, "/"))
-};
-
-(: store the collection configuration :)
-local:mkcol("/db/system/config", $target),
-xdb:store-files-from-pattern(concat("/db/system/config", $target), $dir, "*.xconf")
\ No newline at end of file
diff --git a/repo.xml b/repo.xml
index 1b6efef0..68ac248d 100755
--- a/repo.xml
+++ b/repo.xml
@@ -9,6 +9,5 @@
trueapplicationmermeid
- pre-install.xqlpost-install.xql