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);
}
}
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();
}
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();
}
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;
}
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();
}
Aggregations