com.massimo.tools.scriptrunner.control
Class AbstractCompoundTask

java.lang.Object
  extended by com.massimo.tools.scriptrunner.AbstractTask
      extended by com.massimo.tools.scriptrunner.control.AbstractCompoundTask
All Implemented Interfaces:
Task
Direct Known Subclasses:
IfTask, OptionalTask, ParallelTask, PollTask, SerialTask, SpawnTask

public abstract class AbstractCompoundTask
extends AbstractTask

An AbstractCompoundTask will run multiple component Tasks.


Field Summary
 
Fields inherited from class com.massimo.tools.scriptrunner.AbstractTask
definition, name, parent, properties, type
 
Fields inherited from interface com.massimo.tools.scriptrunner.Task
DATA_ERROR, ERROR, FINISHED, INTERRUPTED, PROMPT, RUNNING, START, SUCCESS
 
Constructor Summary
AbstractCompoundTask(Task parent, String type, Element definition, Map<String,String> parentProperties)
           
 
Method Summary
protected  void addChild(Task child)
          Any sub-class should call this as soon as it creates a child.
protected  int doProcess(ExecutionContext context)
          Implementing classes only need to do their own work and log progress when appropriate.
protected  int doValidate(ValidationContext context)
          Check whether this task should be able to run.
protected  Iterator<Task> getChildren()
          Provides access to the list of child to sub-classes
 void interrupt()
          Tells the Task to stop processing.
protected abstract  int processCompound(ExecutionContext context, Elements tasks)
          Process any and all child tasks.
 
Methods inherited from class com.massimo.tools.scriptrunner.AbstractTask
getBooleanProperty, getCurrentWorkingDirectory, getDefinition, getIntProperty, getLogger, getName, getParent, getProperties, getStartProcessingRow, getText, getType, isIgnoreableError, isIgnoreableError, isInterrupted, isLogProgress, postProcess, preProcess, process, resultCodeToString, substituteParameters, toString, validate, validateConnections, validateParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractCompoundTask

public AbstractCompoundTask(Task parent,
                            String type,
                            Element definition,
                            Map<String,String> parentProperties)
Parameters:
parent - A parent Task, or null for the root Task.
type - The type of task, e.g. SQL, Print, Serial
definition - Task to execute, including new connection properties.
parentProperties -
Method Detail

addChild

protected void addChild(Task child)
Any sub-class should call this as soon as it creates a child.

Parameters:
child - A Task to add to the list of children

doProcess

protected int doProcess(ExecutionContext context)
                 throws Exception
Implementing classes only need to do their own work and log progress when appropriate.
Delegate to processCompound(ExecutionContext, Elements).

Specified by:
doProcess in class AbstractTask
Returns:
O for success. Anything else is a failure.
Throws:
Exception
See Also:
AbstractTask.process(ExecutionContext)

doValidate

protected int doValidate(ValidationContext context)
                  throws Exception
Check whether this task should be able to run. Implementations should check for the prescence of files, attributes,...
Validates all child tasks

Specified by:
doValidate in class AbstractTask
Returns:
O for success. Anything else is a failure.
Throws:
Exception

getChildren

protected Iterator<Task> getChildren()
Provides access to the list of child to sub-classes

Returns:
Iterator over all child Tasks

interrupt

public void interrupt()
Tells the Task to stop processing. This does not garrantee that the task will return immediately.
Attempt to interrupt all children.

Specified by:
interrupt in interface Task
Overrides:
interrupt in class AbstractTask

processCompound

protected abstract int processCompound(ExecutionContext context,
                                       Elements tasks)
                                throws Exception
Process any and all child tasks. Created Tasks should be added to children using addChild(Task)

Parameters:
context -
tasks - A list of Task definition Elements
Returns:
The result of running all tasks
Throws:
Exception