org.universAAL.samples.context.reasoner.client.uaalinterface
Class ReasoningCaller

Package class diagram package ReasoningCaller
java.lang.Object
  extended by org.universAAL.samples.context.reasoner.client.uaalinterface.ReasoningCaller

public class ReasoningCaller
extends Object

This class is used to add/remove/get Situations/Queries/Rules to/from the Reasoner. Since all of the three operations are very similar for the three used types of objects a lot of methods can be reused using generics.

Author:
amarinc

Field Summary
static Random random
           
static String REASONER_CLIENT_NAMESPACE
           
 
Constructor Summary
ReasoningCaller()
           
 
Method Summary
 Query addQuery(ContextEvent event, String queryString, boolean persistent)
          Add a new Query with a random URI to the Reasoner.
 Query addQuery(String fullQuery)
          Creates a new query with the given Query-String and a random URI.
 Query addQuery(String uri, ContextEvent event, String queryString, boolean persistent)
          Add a new Query with the given URI to the Reasoner.
 Query addQuery(String uri, String fullQuery)
          Creates a new query with the given Query-String and the given URI.
 Rule addRule(Situation situation, Query query, boolean persistent)
          A rule combines the given Situation with the given Query.
 Rule addRule(String uri, Situation situation, Query query, boolean persistent)
          A rule combines the given Situation with the given Query.
 Situation addSituation(String subject, String predicate, String object, boolean persistent)
          Creates a new Situation-Object with a random URI, add it to the reasoner and return the new object.
 Situation addSituation(String uri, String subject, String predicate, String object, boolean persistent)
          Creates a new Situation-Object with the given URI, add it to the reasoner and return the new object.
 void communicationChannelBroken()
           
 List<Query> getQueries()
           
 ContextEventRecorder getRecorder()
           
 List<Rule> getRules()
           
 List<Situation> getSituations()
           
static void postInfo(Class<?> targetClass, String methodName, String message)
           
 boolean remove(Query query)
           
 boolean remove(Rule rule)
           
 boolean remove(Situation situation)
           
 void unregister()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REASONER_CLIENT_NAMESPACE

public static final String REASONER_CLIENT_NAMESPACE
See Also:
Constant Field Values

random

public static final Random random
Constructor Detail

ReasoningCaller

public ReasoningCaller()
Method Detail

addSituation

public Situation addSituation(String subject,
                              String predicate,
                              String object,
                              boolean persistent)
Creates a new Situation-Object with a random URI, add it to the reasoner and return the new object.

Parameters:
subject - Can be a type-URI or an URI of a concrete instance
predicate - Need to be a valid property URI of the subject or can be null
object - Need to be a valid property-value of the subject or can be null
persistent - If it is true the Situation will be available also after a restart of the system, otherwise not.
Returns:
The generated Situation-Object. Can be null in case of any trouble.

addSituation

public Situation addSituation(String uri,
                              String subject,
                              String predicate,
                              String object,
                              boolean persistent)
Creates a new Situation-Object with the given URI, add it to the reasoner and return the new object.

Parameters:
uri - URI to be given to the new Situation
subject - Can be a type-URI or an URI of a concrete instance
predicate - Need to be a valid property URI of the subject or can be null
object - Need to be a valid property-value of the subject or can be null
persistent - If it is true the Situation will be available also after a restart of the system, otherwise not.
Returns:
The generated Situation-Object. Can be null in case of any trouble.

addQuery

public Query addQuery(String fullQuery)
Creates a new query with the given Query-String and a random URI. The Query need to be a valid SPARQL-CONSTRUCT query that generates a valid ContextEvent. Currently there is not checked if the query is valid or not!

Parameters:
fullQuery - SPARQL-CONSTRUCT query to be performed at the CHE
Returns:
Generated Query object. Can be null in case of any trouble.

addQuery

public Query addQuery(String uri,
                      String fullQuery)
Creates a new query with the given Query-String and the given URI. The Query need to be a valid SPARQL-CONSTRUCT query that generates a valid ContextEvent. Currently there is not checked if the query is valid or not!

Parameters:
uri - URI for the new Query
fullQuery - SPARQL-CONSTRUCT query to be performed at the CHE
Returns:
Generated Query object. Can be null in case of any trouble.

addQuery

public Query addQuery(ContextEvent event,
                      String queryString,
                      boolean persistent)
Add a new Query with a random URI to the Reasoner. To construct the query the given ContextEvent and a part of a SPARQL-Query is used (this condition part). This means that if the conditions are fulfilled at the CHE the given ContextEvent will be generated.

Parameters:
event - Event to be generated by the Query
queryString - SPARQL Conditions-String to be checked at the CHE
persistent - If it is true the Query will be available also after a restart of the system, otherwise not.
Returns:
The created Query. Can be null in case of any trouble.

addQuery

public Query addQuery(String uri,
                      ContextEvent event,
                      String queryString,
                      boolean persistent)
Add a new Query with the given URI to the Reasoner. To construct the query the given ContextEvent and a part of a SPARQL-Query is used (this condition part). This means that if the conditions are fulfilled at the CHE the given ContextEvent will be generated.

Parameters:
event - Event to be generated by the Query
queryString - SPARQL Conditions-String to be checked at the CHE
persistent - If it is true the Query will be available also after a restart of the system, otherwise not.
Returns:
The created Query. Can be null in case of any trouble.

addRule

public Rule addRule(Situation situation,
                    Query query,
                    boolean persistent)
A rule combines the given Situation with the given Query. This means that if the Situation-Patter was matched by an event at the context-bus the query will be performed at the CHE and if this matches it send out the ContextEvent constructed by the query at the ContextBus.

Parameters:
situation - Situation for the Rule
query - Query to be performed for the Rule
persistent - If it is true the Rule will be available also after a restart of the system, otherwise not.
Returns:
Created Rule object with a random URI. Can be null in case of any trouble.

addRule

public Rule addRule(String uri,
                    Situation situation,
                    Query query,
                    boolean persistent)
A rule combines the given Situation with the given Query. This means that if the Situation-Patter was matched by an event at the context-bus the query will be performed at the CHE and if this matches it send out the ContextEvent constructed by the query at the ContextBus.

Parameters:
uri - URI for the new Rule-Object
situation - Situation for the Rule
query - Query to be performed for the Rule
persistent - If it is true the Rule will be available also after a restart of the system, otherwise not.
Returns:
Created Rule object the given URI. Can be null in case of any trouble.

getSituations

public List<Situation> getSituations()

getQueries

public List<Query> getQueries()

getRules

public List<Rule> getRules()

remove

public boolean remove(Situation situation)

remove

public boolean remove(Query query)

remove

public boolean remove(Rule rule)

getRecorder

public ContextEventRecorder getRecorder()

communicationChannelBroken

public void communicationChannelBroken()

unregister

public void unregister()

postInfo

public static void postInfo(Class<?> targetClass,
                            String methodName,
                            String message)


Copyright © 2014 universAAL Consortium. All Rights Reserved.