@Override public void setBinding(String name, Value value) { delegate.setBinding(name, value); }
@Override public void setBinding(String name, Value value) { delegate.setBinding(name, value); }
public void setBinding(String name, Value value) { delegate.setBinding(name, value); }
public void setBinding(String name, Value value) { delegate.setBinding(name, value); }
public void setBinding(String name, Value value) { delegate.setBinding(name, value); }
public void setBinding(String name, Value value) { delegate.setBinding(name, value); }
/** * @param queryLn * @param sparqlUpdateString * @param baseURI * @param includeInferred * @param dataset * @param bindings * @throws ExecutionException * @throws InterruptedException */ void executeUpdate(QueryLanguage queryLn, String sparqlUpdateString, String baseURI, boolean includeInferred, Dataset dataset, Map<String, Value> bindings) throws InterruptedException, ExecutionException { Future<Boolean> result = submit(() -> { Update update = txnConnection.prepareUpdate(queryLn, sparqlUpdateString); update.setIncludeInferred(includeInferred); if (dataset != null) { update.setDataset(dataset); } for (String bindingName : bindings.keySet()) { update.setBinding(bindingName, bindings.get(bindingName)); } update.execute(); return true; }); getFromFuture(result); }
@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 testInsertEmptyWhereWithBinding() throws Exception { logger.debug("executing test testInsertEmptyWhereWithBinding"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT {?x rdfs:label ?y . } WHERE { }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.setBinding("x", bob); operation.setBinding("y", f.createLiteral("Bob")); 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 testInsertWhereWithBindings() throws Exception { logger.debug("executing test testInsertWhereWithBindings"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT { ?x rdfs:comment ?z . } WHERE { ?x foaf:name ?y }"); Literal comment = f.createLiteral("Bob has a comment"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.setBinding("x", bob); operation.setBinding("z", comment); assertFalse(con.hasStatement(null, RDFS.COMMENT, comment, true)); operation.execute(); assertTrue(con.hasStatement(bob, RDFS.COMMENT, comment, true)); assertFalse(con.hasStatement(alice, RDFS.COMMENT, comment, true)); }
@Test public void testInsertWhereWithBindings2() throws Exception { logger.debug("executing test testInsertWhereWithBindings2"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT {?x rdfs:label ?z . } WHERE {?x foaf:name ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.setBinding("z", f.createLiteral("Bobbie")); operation.setBinding("x", bob); assertFalse(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bobbie"), true)); assertFalse(con.hasStatement(alice, RDFS.LABEL, null, true)); operation.execute(); assertTrue(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bobbie"), true)); assertFalse(con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true)); }
Value bindingValue = ProtocolUtil.parseValueParam(request, parameterName, repository.getValueFactory()); update.setBinding(bindingName, bindingValue);
@Test public void testInsertWhereWithBinding() throws Exception { logger.debug("executing test testInsertWhereWithBinding"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT {?x rdfs:label ?y . } WHERE {?x foaf:name ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.setBinding("x", bob); assertFalse(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); assertFalse(con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true)); operation.execute(); assertTrue(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); assertFalse(con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true)); }
public void execute(RepositoryConnection con) throws RepositoryException { try { Update preparedUpdate = con.prepareUpdate(QueryLanguage.SPARQL, getUpdateString(), getBaseURI()); preparedUpdate.setIncludeInferred(isIncludeInferred()); preparedUpdate.setDataset(getDataset()); if (getBindings() != null) { for (Binding binding : getBindings()) { preparedUpdate.setBinding(binding.getName(), binding.getValue()); } } preparedUpdate.execute(); } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (UpdateExecutionException e) { throw new RepositoryException(e); } }
@Override public void execute(RepositoryConnection con) throws RepositoryException { try { Update preparedUpdate = con.prepareUpdate(QueryLanguage.SPARQL, getUpdateString(), getBaseURI()); preparedUpdate.setIncludeInferred(isIncludeInferred()); preparedUpdate.setDataset(getDataset()); if (getBindings() != null) { for (Binding binding : getBindings()) { preparedUpdate.setBinding(binding.getName(), binding.getValue()); } } preparedUpdate.execute(); } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (UpdateExecutionException e) { throw new RepositoryException(e); } }
public void execute(RepositoryConnection con) throws RepositoryException { try { Update preparedUpdate = con.prepareUpdate(QueryLanguage.SPARQL, getUpdateString(), getBaseURI()); preparedUpdate.setIncludeInferred(isIncludeInferred()); preparedUpdate.setDataset(getDataset()); if (getBindings() != null) { for (Binding binding : getBindings()) { preparedUpdate.setBinding(binding.getName(), binding.getValue()); } } preparedUpdate.execute(); } catch (MalformedQueryException e) { throw new RepositoryException(e); } catch (UpdateExecutionException e) { throw new RepositoryException(e); } }
@Test public void testDeleteInsertWhereWithBindings() throws Exception { logger.debug("executing test testDeleteInsertWhereWithBindings"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DELETE { ?x foaf:name ?y } INSERT {?x rdfs:label ?y . } WHERE {?x foaf:name ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.setBinding("x", bob); assertFalse(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); assertFalse(con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true)); operation.execute(); assertTrue(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); assertFalse(con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true)); assertFalse(con.hasStatement(bob, FOAF.NAME, f.createLiteral("Bob"), true)); assertTrue(con.hasStatement(alice, FOAF.NAME, f.createLiteral("Alice"), true)); }
@Test public void testDeleteInsertWhereWithBindings2() throws Exception { logger.debug("executing test testDeleteInsertWhereWithBindings2"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DELETE { ?x foaf:name ?y } INSERT {?x rdfs:label ?z . } WHERE {?x foaf:name ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.setBinding("z", f.createLiteral("person")); assertFalse(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); assertFalse(con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true)); operation.execute(); assertTrue(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("person"), true)); assertTrue(con.hasStatement(alice, RDFS.LABEL, f.createLiteral("person"), true)); assertFalse(con.hasStatement(bob, FOAF.NAME, f.createLiteral("Bob"), true)); assertFalse(con.hasStatement(alice, FOAF.NAME, f.createLiteral("Alice"), true)); }