/** Example setup - in-memory dataset with two graphs, one triple in each */ private static Dataset setup() { Dataset ds = TDBFactory.createDataset() ; DatasetGraphTDB dsg = (DatasetGraphTDB)(ds.asDatasetGraph()) ; Quad q1 = SSE.parseQuad("(<http://example/g1> <http://example/s> <http://example/p> <http://example/o1>)") ; Quad q2 = SSE.parseQuad("(<http://example/g2> <http://example/s> <http://example/p> <http://example/o2>)") ; dsg.add(q1) ; dsg.add(q2) ; return ds ; }
private void setupPlain() { // Make without transactions. DatasetGraphTDB dsg = createPlain(location) ; dsg.add(quad1) ; dsg.close() ; return ; }
private void setupPlain() { // Make without transactions. DatasetGraphTDB dsg = createPlain(location) ; dsg.add(quad1) ; dsg.close() ; return ; }
/** Example setup - in-memory dataset with two graphs, one triple in each */ private static Dataset setup() { Dataset ds = TDBFactory.createDataset() ; DatasetGraphTDB dsg = (DatasetGraphTDB)(ds.asDatasetGraph()) ; Quad q1 = SSE.parseQuad("(<http://example/g1> <http://example/s> <http://example/p> <http://example/o1>)") ; Quad q2 = SSE.parseQuad("(<http://example/g2> <http://example/s> <http://example/p> <http://example/o2>)") ; dsg.add(q1) ; dsg.add(q2) ; return ds ; }
public static void main(String[] args) { FileManager fm = FileManager.get(); fm.addLocatorClassLoader(ExampleTDB_04.class.getClassLoader()); InputStream in = fm.open("data/data.nt"); DatasetGraphTDB dsg = TDBInternal.getBaseDatasetGraphTDB(TDBFactory.createDatasetGraph()); GraphListener listener = new MyListener(); dsg.getDefaultGraph().getEventManager().register(listener); Iterator<Node> iter = dsg.listGraphNodes(); while ( iter.hasNext() ) { Graph graph = dsg.getGraph(iter.next()); graph.getEventManager().register(listener); } // this does not send events to the GraphListener TDBLoader.load(dsg, in, false); // this does not uses the Graph SPI dsg.add(new Quad(Quad.defaultGraphIRI, NodeFactory.createURI("x"), NodeFactory.createURI("y"), NodeFactory.createURI("z"))); // this does Graph graph = dsg.getDefaultGraph(); graph.add(new Triple(NodeFactory.createURI("x"), NodeFactory.createURI("y"), NodeFactory.createURI("z"))); // this sends events to the GraphListener Model model = ModelFactory.createModelForGraph(dsg.getDefaultGraph()) ; model.add(ResourceFactory.createProperty("foo:x1"), RDFS.label, "X1"); // this does it too in = fm.open("data/data.nt"); model.read(in, "", "N-TRIPLES"); dsg.close(); }
@Test public void testPlain() { assertEquals (3, countRDFNodes()) ; DatasetGraphTDB dsg = createPlain(location) ; assertTrue(dsg.contains(quad1)) ; dsg.add(quad2) ; assertTrue(dsg.contains(quad2)) ; dsg.close() ; StoreConnection.release(location) ; assertEquals (4, countRDFNodes()) ; }
@Test public void testPlain() { assertEquals (3, countRDFNodes()) ; DatasetGraphTDB dsg = createPlain(location) ; assertTrue(dsg.contains(quad1)) ; dsg.add(quad2) ; assertTrue(dsg.contains(quad2)) ; dsg.close() ; StoreConnection.release(location) ; assertEquals (4, countRDFNodes()) ; }