Search in sources :

Example 1 with LocalRepositoryManager

use of org.openrdf.repository.manager.LocalRepositoryManager in project incubator-rya by apache.

the class RyaAccumuloSailFactoryTest method testCreateFromTemplateName.

@Test
public void testCreateFromTemplateName() throws Exception {
    LocalRepositoryManager repoman = new LocalRepositoryManager(Files.createTempDir());
    repoman.initialize();
    try (InputStream templateStream = RepositoryConfig.class.getResourceAsStream("RyaAccumuloSail.ttl")) {
        String template = IOUtils.toString(templateStream);
        final ConfigTemplate configTemplate = new ConfigTemplate(template);
        final Map<String, String> valueMap = ImmutableMap.<String, String>builder().put("Repository ID", "RyaAccumuloSail").put("Repository title", "RyaAccumuloSail Store").put("Rya Accumulo user", "root").put("Rya Accumulo password", "").put("Rya Accumulo instance", "dev").put("Rya Accumulo zookeepers", "zoo1,zoo2,zoo3").put("Rya Accumulo is mock", "true").build();
        final String configString = configTemplate.render(valueMap);
        // final Repository systemRepo = this.state.getManager().getSystemRepository();
        final Graph graph = new LinkedHashModel();
        final RDFParser rdfParser = Rio.createParser(RDFFormat.TURTLE);
        rdfParser.setRDFHandler(new StatementCollector(graph));
        rdfParser.parse(new StringReader(configString), RepositoryConfigSchema.NAMESPACE);
        final Resource repositoryNode = GraphUtil.getUniqueSubject(graph, RDF.TYPE, RepositoryConfigSchema.REPOSITORY);
        final RepositoryConfig repConfig = RepositoryConfig.create(graph, repositoryNode);
        repConfig.validate();
        repoman.addRepositoryConfig(repConfig);
        Repository r = repoman.getRepository("RyaAccumuloSail");
        r.initialize();
    }
}
Also used : RepositoryConfig(org.openrdf.repository.config.RepositoryConfig) SailRepositoryConfig(org.openrdf.repository.sail.config.SailRepositoryConfig) InputStream(java.io.InputStream) StatementCollector(org.openrdf.rio.helpers.StatementCollector) Resource(org.openrdf.model.Resource) RDFParser(org.openrdf.rio.RDFParser) ConfigTemplate(org.openrdf.repository.config.ConfigTemplate) Repository(org.openrdf.repository.Repository) Graph(org.openrdf.model.Graph) LocalRepositoryManager(org.openrdf.repository.manager.LocalRepositoryManager) StringReader(java.io.StringReader) LinkedHashModel(org.openrdf.model.impl.LinkedHashModel) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)1 StringReader (java.io.StringReader)1 Test (org.junit.Test)1 Graph (org.openrdf.model.Graph)1 Resource (org.openrdf.model.Resource)1 LinkedHashModel (org.openrdf.model.impl.LinkedHashModel)1 Repository (org.openrdf.repository.Repository)1 ConfigTemplate (org.openrdf.repository.config.ConfigTemplate)1 RepositoryConfig (org.openrdf.repository.config.RepositoryConfig)1 LocalRepositoryManager (org.openrdf.repository.manager.LocalRepositoryManager)1 SailRepositoryConfig (org.openrdf.repository.sail.config.SailRepositoryConfig)1 RDFParser (org.openrdf.rio.RDFParser)1 StatementCollector (org.openrdf.rio.helpers.StatementCollector)1