Developer's Guide

This section gives you a brief overview about the structure of GrailsFlow and how the system works internally.

The most important elements and components are:

Process Definitions

The workflow engine consists of process definitions and the information about running processes. They define the basic steps of a process. We call these steps nodes.


Process Definitions are stored in Groovy classes using the builder syntax. You find examples in web-app/WEB-INF/workarea/processes/
in your GrailsFlow directory.

When editing processes, this informations gets parsed and stored into ProcessDef and ProcessDefNodes. After the editing process GrailsFlow creates new Groovy files from these definitions.

The node types are:

We move from node to node via so called "events" (also called transitions). When a node gets executed it returns a value (name of the event). Based on this value the workflow engine moves to the next node that is connected via this event. 

Processes

Running Processes as well as historical information is stored in:

Whenever a process enters a new node, a process node record is created in the database. After the process leaves the nodes, the record gets updated with status information.

This means ProcessNode includes all historical information about the process. When the process enters the same node twice, there are two records for this node.

This makes it easy to see the status of running or old processes by looking at the process and processNodes tables.

Process Variables

ProcessVariables are all public variables declared in the process. The variables are read via reflection and stored in the ProcessVariable class as a map. Whenever the variables have changed, they get stored back into the database. 

Therefore, process variables are always persisted in the database, so that the process can go on, even after the application has been restarted. However, process variables do not include any historic information, only the current values. This is different from nodes, where we see the complete history in process nodes.

 Worklist management

GrailsFlow supports automatic execution of nodes and manual user input. Workflows often need the user to make decisions or give input to the process.

GrailsFlow has functions for worklist management integrated. Whenever a process designer specifies a wait node, the execution of the process stops when reaching that node. The node becomes visible in the worklist of the user that is currently assigned to that process node.

When he clicks on the node there are three possible interactions:

Actions

Grailsflow provides several predefined actions out of the box, eg. SendMail, Log, Evaluate. To define a new Action, create a new class that implements the Action interface and put it into "src\groovy\com\jcatalog\grailsflow\actions".

GrailsFlow automatically collects the available actions and presents them in the action editor.

Actions can have parameters. These are defined as simple instance variables within the Action class. The action editor automatically creates a user interface for the parameters and ask the user for the values.

The user can select three different value type for the parameter of an action: process variables, constant values or arbitrary Groovy expressions. 

At runtime, a new action is created, the values of the parameters or constants are assigned to the instance variables of the action and the "execute" methods is called.

Documents

Documents are a special type of process variables that allows to store arbitray files in a process. Your declare a process variable in your process class through the process designer with the type Documents. When the variables can be entered, GrailsFlow presents an upload button for documents. The file is uploaded and stored in a directory. We create one directory for each day. The file name is cleaned up and extended by the process id and a counter. The link to the file is stored in the DB.

If the variable can be changed in a later step, the file can be downloaded and a new version can be uploaded. The new version is stored the same way, so GrailsFlow provides a full version history for documents.