/** create a Statement from the given r, p, and o. */ @Override public Statement createStatement(Resource r, Property p, RDFNode o) { return new StatementImpl( r, p, o, this ); }
@Override public Resource getResource() { return mustBeResource( object ); }
/** .equals() defers to .sameAs so we only get the complexity of one cast. */ @Override public boolean equals(Object o) { return o instanceof Statement && sameAs( (Statement) o ); }
/** * create a Statement from the triple _t_ in the enhanced graph _eg_. The * Statement has subject, predicate, and object corresponding to those of * _t_. */ public static Statement toStatement( Triple t, ModelCom eg ) { Resource s = new ResourceImpl( t.getSubject(), eg ); Property p = new PropertyImpl( t.getPredicate(), eg ); RDFNode o = createObject( t.getObject(), eg ); return new StatementImpl( s, p, o, eg ); }
/** Add all the statements to the model by converting them to an array of corresponding triples and removing those from the underlying graph. */ @Override public Model add( Statement [] statements ) { GraphUtil.add(getGraph(), StatementImpl.asTriples( statements ) ); return this; }
/** Answer a Statement in this Model whcih encodes the given Triple. @param t a triple to wrap as a statement @return a statement wrapping the triple and in this model */ @Override public Statement asStatement( Triple t ) { return StatementImpl.toStatement( t, this ); }
@Override @Deprecated public Resource getResource( ResourceF f ) { return f.createResource( getResource() ); }
@Override public Statement getStatementProperty( Property p ) { return asResource().getRequiredProperty( p ); }
/** create a ReifiedStatement corresponding to this Statement and with the given _uri_. */ @Override public ReifiedStatement createReifiedStatement( String uri ) { return ReifiedStatementImpl.create( (ModelCom) this.getModel(), uri, this ); }
@Override public int hashCode() { return asTriple().hashCode(); }
/** remove all the Statements from the model by converting them to triples and removing those triples from the underlying graph. */ @Override public Model remove( Statement [] statements ) { GraphUtil.delete( getGraph(), StatementImpl.asTriples( statements ) ); return this; }
/** convert a _node_ into a ReifiedStatement in the enhanced graph _eg_ by looking into this graph's reifier to find the binding for the node; throw a DoesNotReify exception if there's no mapping. */ @Override public EnhNode wrap( Node n, EnhGraph eg ) { Triple x = getTriple( eg, n ); if (x == null) throw new DoesNotReifyException( n ); Statement st = StatementImpl.toStatement( x, (ModelCom) eg ); return new ReifiedStatementImpl( eg, n, st ); }
@Override public Statement getProperty(Property p) { return getResource().getRequiredProperty( p ); }
@Override public Statement createStatement( Resource subject, Property predicate, RDFNode object) { return new StatementImpl(subject, predicate, object); }
/** it turns out to be handy to return the new StatementImpl as the result */ @Override protected StatementImpl replace( RDFNode n ) { StatementImpl s = new StatementImpl( subject, predicate, n, model ); model.remove( this ).add( s ); return s; }
/** * Create instance triples corresponding towards a Quality Report * * @param computedOn - The resource URI of the dataset computed on * @param problemReport - A list of quality problem as RDF Jena models * * @return A Jena Model which can be queried or stored */ public Model createQualityReport(Resource computedOn, List<String> problemReportModels){ Model m = dataset.getDefaultModel(); Resource reportURI = Commons.generateURI(); m.add(new StatementImpl(reportURI, RDF.type, QPRO.QualityReport)); m.add(new StatementImpl(reportURI, QPRO.computedOn, computedOn)); for(String prModelURI : problemReportModels){ Model prModel = getProblemReportFromTBD(prModelURI); for(Resource r : getProblemURI(prModel)){ m.add(new StatementImpl(reportURI, QPRO.hasProblem, r)); } m.add(prModel); dataset.removeNamedModel(prModelURI); } return m; }
Resource problemURI = Commons.generateURI(); m.add(new StatementImpl(problemURI, RDF.type, QPRO.QualityProblem)); m.add(new StatementImpl(problemURI, QPRO.isDescribedBy, metricURI)); m.add(new StatementImpl(problemURI, QPRO.problematicThing, bNode)); m.add(new StatementImpl(bNode, RDF.type, RDF.Statement)); m.add(new StatementImpl(bNode, RDF.subject, Commons.asRDFNode(q.getSubject()))); m.add(new StatementImpl(bNode, RDF.predicate, Commons.asRDFNode(q.getPredicate()))); m.add(new StatementImpl(bNode, RDF.object, Commons.asRDFNode(q.getObject()))); m.add(new StatementImpl(bNode, QPRO.inGraph, Commons.asRDFNode(q.getGraph()))); Resource problemURI = Commons.generateURI(); m.add(new StatementImpl(problemURI, RDF.type, QPRO.QualityProblem)); m.add(new StatementImpl(problemURI, QPRO.isDescribedBy, metricURI)); m.add(new StatementImpl(problemURI, QPRO.problematicThing, sNode)); m.add(qpModel); m.add(new StatementImpl(problemURI, RDF.type, QPRO.QualityProblem)); m.add(new StatementImpl(problemURI, QPRO.isDescribedBy, metricURI)); m.add(new StatementImpl(problemURI, QPRO.problematicThing, problemSeq));