public interface Store
StoreFactory
to instantiate concrete implementations.
The store is designed to be used for storing individual IResource
s or
unordered sets of them (due to how triplestores work).
Resources are stored under a specific named graph similar to how the keys are used in the
Map
. That is, a unique named graph must be supplied to store a
(group of)
resource(s) under the same named graph in the triplestore. The named graph is
expected to be
a valid URI
.
In the case of an individual resource, you can use the resource's about URI as the
namedGraph
.
Example uses:
store.containsKey(resource.getAbout().toString())
- returns whether a
resource is stored under its named graph URIstore.putResources(resource.getAbout().toString(), resource)
- store the
resource under the namedGraph that corresponds to the about URI of the resource.
Equivalent
of store.putResource(resource)
store.putResources(serviceProviderId, resources)
- store all resources
managed by a given Service Provider, under a named graph identified by the
serviceProviderId
URI. This assumes that the
serviceProviderId
is a
valid URI.Modifier and Type | Method and Description |
---|---|
default <T extends org.eclipse.lyo.oslc4j.core.model.IResource> |
appendResource(URI namedGraphUri,
T resource)
Adds an OSLC
IResource instance in addition to other instances already
present on this named graph into the triplestore. |
<T extends org.eclipse.lyo.oslc4j.core.model.IResource> |
appendResources(URI namedGraphUri,
Collection<T> resources)
Adds OSLC
IResource instances in addition to other instances already
present on this named graph into the triplestore. |
void |
clear(URI namedGraphUri)
Deletes the resources and statements stored under the given named graph from the triplestore.
|
void |
deleteResources(URI namedGraphUri,
org.eclipse.lyo.oslc4j.core.model.IResource... resources)
Delete all statements whose subject is one of the resources's URis.
|
void |
deleteResources(URI namedGraphUri,
URI... nodeUris)
Delete all statements whose subject is one of nodeUris
|
org.apache.jena.rdf.model.Model |
getJenaModelForSubject(URI namedGraphUri,
URI subject)
Retrieve a Jena model for triples under the given subject from the corresponding named graph.
|
<T extends org.eclipse.lyo.oslc4j.core.model.IResource> |
getResource(URI namedGraphUri,
URI uri,
Class<T> clazz)
Retrieve a single
IResource instance specified by the concrete
type, unmarshaled from the RDF graph persisted in the triplestore under the given
named graph. |
<T extends org.eclipse.lyo.oslc4j.core.model.IResource> |
getResources(URI namedGraphUri,
Class<T> clazz)
Retrieve the collection of
IResource instances specified by the concrete
type, unmarshaled from the RDF graph persisted in the triplestore under the given
named graph. |
<T extends org.eclipse.lyo.oslc4j.core.model.IResource> |
getResources(URI namedGraphUri,
Class<T> clazz,
int limit,
int offset)
Alternative to
getResources(URI, Class) with paging on the OSLC resource level. |
void |
insertJenaModel(URI namedGraphUri,
org.apache.jena.rdf.model.Model model)
Insert a jena model into the named graph with corresponding URI.
|
boolean |
insertResources(URI namedGraphUri,
Object... resources)
Insert Jena models representations of OSLC
IResource instances into the
named graph. |
Set<String> |
keySet()
Enumerates all named graph URIs within the dataset.
|
boolean |
namedGraphExists(URI namedGraphUri)
Checks if the triplestore has the named graph under the corresponding URI.
|
<T extends org.eclipse.lyo.oslc4j.core.model.IResource> |
putResources(URI namedGraphUri,
Collection<T> resources)
Inserts OSLC
IResource instances into the triplestore in the designed
namedGraph. |
void |
removeAll()
Remove EVERYTHING from the triplestore.
|
boolean |
resourceExists(URI namedGraphUri,
URI resourceUri)
Checks if a resource with resourceUri exists under the corresponding named graph.
|
<T extends org.eclipse.lyo.oslc4j.core.model.IResource> |
updateResources(URI namedGraphUri,
T... resources)
Insert Jena models representations of OSLC
IResource instances into the
named graph. |
void insertJenaModel(URI namedGraphUri, org.apache.jena.rdf.model.Model model)
boolean insertResources(URI namedGraphUri, Object... resources) throws StoreAccessException
IResource
instances into the
named graph.
existing statements already present in the named graph are not overridden, nor removed.StoreAccessException
void deleteResources(URI namedGraphUri, URI... nodeUris)
void deleteResources(URI namedGraphUri, org.eclipse.lyo.oslc4j.core.model.IResource... resources)
boolean namedGraphExists(URI namedGraphUri)
namedGraphUri
- URI of a named graph that shall be a valid URI and was used before with
the put*
methods.boolean resourceExists(URI namedGraphUri, URI resourceUri)
org.apache.jena.rdf.model.Model getJenaModelForSubject(URI namedGraphUri, URI subject) throws NoSuchElementException, StoreAccessException, ModelUnmarshallingException
<T extends org.eclipse.lyo.oslc4j.core.model.IResource> List<T> getResources(URI namedGraphUri, Class<T> clazz) throws StoreAccessException, ModelUnmarshallingException
IResource
instances specified by the concrete
type, unmarshaled from the RDF graph persisted in the triplestore under the given
named graph. The
named graph must represent a URI that was previously given to another method call or a
Resource
about URI if the resource was saved alone.clazz
- Concrete type of the stored resources. Must be correct (correspond to the
marshaled type and be a subclass of IResource
), otherwise the
instantiation from model will not succeed.IResource
instances, unmarshaled from the RDF graph persisted
in the triplestore.StoreAccessException
- if there was a problem with the triplestore (or the
dataset, more broadly).ModelUnmarshallingException
- if the classes cannot be instantiated or another error
occurred when working with Jena model.<T extends org.eclipse.lyo.oslc4j.core.model.IResource> List<T> getResources(URI namedGraphUri, Class<T> clazz, int limit, int offset) throws StoreAccessException, ModelUnmarshallingException
getResources(URI, Class)
with paging on the OSLC resource level.namedGraphUri
- URI of a named graph under which resources were storedclazz
- class of the resources being retrievedlimit
- paging limitoffset
- paging offsetStoreAccessException
- if there was a problem with the triplestore (or the
dataset, more broadly).ModelUnmarshallingException
- if the classes cannot be instantiated or another error
occurred when working with Jena model.<T extends org.eclipse.lyo.oslc4j.core.model.IResource> T getResource(URI namedGraphUri, URI uri, Class<T> clazz) throws NoSuchElementException, StoreAccessException, ModelUnmarshallingException
IResource
instance specified by the concrete
type, unmarshaled from the RDF graph persisted in the triplestore under the given
named graph.
namedGraph must represent a URI that was previously given to another call.namedGraphUri
- URI of a named graph under which resources were storedclazz
- Java class of the stored resources.IResource
instance, unmarshaled from the RDF graph persisted in the
triplestore.NoSuchElementException
- if the resource is not present under a given named graph
URI or if the named graph itself contains no resources
(effectively missing).StoreAccessException
- if there was a problem with the triplestore (or the
dataset, more broadly).ModelUnmarshallingException
- if the classes cannot be instantiated or another error
occurred when working with Jena model.<T extends org.eclipse.lyo.oslc4j.core.model.IResource> boolean updateResources(URI namedGraphUri, T... resources) throws StoreAccessException
IResource
instances into the
named graph.
Any existing model representations of these instances are overridden.
other existing statements in the named graph are not overridden, nor removed.StoreAccessException
<T extends org.eclipse.lyo.oslc4j.core.model.IResource> boolean putResources(URI namedGraphUri, Collection<T> resources) throws StoreAccessException
IResource
instances into the triplestore in the designed
namedGraph.
Any previously stored resource(s) and/or statements will be overwritten.
namedGraphUri
- A unique URI that is used as a named graph to which resources are
appendedresources
- A collection of IResource
instancesStoreAccessException
- if the operation can't be performed<T extends org.eclipse.lyo.oslc4j.core.model.IResource> boolean appendResources(URI namedGraphUri, Collection<T> resources) throws StoreAccessException
IResource
instances in addition to other instances already
present on this named graph into the triplestore. Jena models representing existing and added
resource arrays will be combined.namedGraphUri
- A unique URI that is used as a named graph to which resources are
appendedresources
- A collection of IResource
instancesStoreAccessException
- if the operation can't be performeddefault <T extends org.eclipse.lyo.oslc4j.core.model.IResource> boolean appendResource(URI namedGraphUri, T resource) throws StoreAccessException
IResource
instance in addition to other instances already
present on this named graph into the triplestore. Jena models representing existing and added
resource arrays will be combined.namedGraphUri
- A unique URI that is used as a named graph to which resources are
appendedresource
- An IResource
instance with 'about' property setStoreAccessException
- if the operation can't be performedvoid clear(URI namedGraphUri)
May delete the containing named graph, many triplestores will delete the named graph automatically as well as soon as it doesn't contain any triples.
Set<String> keySet()
If the dataset was not manipulated by other means than via this interface, it can be assumed that all URIs in the set are valid keys.
void removeAll()
Copyright © 2017. All rights reserved.