org.universAAL.context.che.database
Interface Backend

Package class diagram package Backend
All Known Implementing Classes:
SesameBackend, SesameBackendCrd, SesameBackendCrdClc, SesameBackendCrdClc2, SesameBackendCrdClc2Cnf, SesameBackendCrdClcCnf, SesameBackendCrdCnf, SesameBackendWithConfidence

public interface Backend

Interface that represents a store back end where the context history is stored.

Author:
Alvaro Fides Valero

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 tstamp)
          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.
 

Method Detail

connect

void connect()
Establishes the connection to the store.


close

void close()
Closes the connection to the store.


storeEvent

void storeEvent(ContextEvent e)
Stores a ContextEvent in the underlying store.

Parameters:
e - The context event to be stored.

retrieveEvent

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. A parameter can be passed a value of null for wildcarding.

This is not used in the current version. Will probably be deprecated.

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.

retrieveEventsFromTstmp

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. A parameter can be passed a value of null for wildcarding.

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

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. A parameter can be passed a value of null for wildcarding.

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.

retrieveEventsBetweenTstmp

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. A parameter can be passed a value of null for wildcarding.

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.

retrieveEventsBySPARQL

ArrayList retrieveEventsBySPARQL(String input)
Retrieves a list of ContextEvent from the underlying store, as a result of a SPARQL query.

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.

queryBySPARQL

String queryBySPARQL(String input)
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.

Parameters:
input - The SPARQL query to be executed.
Returns:
The serialized form of the result from the execution of the query.

removeOldEvents

void removeOldEvents(long tstamp)
Removes all events from the underlying store that were received until the specified timestamp.

Parameters:
tstamp - The timestamp in milliseconds until which events are removed. A value of 0 does nothing.

setuAALParser

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

Parameters:
service - The MessageContentSerializer service implementation found in OSGi

populate

void populate()
              throws org.openrdf.repository.RepositoryException,
                     org.openrdf.rio.RDFParseException,
                     IOException
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.

Throws:
org.openrdf.repository.RepositoryException
org.openrdf.rio.RDFParseException
IOException


Copyright © 2014 universAAL Consortium. All Rights Reserved.