-
Notifications
You must be signed in to change notification settings - Fork 20
Schemas db #84
Schemas db #84
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package com.marklogic.appdeployer.command.schemas; | ||
|
|
||
| import java.io.File; | ||
|
|
||
| import com.marklogic.appdeployer.AppConfig; | ||
| import com.marklogic.appdeployer.command.AbstractCommand; | ||
| import com.marklogic.appdeployer.command.CommandContext; | ||
| import com.marklogic.appdeployer.command.SortOrderConstants; | ||
| import com.marklogic.client.DatabaseClient; | ||
| import com.marklogic.client.dataloader.SchemasDataLoader; | ||
| import com.marklogic.client.dataloader.impl.DefaultSchemasDataFinder; | ||
| import com.marklogic.client.dataloader.impl.DefaultSchemasDataLoader; | ||
|
|
||
| public class LoadSchemasDataCommand extends AbstractCommand { | ||
|
|
||
| private SchemasDataLoader schemasDataLoader; | ||
|
|
||
| public LoadSchemasDataCommand() { | ||
| setExecuteSortOrder(SortOrderConstants.DEPLOY_SQL_VIEWS); | ||
| } | ||
|
|
||
| @Override | ||
| public void execute(CommandContext context) { | ||
| loadSchemasDataIntoSchemasDatabase(context); | ||
| } | ||
|
|
||
| protected void loadSchemasDataIntoSchemasDatabase(CommandContext context) { | ||
| if (schemasDataLoader == null) { | ||
| initializeDefaultSchemasDataLoader(context); | ||
| } | ||
|
|
||
|
|
||
| AppConfig config = context.getAppConfig(); | ||
| DatabaseClient client = config.newSchemasDatabaseClient(); | ||
| try { | ||
| File schemasDataDir = config.getConfigDir().getBaseDir(); | ||
|
||
|
|
||
| logger.info("Loading schemas database data from dir: " + schemasDataDir); | ||
| schemasDataLoader.loadSchemasData(schemasDataDir, new DefaultSchemasDataFinder(), client); | ||
|
|
||
| } finally { | ||
| client.release(); | ||
| } | ||
| } | ||
|
|
||
| private void initializeDefaultSchemasDataLoader(CommandContext context) { | ||
| logger.info("Initializing instance of DefaultSchemasLoader"); | ||
| this.schemasDataLoader = new DefaultSchemasDataLoader(); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| package com.marklogic.appdeployer.command.schemas; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| import com.marklogic.appdeployer.AbstractAppDeployerTest; | ||
| import com.marklogic.appdeployer.command.Command; | ||
| import com.marklogic.appdeployer.command.databases.DeployContentDatabasesCommand; | ||
| import com.marklogic.appdeployer.command.databases.DeploySchemasDatabaseCommand; | ||
| import com.marklogic.appdeployer.command.databases.DeployTriggersDatabaseCommand; | ||
| import com.marklogic.appdeployer.command.restapis.DeployRestApiServersCommand; | ||
|
|
||
| public class LoadSchemasDataTest extends AbstractAppDeployerTest { | ||
|
|
||
| @Test | ||
| public void testSchemaLoading() { | ||
|
||
| initializeAppDeployer(new DeploySchemasDatabaseCommand(), | ||
| new DeployTriggersDatabaseCommand(), | ||
| new DeployContentDatabasesCommand(1), | ||
| new DeployRestApiServersCommand(), | ||
| newCommand()); | ||
| appDeployer.deploy(appConfig); | ||
|
|
||
|
|
||
|
|
||
| //.undeploy(appConfig); | ||
| } | ||
|
|
||
| private Command newCommand() { | ||
| return new LoadSchemasDataCommand(); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Copyright 2014-2016 MarkLogic Corporation. All Rights Reserved. | ||
|
|
||
| prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | ||
| prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
|
|
||
| tbox { | ||
| ?p rdfs:domain ?c . | ||
| } | ||
|
|
||
| rule "domain axioms" construct { | ||
| rdfs:domain rdfs:domain rdf:Property . | ||
| rdfs:domain rdfs:range rdfs:Class . | ||
| } {} | ||
|
|
||
| rule "domain rdfs2" construct { | ||
| ?x a ?c | ||
| } { | ||
| ?x ?p ?y . | ||
| ?p rdfs:domain ?c | ||
| } | ||
|
|
||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| <xsm> | ||
| </xsm> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use a different sort order? I'm wondering if its sort order should be right around when modules are loaded. I don't know enough about schemas to know if there are any dependencies on them that would govern when they should be loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right -- there could be modules that depend on shemas. I'll figure out where it goes, or make a new key for schemas
Created new sort order == 350 for this operation.