org.activemath.content.mediator
Class Mediator

java.lang.Object
  extended by org.activemath.content.mediator.Mediator

public class Mediator
extends Object

The Mediator provides three main methods:
1. it executes queries: The source queries are formulated in terms of OIO. The Mediator maps them to the target-Ontologies that belong to the registered KnowledgeBases.

EBNF for queries:

Relation = "isA" | "isFor" | "id" | "requires" | "isRequiredBy" | "inverseIsA" | "inverseIsFor"
Class = "InstructionalObject" | "Concept" | "Satellite" | ...
ID = id of an item
Property = "learningcontext" | "difficulty" | "typicallearningtime" | ...
Value = "high" | "low" | ...

RelationQuery = "(" "relation" Relation ID ")"
ClassQuery = "(" "class" Class ")"
PropertyQuery = "(" "property" Property Value ")"

Query = {ClassQuery} {RelationQuery} {PropertyQuery}


2. it returns the metadata of a given foreign item.
3. it returns the body (i.e. the whole) of an item as a String.


Field Summary
protected static boolean DEBUG
           
 
Constructor Summary
Mediator()
           
 
Method Summary
 void clearCache()
           
 List execQuery(String string)
          Constructs and executes the query to all registered KBCallers.
 List execQuery(String string, boolean withCaching)
          Constructs and executes the query to all registered KBCallers.
 QueryCache getCache()
           
 String getContent(String uri)
          Returns the whole content of the learning object corresponding to the given uri.
 int getCounter()
           
 List getMetadata(String uri)
          Returns the whole metadata of a learning object whichs URI is given.
static String Iterator2String(Iterator it)
           
 void registerKB(KBCaller kbCaller)
          Registers a KnowledgeBase to the Mediator.
 void unregisterKB(KBCaller kbCaller)
          Removes a kbCaller from the internal List.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

protected static final boolean DEBUG
Constructor Detail

Mediator

public Mediator()
         throws MediatorException
Throws:
MediatorException
Method Detail

execQuery

public List execQuery(String string,
                      boolean withCaching)
               throws MediatorException
Constructs and executes the query to all registered KBCallers. First a Query in OIO is contructed. This method is synchronized as it the OntModel used in the KBCaller is not thread-safe, as Carsten's concurrency tests have shown.

Parameters:
string - the query string
withCaching - if true, caching is done,
if false, no caching is done.
Returns:
a List of all possible items
Throws:
MediatorException

execQuery

public List execQuery(String string)
               throws MediatorException
Constructs and executes the query to all registered KBCallers. First a Query in OIO is contructed.

Parameters:
string -
Returns:
a List of all possible items
Throws:
MediatorException

unregisterKB

public void unregisterKB(KBCaller kbCaller)
Removes a kbCaller from the internal List. This KB wont be queried anymore. TODO: check consistency of iterating over kbregister-list.

Parameters:
kbCaller - The KB not to query anymore.

registerKB

public void registerKB(KBCaller kbCaller)
Registers a KnowledgeBase to the Mediator. Initiates the OntologyModel and creates the OIOMapping out of the kbCallers mapping file.

Parameters:
kbCaller -

getMetadata

public List getMetadata(String uri)
Returns the whole metadata of a learning object whichs URI is given. The result is returned as a List of Lists of the shape {[attribute1,value1],[a2,v2],...}. If there is no repository corresponding to the given URI, the empty List is returned. TODO: think about caching metadata!

Parameters:
uri -
Returns:
a List of Lists

getContent

public String getContent(String uri)
Returns the whole content of the learning object corresponding to the given uri. Use this method to fetch a whole learning object from a foreign repository.

Parameters:
uri -
Returns:
the whole body of a learning object.

Iterator2String

public static String Iterator2String(Iterator it)

getCache

public QueryCache getCache()

getCounter

public int getCounter()
Returns:
the number of requests sent to the mediator

clearCache

public void clearCache()