Search in sources :

Example 1 with SailQueryPreparer

use of org.eclipse.rdf4j.repository.sail.SailQueryPreparer in project AJAN-service by aantakli.

the class SPARQLUtil method queryModel.

public static List<BindingSet> queryModel(final Model model, final ParsedTupleQuery query) throws QueryEvaluationException {
    SailRepository repo = createRepository(model);
    List<BindingSet> resultModel;
    try (SailRepositoryConnection conn = repo.getConnection()) {
        conn.begin();
        SailQueryPreparer preparer = new SailQueryPreparer(conn, false);
        TupleQueryResult results = preparer.prepare(query).evaluate();
        resultModel = getBindingSetList(results);
        conn.commit();
    }
    repo.shutDown();
    return resultModel;
}
Also used : BindingSet(org.eclipse.rdf4j.query.BindingSet) SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) SailQueryPreparer(org.eclipse.rdf4j.repository.sail.SailQueryPreparer) SailRepositoryConnection(org.eclipse.rdf4j.repository.sail.SailRepositoryConnection) TupleQueryResult(org.eclipse.rdf4j.query.TupleQueryResult)

Example 2 with SailQueryPreparer

use of org.eclipse.rdf4j.repository.sail.SailQueryPreparer in project AJAN-service by aantakli.

the class SPARQLUtil method queryModel.

public static Model queryModel(final Model model, final ParsedGraphQuery query) throws QueryEvaluationException {
    SailRepository repo = createRepository(model);
    Model resultModel;
    try (SailRepositoryConnection conn = repo.getConnection()) {
        conn.begin();
        SailQueryPreparer preparer = new SailQueryPreparer(conn, false);
        GraphQueryResult results = preparer.prepare(query).evaluate();
        resultModel = QueryResults.asModel(results);
        conn.commit();
    }
    repo.shutDown();
    return resultModel;
}
Also used : SailRepository(org.eclipse.rdf4j.repository.sail.SailRepository) Model(org.eclipse.rdf4j.model.Model) SailQueryPreparer(org.eclipse.rdf4j.repository.sail.SailQueryPreparer) SailRepositoryConnection(org.eclipse.rdf4j.repository.sail.SailRepositoryConnection) GraphQueryResult(org.eclipse.rdf4j.query.GraphQueryResult)

Aggregations

SailQueryPreparer (org.eclipse.rdf4j.repository.sail.SailQueryPreparer)2 SailRepository (org.eclipse.rdf4j.repository.sail.SailRepository)2 SailRepositoryConnection (org.eclipse.rdf4j.repository.sail.SailRepositoryConnection)2 Model (org.eclipse.rdf4j.model.Model)1 BindingSet (org.eclipse.rdf4j.query.BindingSet)1 GraphQueryResult (org.eclipse.rdf4j.query.GraphQueryResult)1 TupleQueryResult (org.eclipse.rdf4j.query.TupleQueryResult)1