Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Add support for database default-rulesets #558

Open
grtjn opened this issue Nov 26, 2015 · 2 comments
Open

Add support for database default-rulesets #558

grtjn opened this issue Nov 26, 2015 · 2 comments

Comments

@grtjn
Copy link
Contributor

grtjn commented Nov 26, 2015

I made following changes to setup.xqy locally to make it work..

Added this to setup:configure-indexes:

  let $admin-config := setup:add-default-rulesets($admin-config, $database, $db-config)

Added this to setup:validate-database-indexes:

    setup:validate-default-rulesets($admin-config, $database, $db-config)

And inserted this somewhere:

declare function setup:remove-existing-default-rulesets(
  $admin-config as element(configuration),
  $database as xs:unsignedLong) as element(configuration)
{
  admin:database-delete-default-ruleset($admin-config, $database, 
    admin:database-get-default-rulesets($admin-config, $database)
  )
};

declare function setup:add-default-rulesets(
  $admin-config as element(configuration),
  $database as xs:unsignedLong,
  $db-config as element(db:database)) as element(configuration)
{
  admin:database-add-default-ruleset(
    setup:remove-existing-default-rulesets($admin-config, $database),
    $database,
    $db-config/db:default-rulesets/db:default-ruleset/admin:database-ruleset(string(.))
  )
};

declare function setup:validate-default-rulesets(
  $admin-config as element(configuration),
  $database as xs:unsignedLong,
  $db-config as element(db:database))
{
  let $existing := admin:database-get-default-rulesets($admin-config, $database)
  for $expected in $db-config/db:default-rulesets/db:default-ruleset
  return
    if ($existing[fn:deep-equal(., $expected)]) then ()
    else
      setup:validation-fail(fn:concat("Missing default ruleset: ", $expected/db:location/fn:string(.)))
};
@grtjn
Copy link
Contributor Author

grtjn commented Aug 26, 2016

Adding this to selftest would be nice, but only for ML8+..

@grtjn
Copy link
Contributor Author

grtjn commented Jun 13, 2017

selftest would be possible if PR for #796 is merged..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant