/** * @param rs * The reified statement to look for predicate. * @return The predicate uri or null if an error occurs */ protected String getReifiedStatementPredicate(final ReifiedStatement rs) { return rs.getStatement().getPredicate().getURI(); }
/** If _n_ is a ReifiedStatement, create a local copy of it, which will force the underlying reifier to take note of the mapping. */ private void noteIfReified( RDFNode n ) { if (n.canAs( ReifiedStatement.class )) { ReifiedStatement rs = n.as( ReifiedStatement.class ); createReifiedStatement( rs.getURI(), rs.getStatement() ); } }
/** Remove a given reification from this model. Other reifications of the same statement are untouched. @param rs the reified statement to be removed */ public void removeReification( ReifiedStatement rs ) { ReifierStd.remove( model.getGraph(), rs.asNode(), rs.getStatement().asTriple() ); }
/** * @return A list containing every statements including the one that are subject of reifications but not the reification implementation ones (subject, * object...). */ protected List<Statement> listStatements() { final List<Statement> stats = new ArrayList<Statement>(); final StmtIterator sit = this.model.listStatements(); while (sit.hasNext()) { final Statement stat = sit.nextStatement(); // Filtering reified statement if (!stat.getPredicate().equals(RDF.subject) && !stat.getPredicate().equals(RDF.predicate) && !stat.getPredicate().equals(RDF.object)) { if (stat.getPredicate().equals(RDF.type) && stat.getObject().isResource()) { if (!((Resource) stat.getObject()).equals(RDF.Statement)) { stats.add(stat); } } else { stats.add(stat); } } } sit.close(); final RSIterator rsit = this.model.listReifiedStatements(); while (rsit.hasNext()) { stats.add(rsit.nextRS().getStatement()); } rsit.close(); return stats; }
/** * @param rs * The reified statement to look for subject. * @param type * The type of the subject. * @return The subject (uri or id) or null if an error occurs */ protected String getReifiedStatementSubject(final ReifiedStatement rs, final ResourceTypes type) { String toRet = null; final Resource subj = rs.getStatement().getSubject(); if (type.equals(ResourceTypes.ANON) && subj.isAnon()) { toRet = subj.getId().getLabelString(); } else if (type.equals(ResourceTypes.NAMED) && subj.isURIResource()) { toRet = subj.getURI(); } return toRet; }
statementsToRemove.add(rstmt.getRequiredProperty(DC.source)); statementsToRemove.add(rstmt.getStatement()); ReifiedStatement rstmt = rsIter.next(); cleanModel.add(rstmt.getStatement());
/** * @param rs * The reified statement to look for object. * @param type * The type of the object. * @return The object (literal value, id or uri) or null if an error occurs */ protected String getReifiedStatementObject(final ReifiedStatement rs, final RDFNodeTypes type) { String toRet = null; final RDFNode obj = rs.getStatement().getObject(); if (type.equals(RDFNodeTypes.ANON_R) && obj.isAnon()) { toRet = ((Resource) obj).getId().getLabelString(); } else if (type.equals(RDFNodeTypes.LITERAL) && obj.isLiteral()) { toRet = ((Literal) obj).getLexicalForm(); } else if (type.equals(RDFNodeTypes.NAMED_R) && obj.isURIResource()) { toRet = ((Resource) obj).getURI(); } return toRet; }