Adding Conditions in Process Flow
Conditions determine whether a certain transition is executed in a process flow. Conditions are used to change the direction of the process flow based on a decision. There are three types of conditions:
Process Variable Condition
A transition may have a condition based on the value of the context variable present in the current process flow. Once the condition is met, a transition takes place. The Process Variable Condition is used to define a condition based on the value activity specific context variable in a process flow.
To add a Condition in a process flow using activity attributes:
In Web Process Designer, in the Toggle Palette panel, select Gateway element and drag it in the canvas area. Alternatively, click the Source element and select Append Gateway option from Context pad.
Connect the activities, for information on how to connect activities, refer to Creating Process Flow.
To add a condition, select the control flow and click the Options icon and then select Define Condition to display Sequence Flow Condition window.
On the Sequence Flow Condition window, select Process Variable and provide the details of each field. Click Done.
Repeat the steps to add a condition on another control flow.
Java Condition
A transition may have a condition that can be either in the form of script or Custom APIs. Once the condition is met, the transition takes place. Java Condition is a part of the transition.
The sample conditional transition is given below:
|
A State in Process XML either has a normal transition(s) and/or conditional transition(s). If there is more than one transition from a State, only one transition takes place at a time and it depends upon the order of their occurrence and condition satisfaction (in case of conditional transition). A conditional transition takes place based on an appropriate condition defined in the form of Java code. When the condition is met, the transition takes place. A Condition is satisfied when Java code script returns true. The Java code script should return true or false otherwise an exception is raised.
A transition may have a condition in the form of Custom APIs. If you want to use Custom APIs in the Java Condition, first create a class with method(s) and put them in the .../<AdeptiaInstallFolder>/ServerKernel/customClasses/<ClassPackage> folder where <ClassPackage> is the package where you have defined the Java class.
For example, if you have defined the Java class in the org.custom package then first create the org/custom folder in the .../<AdeptiaInstallFolder>/ServerKernel/customClasses folder and put the class in the custom folder. Ensure that:
The class must implement ConditionExecutor interface.
The method should accept only one parameter and that must have an object of ExecutionEvent.
The method must be public.
Adding Condition Using Java Condition
To add a Condition in a process flow using Java condition:
In Web Process Designer, in the Toggle Palette panel, select Gateway element and drag it in the canvas area. Alternatively, click the Source element and select Append Gateway option from Context pad.
Connect the activities, for information on how to connect activities, refer to Creating Process Flow.
To add a condition, select the control flow and click the Options icon and then select Define Condition to display Sequence Flow Condition window.
On the Sequence Flow Condition window, select Java and then select the interpreter type.
Repeat the steps to add a condition on another control flow.
Expression Condition
A transition may have a condition based on an expression. This expression is built using the Activity Attributes or the process flow variable with 'AND' & 'OR' condition.
To add a Condition in a process flow using Expression:
In Web Process Designer, in the Toggle Palette panel, select Gateway element and drag it in the canvas area. Alternatively, click the Source element and select Append Gateway option from Context pad.
Connect the activities, for information on how to connect activities, refer to Creating Process Flow.
To add a condition, select the control flow and click the Options icon and then select Define Condition to display Sequence Flow Condition window.
On the Sequence Flow Condition window, select Expression.
Select the condition to be used for building the expression from the Operator option. You can select the values && (AND) and || (OR).
For defining expressions you need to define rules. A rule supports multiple expressions. You can link the multiple expressions using the rule operator.
Click Add to define the rule.
Provide the details of the rule.
Click Add to insert the defined condition (comprising of activity attribute or process flow variable) into the Expression text area.
Once the activity attributes or process flow variable is inserted, you can create another condition for building the expression. Select the condition to be used for building the expression from the Declare Operator to build Expression with values of && (AND) and || (OR).
Select the operator on the basis of which you want to evaluate these rules from the Rule Operator. The supported rule operators are.
You can evaluate the rules using one operator at a time. For example, if you select || then all rules will be evaluated on the basis of the OR operator. You cannot evaluate two rules based on the OR operator and two rules based on the AND operator.Click Add to insert the selected operator into the Expression text area.
Both the conditions are displayed in the Expression text area. You can edit this expression for evaluation based on certain rules. These rules are outlined in the table below.
The transaction will get aborted if an invalid expression is entered in the Expression text area.Click Done. This returns to the Sequence Flow Condition window with the newly added rule. Similarly, you can add more rules.
You can also edit the Rule Name and Rule Reason from this window by selecting the rule and then clicking Edit option.Click Done. This closes the window and returns to the Canvas area.
Once you execute the process flow, all the listed rules will be evaluated in the top to bottom sequential order.
If they are evaluated using the OR (||) rule operator, then if any of the listed rules are true, then the decision value will be true and the process flow will be executed in the True path. The reason for all rules that are evaluated as True, will be added as comma separated values, and set as a single value in the context variable ruleReason in the format ruleName (ruleReason).
If the rules are evaluated using the AND (&&) rule operator, then only if all the listed rules are true, then the decision value will be true and the process flow will be executed in the True path. Even if one rule is evaluated to false, then the decision value will be false and process flow will execute in the False path. The reason for all rules that are evaluated as True, will be added as comma separated values and set as a single value in the context variable ruleReason in the format ruleName (ruleReason). The rules that are evaluated as False, will appear as an empty value in the ruleReason context variable.