com.ingenta.clownbike
Interface Task

All Known Implementing Classes:
SimpleTask

public interface Task

A task changes the system. It is a work that is broken down into units called steps (TaskStep). The steps are performed in sequenece but, since this is the web, not necessarly so. However, there is always the assumption that while the task is active there is a "current" step.


Method Summary
 void canceled(DatabaseTransaction transaction)
          Cancel the task.
 void completed(DatabaseTransaction transaction)
          Finish the task.
 void doGet(DatabaseTransaction transaction, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 void doPost(DatabaseTransaction transaction, MultipartHttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 Attribute findAttribute(java.lang.String name)
          Return the attribute with the given name or null.
 java.util.List findAttributes(java.lang.String name)
          Return the attributes with the given name or an empty list.
 TaskStep findStep(java.lang.Integer stepId)
          Returns the step with the given step id or null if step not found.
 TaskStep findStepAfter(TaskStep step)
          Returns the step after the given step or null if the given step is the last step.
 TaskStep findStepBefore(TaskStep step)
          Returns the step before the given step or null if the given step is the first step.
 Attribute getAttribute(java.lang.String name)
          Return the attribute with the given name or throws IllegalArgumentException.
 TaskStep getCurrentStep()
          Returns the current step active step.
 TaskStep getStep(java.lang.Integer stepId)
          Returns the step with the given step id or throws TaskException if step not found.
 java.util.List getSteps()
          Retruns a list of steps in activation order.
 void setCurrentStep(TaskStep step)
          Sets the given step as the current step.
 void started(DatabaseTransaction transaction)
          Start the task.
 

Method Detail

started

public void started(DatabaseTransaction transaction)
             throws DatabaseException,
                    TaskException
Start the task. Throws an TaskException if the task is already active.

Throws:
DatabaseException
TaskException

canceled

public void canceled(DatabaseTransaction transaction)
              throws DatabaseException,
                     TaskException
Cancel the task. Throws an TaskException if the task is not active.

Throws:
DatabaseException
TaskException

completed

public void completed(DatabaseTransaction transaction)
               throws DatabaseException,
                      TaskException
Finish the task. Throws an TaskException if the task is not active.

Throws:
DatabaseException
TaskException

getSteps

public java.util.List getSteps()
Retruns a list of steps in activation order.


getStep

public TaskStep getStep(java.lang.Integer stepId)
                 throws TaskException
Returns the step with the given step id or throws TaskException if step not found.

Throws:
TaskException

findStep

public TaskStep findStep(java.lang.Integer stepId)
Returns the step with the given step id or null if step not found.


findStepBefore

public TaskStep findStepBefore(TaskStep step)
Returns the step before the given step or null if the given step is the first step. Throws IllegalArgumentException if the given step is null or not in the task's list of steps.


findStepAfter

public TaskStep findStepAfter(TaskStep step)
Returns the step after the given step or null if the given step is the last step. Throws IllegalArgumentException if the given step is null or not in the task's list of steps.


getCurrentStep

public TaskStep getCurrentStep()
Returns the current step active step. Throws an IllegalStateException if the task is not active.


setCurrentStep

public void setCurrentStep(TaskStep step)
Sets the given step as the current step. Throws IllegalArgumentException if the given step is null or not in the task's list of steps.


getAttribute

public Attribute getAttribute(java.lang.String name)
                       throws TaskException
Return the attribute with the given name or throws IllegalArgumentException.

Throws:
TaskException

findAttribute

public Attribute findAttribute(java.lang.String name)
Return the attribute with the given name or null.


findAttributes

public java.util.List findAttributes(java.lang.String name)
Return the attributes with the given name or an empty list.


doPost

public void doPost(DatabaseTransaction transaction,
                   MultipartHttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws DatabaseException,
                   TaskException
Throws:
DatabaseException
TaskException

doGet

public void doGet(DatabaseTransaction transaction,
                  javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws DatabaseException,
                  TaskException
Throws:
DatabaseException
TaskException