Search in sources :

Example 41 with SailRepository

use of org.openrdf.repository.sail.SailRepository in project gocd by gocd.

the class InMemoryRepositoryFactory method emptyRepository.

public static Repository emptyRepository() {
    try {
        Repository repo = new SailRepository(new MemoryStore());
        repo.initialize();
        return repo;
    } catch (RepositoryException ex) {
        throw new ShineRuntimeException(ex);
    }
}
Also used : MemoryStore(org.openrdf.sail.memory.MemoryStore) Repository(org.openrdf.repository.Repository) SailRepository(org.openrdf.repository.sail.SailRepository) ShineRuntimeException(com.thoughtworks.studios.shine.ShineRuntimeException) SailRepository(org.openrdf.repository.sail.SailRepository) RepositoryException(org.openrdf.repository.RepositoryException)

Example 42 with SailRepository

use of org.openrdf.repository.sail.SailRepository in project incubator-rya by apache.

the class RdfCloudTripleStoreTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    connector = new MockInstance().getConnector("", "");
    RdfCloudTripleStore sail = new RdfCloudTripleStore();
    AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
    conf.setTablePrefix("lubm_");
    sail.setConf(conf);
    AccumuloRyaDAO crdfdao = new AccumuloRyaDAO();
    crdfdao.setConnector(connector);
    crdfdao.setConf(conf);
    sail.setRyaDAO(crdfdao);
    repository = new SailRepository(sail);
    repository.initialize();
    connection = repository.getConnection();
    loadData();
}
Also used : RdfCloudTripleStore(org.apache.rya.rdftriplestore.RdfCloudTripleStore) AccumuloRyaDAO(org.apache.rya.accumulo.AccumuloRyaDAO) MockInstance(org.apache.accumulo.core.client.mock.MockInstance) SailRepository(org.openrdf.repository.sail.SailRepository) AccumuloRdfConfiguration(org.apache.rya.accumulo.AccumuloRdfConfiguration)

Example 43 with SailRepository

use of org.openrdf.repository.sail.SailRepository in project incubator-rya by apache.

the class CbSailComponent method createEndpoint.

@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    String sailRepoNameParam = Repository.class.getName();
    if (parameters.containsKey(sailRepoNameParam)) {
        sailRepoNameParam = getAndRemoveParameter(parameters, SAILREPONAME, String.class);
    }
    Repository sailRepository = getCamelContext().getRegistry().lookup(sailRepoNameParam, Repository.class);
    checkNotNull(sailRepository, "Sail Repository must exist within the camel registry. Using lookup name[" + sailRepoNameParam + "]");
    CbSailEndpoint sailEndpoint = new CbSailEndpoint(uri, this, sailRepository, remaining);
    setProperties(sailEndpoint, parameters);
    return sailEndpoint;
}
Also used : Repository(org.openrdf.repository.Repository) SailRepository(org.openrdf.repository.sail.SailRepository)

Example 44 with SailRepository

use of org.openrdf.repository.sail.SailRepository in project incubator-rya by apache.

the class TriplestoreProvenanceCollectorTest method testCollect.

@Test
public void testCollect() throws ProvenanceCollectionException, RepositoryException, MalformedQueryException, QueryEvaluationException {
    Sail ms = new MemoryStore();
    SailRepository repo = new SailRepository(ms);
    repo.initialize();
    TriplestoreProvenanceCollector coll = new TriplestoreProvenanceCollector(repo, "fakeUser", "SPARQL");
    coll.recordQuery("fakeQuery");
    String queryString = "SELECT ?x ?y WHERE { ?x ?p ?y } ";
    TupleQuery tupleQuery = repo.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    TupleQueryResult result = tupleQuery.evaluate();
    // TODO not asserting on the results.
    assertTrue(result.hasNext());
}
Also used : MemoryStore(org.openrdf.sail.memory.MemoryStore) SailRepository(org.openrdf.repository.sail.SailRepository) Sail(org.openrdf.sail.Sail) TupleQuery(org.openrdf.query.TupleQuery) TupleQueryResult(org.openrdf.query.TupleQueryResult) Test(org.junit.Test)

