/** * Returns the URI of the specified RDFNode or null if the node is null. If the * node does not represent a resource, a ResourceRequiredException is thrown. * * @param node * @return */ public static URI toURI(RDFNode node) { if (node == null) return null; return URI.create(node.asResource().getURI()); }
/** * Determines the Source of the Message * @param soln to retrieve the needUri * @param requesterUri determines your need uri (to know which messages are from you) * @return true if the message came from you, false if the message did not come from you */ private static boolean isYourMessage(QuerySolution soln, URI requesterUri) { return requesterUri.toString().equals(soln.get("needUri").asResource().getURI()); }
/** * return the needURI of a connection * * @param dataset <code>Dataset</code> object which contains connection information * @param connectionURI * @return <code>URI</code> of the need */ public static URI getLocalNeedURIFromConnection(Dataset dataset, final URI connectionURI) { return URI.create(findOnePropertyFromResource( dataset, connectionURI, WON.BELONGS_TO_NEED).asResource().getURI()); }
private URI getUriVar(QuerySolution solution, String name) { RDFNode node = solution.get(name); if (node == null) { return null; } return URI.create(node.asResource().getURI()); } }
@Override public URI apply(QuerySolution solution) { RDFNode uriNode = solution.get("uri"); if (uriNode == null) { throw new IllegalStateException("Query has no variable named 'uri'"); } if (!uriNode.isURIResource()) { throw new IllegalStateException("Value of result variable 'uri' is not a resource"); } return URI.create(uriNode.asResource().getURI().toString()); }
private boolean isSplittableNode(RDFNode node) { return node.isResource() && (node.isAnon() || ( node.asResource().getURI().startsWith(getNeedUri()) && (! node.asResource().getURI().equals(getNeedUri())) )); }
private static URI getUri(RDFNode node) { if (!node.isResource() || node.isAnon()) return null; return URI.create(node.asResource().getURI()); }
private synchronized List<String> findContainedEnvelopeUris(final Model envelopeGraph, final String envelopeGraphUri) { Resource envelopeGraphResource = envelopeGraph.getResource(envelopeGraphUri); StmtIterator it = envelopeGraphResource.listProperties(WONMSG.CONTAINS_ENVELOPE); if (it.hasNext()) { List ret = new ArrayList<String>(); while (it.hasNext()) { ret.add(it.nextStatement().getObject().asResource().getURI()); } return ret; } return Collections.emptyList(); }
private static void addToIdList(Statement stmt, Set<AnonId> ids) { if (stmt.getSubject().isAnon()) { ids.add(stmt.getSubject().getId()); } if (stmt.getObject().isAnon()) { ids.add(stmt.getObject().asResource().getId()); } }
private static void addToIdList(Statement stmt, Set<AnonId> ids) { if (stmt.getSubject().isAnon()) { ids.add(stmt.getSubject().getId()); } if (stmt.getObject().isAnon()) { ids.add(stmt.getObject().asResource().getId()); } }
private boolean evaluate( Object principal, Node node ) { if (node.equals( Node.ANY )) { return false; // all wild cards are false } if (node.isURI() || node.isBlank()) { Resource r = model.getRDFNode( node ).asResource(); return evaluate( principal, r ); } return true; }
private static String rdfNodeToString(RDFNode node) { if (node.isLiteral()) { return node.asLiteral().getString(); } else if (node.isResource()) { return node.asResource().getURI(); } return null; }
public String getDataGraphName(Resource goalNode) { if (goalNode != null) { NodeIterator nodeIter = getNeedModel().listObjectsOfProperty(goalNode, WON.HAS_DATA_GRAPH); if (nodeIter.hasNext()) { String dataGraphUri = nodeIter.next().asResource().getURI(); return dataGraphUri; } } return null; }
private static String rdfNodeToString(RDFNode node) { if (node.isLiteral()) { return node.asLiteral().getString(); } else if (node.isResource()) { return node.asResource().getURI(); } return null; }
public Model getDataGraph(Resource goalNode) { if (goalNode != null) { NodeIterator nodeIter = getNeedModel().listObjectsOfProperty(goalNode, WON.HAS_DATA_GRAPH); if (nodeIter.hasNext()) { String dataGraphUri = nodeIter.next().asResource().getURI(); return needDataset.getNamedModel(dataGraphUri); } } return null; }
public Model getShapesGraph(Resource goalNode) { if (goalNode != null) { NodeIterator nodeIter = getNeedModel().listObjectsOfProperty(goalNode, WON.HAS_SHAPES_GRAPH); if (nodeIter.hasNext()) { String shapesGraphUri = nodeIter.next().asResource().getURI(); return needDataset.getNamedModel(shapesGraphUri); } } return null; }
public void testRDFNodeAsResource() { final Model m = ModelHelper.modelWithStatements(this, ""); final Resource r = m.createResource("eh:/spoo"); Assert.assertSame(r, ((RDFNode) r).asResource()); }
public void testRDFNodeAsResource() { final Model m = ModelHelper.modelWithStatements(this, ""); final Resource r = m.createResource("eh:/spoo"); Assert.assertSame(r, ((RDFNode) r).asResource()); }
private boolean nodeIsPartOfInputModel(ShaclLiteTestCaseResult r) { boolean isResourceAsSubject = r.getFailingNode().isResource() && testCase.getTestInputModel().contains(r.getFailingNode().asResource(), null, (RDFNode) null); boolean asObject = testCase.getTestInputModel().contains(null, null, r.getFailingNode()); return isResourceAsSubject || asObject ; }
private boolean evaluate( Node node ) { if (node.equals( Node.ANY )) { return false; // all wild cards are false } if (node.isURI() || node.isBlank()) { Resource r = model.getRDFNode( node ).asResource(); return evaluate( r ); } else { return true; } }