/** Answer a new graph which is the reachable subgraph from <code>node</code> in <code>graph</code> with the terminating condition given by the TripleBoundary passed to the constructor. */ public Graph extract( Node node, Graph graph ) { return extractInto( Factory.createGraphMem(), node, graph ); }
/** Answer a new graph which is the reachable subgraph from <code>node</code> in <code>graph</code> with the terminating condition given by the TripleBoundary passed to the constructor. */ public Graph extract( Node node, Graph graph ) { return extractInto( Factory.createGraphMem(), node, graph ); }
@Override public Graph extractInto( final Graph toUpdate, final Node n, final Graph source ) { root = n; return result = super.extractInto(toUpdate, n, subject = source); } };
@Override public Graph extractInto( final Graph toUpdate, final Node n, final Graph source ) { root = n; return result = super.extractInto(toUpdate, n, subject = source); } };
/** Answer <code>model</code> after updating it with the sub-graph of <code>s</code> rooted at <code>r</code>, bounded by this instances <code>boundary</code>. */ public Model extractInto( Model model, Resource r, Model s ) { TripleBoundary tb = boundary.asTripleBoundary( s ); Graph g = getGraphExtract( tb ) .extractInto( model.getGraph(), r.asNode(), s.getGraph() ); return ModelFactory.createModelForGraph( g ); }
/** Answer <code>model</code> after updating it with the sub-graph of <code>s</code> rooted at <code>r</code>, bounded by this instances <code>boundary</code>. */ public Model extractInto( Model model, Resource r, Model s ) { TripleBoundary tb = boundary.asTripleBoundary( s ); Graph g = getGraphExtract( tb ) .extractInto( model.getGraph(), r.asNode(), s.getGraph() ); return ModelFactory.createModelForGraph( g ); }
/** This test exposed that the update-existing-graph functionality was broken if the target graph already contained any statements with a subject S appearing as subject in the source graph - no further Spo statements were added. */ public void testPartialUpdate() { Graph source = graphWith( "a R b; b S e" ); Graph dest = graphWith( "b R d" ); GraphExtract e = new GraphExtract( TripleBoundary.stopNowhere ); e.extractInto( dest, node( "a" ), source ); assertIsomorphic( graphWith( "a R b; b S e; b R d" ), dest ); }
/** This test exposed that the update-existing-graph functionality was broken if the target graph already contained any statements with a subject S appearing as subject in the source graph - no further Spo statements were added. */ public void testPartialUpdate() { Graph source = graphWith( "a R b; b S e" ); Graph dest = graphWith( "b R d" ); GraphExtract e = new GraphExtract( TripleBoundary.stopNowhere ); e.extractInto( dest, node( "a" ), source ); assertIsomorphic( graphWith( "a R b; b S e; b R d" ), dest ); }
/** * This test exposed that the update-existing-graph functionality was broken * if the target graph already contained any statements with a subject S * appearing as subject in the source graph - no further Spo statements were * added. */ @ContractTest public void testPartialUpdate() { Graph source = graphWith(producer.newInstance(), "a R b; b S e"); Graph dest = graphWith(producer.newInstance(), "b R d"); txnBegin(source); try { GraphExtract e = new GraphExtract(TripleBoundary.stopNowhere); e.extractInto(dest, node("a"), source); txnCommit(source); } catch (RuntimeException e) { txnRollback(source); e.printStackTrace(); fail(e.getMessage()); } txnBegin(source); assertIsomorphic(graphWith("a R b; b S e; b R d"), dest); txnRollback(source); }
/** * This test exposed that the update-existing-graph functionality was broken * if the target graph already contained any statements with a subject S * appearing as subject in the source graph - no further Spo statements were * added. */ @ContractTest public void testPartialUpdate() { Graph source = graphWith(producer.newInstance(), "a R b; b S e"); Graph dest = graphWith(producer.newInstance(), "b R d"); txnBegin(source); try { GraphExtract e = new GraphExtract(TripleBoundary.stopNowhere); e.extractInto(dest, node("a"), source); txnCommit(source); } catch (RuntimeException e) { txnRollback(source); e.printStackTrace(); fail(e.getMessage()); } txnBegin(source); assertIsomorphic(graphWith("a R b; b S e; b R d"), dest); txnRollback(source); }