| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Workflow::Condition::LazyAND; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
319625
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
191
|
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
80
|
|
|
5
|
2
|
|
|
2
|
|
28
|
use v5.14.0; |
|
|
2
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '2.09'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
13
|
use parent qw( Workflow::Condition ); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
37
|
|
|
10
|
2
|
|
|
2
|
|
160
|
use Workflow::Exception qw( configuration_error ); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
1064
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors('conditions'); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub init { |
|
15
|
2
|
|
|
2
|
1
|
7
|
my ( $self, $params ) = @_; |
|
16
|
2
|
|
|
|
|
12
|
$self->SUPER::init( $params ); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# This is a tricky one. The admin may have configured this by repeating |
|
19
|
|
|
|
|
|
|
# the param name "condition" or by using unique names (e.g.: "condition1", |
|
20
|
|
|
|
|
|
|
# "condition2", etc.). We'll need to string these back together as |
|
21
|
|
|
|
|
|
|
# an array. |
|
22
|
|
|
|
|
|
|
# Yes, I know. The regex doesn't require the suffix to be numeric. |
|
23
|
2
|
|
|
|
|
24
|
my @conditions = (); |
|
24
|
2
|
|
|
|
|
4
|
foreach my $key ( sort grep {m/^condition/} keys %{$params} ) { |
|
|
9
|
|
|
|
|
28
|
|
|
|
2
|
|
|
|
|
9
|
|
|
25
|
5
|
|
|
|
|
19
|
push @conditions, $self->normalize_array( $params->{$key} ); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
2
|
|
|
|
|
11
|
$self->conditions( [@conditions] ); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub evaluate { |
|
31
|
4
|
|
|
4
|
1
|
16
|
my ( $self, $wf ) = @_; |
|
32
|
4
|
|
|
|
|
25
|
my $conditions = $self->conditions; |
|
33
|
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
61
|
my $total = 0; |
|
35
|
|
|
|
|
|
|
|
|
36
|
4
|
50
|
|
|
|
11
|
return Workflow::Condition::IsFalse->new("No conditions were defined") unless(@{$conditions}); |
|
|
4
|
|
|
|
|
22
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
31
|
foreach my $cond ( @{$conditions} ) { |
|
|
4
|
|
|
|
|
16
|
|
|
39
|
8
|
|
|
|
|
70
|
my $result = $self->evaluate_condition( $wf, $cond ); |
|
40
|
8
|
100
|
|
|
|
53
|
if ( not $result ) { |
|
41
|
2
|
|
|
|
|
16
|
return Workflow::Condition::IsFalse->new("Stopped after checking $total conditions"); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
6
|
|
|
|
|
26
|
$total++; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
2
|
|
|
|
|
19
|
return Workflow::Condition::IsTrue->new("Matched a total of $total conditions"); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=pod |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Workflow::Condition::LazyAND |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 VERSION |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This documentation describes version 2.09 of this package |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Using nested conditions (See Workflow::Condition::Nested), this evaluates |
|
66
|
|
|
|
|
|
|
the given conditions using lazy-evaluation, returning I<true> if B<all> |
|
67
|
|
|
|
|
|
|
nested conditions are I<true>. If a nested condition evaluates to I<false>, |
|
68
|
|
|
|
|
|
|
further evaluation is aborted and I<false> is returned. |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
In condition.yaml: |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
condition: |
|
75
|
|
|
|
|
|
|
- name: cond1 |
|
76
|
|
|
|
|
|
|
... |
|
77
|
|
|
|
|
|
|
- name: cond2 |
|
78
|
|
|
|
|
|
|
... |
|
79
|
|
|
|
|
|
|
- name cond3 |
|
80
|
|
|
|
|
|
|
... |
|
81
|
|
|
|
|
|
|
- name: check_prereqs |
|
82
|
|
|
|
|
|
|
class: Workflow::Condition::LazyAND |
|
83
|
|
|
|
|
|
|
param: |
|
84
|
|
|
|
|
|
|
- name: condition |
|
85
|
|
|
|
|
|
|
value: cond1 |
|
86
|
|
|
|
|
|
|
- name: condition |
|
87
|
|
|
|
|
|
|
value: cond2 |
|
88
|
|
|
|
|
|
|
- name: condition |
|
89
|
|
|
|
|
|
|
value: cond3 |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
In workflow.yaml: |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
state: |
|
94
|
|
|
|
|
|
|
- name: CHECK_PREREQS |
|
95
|
|
|
|
|
|
|
autorun: yes |
|
96
|
|
|
|
|
|
|
action: |
|
97
|
|
|
|
|
|
|
- name: null_1 |
|
98
|
|
|
|
|
|
|
resulting_state: HAVE_PREREQS |
|
99
|
|
|
|
|
|
|
condition: |
|
100
|
|
|
|
|
|
|
- name: check_prereqs |
|
101
|
|
|
|
|
|
|
- name: null_2 |
|
102
|
|
|
|
|
|
|
resulting_state: FAILURE |
|
103
|
|
|
|
|
|
|
condition: |
|
104
|
|
|
|
|
|
|
- name: !check_prereqs |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 PARAMETERS |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
The following parameters may be configured in the C<param> key of the |
|
111
|
|
|
|
|
|
|
condition in the YAML configuration: |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 condition, conditionN |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The condition parameter may be specified as either a list of repeating |
|
116
|
|
|
|
|
|
|
entries B<or> with a unique integer appended to the I<condition> string: |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
param: |
|
119
|
|
|
|
|
|
|
- name: condition |
|
120
|
|
|
|
|
|
|
value: first_condition_to_test |
|
121
|
|
|
|
|
|
|
- name: condition |
|
122
|
|
|
|
|
|
|
value: second_condition_to_test |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
B<or> |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
param: |
|
127
|
|
|
|
|
|
|
- name: condition1 |
|
128
|
|
|
|
|
|
|
value: first_condition_to_test |
|
129
|
|
|
|
|
|
|
- name: condition2 |
|
130
|
|
|
|
|
|
|
value: second_condition_to_test |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Copyright (c) 2003-2021 Chris Winters. All rights reserved. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
137
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Please see the F<LICENSE> |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 AUTHORS |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Please see L<Workflow> |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |