/** Calculate the bNode closure from a resource . * The Statement itself does not automatically get included. * @param resource * @param test The test object to be applied * @param testThisNode Indicate whether to apply the closure test to the Resource argument. * @param results Add the statements to this model * @return A model containing statements */ public static Model closure(Resource resource, ClosureTest test, boolean testThisNode, Model results) { //Set s = new HashSet() ; //Set visited = new HashSet() ; List<Resource> visited = new ArrayList<>() ; if ( ! testThisNode ) closureNoTest(resource, results, visited, test) ; else closure(resource, results, visited, test) ; return results ; }
/** Calculate the bNode closure from a statement . * The Statement itself does not automatically get included. * @param statement Starting point for the closure. * @param test The test object to be applied * @param model Add the statements to this model * @return A model containing statements * @see ClosureTest */ public static Model closure(Statement statement, ClosureTest test, Model model) { //Set visited = new HashSet() ; List<Resource> visited = new ArrayList<>() ; closure(statement, model, visited, test) ; return model ; }
/** Calculate the bNode closure from a statement . * The Statement itself does not automatically get included. * @param statement Starting point for the closure. * @param model Add the statements to this model * @return A model containing statements * @see ClosureTest */ public static Model closure(Statement statement, Model model) { return closure(statement, new ClosureBNode(), model) ; }
/** Calculate the bNode closure from a statement . * The Statement itself does not automatically get included. * @param stmt * @return A model containing statements */ public static Model closure(Statement stmt) { return closure(stmt, new ClosureBNode()) ; }
/** Calculate the bNode closure from a resource . * The Statement itself does not automatically get included. * @param resource * @param testThisNode Indicate whether to apply the closure test to the Resource argument. * @param results Add the statements to this model * @return A model containing statements */ public static Model closure(Resource resource, boolean testThisNode, Model results) { return closure(resource, new ClosureBNode(), testThisNode, results) ; }
/** Calculate the bNode closure from a statement . * The Statement itself does not automatically get included. * @param statement Starting point for the closure. * @param test The test object to be applied * @return A model containing statements * @see ClosureTest */ public static Model closure(Statement statement, ClosureTest test) { return closure(statement, test, GraphFactory.makeJenaDefaultModel()) ; }
/** Calculate the bNode closure from a resource. * The Statement itself does not automatically get included. * @param resource Starting point for the closure. * @param testThisNode Indicate whether to apply the closure test to the Resource argument. * @return A model containing statements */ public static Model closure(Resource resource, boolean testThisNode) { return closure(resource, new ClosureBNode(), testThisNode) ; }
/** Calculate the bNode closure from a resource . * The Statement itself does not automatically get included. * @param resource * @param test The test object to be applied * @param testThisNode Indicate whether to apply the closure test to the Resource argument. * @return A model containing statements */ public static Model closure(Resource resource, ClosureTest test, boolean testThisNode) { return closure(resource, test, testThisNode, GraphFactory.makeJenaDefaultModel()) ; }
private static void closureNoTest(Resource r, Model closureBlob, Collection<Resource> visited, ClosureTest test) { visited.add(r) ; StmtIterator sIter = r.listProperties() ; for ( ; sIter.hasNext() ; ) { Statement stmt = sIter.nextStatement() ; closure(stmt, closureBlob, visited, test) ; } }
private static void addToSubGraph(Statement stmt, Map<AnonId, Model> subGraphs) { Set<AnonId> ids = new HashSet<>(); addToIdList(stmt, ids); // Here we take a copy of the IDs Model subGraph = null; for (AnonId id : ids) { if (!subGraphs.containsKey(id)) { subGraph = Closure.closure(stmt); subGraph.add(stmt); break; } } // May already have built the sub-graph that includes this statement if (subGraph == null) return; // Find any further IDs that occur in the sub-graph StmtIterator sIter = subGraph.listStatements(); while (sIter.hasNext()) { addToIdList(sIter.next(), ids); } // Associate the sub-graph with all mentioned blank node IDs for (AnonId id : ids) { if (subGraphs.containsKey(id)) throw new IllegalStateException(String.format("ID %s occurs in multiple sub-graphs", id)); subGraphs.put(id, subGraph); } }
private static void addToSubGraph(Statement stmt, Map<AnonId, Model> subGraphs) { Set<AnonId> ids = new HashSet<>(); addToIdList(stmt, ids); // Here we take a copy of the IDs Model subGraph = null; for (AnonId id : ids) { if (!subGraphs.containsKey(id)) { subGraph = Closure.closure(stmt); subGraph.add(stmt); break; } } // May already have built the sub-graph that includes this statement if (subGraph == null) return; // Find any further IDs that occur in the sub-graph StmtIterator sIter = subGraph.listStatements(); while (sIter.hasNext()) { addToIdList(sIter.next(), ids); } // Associate the sub-graph with all mentioned blank node IDs for (AnonId id : ids) { if (subGraphs.containsKey(id)) throw new IllegalStateException(String.format("ID %s occurs in multiple sub-graphs", id)); subGraphs.put(id, subGraph); } }