/** * <p>Answer a resource presenting the {@link OntResource} facet, which * corresponds to the given resource but attached to this model.</p> * @param res An existing resource * @return An {@link OntResource} attached to this model that has the same URI * or anonID as the given resource */ @Override public OntResource getOntResource( Resource res ) { return res.inModel( this ).as( OntResource.class ); }
@Override public Alt getAlt( Resource r ) { return r.inModel( this ).as( Alt.class ); }
@Override public Seq getSeq( Resource r ) { return r.inModel( this ).as( Seq.class ); }
@Override public Bag getBag( Resource r ) { return r.inModel( this ).as( Bag.class ); }
public StatementImpl(Resource subject, Property predicate, RDFNode object) { super( empty ); this.subject = subject.inModel( model ); this.predicate = predicate.inModel( model ); this.object = object.inModel( model ); }
/** Creates new StatementImpl */ public StatementImpl(Resource subject, Property predicate, RDFNode object, ModelCom model) { super( model ); this.subject = subject.inModel( model ); this.predicate = predicate.inModel( model ); this.object = object.inModel( model ); }
/** Answer a Resource .equals() to <code>root</code>, but in the expanded model. */ public static Resource withFullModel( Resource root ) { return root.inModel( fullModel( root.getModel() ) ); }
public APIResultSet(Graph graph, List<Resource> results, boolean isCompleted, boolean enableETags, String detailsQuery, View v) { model = new MergedModels( ModelFactory.createModelForGraph( graph ) ); setUsedPrefixes( model, getResultPrefixes( results ) ); this.results = results; this.isCompleted = isCompleted; this.detailsQuery = detailsQuery; this.hash = 0; this.timestamp = new Date(); this.enableETags = enableETags; this.view = v; if (!results.isEmpty()) this.root = results.get(0).inModel(model.merged); }
public void addBindings( Model toScan, Model meta, Resource anExec, CompleteContext cc ) { Resource exec = anExec.inModel(meta), page = thisPage.inModel(meta); exec.addProperty( RDF.type, API.Execution ); addVariableBindings( meta, exec ); cc.include( meta ); addTermBindings( toScan, meta, exec, cc ); page.addProperty( API.wasResultOf, exec ); }
public void addExecution( Model meta, Resource anExec ) { Resource exec = anExec.inModel(meta), page = thisPage.inModel(meta); exec.addProperty( RDF.type, API.Execution ); Resource P = createBNode( meta ); ELDA.addEldaMetadata( P ); exec.addProperty( API.processor, P ); page.addProperty( API.wasResultOf, exec ); }
/** * Return a {@link Page} object decorating the underlying page resource in * the API results model * @return A page object */ public Page page() { return new Page( this, results.getRoot().inModel( this.getModel() ) ); }
public void setResource(Resource resource) { StmtIterator itr = resource.listProperties(); model.removeAll(); model.add(itr); res = (Resource) resource.inModel(model); }
private Resource completedClone( Resource root, Resource newRoot, Model fragment ) { Model typed = fragment.add( newRoot, RDF.type, JA.Content ); return newRoot.inModel( ModelFactory.createUnion( root.getModel(), typed ) ); }
/** External rendering API. e is the XML element representing the result, x is the root node, and mm comprises the object and meta data. */ public Element addResourceToElement( Element e, Resource x, MergedModels mm ) { Resource xInMetaModel = x.inModel( mm.getMetaModel() ); renderMetadata( e, x, xInMetaModel ); renderObjectData( e, x, mm.getObjectModel(), xInMetaModel ); return e; }
protected Resource resourceInModel( String string ) { Model m = ModelTestBase.modelWithStatements( string ); String firstResourceString = string.substring( 0, string.indexOf( ' ' ) ); Resource r = ModelTestBase.resource( m, firstResourceString ); return r.inModel( m ); }
/** * @return The page root resource, but attached only to the metadata model */ public RDFNodeWrapper metadataRoot() { return new RDFNodeWrapper( new ModelWrapper( metadataModel() ), results.getRoot().inModel( metadataModel() ) ); }
/** @return My wrapped node, but restricted to only the results object graph (ie not metadata) */ public RDFNodeWrapper objectResourceWrapped() { Resource objResource = this.asResource().inModel( page().pageObjectModel() ); ModelWrapper mw = new ModelWrapper( page().pageObjectModel() ); RDFNodeWrapper objResourceWrapper = new RDFNodeWrapper( mw, objResource ); return objResourceWrapper; }
/** * <p>Answer true if the given class is a sub-class of this class. * See {@link #listSubClasses( boolean )} for a full explanation of the <em>direct</em> * parameter. * </p> * @param cls A class to test. * @param direct If true, only search the classes that are directly adjacent to this * class in the class hierarchy. * @return True if the given class is a sub-class of this class. * @exception OntProfileException If the {@link Profile#SUB_CLASS_OF()} property is not supported in the current language profile. */ @Override public boolean hasSubClass( Resource cls, boolean direct ) { if (getModel() instanceof OntModel && (cls.getModel() == null || !(cls.getModel() instanceof OntModel))) { // could be outside an ontmodel if a constant cls = cls.inModel( getModel() ); } return cls.as( OntClass.class ).hasSuperClass( this, direct ); }
/** Create metadata which describes the available alternative formats this page could be presented in. */ public void addFormats( Model meta, Set<FormatNameAndType> formats ) { List<String> formatNames = getFormatNames( formats ); Resource page = thisPage.inModel(meta); for (FormatNameAndType format: formats) { Resource v = resourceForFormat( thisPageAsURI, meta, formatNames, format.name ); Resource formatNode = createBNode( meta ).addProperty( RDFS.label, format.mediaType ); page.addProperty( DCTerms.hasFormat, v ); v.addProperty( DCTerms.isFormatOf, thisPage ); v.addProperty( DCTerms.format, formatNode ); v.addProperty( RDFS.label, format.name ); } }
public void addQueryMetadata( Model meta, Resource anExec, String selectQuery, String viewQuery, Source source, boolean listEndpoint ) { Resource EP = meta.createResource( SPARQL.Service ); // source.addMetadata( EP ); Resource url = EP.getRequiredProperty( API.sparqlEndpoint ).getResource(); EP.addProperty( SPARQL.url, url ); // Resource exec = anExec.inModel(meta); if (listEndpoint) { Resource sr = meta.createResource( SPARQL.QueryResult ); sr.addProperty( SPARQL.query, inValue( meta, selectQuery ) ); sr.addProperty( SPARQL.endpoint, EP ); exec.addProperty( API.selectionResult, sr ); } // Resource vr = meta.createResource( SPARQL.QueryResult ); vr.addProperty( SPARQL.query, inValue( meta, viewQuery ) ); vr.addProperty( SPARQL.endpoint, EP ); exec.addProperty( API.viewingResult, vr ); }