org.universAAL.context.che.database.impl
Class SesameBackend

Package class diagram package SesameBackend
java.lang.Object
  extended by org.universAAL.context.che.database.impl.SesameBackend
All Implemented Interfaces:
Backend
Direct Known Subclasses:
SesameBackendCrd, SesameBackendCrdClc, SesameBackendCrdClc2, SesameBackendWithConfidence

public class SesameBackend
extends Object
implements Backend

Implementation of 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.

Author:
Alvaro Fides Valero

Field Summary
protected  MessageContentSerializer uAALParser
          uaal-turtle parser.
 
Constructor Summary
SesameBackend()
           
 
Method Summary
 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).
 String queryBySPARQL(String input)
          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)
          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)
          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)
          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)
          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)
          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 setuAALParser(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uAALParser

protected MessageContentSerializer uAALParser
uaal-turtle parser.

Constructor Detail

SesameBackend

public SesameBackend()
Method Detail

connect

public void connect()
Description copied from interface: Backend
Establishes the connection to the store.

Specified by:
connect in interface Backend

populate

public void populate()
              throws org.openrdf.repository.RepositoryException,
                     org.openrdf.rio.RDFParseException,
                     IOException
Description copied from interface: Backend
Fills the initial store with the OWL data of the ontologies from the OWL files in the config folder (or registered in the system). Also used for updates when new ontologies are installed.

Specified by:
populate in interface Backend
Throws:
org.openrdf.repository.RepositoryException
org.openrdf.rio.RDFParseException
IOException

close

public void close()
Description copied from interface: Backend
Closes the connection to the store.

Specified by:
close in interface Backend

storeEvent

public void storeEvent(ContextEvent e)
Description copied from interface: Backend
Stores a ContextEvent in the underlying store.

Specified by:
storeEvent in interface Backend
Parameters:
e - The context event to be stored.

queryBySPARQL

public String queryBySPARQL(String input)
Description copied from interface: Backend
Returns the result of a SPARQL query issued to the underlying store. The types of SPARQL queries allowed depend on the underlying implementation, but these are mandated to include at least SELECT and DESCRIBE, and encouraged to also allow CONSTRUCT and ASK. SPARQL-Update is optional. Implementations should inform in case an unsupported query is received. The underlying implementations should return results in RDF/XML-ABBREV format encoded in UTF-8 in case of RDF models, and also if possible in case of lists of bindings for SELECT queries. Results for ASK and UPDATE queries (if implemented) should follow the format \"true\" or \"false\" Strings in case of ASK and \"true\" in case of a successful UPDATE query.

Specified by:
queryBySPARQL in interface Backend
Parameters:
input - The SPARQL query to be executed.
Returns:
The serialized form of the result from the execution of the query.

retrieveEventsBySPARQL

public ArrayList retrieveEventsBySPARQL(String input)
Description copied from interface: Backend
Retrieves a list of ContextEvent from the underlying store, as a result of a SPARQL query.

Specified by:
retrieveEventsBySPARQL in interface Backend
Parameters:
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.
Returns:
The list of context events that matched the query.

retrieveEvent

public ArrayList retrieveEvent(String subject,
                               String subjecttype,
                               String predicate,
                               Object object,
                               Integer confidence,
                               Long expiration,
                               Object provider,
                               Long tstamp)
Description copied from interface: Backend
Retrieves a list of 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.

Specified by:
retrieveEvent in interface Backend
Parameters:
subject - The URI of the subject of the event to be matched
subjecttype - The URI of the type of subject of the event to be matched
predicate - The URI of the predicate of the event to be matched
object - 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 matched
expiration - The expiration time of the event to be matched
provider - The context provider of the event to be matched
tstamp - The timestamp in milliseconds of the event to be matched
Returns:
The list of context events that matched the values passed as parameters.

retrieveEventsBetweenTstmp

public ArrayList retrieveEventsBetweenTstmp(String subject,
                                            String subjecttype,
                                            String predicate,
                                            Object object,
                                            Integer confidence,
                                            Long expiration,
                                            ContextProvider provider,
                                            Long tstamp,
                                            Long tstfrom,
                                            Long tstto)
Description copied from interface: Backend
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. A parameter can be passed a value of null for wildcarding.

Specified by:
retrieveEventsBetweenTstmp in interface Backend
Parameters:
subject - The URI of the subject of the event to be matched
subjecttype - The URI of the type of subject of the event to be matched
predicate - The URI of the predicate of the event to be matched
object - 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 matched
expiration - The expiration time of the event to be matched
provider - The context provider of the event to be matched
tstamp - 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
tstfrom - 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.
Returns:
The list of context events that matched the values passed as parameters.

retrieveEventsFromTstmp

public ArrayList retrieveEventsFromTstmp(String subject,
                                         String subjecttype,
                                         String predicate,
                                         Object object,
                                         Integer confidence,
                                         Long expiration,
                                         ContextProvider provider,
                                         Long tstamp,
                                         Long tstfrom)
Description copied from interface: Backend
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. A parameter can be passed a value of null for wildcarding.

Specified by:
retrieveEventsFromTstmp in interface Backend
Parameters:
subject - The URI of the subject of the event to be matched
subjecttype - The URI of the type of subject of the event to be matched
predicate - The URI of the predicate of the event to be matched
object - 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 matched
expiration - The expiration time of the event to be matched
provider - The context provider of the event to be matched
tstamp - 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.
Returns:
The list of context events that matched the values passed as parameters.

retrieveEventsToTstmp

public ArrayList retrieveEventsToTstmp(String subject,
                                       String subjecttype,
                                       String predicate,
                                       Object object,
                                       Integer confidence,
                                       Long expiration,
                                       ContextProvider provider,
                                       Long tstamp,
                                       Long tstto)
Description copied from interface: Backend
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. A parameter can be passed a value of null for wildcarding.

Specified by:
retrieveEventsToTstmp in interface Backend
Parameters:
subject - The URI of the subject of the event to be matched
subjecttype - The URI of the type of subject of the event to be matched
predicate - The URI of the predicate of the event to be matched
object - 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 matched
expiration - The expiration time of the event to be matched
provider - The context provider of the event to be matched
tstamp - 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.
Returns:
The list of context events that matched the values passed as parameters.

removeOldEvents

public void removeOldEvents(long tst)
Description copied from interface: Backend
Removes all events from the underlying store that were received until the specified timestamp.

Specified by:
removeOldEvents in interface Backend
Parameters:
tst - The timestamp in milliseconds until which events are removed. A value of 0 does nothing.

setuAALParser

public void setuAALParser(MessageContentSerializer service)
Description copied from interface: Backend
Set the MessageContentSerializer universAAL Parser that can be used to serialize and parse RDF data to universAAL data and vice-versa. This might be helpful in many implementations, and allows the activator of the CHE to look for such service in OSGi, which should be provided by the mandatory component mw.data.serialization. There is no guarantee though that the parser is set before it is used in the implementation, so check for nulls. If an implementation of a Backend does not need to use such parser, leave its implementation of this method empty.

Specified by:
setuAALParser in interface Backend
Parameters:
service - The MessageContentSerializer service implementation found in OSGi


Copyright © 2014 universAAL Consortium. All Rights Reserved.