Package org.openrdf.query

Examples of org.openrdf.query.Update


        RepositoryConnection connection2 = repository.getConnection();
        try {
            String query = String.format("DELETE { <%s> <%s> ?v } INSERT { <%s> <%s> ?v . } WHERE { <%s> <%s> ?v }", subject.stringValue(), predicate.stringValue(), subject.stringValue(), predicate.stringValue(), subject.stringValue(), predicate.stringValue());

            Update u = connection2.prepareUpdate(QueryLanguage.SPARQL, query);
            u.execute();

            connection2.commit();
        } finally {
            connection2.close();
        }
View Full Code Here


        String update = "DELETE { ?s ?p ?o } INSERT { <http://localhost:8080/LMF/resource/hans_meier> <http://xmlns.com/foaf/0.1/name> \"Hans Meier\" . <http://localhost:8080/LMF/resource/hans_meier> <http://xmlns.com/foaf/0.1/based_near> <http://dbpedia.org/resource/Traunstein> . <http://localhost:8080/LMF/resource/hans_meier> <http://xmlns.com/foaf/0.1/interest> <http://rdf.freebase.com/ns/en.linux> } WHERE { ?s ?p ?o . FILTER ( ?s = <http://localhost:8080/LMF/resource/hans_meier> ) }";

        RepositoryConnection connectionUpdate = repository.getConnection();
        try {
            Update u = connectionUpdate.prepareUpdate(QueryLanguage.SPARQL, update);
            u.execute();
            connectionUpdate.commit();
        } finally {
            connectionUpdate.close();
        }
View Full Code Here

                "   <http://resource.org/fragment1> <http://ontology.org#shows> <http://resource.org/subject1>." +
                "} WHERE {}";

        RepositoryConnection connectionInsert = repository.getConnection();
        try {
            Update u = connectionInsert.prepareUpdate(QueryLanguage.SPARQL, insert);
            u.execute();
            connectionInsert.commit();
        } finally {
            connectionInsert.close();
        }

        //update quadruples
        String update =
                "WITH <http://resource.org/video>" +
                "DELETE { " +
                "   ?annotation ?p ?v." +
                "   ?fragment ?r ?s." +
                "   <http://resource.org/video> <http://ontology.org#hasFragment> ?fragment." +
                "} INSERT {" +
                "   <http://resource.org/video> <http://ontology.org#hasFragment> <http://resource.org/fragment1>." +
                "   <http://resource.org/annotation1> <http://ontology.org#hasTarget> <http://resource.org/fragment1>." +
                "   <http://resource.org/annotation1> <http://ontology.org#hasBody> <http://resource.org/subject1>." +
                "   <http://resource.org/fragment1> <http://ontology.org#shows> <http://resource.org/subject1>." +
                "} WHERE {" +
                "   ?annotation <http://ontology.org#hasTarget> ?fragment." +
                "   ?annotation ?p ?v." +
                "   OPTIONAL {" +
                "       ?fragment ?r ?s" +
                "   }" +
                "   FILTER (?fragment = <http://resource.org/fragment1>)" +
                "} ";

        RepositoryConnection connectionUpdate = repository.getConnection();
        try {
            Update u = connectionUpdate.prepareUpdate(QueryLanguage.SPARQL, update);
            u.execute();
            connectionUpdate.commit();
        } finally {
            connectionUpdate.close();
        }
