Skip to content

Resource views

Dave Reynolds edited this page May 27, 2014 · 5 revisions

Resource views are a simplified alternative to Wrapped sources. Wrapped sources work well for generic browsing over largely static data. However, they are relatively heavyweight, inflexible and subject to caching problems.

A ResourceView is simply a wrapper round a Resource which provides some of the access convenience for use in scripts but with no support for dynamic or centrally cached descriptions. Each ResourceView has some associated (memory) model which is assumed to contain relevant properties of the resource but that might only be a partial view onto all of the data in the originating source. Machinery is provided to allow sub-classes of ResourceView to project out specific shapes of view.

ResourceView

A summary of the core interface (see javadoc for definitive version). As for wrapped sources a property can be specified flexibly as a string (URI or curie), Property, Resource, Wrapped Resource, Resource View.

Method Description
getURI() URI of the resource
asResource() Plain Jena resource
getModel() Plan Jena Model holding the view (may be shared between multiple view)
getMinimalModel() A subset of the view which describes the root resource
getLabel() getLabel(lang) Return a label for the resource, chosen from any available label properties in the view
getLabel(String lang) Pick a label in the given language if possible
getDescription() getDescription(lang) A description for the resource, chosen from a built in set of plausible description properties in the view
hasProperty(prop) True if this view of the resource contains a value for the property
hasResourceValue(prop,resource) True if this view of the resource contains a matching resource value for the property
getStringValue(prop) Return value for the property as a String (null if none)
getStringValue(prop,deflt) Return value for the property as a String (deflt if none)
getResourceValue(prop) Return value for a property as a plain resource
getResourceValues(prop) Return all resource values for the property
getIntValue(prop,ifAbsent) Get an integer value or return the ifAbsent default
getLongValue(prop) Return property value as a Long or null
getDoubleValue(prop) Return property value as a Double or null
getBooleanValue(prop,ifAbsent ) Get boolean value for peorpty
getTimestampValue(prop) Return value for property as a timestamp (converting xsd datetimes to Unix style longs)
getConnectedLiterals(path) Return literal values connected to the resource by the given path
getConnectedResource(path) Return resource values connected to the resource by the given path
getConnectedResourceViews(path) Return resource values as ResourceViews connected to the resource by the given path
getSelectedResources(query) Return set of resources found by a SPARQL query over the view
getSelectedResource(query) Return single resource found by a SPARQL query over the view
select(query) SPARQL query over the view returning a normal ResultSet
selectOne(query) SPARQL query over the view returning the first row from the ResultSet

ResourceViewFactory

Provides a set of convenience methods for constructing ResourceViews from a SparqlSource

Provides for subclasses of ResourceView (which should inherit from ResourceViewBase) which define what RDF view should be extracted (class in the API summary).

Method Summary
getView(source,uri) Get default view, a describe
getView(source,uri,class) Get a ResourceView defined by the class
getViews(source,describe,select,class) Get a list of custom views by using the describe query to extract a set of descriptions then the select query to find the subset of those to return.
getViews(source,describe,select) Get a list of custom views by using the describe query to extract a set of descriptions then the select query to find the subset of those to return.
getViews(source,select,class) Get a describe view for each resource that matches the select query
getViews(source,select) Get a describe view for each resource that matches the select query
Clone this wiki locally