line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.60'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use base qw( Workflow::Condition ); |
8
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
151
|
|
9
|
|
|
|
|
|
|
1; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=pod |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Workflow::Condition::Nested - Evaluate nested workflow conditions |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 VERSION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This documentation describes version 1.60 of this package |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Typically, the workflow conditions are evaluated directly by the framework |
25
|
|
|
|
|
|
|
in Workflow::State when the action is evaluated. This module allows |
26
|
|
|
|
|
|
|
a workflow condition to contain nested conditions that are evaluated |
27
|
|
|
|
|
|
|
directly rather than via separate workflow actions. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This allows the workflow to be designed to group multiple conditions |
30
|
|
|
|
|
|
|
and perform advanced operations like an OR comparision of multiple |
31
|
|
|
|
|
|
|
conditions with "greedy" evaluation (as opposed to "lazy" evaluation). |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
A usage example might be a case where 3 of 5 possible approvals are needed |
34
|
|
|
|
|
|
|
for an action to be allowed. The "Greedy OR" condition would define the |
35
|
|
|
|
|
|
|
list of conditions to be evaluated. After checking each condition, it would |
36
|
|
|
|
|
|
|
return the total number of successes. The result is then checked against |
37
|
|
|
|
|
|
|
the number needed, returning the boolean value needed by Workflow::State. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
B<Note:> This class is not used directly, but subclassed by your class |
40
|
|
|
|
|
|
|
that implements the C<evaluate()> method and calls the C<evaluate_condition> |
41
|
|
|
|
|
|
|
method to evaluate its nested conditions. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 SYNOPSIS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
In condition.xml: |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
<condition name="cond1" ... /> |
48
|
|
|
|
|
|
|
<condition name="cond2" ... /> |
49
|
|
|
|
|
|
|
<condition name="cond3" ... /> |
50
|
|
|
|
|
|
|
<condition name="cond4" ... /> |
51
|
|
|
|
|
|
|
<condition name="cond5" ... /> |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
<condition name="count_approvals" class="Workflow::Condition::GreedyOR"> |
54
|
|
|
|
|
|
|
<param name="condition" value="cond1" /> |
55
|
|
|
|
|
|
|
<param name="condition" value="cond2" /> |
56
|
|
|
|
|
|
|
<param name="condition" value="cond3" /> |
57
|
|
|
|
|
|
|
<param name="condition" value="cond4" /> |
58
|
|
|
|
|
|
|
<param name="condition" value="cond5" /> |
59
|
|
|
|
|
|
|
</condition> |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
<condition name="check_approvals" class="Workflow::Condition::CheckReturn"> |
62
|
|
|
|
|
|
|
<param name="condition" value="count_approvals" /> |
63
|
|
|
|
|
|
|
<!-- operator "ge" means: greater than or equal to --> |
64
|
|
|
|
|
|
|
<param name="operator" value="ge" /> |
65
|
|
|
|
|
|
|
<param name="argument" value="$context->{approvals_needed}" /> |
66
|
|
|
|
|
|
|
</condition> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
In workflow.xml: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
<state name="CHECK_APPROVALS" autorun="yes"> |
71
|
|
|
|
|
|
|
<action name="null_1" resulting_state="APPROVED"> |
72
|
|
|
|
|
|
|
<condition name="check_approvals" /> |
73
|
|
|
|
|
|
|
</action> |
74
|
|
|
|
|
|
|
<action name="null_2" resulting_state="REJECTED"> |
75
|
|
|
|
|
|
|
<condition name="!check_approvals" /> |
76
|
|
|
|
|
|
|
</action> |
77
|
|
|
|
|
|
|
</state> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHORS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
See L<Workflow> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 COPYRIGHT |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Copyright (c) 2004-2022 Chris Winters. All rights reserved. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
90
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Please see the F<LICENSE> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHORS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Please see L<Workflow> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |