Search in sources :

Example 1 with NamespaceManager

use of org.apache.rya.rdftriplestore.namespace.NamespaceManager in project incubator-rya by apache.

the class RdfCloudTripleStore method initializeInternal.

@Override
protected void initializeInternal() throws SailException {
    checkNotNull(ryaDAO);
    if (this.conf == null) {
        this.conf = ryaDAO.getConf();
    }
    checkNotNull(this.conf);
    try {
        if (!ryaDAO.isInitialized()) {
            ryaDAO.setConf(this.conf);
            ryaDAO.init();
        }
    } catch (final RyaDAOException e) {
        throw new SailException(e);
    }
    if (rdfEvalStatsDAO != null && !rdfEvalStatsDAO.isInitialized()) {
        rdfEvalStatsDAO.setConf(this.conf);
        rdfEvalStatsDAO.init();
    }
    if (namespaceManager == null) {
        this.namespaceManager = new NamespaceManager(ryaDAO, this.conf);
    }
}
Also used : NamespaceManager(org.apache.rya.rdftriplestore.namespace.NamespaceManager) RyaDAOException(org.apache.rya.api.persist.RyaDAOException) SailException(org.openrdf.sail.SailException)

Example 2 with NamespaceManager

use of org.apache.rya.rdftriplestore.namespace.NamespaceManager in project incubator-rya by apache.

the class RdfCloudTripleStoreConnectionTest method testNamedGraphLoadWAuth.

public void testNamedGraphLoadWAuth() throws Exception {
    InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("namedgraphs.trig");
    assertNotNull(stream);
    RdfCloudTripleStore tstore = new MockRdfCloudStore();
    NamespaceManager nm = new NamespaceManager(tstore.getRyaDAO(), tstore.getConf());
    tstore.setNamespaceManager(nm);
    SailRepository repo = new SailRepository(tstore);
    tstore.getRyaDAO().getConf().setCv("1|2");
    repo.initialize();
    RepositoryConnection conn = repo.getConnection();
    conn.add(stream, "", RDFFormat.TRIG);
    conn.commit();
    String query = "PREFIX  ex:  <http://www.example.org/exampleDocument#>\n" + "PREFIX  voc:  <http://www.example.org/vocabulary#>\n" + "PREFIX  foaf:  <http://xmlns.com/foaf/0.1/>\n" + "PREFIX  rdfs:  <http://www.w3.org/2000/01/rdf-schema#>\n" + "\n" + "SELECT * \n" + // "FROM NAMED <http://www.example.org/exampleDocument#G1>\n" +
    "WHERE\n" + "{\n" + "  GRAPH ex:G1\n" + "  {\n" + "    ?m voc:name ?name ;\n" + "           voc:homepage ?hp .\n" + "  } .\n" + " GRAPH ex:G2\n" + "  {\n" + "    ?m voc:hasSkill ?skill .\n" + "  } .\n" + "}";
    TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
    tupleQuery.setBinding(RdfCloudTripleStoreConfiguration.CONF_QUERY_AUTH, vf.createLiteral("2"));
    CountTupleHandler tupleHandler = new CountTupleHandler();
    tupleQuery.evaluate(tupleHandler);
    assertEquals(1, tupleHandler.getCount());
    // no auth
    tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
    tupleHandler = new CountTupleHandler();
    tupleQuery.evaluate(tupleHandler);
    assertEquals(0, tupleHandler.getCount());
    conn.close();
    repo.shutDown();
}
Also used : RepositoryConnection(org.openrdf.repository.RepositoryConnection) RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) NamespaceManager(org.apache.rya.rdftriplestore.namespace.NamespaceManager) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) SailRepository(org.openrdf.repository.sail.SailRepository) InputStream(java.io.InputStream) TupleQuery(org.openrdf.query.TupleQuery)

Example 3 with NamespaceManager

use of org.apache.rya.rdftriplestore.namespace.NamespaceManager in project incubator-rya by apache.

the class RdfCloudTripleStoreConnectionTest method testUpdateWAuthOnConfig.

