/** Answer the resource at the end of the path, if defined, or null */ public Resource getTerminalResource() { RDFNode n = getTerminal(); return (n != null && n.isResource()) ? (Resource) n : null; } }
/** Answer the resource at the end of the path, if defined, or null */ public Resource getTerminalResource() { RDFNode n = getTerminal(); return (n != null && n.isResource()) ? (Resource) n : null; } }
public static List<Resource> multiValueResource(Resource r, Property p) { List<RDFNode> nodes = multiValue(r, p) ; List<Resource> values = new ArrayList<>() ; for ( RDFNode n : nodes ) { if ( n.isResource() ) { values.add((Resource)n) ; } } return values ; }
@Override public boolean isResource() { return holder.getBaseItem().isResource(); }
/** Answer the given node presenting the OntResource facet if it can */ private static RDFNode asOntResource( RDFNode n ) { return n.isResource() ? n.as( OntResource.class ) : n; }
public String getValueAsString() { if (value.isResource()) { // some vocabularies use spaces in uris return "<" + value.toString().trim().replace(" ", "") + ">"; } else { return value.asLiteral().getLexicalForm(); } }
private void processFeedback(Connection connection, final RDFNode feedbackNode) { if (!feedbackNode.isResource()) { logger.warn("feedback node is not a resource, cannot process feedback for {}", connection.getConnectionURI()); return; } final Resource feedbackRes = (Resource) feedbackNode; if (!dataService.addFeedback(connection, feedbackRes)) { logger.warn("failed to add feedback to resource {}", connection.getConnectionURI()); } }
private List<ShapeTarget> collectClassTarget(Resource resource) { return resource.listProperties(SHACL.targetClass) .toList().stream() .filter(smt -> smt.getObject().isResource()) .map(smt -> ShapeTargetCore.create(ShapeTargetType.ClassTarget, smt.getObject())) .collect(Collectors.toList()); }
private static URI getUri(RDFNode node) { if (!node.isResource() || node.isAnon()) return null; return URI.create(node.asResource().getURI()); }
private Analyzer analyzerWithStopWords(Resource root) { RDFNode node = root.getProperty(TextVocab.pStopWords).getObject(); if (! node.isResource()) { throw new TextIndexException("text:stopWords property takes a list as a value : " + node); } CharArraySet stopWords = toCharArraySet((Resource) node); return new StandardAnalyzer(stopWords); }
private Analyzer analyzerWithStopWords(Resource root) { RDFNode node = root.getProperty(TextVocab.pStopWords).getObject(); if (! node.isResource()) { throw new TextIndexException("text:stopWords property takes a list as a value : " + node); } CharArraySet stopWords = toCharArraySet((Resource) node); return new StandardAnalyzer(stopWords); }
default Optional<Resource> getValueFormatter() { Statement smt = getElement().getProperty(RDFUNIT_SHACL_EXT.formatParameterValueAs); if (smt != null && smt.getObject().isResource()) { return Optional.of(smt.getObject().asResource()); } else { return Optional.empty(); } }
public static Resource getResourceProperty(Resource subject, Property predicate) { Statement s = subject.getProperty(predicate); if(s != null && s.getObject().isResource()) { return s.getResource(); } else { return null; } }
private boolean isSplittableNode(RDFNode node) { return node.isResource() && (node.isAnon() || ( node.asResource().getURI().startsWith(getNeedUri()) && (! node.asResource().getURI().equals(getNeedUri())) )); }
public static ReasonerStatementPattern objectPattern(Statement stmt) { if (!stmt.getObject().isResource()) { throw new IllegalArgumentException( "Object of stmt must be a resource."); } return new ReasonerStatementPattern(stmt.getSubject(), stmt.getPredicate(), stmt.getObject().asResource()); }
private static String rdfNodeToString(RDFNode node) { if (node.isLiteral()) { return node.asLiteral().getString(); } else if (node.isResource()) { return node.asResource().getURI(); } return null; }
private boolean ignore(Statement stmt) { return ( (stmt.getSubject().isAnon() || stmt.getObject().isAnon()) // can't deal with blank nodes || (!stmt.getObject().isResource()) // don't deal with literal values ); }
private void makeClass(RDFNode node, OntModel tboxOntModel) { if (!node.isResource() || node.isAnon()) { return; } Resource typeRes = (Resource) node; if (tboxOntModel.getOntClass(typeRes.getURI()) == null) { tboxOntModel.createClass(typeRes.getURI()); } }
private static String rdfNodeToString(RDFNode node) { if (node.isLiteral()) { return node.asLiteral().getString(); } else if (node.isResource()) { return node.asResource().getURI(); } return null; }
public static String getAsStringValue(Resource r, Property p) { if ( !atmostOneProperty(r, p) ) throw new NotUniqueException(r, p) ; Statement s = r.getProperty(p) ; if ( s == null ) return null ; if ( s.getObject().isResource() ) return s.getResource().getURI() ; return s.getString() ; }