1Workflow::Condition::NeUssteerd(C3o)ntributed Perl DocumWeonrtkaftlioown::Condition::Nested(3)
2
3
4

NAME

6       Workflow::Condition::Nested - Evaluate nested workflow conditions
7

DESCRIPTION

9       Typically, the workflow conditions are evaluated directly by the
10       framework in Workflow::State when the action is evaluated. This module
11       allows a workflow condition to contain nested conditions that are
12       evaluated directly rather than via separate workflow actions.
13
14       This allows the workflow to be designed to group multiple conditions
15       and perform advanced  operations like an OR comparision of multiple
16       conditions with "greedy" evaluation (as opposed to "lazy" evaluation).
17
18       A usage example might be a case where 3 of 5 possible approvals are
19       needed for an action to be allowed. The "Greedy OR" condition would
20       define the list of conditions to be evaluated. After checking each
21       condition, it would return the total number of successes. The result is
22       then checked against the number needed, returning the boolean value
23       needed by Workflow::State.
24
25       Note: This class is not used directly, but subclassed by your class
26       that implements the "evaluate()" method and calls methods declared
27       here.
28

SYNOPSIS

30       In condition.xml:
31
32           <condition name="cond1" ... />
33           <condition name="cond2" ... />
34           <condition name="cond3" ... />
35           <condition name="cond4" ... />
36           <condition name="cond5" ... />
37
38           <condition name="count_approvals" class="Workflow::Condition::GreedyOR">
39               <param name="condition" value="cond1" />
40               <param name="condition" value="cond2" />
41               <param name="condition" value="cond3" />
42               <param name="condition" value="cond4" />
43               <param name="condition" value="cond5" />
44           </condition>
45
46           <condition name="check_approvals" class="Workflow::Condition::CheckReturn">
47               <param name="condition" value="count_approvals" />
48               <!-- operator "ge" means: greater than or equal to -->
49               <param name="operator"  value="ge" />
50               <param name="argument"  value="$context->{approvals_needed}" />
51           </condition>
52
53       In workflow.xml:
54
55           <state name="CHECK_APPROVALS" autorun="yes">
56               <action name="null_1" resulting_state="APPROVED">
57                   <condition name="check_approvals" />
58               </action>
59               <action name="null_2" resulting_state="REJECTED">
60                   <condition name="!check_approvals" />
61               </action>
62           </state>
63

IMPLEMENTATION DETAILS

65       This wicked hack runs the condition half-outside of the Workflow
66       framework.  If the Workflow internals change, this may break.
67
68   $self->evaluate_condition( $WORKFLOW, $CONDITION_NAME )
69       The child object class that subclasses this object calls this method to
70       evaluate a nested condition.
71
72       If the condition name starts with an '!', the result of the condition
73       is negated. Note that a side-effect of this is that the return value of
74       the nested condition is ignored. Only the negated boolean-ness is
75       preserved.
76
77       This does implement a trick that is not a convention in the underlying
78       Workflow library. By default, workflow conditions throw an error when
79       the condition is false and just return when the condition is true. To
80       allow for counting the true conditions, we also look at the return
81       value here. If a condition returns zero or an undefined value, but did
82       not throw an exception, we consider it to be '1'. Otherwise, we
83       consider it to be the value returned.
84

AUTHORS

86       See Workflow
87
89       This library is free software; you can redistribute it and/or modify it
90       under the same terms as Perl itself.
91
92
93
94perl v5.32.0                      2020-07-28    Workflow::Condition::Nested(3)
Impressum