// Set the persistence visibilites on the config
public void testUpdateWAuthOnConfig() throws Exception {
    String sparqlUpdate = getSparqlUpdate();
    RdfCloudTripleStore tstore = new MockRdfCloudStore();
    NamespaceManager nm = new NamespaceManager(tstore.getRyaDAO(), tstore.getConf());
    tstore.setNamespaceManager(nm);
    SailRepository repo = new SailRepository(tstore);
    tstore.getRyaDAO().getConf().setCv("1|2");
    repo.initialize();
    RepositoryConnection conn = repo.getConnection();
    Update u = conn.prepareUpdate(QueryLanguage.SPARQL, sparqlUpdate);
    u.execute();
    String query = "PREFIX  ex:  <http://www.example.org/exampleDocument#>\n" + "PREFIX  voc:  <http://www.example.org/vocabulary#>\n" + "PREFIX  foaf:  <http://xmlns.com/foaf/0.1/>\n" + "PREFIX  rdfs:  <http://www.w3.org/2000/01/rdf-schema#>\n" + "\n" + "SELECT * \n" + // "FROM NAMED <http://www.example.org/exampleDocument#G1>\n" +
    "WHERE\n" + "{\n" + "  GRAPH ex:G1\n" + "  {\n" + "    ?m voc:name ?name ;\n" + "           voc:homepage ?hp .\n" + "  } .\n" + " GRAPH ex:G2\n" + "  {\n" + "    ?m voc:hasSkill ?skill .\n" + "  } .\n" + "}";
    TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
    tupleQuery.setBinding(RdfCloudTripleStoreConfiguration.CONF_QUERY_AUTH, vf.createLiteral("2"));
    CountTupleHandler tupleHandler = new CountTupleHandler();
    tupleQuery.evaluate(tupleHandler);
    assertEquals(1, tupleHandler.getCount());
    // no auth
    tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
    tupleHandler = new CountTupleHandler();
    tupleQuery.evaluate(tupleHandler);
    assertEquals(0, tupleHandler.getCount());
    conn.close();
    repo.shutDown();
}
Also used : RepositoryConnection(org.openrdf.repository.RepositoryConnection) RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) NamespaceManager(org.apache.rya.rdftriplestore.namespace.NamespaceManager) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) SailRepository(org.openrdf.repository.sail.SailRepository) TupleQuery(org.openrdf.query.TupleQuery) Update(org.openrdf.query.Update)

Example 4 with NamespaceManager

use of org.apache.rya.rdftriplestore.namespace.NamespaceManager in project incubator-rya by apache.

the class CbSailTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    store = new MockRdfCloudStore();
    // store.setDisplayQueryPlan(true);
    // store.setInferencing(false);
    NamespaceManager nm = new NamespaceManager(store.getRyaDAO(), store.getConf());
    store.setNamespaceManager(nm);
    repository = new RyaSailRepository(store);
    repository.initialize();
    JndiRegistry registry = super.createRegistry();
    registry.bind(Repository.class.getName(), repository);
    return registry;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) NamespaceManager(org.apache.rya.rdftriplestore.namespace.NamespaceManager) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository) Repository(org.openrdf.repository.Repository) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository)

Example 5 with NamespaceManager

use of org.apache.rya.rdftriplestore.namespace.NamespaceManager in project incubator-rya by apache.

the class ArbitraryLengthQueryTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    final RdfCloudTripleStore store = new MockRdfCloudStore();
    final NamespaceManager nm = new NamespaceManager(store.getRyaDAO(), store.getConf());
    store.setNamespaceManager(nm);
    repository = new RyaSailRepository(store);
    repository.initialize();
    load();
}
Also used : RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) NamespaceManager(org.apache.rya.rdftriplestore.namespace.NamespaceManager) RyaSailRepository(org.apache.rya.rdftriplestore.RyaSailRepository)

Aggregations

NamespaceManager (org.apache.rya.rdftriplestore.namespace.NamespaceManager)6 RyaSailRepository (org.apache.rya.rdftriplestore.RyaSailRepository)5 RdfCloudTripleStore (org.apache.rya.rdftriplestore.RdfCloudTripleStore)3 TupleQuery (org.openrdf.query.TupleQuery)2 RepositoryConnection (org.openrdf.repository.RepositoryConnection)2 SailRepository (org.openrdf.repository.sail.SailRepository)2 InputStream (java.io.InputStream)1 JndiRegistry (org.apache.camel.impl.JndiRegistry)1 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)1 Update (org.openrdf.query.Update)1 Repository (org.openrdf.repository.Repository)1 SailException (org.openrdf.sail.SailException)1