/** *{@inheritDoc} */ @Override public Model getModel() { return blankNode.getModel(); }
public static StmtIterator listReverseProperties(RDFNode s, Property p) { StmtIterator result = s.getModel().listStatements(null, p, s); return result; }
public static void addValueNodes(RDFNode focusNode, Path path, Collection<RDFNode> results) { Set<Node> seen = new HashSet<>(); Iterator<Node> it = PathEval.eval(focusNode.getModel().getGraph(), focusNode.asNode(), path, Context.emptyContext); while(it.hasNext()) { Node node = it.next(); if(!seen.contains(node)) { seen.add(node); results.add(focusNode.getModel().asRDFNode(node)); } } }
public static void addValueNodes(RDFNode focusNode, Path path, Collection<RDFNode> results) { Set<Node> seen = new HashSet<>(); Iterator<Node> it = PathEval.eval(focusNode.getModel().getGraph(), focusNode.asNode(), path, Context.emptyContext); while(it.hasNext()) { Node node = it.next(); if(!seen.contains(node)) { seen.add(node); results.add(focusNode.getModel().asRDFNode(node)); } } }
public static String stringForRDFNode(RDFNode obj) { Model m = null ; if ( obj instanceof Resource ) m = obj.getModel() ; return stringForRDFNode(obj, newSerializationContext(m)) ; }
public static boolean addReverseProperty(RDFNode s, Property p, Resource o) { Resource newS = o.inModel(s.getModel()); RDFNode newO = s; boolean result = addProperty(newS, p, newO); return result; }
private void recursiveCopyWhereMultipleInEdges(RDFNode node) { ModelModification modelModification = new ModelModification(); recursiveCopyWhereMultipleInEdges(node, modelModification, new HashSet<>()); modelModification.modify(node.getModel()); }
private Model reanonimisePathBlankNodes(Resource resource, RDFNode rdfNode) { Model pathModel = ModelFactory.createDefaultModel(); pathModel.add(rdfNode.getModel()); pathModel.add(resource, SHACL.resultPath, rdfNode); ImmutableSet<Resource> resources = ImmutableSet.copyOf(pathModel.listSubjects()); resources.stream() .filter(Resource::isAnon) .filter(r -> r != resource) .forEach(r -> ResourceUtils.renameResource(r, null)); return pathModel; } }
private Model reanonimisePathBlankNodes(Resource resource, RDFNode rdfNode) { Model pathModel = ModelFactory.createDefaultModel(); pathModel.add(rdfNode.getModel()); pathModel.add(resource, SHACL.resultPath, rdfNode); ImmutableSet<Resource> resources = ImmutableSet.copyOf(pathModel.listSubjects()); resources.stream() .filter(Resource::isAnon) .filter(r -> r != resource) .forEach(r -> ResourceUtils.renameResource(r, null)); return pathModel; } }
public static boolean isJSConstraint(RDFNode node) { return node instanceof Resource && (JenaUtil.hasIndirectType((Resource)node, SH.JSConstraint) || (!((Resource)node).hasProperty(RDF.type) && node.getModel().contains(null, SH.js, node))); }
public static boolean isSPARQLConstraint(RDFNode node) { return node instanceof Resource && (JenaUtil.hasIndirectType((Resource)node, SH.SPARQLConstraint) || (!((Resource)node).hasProperty(RDF.type) && node.getModel().contains(null, SH.sparql, node))); }
public static boolean isJSConstraint(RDFNode node) { return node instanceof Resource && (JenaUtil.hasIndirectType((Resource)node, SH.JSConstraint) || (!((Resource)node).hasProperty(RDF.type) && node.getModel().contains(null, SH.js, node))); }
public static boolean isSPARQLConstraint(RDFNode node) { return node instanceof Resource && (JenaUtil.hasIndirectType((Resource)node, SH.SPARQLConstraint) || (!((Resource)node).hasProperty(RDF.type) && node.getModel().contains(null, SH.sparql, node))); }
public static RDFNode copy(RDFNode source) { RDFNode result = source.inModel(ModelFactory.createDefaultModel().add(source.getModel())); return result; }
public static RDFNode copy(RDFNode source) { RDFNode result = source.inModel(ModelFactory.createDefaultModel().add(source.getModel())); return result; }
private boolean isReachableFrom(RDFNode src, RDFNode target, Collection<RDFNode> visited){ if (src.equals(target)) return true; if (!src.isResource()) return false; if (visited.contains(src)) return false; visited.add(src); StmtIterator it = src.getModel().listStatements(src.asResource(), null, (RDFNode) null); while(it.hasNext()){ Statement stmt = it.nextStatement(); if (isReachableFrom(src, stmt.getObject(), visited)){ return true; } } return false; }
private void findReachableResources(RDFNode src, Set<Resource> found){ if (!src.isResource()) return; if (found.contains(src)) return; found.add(src.asResource()); StmtIterator it = src.getModel().listStatements(src.asResource(), null, (RDFNode) null); while(it.hasNext()){ Statement stmt = it.nextStatement(); findReachableResources(src, found); } }
@Test public void testAnonymousInModel() { // test anonymous final RDFNode rdfNode = ResourceFactory.createResource(); final RDFNode rdfNode2 = rdfNode.inModel(securedModel); Assert.assertEquals("Should have placed RDFNode in secured securedModel", securedModel, rdfNode2.getModel()); }
@Test public void testRDFNodeInModel() { // test uri final RDFNode rdfNode = ResourceFactory.createResource("http://exmple.com/testInModel"); final RDFNode rdfNode2 = rdfNode.inModel(securedModel); Assert.assertEquals("Should have placed RDFNode in secured securedModel", securedModel, rdfNode2.getModel()); }