private void loadSchema( Graph result, Assembler a, Resource root ) { Model m = a.openModel( root ); GraphUtil.addInto(result, m.getGraph()) ; }
private static Optional<String> getValue(final Graph graph, final Node subject, final Node predicate) { final Iterator<Node> objects = listObjects(graph, subject, predicate); return Optional.ofNullable(objects.hasNext() ? objects.next().getLiteralValue().toString() : null); }
/** 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 in {@code srcGraph} from {@code dstGraph} * by looping on {@code srcGraph}. * */ public static void deleteLoopSrc(Graph dstGraph, Graph srcGraph) { deleteIteratorWorker(dstGraph, findAll(srcGraph)) ; dstGraph.getEventManager().notifyDeleteGraph(dstGraph, srcGraph) ; }
@Override public boolean removeAllEdges(Collection<? extends Triple> edges) { Iterator<Triple> it = edges.stream().map(e -> (Triple)e).iterator(); GraphUtil.delete(graph, it); return true; }
/** Assert that <code>g</code> contains every triple in <code>other</code>. */ public void testContains( Graph g, Graph other ) { testContains( g, GraphUtil.findAll( other ) ); }
private ResIterator listSubjectsFor( RDFNode p, RDFNode o ) { ClosableIterator<Node> xit = GraphUtil.listSubjects( graph, asNode( p ), asNode( o ) ); return IteratorFactory.asResIterator( xit, this ); }
/** Add triples into the destination (arg 1) from the source (arg 2)*/ public static void addInto(Graph dstGraph, Graph srcGraph ) { if ( dstGraph == srcGraph && ! dstGraph.getEventManager().listening() ) return ; dstGraph.getPrefixMapping().setNsPrefixes(srcGraph.getPrefixMapping()) ; addIteratorWorker(dstGraph, findAll( srcGraph )); dstGraph.getEventManager().notifyAddGraph( dstGraph, srcGraph ); }
protected Graph remove( Graph toUpdate, Graph toRemove ) { GraphUtil.deleteFrom(toUpdate, toRemove) ; return toUpdate; }
private boolean containsNode(Graph g, Node node) { return GraphUtil.containsNode(g, node) ; }
/** * Avoid dstGraph.size(). Instead step through {@codedstGraph.find} to compare to {@code srcGraph.size()} * */ private static boolean decideHowtoExecuteBySizeStep(Graph dstGraph, Graph srcGraph) { // loopOnSrc if: // size(src) <= MIN_SRC_SIZE // size(src)*DST_SRC_RATIO <= |find(dst)| int srcSize = srcGraph.size(); if ( srcSize <= MIN_SRC_SIZE ) return true ; boolean loopOnSrc = (srcSize <= MIN_SRC_SIZE || compareSizeTo(dstGraph, DST_SRC_RATIO*srcSize) == CMP_GREATER) ; return loopOnSrc; }
/** 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; }
/** Assert that <code>g</code> contains none of the triples in <code>other</code>. */ public void testOmits( Graph g, Graph other ) { testOmits( g, GraphUtil.findAll( other ) ); }
protected Set<Node> listSubjects( Graph g ) { return GraphUtil.listSubjects( g, Node.ANY, Node.ANY ).toSet(); }
/** Add triples into the destination (arg 1) from the source (arg 2)*/ public static void addInto(Graph dstGraph, Graph srcGraph ) { if ( dstGraph == srcGraph && ! dstGraph.getEventManager().listening() ) return ; dstGraph.getPrefixMapping().setNsPrefixes(srcGraph.getPrefixMapping()) ; addIteratorWorker(dstGraph, findAll( srcGraph )); dstGraph.getEventManager().notifyAddGraph( dstGraph, srcGraph ); }
protected Graph remove( Graph toUpdate, Graph toRemove ) { GraphUtil.deleteFrom(toUpdate, toRemove) ; return toUpdate; }
private boolean containsNode(Graph g, Node node) { return GraphUtil.containsNode(g, node) ; }
/** * Avoid dstGraph.size(). Instead step through {@codedstGraph.find} to compare to {@code srcGraph.size()} * */ private static boolean decideHowtoExecuteBySizeStep(Graph dstGraph, Graph srcGraph) { // loopOnSrc if: // size(src) <= MIN_SRC_SIZE // size(src)*DST_SRC_RATIO <= |find(dst)| int srcSize = srcGraph.size(); if ( srcSize <= MIN_SRC_SIZE ) return true ; boolean loopOnSrc = (srcSize <= MIN_SRC_SIZE || compareSizeTo(dstGraph, DST_SRC_RATIO*srcSize) == CMP_GREATER) ; return loopOnSrc; }
@Override public Model add(Model m) { GraphUtil.addInto(getGraph(), m.getGraph()) ; return this ; }
/** * Determines whether the subject is of type memento:Memento. * * @param graph the graph * @param subject the subject * @return whether the subject is a versioned node */ public boolean isVersionedNode(final Graph graph, final Node subject) { return listObjects(graph, subject, RDF.type.asNode()).toList().stream().map(Node::getURI) .anyMatch((MEMENTO_TYPE)::equals); }