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

Support for TDE #848

Open
grtjn opened this issue Sep 22, 2017 · 4 comments
Open

Support for TDE #848

grtjn opened this issue Sep 22, 2017 · 4 comments

Comments

@grtjn
Copy link
Contributor

grtjn commented Sep 22, 2017

Includes inserting and validating templates. http://docs.marklogic.com/tde

@grtjn
Copy link
Contributor Author

grtjn commented Sep 22, 2017

These get uploaded to the schemas database. Seems to make sense to attach to deploy schema, but might require specific logic..

@grtjn
Copy link
Contributor Author

grtjn commented Sep 22, 2017

Similar like I commented on #645, might be worth auto-detecting file format based on introspection. XML has this at the root: <template xmlns="http://marklogic.com/xdmp/tde">, and JSON must have something similar..

@grtjn
Copy link
Contributor Author

grtjn commented Sep 22, 2017

Hmm, thought.. how about doing the introspection after loading in schema db using xqy or sjs?

@grtjn
Copy link
Contributor Author

grtjn commented Aug 28, 2018

Not the prettiest code, but this seemed to work:

  def deploy_schemas
    original_deploy_schemas
    logger.info "Generating TDE templates for models:"
    r = execute_query(
      %Q{
        xquery version "1.0-ml";
        import module namespace es = "http://marklogic.com/entity-services" at "/MarkLogic/entity-services/entity-services.xqy";
        import module namespace tde = "http://marklogic.com/xdmp/tde" at "/MarkLogic/tde.xqy";
        for $entity-doc-uri as xs:string? in cts:uris((), (), cts:directory-query("/entities/", "infinity"))
        let $t := es:extraction-template-generate(fn:doc($entity-doc-uri))
        let $path := fn:substring-before($entity-doc-uri, ".json") || ".xml"
        return (
          $entity-doc-uri,
          tde:template-insert($path, es:extraction-template-generate(fn:doc($entity-doc-uri)))
        )
      },
      { :db_name => @properties["ml.content-db"] }
    )
    r.body = parse_body r.body
    logger.info r.body
    logger.info ""

    logger.info "Applying custom TDE templates:"
    query = File.read ServerConfig.expand_path("#{@@path}/../tde/tdeDataStore.xqy")
    r = execute_query(
      query,
      { :app_name => @properties["ml.app-name"] }
    )
    r.body = parse_body r.body
    logger.info r.body
    logger.info ""

    change_permissions(@properties["ml.schemas-db"])
  end

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

No branches or pull requests

1 participant