public void execute() throws UpdateExecutionException { delegate.execute(); if (activated) { for (RepositoryConnectionListener listener : listeners) { listener.execute(conn, ql, update, baseURI, delegate); } } }
public void execute() throws UpdateExecutionException { delegate.execute(); if (activated) { for (RepositoryConnectionListener listener : listeners) { listener.execute(conn, ql, update, baseURI, delegate); } } }
@Override public void execute() throws UpdateExecutionException { delegate.execute(); if (activated) { for (RepositoryConnectionListener listener : listeners) { listener.execute(conn, ql, update, baseURI, delegate); } } }
/** * Executes the given SPARQL Update queries against the given repository. */ private static void executeSparqlUpdateQueries(RepositoryConnection repositoryConnection, List<String> nextQueries) throws RepositoryException, MalformedQueryException, UpdateExecutionException { for (String nextQuery : nextQueries) { logger.info("nextQuery=" + nextQuery); Update preparedUpdate = repositoryConnection.prepareUpdate(QueryLanguage.SPARQL, nextQuery); preparedUpdate.execute(); } } }
public void executeUpdate(String sparqlUpdate) throws UpdateExecutionException, RepositoryException, MalformedQueryException { RepositoryConnection connection = repository.getConnection(); Update tupleQuery; tupleQuery = connection.prepareUpdate(QueryLanguage.SPARQL, sparqlUpdate); tupleQuery.execute(); connection.close(); }
public void executeUpdate(String sparqlUpdate) throws UpdateExecutionException, RepositoryException, MalformedQueryException { RepositoryConnection connection = repository.getConnection(); Update tupleQuery; tupleQuery = connection.prepareUpdate(QueryLanguage.SPARQL, sparqlUpdate); tupleQuery.execute(); connection.close(); }
@Test public void testInsertNonMatchingWhere() throws Exception { logger.debug("executing test testInsertNonMatchingWhere"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT { ?x rdfs:label ?y . } WHERE { ?x rdfs:comment ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertFalse(con.hasStatement(bob, RDFS.LABEL, null, true)); operation.execute(); assertFalse(con.hasStatement(bob, RDFS.LABEL, null, true)); }
@Test public void testCopyToNewNamed() throws Exception { logger.debug("executing testCopyToNewNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("COPY GRAPH ex:graph1 TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, f.createIRI(EX_NS, "graph3"))); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
@Test public void testDropAll() throws Exception { logger.debug("executing testDropAll"); String update = "DROP ALL"; Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update); operation.execute(); assertFalse(con.hasStatement(null, null, null, false)); }
@Test public void testClearAll() throws Exception { logger.debug("executing testClearAll"); String update = "CLEAR ALL"; Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update); operation.execute(); assertFalse(con.hasStatement(null, null, null, false)); }
@Test public void testAddToNewNamed() throws Exception { logger.debug("executing testAddToNewNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("ADD GRAPH ex:graph1 TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, f.createIRI(EX_NS, "graph3"))); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
@Test public void testMoveToNewNamed() throws Exception { logger.debug("executing testMoveToNewNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("MOVE GRAPH ex:graph1 TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, f.createIRI(EX_NS, "graph3"))); assertFalse(con.hasStatement(null, null, null, false, graph1)); }
@Test public void testInsertEmptyWhere() throws Exception { logger.debug("executing test testInsertEmptyWhere"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT { <" + bob + "> rdfs:label \"Bob\" . } WHERE { }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertFalse(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); operation.execute(); assertTrue(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); }
@Test public void testCopyToExistingNamed() throws Exception { logger.debug("executing testCopyToExistingNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("COPY GRAPH ex:graph1 TO ex:graph2"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph2)); assertFalse(con.hasStatement(alice, FOAF.NAME, null, false, graph2)); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
@Test public void testAddToExistingNamed() throws Exception { logger.debug("executing testAddToExistingNamed"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("ADD GRAPH ex:graph1 TO ex:graph2"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph2)); assertTrue(con.hasStatement(alice, FOAF.NAME, null, false, graph2)); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
@Test public void testDropGraph() throws Exception { logger.debug("executing testDropGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DROP GRAPH <" + graph1.stringValue() + "> "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertFalse(con.hasStatement(null, null, null, false, graph1)); assertTrue(con.hasStatement(null, null, null, false, graph2)); assertTrue(con.hasStatement(null, null, null, false)); }
@Test public void testClearGraph() throws Exception { logger.debug("executing testClearGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("CLEAR GRAPH <" + graph1.stringValue() + "> "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertFalse(con.hasStatement(null, null, null, false, graph1)); assertTrue(con.hasStatement(null, null, null, false, graph2)); assertTrue(con.hasStatement(null, null, null, false)); }
@Test public void testInsertNonMatchingWhereWithBindings() throws Exception { logger.debug("executing test testInsertNonMatchingWhereWithBindings"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT { ?x rdfs:label ?y . } WHERE { ?x rdfs:comment ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.setBinding("x", bob); operation.setBinding("y", f.createLiteral("Bob")); assertFalse(con.hasStatement(bob, RDFS.LABEL, null, true)); operation.execute(); assertFalse(con.hasStatement(bob, RDFS.LABEL, null, true)); }
@Test public void testClearNamed() throws Exception { logger.debug("executing testClearNamed"); String update = "CLEAR NAMED"; Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update); operation.execute(); assertFalse(con.hasStatement(null, null, null, false, graph1)); assertFalse(con.hasStatement(null, null, null, false, graph2)); assertTrue(con.hasStatement(null, null, null, false)); }
@Test public void testDropNamed() throws Exception { logger.debug("executing testDropNamed"); String update = "DROP NAMED"; Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update); operation.execute(); assertFalse(con.hasStatement(null, null, null, false, graph1)); assertFalse(con.hasStatement(null, null, null, false, graph2)); assertTrue(con.hasStatement(null, null, null, false)); }