Example 45 with SailRepository

use of org.openrdf.repository.sail.SailRepository in project incubator-rya by apache.

the class MongoGeoTemporalIndexIT method variableSubjQuery_Test.

@Test
public void variableSubjQuery_Test() throws Exception {
    final Sail sail = GeoRyaSailFactory.getInstance(conf);
    final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
    try {
        addStatements(conn);
        final String query = "PREFIX time: <http://www.w3.org/2006/time#> \n" + "PREFIX tempo: <tag:rya-rdf.org,2015:temporal#> \n" + "PREFIX geo: <http://www.opengis.net/ont/geosparql#>" + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>" + "SELECT * " + "WHERE { " + "  ?subj time:atTime ?time . " + "  ?subj geo:asWKT ?point . " + "  FILTER(geof:sfWithin(?point, \"POLYGON((-3 -2, -3 2, 1 2, 1 -2, -3 -2))\"^^geo:wktLiteral)) " + "  FILTER(tempo:equals(?time, \"2015-12-30T12:00:00Z\")) " + "}";
        final TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
        final List<BindingSet> results = new ArrayList<>();
        while (rez.hasNext()) {
            final BindingSet bs = rez.next();
            results.add(bs);
        }
        final MapBindingSet expected1 = new MapBindingSet();
        expected1.addBinding("point", VF.createLiteral("POINT (0 0)"));
        expected1.addBinding("time", VF.createLiteral("2015-12-30T12:00:00Z"));
        final MapBindingSet expected2 = new MapBindingSet();
        expected2.addBinding("point", VF.createLiteral("POINT (1 1)"));
        expected2.addBinding("time", VF.createLiteral("2015-12-30T12:00:00Z"));
        assertEquals(2, results.size());
        assertEquals(expected1, results.get(0));
        assertEquals(expected2, results.get(1));
    } finally {
        conn.close();
        sail.shutDown();
    }
}
Also used : MapBindingSet(org.openrdf.query.impl.MapBindingSet) BindingSet(org.openrdf.query.BindingSet) SailRepository(org.openrdf.repository.sail.SailRepository) Sail(org.openrdf.sail.Sail) ArrayList(java.util.ArrayList) MapBindingSet(org.openrdf.query.impl.MapBindingSet) SailRepositoryConnection(org.openrdf.repository.sail.SailRepositoryConnection) TupleQueryResult(org.openrdf.query.TupleQueryResult) Test(org.junit.Test)

Aggregations

SailRepository (org.openrdf.repository.sail.SailRepository)64 Sail (org.openrdf.sail.Sail)45 SailRepositoryConnection (org.openrdf.repository.sail.SailRepositoryConnection)41 Test (org.junit.Test)27 BindingSet (org.openrdf.query.BindingSet)14 RepositoryException (org.openrdf.repository.RepositoryException)14 TupleQueryResult (org.openrdf.query.TupleQueryResult)13 AccumuloRdfConfiguration (org.apache.rya.accumulo.AccumuloRdfConfiguration)11 TupleQuery (org.openrdf.query.TupleQuery)10 Configuration (org.apache.hadoop.conf.Configuration)9 SailException (org.openrdf.sail.SailException)9 HashSet (java.util.HashSet)8 ArrayList (java.util.ArrayList)7 AccumuloException (org.apache.accumulo.core.client.AccumuloException)7 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)7 RyaClientException (org.apache.rya.api.client.RyaClientException)7 RyaDAOException (org.apache.rya.api.persist.RyaDAOException)7 Repository (org.openrdf.repository.Repository)7 IOException (java.io.IOException)6 RyaURI (org.apache.rya.api.domain.RyaURI)6