org.openrdf.query.Update Java Examples
The following examples show how to use
org.openrdf.query.Update.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testDeleteDataMultiplePatterns() throws Exception { logger.debug("executing testDeleteData"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DELETE DATA { ex:alice foaf:knows ex:bob. ex:alice foaf:mbox \"[email protected]\" .} "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(alice, FOAF.KNOWS, bob, true)); assertTrue(con.hasStatement(alice, FOAF.MBOX, f.createLiteral("[email protected]"), true)); operation.execute(); String msg = "statement should have been deleted."; assertFalse(msg, con.hasStatement(alice, FOAF.KNOWS, bob, true)); assertFalse(msg, con.hasStatement(alice, FOAF.MBOX, f.createLiteral("[email protected]"), true)); }
Example #2
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@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)); }
Example #3
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@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)); }
Example #4
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@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)); }
Example #5
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testInsertWhereUsing() throws Exception { logger.debug("executing testInsertWhereUsing"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT {?x rdfs:label ?y . } USING ex:graph1 WHERE {?x foaf:name ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); String message = "label should have been inserted in default graph, for ex:bob only"; assertTrue(message, con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); assertFalse(message, con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true, graph1)); assertFalse(message, con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true, graph2)); assertFalse(message, con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true)); }
Example #6
Source File: TestTicket1716.java From database with GNU General Public License v2.0 | 6 votes |
private void executeQuery(final BigdataSailRepository repo) throws UpdateExecutionException, RepositoryException, MalformedQueryException { try { repo.initialize(); final BigdataSailRepositoryConnection conn = repo.getConnection(); try { String update = "insert {" + "<http://dbpedia.org/resource/Jules_Verne> <http://dbpedia.org/property/period> \"\"^^<http://www.w3.org/2001/XMLSchema#int>\r\n" + "} where {}"; Update preparedUpdate = conn.prepareUpdate(QueryLanguage.SPARQL, update); preparedUpdate.execute(); // no exception should occur on execution, overwise test will fail } finally { conn.close(); } } finally { repo.shutDown(); } }
Example #7
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testDeleteWhereShortcut() throws Exception { logger.debug("executing testDeleteWhereShortcut"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DELETE WHERE {?x foaf:name ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(bob, FOAF.NAME, f.createLiteral("Bob"), true)); assertTrue(con.hasStatement(alice, FOAF.NAME, f.createLiteral("Alice"), true)); operation.execute(); String msg = "foaf:name properties should have been deleted"; assertFalse(msg, con.hasStatement(bob, FOAF.NAME, f.createLiteral("Bob"), true)); assertFalse(msg, con.hasStatement(alice, FOAF.NAME, f.createLiteral("Alice"), true)); msg = "foaf:knows properties should not have been deleted"; assertTrue(msg, con.hasStatement(bob, FOAF.KNOWS, null, true)); assertTrue(msg, con.hasStatement(alice, FOAF.KNOWS, null, true)); }
Example #8
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testDeleteWhere() throws Exception { logger.debug("executing testDeleteWhere"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DELETE {?x foaf:name ?y } WHERE {?x foaf:name ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(bob, FOAF.NAME, f.createLiteral("Bob"), true)); assertTrue(con.hasStatement(alice, FOAF.NAME, f.createLiteral("Alice"), true)); operation.execute(); String msg = "foaf:name properties should have been deleted"; assertFalse(msg, con.hasStatement(bob, FOAF.NAME, f.createLiteral("Bob"), true)); assertFalse(msg, con.hasStatement(alice, FOAF.NAME, f.createLiteral("Alice"), true)); }
Example #9
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testDeleteTransformedWhere() throws Exception { logger.debug("executing testDeleteTransformedWhere"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DELETE {?y foaf:name ?n } WHERE {?x ex:containsPerson ?y . ?y foaf:name ?n . }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(bob, FOAF.NAME, f.createLiteral("Bob"), true)); assertTrue(con.hasStatement(alice, FOAF.NAME, f.createLiteral("Alice"), true)); operation.execute(); String msg = "foaf:name properties should have been deleted"; assertFalse(msg, con.hasStatement(bob, FOAF.NAME, f.createLiteral("Bob"), true)); assertFalse(msg, con.hasStatement(alice, FOAF.NAME, f.createLiteral("Alice"), true)); msg = "ex:containsPerson properties should not have been deleted"; assertTrue(msg, con.hasStatement(graph1, f.createURI(EX_NS, "containsPerson"), bob, true)); assertTrue(msg, con.hasStatement(graph2, f.createURI(EX_NS, "containsPerson"), alice, true)); }
Example #10
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testInsertData() throws Exception { logger.debug("executing testInsertData"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT DATA { ex:book1 dc:title \"book 1\" ; dc:creator \"Ringo\" . } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); URI book1 = f.createURI(EX_NS, "book1"); assertFalse(con.hasStatement(book1, DC.TITLE, f.createLiteral("book 1"), true)); assertFalse(con.hasStatement(book1, DC.CREATOR, f.createLiteral("Ringo"), true)); operation.execute(); String msg = "two new statements about ex:book1 should have been inserted"; assertTrue(msg, con.hasStatement(book1, DC.TITLE, f.createLiteral("book 1"), true)); assertTrue(msg, con.hasStatement(book1, DC.CREATOR, f.createLiteral("Ringo"), true)); }
Example #11
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testMoveFromDefaultToDefault() throws Exception { logger.debug("executing testMoveFromDefaultToDefault"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("MOVE DEFAULT TO DEFAULT"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); operation.execute(); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); }
Example #12
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testInsertDataMultiplePatterns() throws Exception { logger.debug("executing testInsertData"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT DATA { ex:book1 dc:title \"book 1\". ex:book1 dc:creator \"Ringo\" . ex:book2 dc:creator \"George\". } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); URI book1 = f.createURI(EX_NS, "book1"); URI book2 = f.createURI(EX_NS, "book2"); assertFalse(con.hasStatement(book1, DC.TITLE, f.createLiteral("book 1"), true)); assertFalse(con.hasStatement(book1, DC.CREATOR, f.createLiteral("Ringo"), true)); assertFalse(con.hasStatement(book2, DC.CREATOR, f.createLiteral("George"), true)); operation.execute(); String msg = "newly inserted statement missing"; assertTrue(msg, con.hasStatement(book1, DC.TITLE, f.createLiteral("book 1"), true)); assertTrue(msg, con.hasStatement(book1, DC.CREATOR, f.createLiteral("Ringo"), true)); assertTrue(msg, con.hasStatement(book2, DC.CREATOR, f.createLiteral("George"), true)); }
Example #13
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testInsertDataInGraph() throws Exception { logger.debug("executing testInsertDataInGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT DATA { GRAPH ex:graph1 { ex:book1 dc:title \"book 1\" ; dc:creator \"Ringo\" . } } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); URI book1 = f.createURI(EX_NS, "book1"); assertFalse(con.hasStatement(book1, DC.TITLE, f.createLiteral("book 1"), true, graph1)); assertFalse(con.hasStatement(book1, DC.CREATOR, f.createLiteral("Ringo"), true, graph1)); operation.execute(); String msg = "two new statements about ex:book1 should have been inserted in graph1"; assertTrue(msg, con.hasStatement(book1, DC.TITLE, f.createLiteral("book 1"), true, graph1)); assertTrue(msg, con.hasStatement(book1, DC.CREATOR, f.createLiteral("Ringo"), true, graph1)); }
Example #14
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testMoveFromDefault() throws Exception { logger.debug("executing testMoveFromDefault"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("MOVE DEFAULT TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); operation.execute(); assertFalse(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertFalse(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, f.createURI(EX_NS, "graph3"))); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, f.createURI(EX_NS, "graph3"))); }
Example #15
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testDeleteData() throws Exception { logger.debug("executing testDeleteData"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DELETE DATA { ex:alice foaf:knows ex:bob. } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(alice, FOAF.KNOWS, bob, true)); operation.execute(); String msg = "statement should have been deleted."; assertFalse(msg, con.hasStatement(alice, FOAF.KNOWS, bob, true)); }
Example #16
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testInsertWhereGraph() throws Exception { logger.debug("executing testInsertWhereGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT {GRAPH ?g {?x rdfs:label ?y . }} WHERE {GRAPH ?g {?x foaf:name ?y }}"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); String message = "labels should have been inserted in corresponding named graphs only."; assertTrue(message, con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true, graph1)); assertFalse(message, con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true, graph2)); assertTrue(message, con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true, graph2)); assertFalse(message, con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true, graph1)); }
Example #17
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testDeleteDataFromGraph() throws Exception { logger.debug("executing testDeleteDataFromGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DELETE DATA { GRAPH ex:graph1 {ex:alice foaf:knows ex:bob. } } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(alice, FOAF.KNOWS, bob, true, graph1)); operation.execute(); String msg = "statement should have been deleted from graph1"; assertFalse(msg, con.hasStatement(alice, FOAF.KNOWS, bob, true, graph1)); }
Example #18
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testDeleteDataFromWrongGraph() throws Exception { logger.debug("executing testDeleteDataFromWrongGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); // statement does not exist in graph2. update.append("DELETE DATA { GRAPH ex:graph2 {ex:alice foaf:knows ex:bob. } } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(alice, FOAF.KNOWS, bob, true, graph1)); assertFalse(con.hasStatement(alice, FOAF.KNOWS, bob, true, graph2)); operation.execute(); String msg = "statement should have not have been deleted from graph1"; assertTrue(msg, con.hasStatement(alice, FOAF.KNOWS, bob, true, graph1)); }
Example #19
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testCreateNewGraph() throws Exception { logger.debug("executing testCreateNewGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); URI newGraph = f.createURI(EX_NS, "new-graph"); update.append("CREATE GRAPH <" + newGraph + "> "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); assertTrue(con.hasStatement(null, null, null, false, graph1)); assertTrue(con.hasStatement(null, null, null, false, graph2)); assertFalse(con.hasStatement(null, null, null, false, newGraph)); assertTrue(con.hasStatement(null, null, null, false)); }
Example #20
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testCreateExistingGraph() throws Exception { logger.debug("executing testCreateExistingGraph"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("CREATE GRAPH <" + graph1 + "> "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); try { operation.execute(); fail("creation of existing graph should have resulted in error."); } catch (UpdateExecutionException e) { // expected behavior con.rollback(); } }
Example #21
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testCopyToDefault() throws Exception { logger.debug("executing testCopyToDefault"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("COPY GRAPH <" + graph1.stringValue() + "> TO DEFAULT"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); operation.execute(); assertFalse(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertFalse(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, (Resource)null)); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
Example #22
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@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()); assertTrue(con.hasStatement(alice, FOAF.NAME, null, false, graph2)); 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)); }
Example #23
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@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.createURI(EX_NS, "graph3"))); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
Example #24
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testCopyFromDefault() throws Exception { logger.debug("executing testCopyFromDefault"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("COPY DEFAULT TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); operation.execute(); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, f.createURI(EX_NS, "graph3"))); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, f.createURI(EX_NS, "graph3"))); }
Example #25
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testCopyFromDefaultToDefault() throws Exception { logger.debug("executing testCopyFromDefaultToDefault"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("COPY DEFAULT TO DEFAULT"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); operation.execute(); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); }
Example #26
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@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)); }
Example #27
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@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.createURI(EX_NS, "graph3"))); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, graph1)); }
Example #28
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testAddFromDefault() throws Exception { logger.debug("executing testAddFromDefault"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("ADD DEFAULT TO ex:graph3"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); URI graph3 = f.createURI(EX_NS, "graph3"); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(alice, FOAF.KNOWS, bob, false, graph1)); operation.execute(); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, graph3)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, graph3)); assertTrue(con.hasStatement(alice, FOAF.KNOWS, bob, false, graph1)); assertFalse(con.hasStatement(alice, FOAF.KNOWS, bob, false, graph3)); }
Example #29
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testAddFromDefaultToDefault() throws Exception { logger.debug("executing testAddFromDefaultToDefault"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("ADD DEFAULT TO DEFAULT"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); operation.execute(); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); }
Example #30
Source File: SPARQLUpdateTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testMoveToDefault() throws Exception { logger.debug("executing testMoveToDefault"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("MOVE GRAPH <" + graph1.stringValue() + "> TO DEFAULT"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); assertTrue(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); operation.execute(); assertFalse(con.hasStatement(graph1, DC.PUBLISHER, null, false, (Resource)null)); assertFalse(con.hasStatement(graph2, DC.PUBLISHER, null, false, (Resource)null)); assertTrue(con.hasStatement(bob, FOAF.NAME, null, false, (Resource)null)); assertFalse(con.hasStatement(null, null, null, false, graph1)); }