Workflow structure
Logical structure
A workflow is composed of:
...
Below is an example of a three-step workflow and three actions.
...
Physical structure
A workflow type consists of two object types:
...
name (name of the action)
condition (source of the condition for the execution of this condition)
onTransition (source of the onTransition trigger)
state_in (child on the start state)
state_out (child on arrival state)
Interface description
...
Conditions and triggers
Workflows can integrate directly from the code to be executed while passing from one step to another or to condition the execution of an action. This makes it possible to concentrate business logic on the workflow level by releasing security and object triggers.
There are two types of code:
Conditions
Triggers
The conditions
The conditions allow for more freedom than security to authorize the execution of an action. They are executed:
on request to test whether it is possible to execute an action. This makes it possible to condition the display of this action in a backoffice.
At the very beginning of the execution of an action to avoid its unfolding if the action has been executed by a different mechanism than an interaction with the user. E.g.: Call by PLC.
The triggers
Triggers can be used to execute actions (mail, archiving) and/or to update object fields when changing status. There are three interveners at a specific point in time when the object changes state:
...
To be able to factorize or specialize pieces of code. + Indeed, since it is possible to exit or enter a state via different paths (actions), the code that does not depend on the path can be entered on the onEnter or onLeave of a state. On the other hand, to execute code only when executing a particular path, it is preferable to fill in your code onTransition event in order to specialize it.
To manage the life cycle of an object.
Indeed, as the diagram below suggests, some triggers such as onLeave and onTransition allow to interrupt the status change of an object while allowing to update these fields and save. A concrete example of such use can be found in this documentation.
Examples
Consensus Validation
In this example, our worflow has two states: draft and published; and an action: validate.
...
Code Block |
---|
import wsnoheto.engine.*; import java.util.*; try { IObjectWritable owner = workflow.getOwner(); String validateurs = owner.getProperty("validateurs"); if( validateurs != null ) { StringTokenizer tokenizer = new StringTokenizer(validateurs, ", "); TreeSet<String> v_set = new TreeSet<String>(); while( tokenizer.hasMoreTokens() ) { v_set.add(tokenizer.nextToken()); } if( v_set.size() >= 3 ) return false; String surfer_id = surfer.getProperty("id"); if( v_set.contains(surfer_id) ) return false; v_set.add(surfer_id); Iterator<String> it = v_set.iterator(); StringBuffer new_validators = new StringBuffer(); while( it.hasNext() ) { new_validators.append(","); new_validators.append(it.next().toString()); } new_validators.append(","); owner.setProperty("validateurs", new_validators.toString()); return v_set.size() == 3; } else { return true; } } catch(Throwable e) { return false; } |
Associate objects with a workflow type
There are two ways of assigning an object to a workflow type, that is, this object is managed by this workflow.
...
Select the workflow to which you want to assign an object.
Select the Assignments tab.
In the selection box, on the right: find the object to assign.
Click the Assign button.
...
Change the attributes of reading/writing properties of an object according to its state in the workflow
By default, it is possible to specify whether a field appears during the editing or visualization of an object in order to dynamically generate input forms and consultation screens. These read/write attributes can be modified from the structure modification backoffice.
...