public class SesameBackend extends Object implements Backend
Backend
that
uses Sesame to store and retrieve the context events in/from an underlying
store server (a SAIL in Sesame). In this case it uses the Sesame native
Filesystem repository, interfaced with a forward chaining RDFS inferencer.Modifier and Type | Field and Description |
---|---|
static String |
PRELOAD_FILE
Name of file holding the stored OWLs
|
protected MessageContentSerializer |
serializer
turtle parser.
|
static Boolean |
tenantAware
Determines if data is stored/queried in tenant-aware mode
|
Constructor and Description |
---|
SesameBackend() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the connection to the store.
|
void |
connect()
Establishes the connection to the store.
|
void |
populate()
Fills the initial store with the OWL data of the ontologies from the OWL
files in the config folder (or registered in the system).
|
void |
populate(String filename)
Fills the store with the OWL data of a certain ontologies from the OWL
file in the config folder (or registered in the system).
|
String |
queryBySPARQL(String input,
String... scopeArray)
Returns the result of a SPARQL query issued to the underlying store.
|
void |
removeOldEvents(long tst)
Removes all events from the underlying store that were received until the
specified timestamp.
|
ArrayList |
retrieveEvent(String subject,
String subjecttype,
String predicate,
Object object,
Integer confidence,
Long expiration,
Object provider,
Long tstamp,
String... scopeArray)
Retrieves a list of
ContextEvent from the
underlying store, which members are the context events that match the
parameters passed. |
ArrayList |
retrieveEventsBetweenTstmp(String subject,
String subjecttype,
String predicate,
Object object,
Integer confidence,
Long expiration,
ContextProvider provider,
Long tstamp,
Long tstfrom,
Long tstto,
String... scopeArray)
Retrieves a list of
ContextEvent from the
underlying store, which members are the context events that match the
parameters passed, and were received within the specified time range. |
ArrayList |
retrieveEventsBySPARQL(String input,
String... scopeArray)
Retrieves a list of
ContextEvent from the
underlying store, as a result of a SPARQL query. |
ArrayList |
retrieveEventsFromTstmp(String subject,
String subjecttype,
String predicate,
Object object,
Integer confidence,
Long expiration,
ContextProvider provider,
Long tstamp,
Long tstfrom,
String... scopeArray)
Retrieves a list of
ContextEvent from the
underlying store, which members are the context events that match the
parameters passed, and were received after the specified timestamp. |
ArrayList |
retrieveEventsToTstmp(String subject,
String subjecttype,
String predicate,
Object object,
Integer confidence,
Long expiration,
ContextProvider provider,
Long tstamp,
Long tstto,
String... scopeArray)
Retrieves a list of
ContextEvent from the
underlying store, which members are the context events that match the
parameters passed, and were received before the specified timestamp. |
void |
setSerializer(MessageContentSerializer service)
Set the MessageContentSerializer universAAL Parser that can be used to
serialize and parse RDF data to universAAL data and vice-versa.
|
void |
storeEvent(ContextEvent e)
Stores a
ContextEvent in the
underlying store. |
protected MessageContentSerializer serializer
public static final String PRELOAD_FILE
public static Boolean tenantAware
public void connect()
Backend
public void populate() throws org.openrdf.repository.RepositoryException, org.openrdf.rio.RDFParseException, IOException
Backend
populate
in interface Backend
org.openrdf.repository.RepositoryException
org.openrdf.rio.RDFParseException
IOException
public void populate(String filename) throws org.openrdf.repository.RepositoryException, org.openrdf.rio.RDFParseException, IOException
Backend
populate
in interface Backend
filename
- The naem of the OWL file to storeorg.openrdf.repository.RepositoryException
org.openrdf.rio.RDFParseException
IOException
public void close()
Backend
public void storeEvent(ContextEvent e)
Backend
ContextEvent
in the
underlying store.storeEvent
in interface Backend
e
- The context event to be stored.public String queryBySPARQL(String input, String... scopeArray)
Backend
queryBySPARQL
in interface Backend
input
- The SPARQL query to be executed.scopeArray
- Optional argument: scopes defining the origin tenants of the
requested infopublic ArrayList retrieveEventsBySPARQL(String input, String... scopeArray)
Backend
ContextEvent
from the
underlying store, as a result of a SPARQL query.retrieveEventsBySPARQL
in interface Backend
input
- The SPARQL query that defines the events to be returned. The
variable that represents the event MUST be named
c
. For instance: "SELECT ?c WHERE {...". Only
SELECT queries are allowed.scopeArray
- Optional argument: scopes defining the origin tenants of the
requested infopublic ArrayList retrieveEvent(String subject, String subjecttype, String predicate, Object object, Integer confidence, Long expiration, Object provider, Long tstamp, String... scopeArray)
Backend
ContextEvent
from the
underlying store, which members are the context events that match the
parameters passed. A parameter can be passed a value of null
for wildcarding.
This is not used in the current version. Will probably be deprecated.
retrieveEvent
in interface Backend
subject
- The URI of the subject of the event to be matchedsubjecttype
- The URI of the type of subject of the event to be matchedpredicate
- The URI of the predicate of the event to be matchedobject
- The Object of the event to be matched. It depends on the
implementer of this method how to match the object.confidence
- The confidence of the event to be matchedexpiration
- The expiration time of the event to be matchedprovider
- The context provider of the event to be matchedtstamp
- The timestamp in milliseconds of the event to be matchedscopeArray
- Optional argument: scopes defining the origin tenants of the
requested infopublic ArrayList retrieveEventsBetweenTstmp(String subject, String subjecttype, String predicate, Object object, Integer confidence, Long expiration, ContextProvider provider, Long tstamp, Long tstfrom, Long tstto, String... scopeArray)
Backend
ContextEvent
from the
underlying store, which members are the context events that match the
parameters passed, and were received within the specified time range. A
parameter can be passed a value of null
for wildcarding.retrieveEventsBetweenTstmp
in interface Backend
subject
- The URI of the subject of the event to be matchedsubjecttype
- The URI of the type of subject of the event to be matchedpredicate
- The URI of the predicate of the event to be matchedobject
- The Object of the event to be matched. It depends on the
implementer of this method how to match the object.confidence
- The confidence of the event to be matchedexpiration
- The expiration time of the event to be matchedprovider
- The context provider of the event to be matchedtstamp
- The timestamp in milliseconds of the event to be matched. If
not null
, only events with this specified
timestamp will be returned, as long as it is inside the time
rangetstfrom
- The timestamp in milliseconds from which events are requested.
Only events stored after this timestamp will be returned.tstto
- The timestamp in milliseconds until which events are
requested. Only events stored before this timestamp will be
returned.scopeArray
- Optional argument: scopes defining the origin tenants of the
requested infopublic ArrayList retrieveEventsFromTstmp(String subject, String subjecttype, String predicate, Object object, Integer confidence, Long expiration, ContextProvider provider, Long tstamp, Long tstfrom, String... scopeArray)
Backend
ContextEvent
from the
underlying store, which members are the context events that match the
parameters passed, and were received after the specified timestamp. A
parameter can be passed a value of null
for wildcarding.retrieveEventsFromTstmp
in interface Backend
subject
- The URI of the subject of the event to be matchedsubjecttype
- The URI of the type of subject of the event to be matchedpredicate
- The URI of the predicate of the event to be matchedobject
- The Object of the event to be matched. It depends on the
implementer of this method how to match the object.confidence
- The confidence of the event to be matchedexpiration
- The expiration time of the event to be matchedprovider
- The context provider of the event to be matchedtstamp
- The timestamp in milliseconds of the event to be matched. If
not null
, only events with this specified
timestamp will be returned, as long as it is inside the time
range specified by tstinputfrom
tstfrom
- The timestamp in milliseconds from which events are requested.
Only events stored after this timestamp will be returned.scopeArray
- Optional argument: scopes defining the origin tenants of the
requested infopublic ArrayList retrieveEventsToTstmp(String subject, String subjecttype, String predicate, Object object, Integer confidence, Long expiration, ContextProvider provider, Long tstamp, Long tstto, String... scopeArray)
Backend
ContextEvent
from the
underlying store, which members are the context events that match the
parameters passed, and were received before the specified timestamp. A
parameter can be passed a value of null
for wildcarding.retrieveEventsToTstmp
in interface Backend
subject
- The URI of the subject of the event to be matchedsubjecttype
- The URI of the type of subject of the event to be matchedpredicate
- The URI of the predicate of the event to be matchedobject
- The Object of the event to be matched. It depends on the
implementer of this method how to match the object.confidence
- The confidence of the event to be matchedexpiration
- The expiration time of the event to be matchedprovider
- The context provider of the event to be matchedtstamp
- The timestamp in milliseconds of the event to be matched. If
not null
, only events with this specified
timestamp will be returned, as long as it is inside the time
range specified by tstinputto
tstto
- The timestamp in milliseconds until which events are
requested. Only events stored before this timestamp will be
returned.scopeArray
- Optional argument: scopes defining the origin tenants of the
requested infopublic void removeOldEvents(long tst)
Backend
removeOldEvents
in interface Backend
tst
- The timestamp in milliseconds until which events are removed.
A value of 0 does nothing.public void setSerializer(MessageContentSerializer service)
Backend
setSerializer
in interface Backend
service
- The MessageContentSerializer service implementation found in
OSGiCopyright © 2018 universAAL Consortium. All rights reserved.