User's Manual

Chapter 11. Services Tutorials 135
an email alert going out to 1000 users will occupy the same amount of space in the database as a single
email.
11.4. Workflow Tutorial
This tutorial covers various tasks that can be accomplished with the workflow service a simple
workflow, adding a task, rolling back a task, and completing a task.
11.4.1. Simple Workflow
These steps describe the procedure in Procedure 11.1, Creating a Simple Workflow. The procedure
covers creating a hello world workflow and describing the task state change.
1. Design a workflow by defining the desired tasks and the dependencies between them.
2. Create a new named task class for the different task types. Be sure to define the
BASE_DATA_OBJECT_TYPE, the getBaseDataObjectType, constructors, and clone
methods. Also include the methods to invoke.
3. Write the PDL file to support the new task type.
4. Create an instantiator for DomainObjectFactory.
5. Create a workflow template based on the design.
6. Instantiate a workflow from a workflow template.
7. Call the workflow start method to start the Engine.
Creating a Simple Workflow
1. Design your workflow.
2. Create a new task type by subclassing task:
public class HelloWorldTask extends Task {
//The base data object is used for the domain object
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.workflow.simple.HelloWorldTask";
protected String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE;
}
//constructors are not inherited from subclasses
//so you’ll need to add them
public HelloWorldTask(String label, String description) {
this(BASE_DATA_OBJECT_TYPE);
initAttributes(label,description);
}
public HelloWorldTask(DataObject taskDataObject) {
super(taskDataObject);
}
public HelloWorldTask() {
this(BASE_DATA_OBJECT_TYPE);
setState(DISABLED);
}