Search in sources :

Example 16 with SPARQLRepository

use of org.eclipse.rdf4j.repository.sparql.SPARQLRepository in project AJAN-service by aantakli.

the class SendHTLELogs method readExternalRepo.

private boolean readExternalRepo(final ArrayNode array) throws IOException {
    boolean bool = false;
    Repository repo = new SPARQLRepository(repository.toString());
    try (RepositoryConnection conn = repo.getConnection()) {
        conn.begin(IsolationLevels.SERIALIZABLE);
        TupleQuery mmuQuery = conn.prepareTupleQuery(MMU_LOGS);
        TupleQueryResult mmuResult = mmuQuery.evaluate();
        if (readMMUInstructions(array, mmuResult)) {
            bool = true;
            TupleQuery abortQuery = conn.prepareTupleQuery(ABORT_LOGS);
            TupleQueryResult abortResult = abortQuery.evaluate();
            readAbortInstructions(array, abortResult);
        }
        conn.close();
    }
    return bool;
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) Repository(org.eclipse.rdf4j.repository.Repository) SPARQLRepository(org.eclipse.rdf4j.repository.sparql.SPARQLRepository) SPARQLRepository(org.eclipse.rdf4j.repository.sparql.SPARQLRepository) TupleQuery(org.eclipse.rdf4j.query.TupleQuery) TupleQueryResult(org.eclipse.rdf4j.query.TupleQueryResult)

Example 17 with SPARQLRepository

use of org.eclipse.rdf4j.repository.sparql.SPARQLRepository in project amazon-neptune-tools by awslabs.

the class NeptuneSparqlClient method executeTupleQuery.

public void executeTupleQuery(String sparql, RdfTargetConfig targetConfig) throws IOException {
    SPARQLRepository repository = chooseRepository();
    ValueFactory factory = repository.getValueFactory();
    try (RepositoryConnection connection = repository.getConnection();
        OutputWriter outputWriter = targetConfig.createOutputWriter()) {
        RDFWriter writer = targetConfig.createRDFWriter(outputWriter);
        connection.prepareTupleQuery(sparql).evaluate(new TupleQueryHandler(writer, factory));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) SPARQLRepository(org.eclipse.rdf4j.repository.sparql.SPARQLRepository) RDFWriter(org.eclipse.rdf4j.rio.RDFWriter) ValueFactory(org.eclipse.rdf4j.model.ValueFactory) OutputWriter(com.amazonaws.services.neptune.io.OutputWriter) IOException(java.io.IOException) NeptuneSigV4SignerException(com.amazonaws.neptune.auth.NeptuneSigV4SignerException)

Aggregations

SPARQLRepository (org.eclipse.rdf4j.repository.sparql.SPARQLRepository)17 RepositoryConnection (org.eclipse.rdf4j.repository.RepositoryConnection)8 Repository (org.eclipse.rdf4j.repository.Repository)6 IOException (java.io.IOException)4 TupleQuery (org.eclipse.rdf4j.query.TupleQuery)4 TupleQueryResult (org.eclipse.rdf4j.query.TupleQueryResult)4 URI (java.net.URI)3 BindingSet (org.eclipse.rdf4j.query.BindingSet)3 NeptuneSigV4SignerException (com.amazonaws.neptune.auth.NeptuneSigV4SignerException)2 OutputWriter (com.amazonaws.services.neptune.io.OutputWriter)2 HashMap (java.util.HashMap)2 Resource (org.eclipse.rdf4j.model.Resource)2 Statement (org.eclipse.rdf4j.model.Statement)2 Value (org.eclipse.rdf4j.model.Value)2 SailRepository (org.eclipse.rdf4j.repository.sail.SailRepository)2 RDFWriter (org.eclipse.rdf4j.rio.RDFWriter)2 File (java.io.File)1 InputStream (java.io.InputStream)1 HttpURLConnection (java.net.HttpURLConnection)1 MalformedURLException (java.net.MalformedURLException)1