@Override public StmtIterator listStatements() { return IteratorFactory.asStmtIterator( GraphUtil.findAll( graph ), this); }
private void mergeGraph(Graph graph, Graph data) { GraphUtil.addInto(graph, data) ; }
/** Add all the statements to the model by converting them to an array of corresponding triples and removing those from the underlying graph. */ @Override public Model add( Statement [] statements ) { GraphUtil.add(getGraph(), StatementImpl.asTriples( statements ) ); return this; }
/** Delete triples the destination (arg 1) as given in the source (arg 2) */ public static void deleteFrom(Graph dstGraph, Graph srcGraph) { deleteIteratorWorker(dstGraph, GraphUtil.findAll( srcGraph )); dstGraph.getEventManager().notifyDeleteGraph( dstGraph, srcGraph ); }
/** Add triples into the destination (arg 1) from the source (arg 2)*/ public static void addInto(Graph dstGraph, Graph srcGraph ) { addIteratorWorker(dstGraph, GraphUtil.findAll( srcGraph )); dstGraph.getEventManager().notifyAddGraph( dstGraph, srcGraph ); }
private ResIterator listSubjectsFor( RDFNode p, RDFNode o ) { ClosableIterator<Node> xit = GraphUtil.listSubjects( graph, asNode( p ), asNode( o ) ); return IteratorFactory.asResIterator( xit, this ); }
@Override public Model remove( StmtIterator iter ) { GraphUtil.delete( getGraph(), asTriples( iter ) ); return this; }
@Override public boolean containsResource( RDFNode r ) { return GraphUtil.containsNode( graph, r.asNode() ); }
@Override @Deprecated public Model remove( Model m, boolean suppressReifications ) { GraphUtil.deleteFrom( getGraph(), m.getGraph()); return this; }
private static void output(Sink<Pair<Node, Map<Node, Set<Node>>>> sink, Graph graph) { ExtendedIterator<Node> subjects = GraphUtil.listSubjects(graph, Node.ANY, Node.ANY) ; try { Map<Node, Set<Node>> predicates = new HashMap<Node, Set<Node>>() ; while ( subjects.hasNext() ) { Node subject = subjects.next() ; ExtendedIterator<Triple> triples = graph.find(subject, Node.ANY, Node.ANY) ; try { while ( triples.hasNext() ) { Triple triple = triples.next() ; Node p = triple.getPredicate() ; if ( predicates.containsKey(p) ) { predicates.get(p).add(triple.getObject()) ; } else { Set<Node> objects = new HashSet<Node>() ; objects.add(triple.getObject()) ; predicates.put(p, objects) ; } } } finally { if ( triples != null ) triples.close() ; } sink.send(new Pair<Node, Map<Node, Set<Node>>>(subject, predicates)) ; predicates.clear() ; } } finally { if ( subjects != null ) subjects.close() ; sink.close() ; } }
/** remove all the Statements from the model by converting them to triples and removing those triples from the underlying graph. */ @Override public Model remove( Statement [] statements ) { GraphUtil.delete( getGraph(), StatementImpl.asTriples( statements ) ); return this; }
@Override @Deprecated public void add(Graph g) { addIterator(GraphUtil.findAll(g), false) ; manager.notifyAddGraph(graph, g) ; }
@Deprecated @Override public Model add( Model m, boolean suppressReifications ) { // suppressReifications is a no-op. GraphUtil.addInto( getGraph(), m.getGraph() ); return this; }
/** Remove all the Statements from the model by converting the List to a List(Statement) and removing that. */ @Override public Model remove( List<Statement> statements ) { GraphUtil.delete( getGraph(), asTriples( statements ) ); return this; }
/** Add all the statements to the model by converting the list to an array of Statement and removing that. */ @Override public Model add( List<Statement> statements ) { GraphUtil.add(getGraph(), asTriples( statements ) ); return this; }
/** Answer a human-consumable representation of <code>that</code>. The string <code>prefix</code> will appear near the beginning of the string. Nodes may be prefix-compressed using <code>that</code>'s prefix-mapping. This default implementation will display all the triples exposed by the graph (ie including reification triples if it is Standard). */ public static String toString( String prefix, Graph that ) { PrefixMapping pm = that.getPrefixMapping(); StringBuffer b = new StringBuffer( prefix + " {" ); int count = 0; String gap = ""; ClosableIterator<Triple> it = GraphUtil.findAll( that ); while (it.hasNext() && count < TOSTRING_TRIPLE_LIMIT) { b.append( gap ); gap = "; "; count += 1; b.append( it.next().toString( pm ) ); } if (it.hasNext()) b.append( "..." ); it.close(); b.append( "}" ); return b.toString(); }
private void loadSchema( Graph result, Assembler a, Resource root ) { Model m = a.openModel( root ); GraphUtil.addInto(result, m.getGraph()) ; }
@Override public Model add( StmtIterator iter ) { try { GraphUtil.add( getGraph(), asTriples( iter ) ); } finally { iter.close(); } return this; }
@Override @Deprecated public void delete( Graph g, boolean withReifications ) { if (g.dependsOn( graph )) delete( triplesOf( g ) ); else deleteIterator( GraphUtil.findAll( g ), false ); manager.notifyDeleteGraph( graph, g ); }
@Override public void addGraph(Node graphName, Graph graph) { removeGraph(graphName) ; GraphUtil.addInto(getGraph(graphName), graph) ; }