View Full Code Here

        try {
            RepositoryConnection connection = sesameService.getConnection();
            try {
                connection.begin();
                Update update = connection.prepareUpdate(queryLanguage,query,configurationService.getBaseUri());
                update.execute();
                connection.commit();
            } catch (UpdateExecutionException e) {
                connection.rollback();
                throw new MarmottaException("error while executing update",e);
            } catch (MalformedQueryException e) {
View Full Code Here

        RepositoryConnection connection2 = repository.getConnection();
        try {
            String query = String.format("DELETE { <%s> <%s> ?v } INSERT { <%s> <%s> ?v . } WHERE { <%s> <%s> ?v }", subject.stringValue(), predicate.stringValue(), subject.stringValue(), predicate.stringValue(), subject.stringValue(), predicate.stringValue());

            Update u = connection2.prepareUpdate(QueryLanguage.SPARQL, query);
            u.execute();

            connection2.commit();
        } finally {
            connection2.close();
        }
View Full Code Here

        String update = "DELETE { ?s ?p ?o } INSERT { <http://localhost:8080/LMF/resource/hans_meier> <http://xmlns.com/foaf/0.1/name> \"Hans Meier\" . <http://localhost:8080/LMF/resource/hans_meier> <http://xmlns.com/foaf/0.1/based_near> <http://dbpedia.org/resource/Traunstein> . <http://localhost:8080/LMF/resource/hans_meier> <http://xmlns.com/foaf/0.1/interest> <http://rdf.freebase.com/ns/en.linux> } WHERE { ?s ?p ?o . FILTER ( ?s = <http://localhost:8080/LMF/resource/hans_meier> ) }";

        RepositoryConnection connectionUpdate = repository.getConnection();
        try {
            Update u = connectionUpdate.prepareUpdate(QueryLanguage.SPARQL, update);
            u.execute();
            connectionUpdate.commit();
        } finally {
            connectionUpdate.close();
        }
View Full Code Here

                "   <http://resource.org/fragment1> <http://ontology.org#shows> <http://resource.org/subject1>." +
                "} WHERE {}";

        RepositoryConnection connectionInsert = repository.getConnection();
        try {
            Update u = connectionInsert.prepareUpdate(QueryLanguage.SPARQL, insert);
            u.execute();
            connectionInsert.commit();
        } finally {
            connectionInsert.close();
        }

        //update quadruples
        String update =
                "WITH <http://resource.org/video>" +
                "DELETE { " +
                "   ?annotation ?p ?v." +
                "   ?fragment ?r ?s." +
                "   <http://resource.org/video> <http://ontology.org#hasFragment> ?fragment." +
                "} INSERT {" +
                "   <http://resource.org/video> <http://ontology.org#hasFragment> <http://resource.org/fragment1>." +
                "   <http://resource.org/annotation1> <http://ontology.org#hasTarget> <http://resource.org/fragment1>." +
                "   <http://resource.org/annotation1> <http://ontology.org#hasBody> <http://resource.org/subject1>." +
                "   <http://resource.org/fragment1> <http://ontology.org#shows> <http://resource.org/subject1>." +
                "} WHERE {" +
                "   ?annotation <http://ontology.org#hasTarget> ?fragment." +
                "   ?annotation ?p ?v." +
                "   OPTIONAL {" +
                "       ?fragment ?r ?s" +
                "   }" +
                "   FILTER (?fragment = <http://resource.org/fragment1>)" +
                "} ";

        RepositoryConnection connectionUpdate = repository.getConnection();
        try {
            Update u = connectionUpdate.prepareUpdate(QueryLanguage.SPARQL, update);
            u.execute();
            connectionUpdate.commit();
        } finally {
            connectionUpdate.close();
        }
View Full Code Here

        try {
            RepositoryConnection connection = sesameService.getConnection();
            try {
                connection.begin();
                Update update = connection.prepareUpdate(queryLanguage,query,configurationService.getBaseUri());
                update.execute();
                connection.commit();
            } catch (UpdateExecutionException e) {
                connection.rollback();
                throw new MarmottaException("error while executing update",e);
            } catch (MalformedQueryException e) {
View Full Code Here

        try {
            RepositoryConnection connection = sesameService.getConnection();
            try {
                connection.begin();
                Update update = connection.prepareUpdate(queryLanguage,query,configurationService.getBaseUri());
                update.execute();
                connection.commit();
            } catch (UpdateExecutionException e) {
                connection.rollback();
                throw new MarmottaException("error while executing update",e);
            } catch (MalformedQueryException e) {
View Full Code Here

  public Update prepareUpdate(QueryLanguage language, final String update, String baseURI) throws RepositoryException, MalformedQueryException
  {
    if (language != QueryLanguage.SPARQL)
      throw new UnsupportedQueryLanguageException(" : Only SPARQL queries are supported");

    Update u = new VirtuosoUpdate() {
      public void execute() throws UpdateExecutionException {
        executeSPARUL(update, getDataset(), getIncludeInferred(), getBindings());
      }
    };
    return u;
View Full Code Here

TOP

Related Classes of org.openrdf.query.Update

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.