@Override public boolean exists(ID subject, UID predicate, NODE object, UID context, boolean includeInferred) { return connections[0].exists(subject, predicate, object, context, includeInferred); }
private boolean exists(ID subject, MappedClass mappedClass, UID context) { UID type = mappedClass.getUID(); if (type != null) { return connection.exists(subject, RDF.type, type, context, true); } return false; }
@Test public void Delete_From_From_Where() throws IOException { connection().update(null, Collections.singleton(new STMT(RDFS.Resource, RDF.type, RDFS.Class, ex1))); connection().update(null, Collections.singleton(new STMT(RDFS.Resource, RDF.type, RDFS.Class, ex2))); RDFUpdate delete = update().delete(s.a(RDFS.Class)).from(ex1, ex2).where(s.has(p, o)); delete.execute(); assertFalse(connection().exists(null, null, null, ex1, false)); assertFalse(connection().exists(null, null, null, ex2, false)); assertTrue(connection().exists(null, null, null, null, false)); }
@Test public void Insert_Into_Into_Where() throws IOException { RDFUpdate insert = update().insert(s.a(example)).into(ex1, ex2).where(s.has(p, o)); insert.execute(); assertTrue(connection().exists(RDFS.Resource, RDF.type, example, ex1, false)); assertTrue(connection().exists(RDFS.Resource, RDF.type, example, ex2, false)); }
@Test public void Delete_From_Where() throws IOException { connection().update(null, Collections.singleton(new STMT(RDFS.Resource, RDF.type, RDFS.Class, ex1))); RDFUpdate delete = update().delete(s.a(RDFS.Class)).from(ex1).where(s.has(p, o)); delete.execute(); assertFalse(connection().exists(null, null, null, ex1, false)); assertTrue(connection().exists(null, null, null, null, false)); }
@Test public void Delete_Where_No_Match() throws IOException { RDFUpdate delete = update().delete(s.a(example)).where(s.has(p, o)); delete.execute(); assertTrue(connection().exists(null, null, null, null, false)); }
@Test public void Delete_Where_Matches() throws IOException { RDFUpdate delete = update().delete(s.a(RDFS.Class)).where(s.has(p, o)); delete.execute(); assertFalse(connection().exists(null, RDF.type, RDFS.Class, null, false)); }
@Test public void Insert_Where() throws IOException { RDFUpdate insert = update().insert(s.a(ex2)).where(s.has(p, o)); insert.execute(); assertTrue(connection().exists(RDFS.Resource, RDF.type, ex2, null, false)); }
@Test public void Insert_Into_Where() throws IOException { RDFUpdate insert = update().insert(s.a(ex2)).into(ex1).where(s.has(p, o)); insert.execute(); assertTrue(connection().exists(RDFS.Resource, RDF.type, ex2, ex1, false)); }