maito.integration
Class IntegratorImpl

java.lang.Object
  extended by maito.integration.IntegratorImpl
All Implemented Interfaces:
DataProcessor, Integrator

public class IntegratorImpl
extends java.lang.Object
implements Integrator

Author:
Tuomas Tanner, Oskari Saarekas This software is released under the GNU GPL license

Constructor Summary
IntegratorImpl()
          Loads the database config into memory.
 
Method Summary
 void addGraph(java.lang.String graphName)
          Adds a new graph to this Integrator.
static void debug(java.lang.String s)
           
 java.lang.String[] getCurrentTasks()
          Returns a user readable description of every task that is in progress at the moment.
 java.lang.String[] getErrors()
          Returns all errors that have occurred since the last data processing was started.
 java.util.List getGraphs()
          Returns an array of all resource graphs known to this Integrator.
 java.util.List getSources(java.lang.String graphName)
          Returns the descriptions of the sources that are integrated into a graph.
 void integrate(DataSourceDescription[] sources, java.lang.String graph)
          Starts the creation of a new resource graph in the integration subsystem.
static void main(java.lang.String[] args)
           
 void setLogListener(LogListener listener)
          Sets a listener for all log messages sent by this DataProcessor.
 java.lang.String setLogListener(java.lang.String graph, LogListener listener)
          Sets a listener for log messages sent by this Integrator.
protected  void taskEnded()
           
protected  void taskStarted()
           
 boolean workInProgress()
          Tells whether this DataProcessor is currently processing data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegratorImpl

public IntegratorImpl()
Loads the database config into memory.

Method Detail

addGraph

public void addGraph(java.lang.String graphName)
              throws java.lang.IllegalArgumentException
Description copied from interface: Integrator
Adds a new graph to this Integrator. Actual integration is not done until the integrate-method is called.

Specified by:
addGraph in interface Integrator
Parameters:
graphName - The name of the new resource graph
Throws:
java.lang.IllegalArgumentException - Thrown when the graph with the given name already exists.

getGraphs

public java.util.List getGraphs()
Description copied from interface: Integrator
Returns an array of all resource graphs known to this Integrator.

Specified by:
getGraphs in interface Integrator
Returns:
A List of resource graph name Strings. If no graphs exist an empty List is returned.

getSources

public java.util.List getSources(java.lang.String graphName)
                          throws java.lang.IllegalArgumentException
Description copied from interface: Integrator
Returns the descriptions of the sources that are integrated into a graph.

Specified by:
getSources in interface Integrator
Parameters:
graphName - The graph that's source are to be returned.
Returns:
A list of String arrays where the arrary[0] displays the source name. The array[1] displays integration date. If no sources are found returns an empty List.
Throws:
java.lang.IllegalArgumentException - Thrown if something is wrong with the graph parameter.

integrate

public void integrate(DataSourceDescription[] sources,
                      java.lang.String graph)
               throws IntegrationException
Description copied from interface: Integrator
Starts the creation of a new resource graph in the integration subsystem.

Specified by:
integrate in interface Integrator
Parameters:
sources - The data sources that are integrated.
graph - The name of the graph that is to be integrated.
Throws:
IntegrationException - Thrown if something goes wrong during the integration process.

setLogListener

public java.lang.String setLogListener(java.lang.String graph,
                                       LogListener listener)
Description copied from interface: Integrator
Sets a listener for log messages sent by this Integrator.

Specified by:
setLogListener in interface Integrator
Parameters:
graph - The resource graph that's log messages are to be listened to. If null all messages are listened to.
listener - The object that listens to this Integrator's log messages.

workInProgress

public boolean workInProgress()
Description copied from interface: DataProcessor
Tells whether this DataProcessor is currently processing data.

Specified by:
workInProgress in interface DataProcessor
Returns:
true if data is being processed, otherwise false.

getCurrentTasks

public java.lang.String[] getCurrentTasks()
Description copied from interface: DataProcessor
Returns a user readable description of every task that is in progress at the moment.

Specified by:
getCurrentTasks in interface DataProcessor
Returns:
An array of String objects containing the description of each task. If no tasks are in progress returns an empty array.

taskStarted

protected void taskStarted()

taskEnded

protected void taskEnded()

getErrors

public java.lang.String[] getErrors()
Description copied from interface: DataProcessor
Returns all errors that have occurred since the last data processing was started. The errors are in a user readable form.

Specified by:
getErrors in interface DataProcessor
Returns:
An array of String objects where each String is a description of the error. If no errors have occurred the array is empty.

setLogListener

public void setLogListener(LogListener listener)
Description copied from interface: DataProcessor
Sets a listener for all log messages sent by this DataProcessor.

Specified by:
setLogListener in interface DataProcessor
Parameters:
listener - The object that listens to this DataProcessor's log messages.

debug

public static void debug(java.lang.String s)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception