| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package UR::BoolExpr::Template::PropertyComparison; |
|
3
|
|
|
|
|
|
|
|
|
4
|
266
|
|
|
266
|
|
1081
|
use warnings; |
|
|
266
|
|
|
|
|
361
|
|
|
|
266
|
|
|
|
|
12111
|
|
|
5
|
266
|
|
|
266
|
|
971
|
use strict; |
|
|
266
|
|
|
|
|
322
|
|
|
|
266
|
|
|
|
|
15965
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.46"; # UR $VERSION;; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Define the class metadata. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require UR; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
UR::Object::Type->define( |
|
13
|
|
|
|
|
|
|
class_name => __PACKAGE__, |
|
14
|
|
|
|
|
|
|
is => ['UR::BoolExpr::Template'], |
|
15
|
|
|
|
|
|
|
#has => [qw/ |
|
16
|
|
|
|
|
|
|
# rule_type |
|
17
|
|
|
|
|
|
|
# subject_class_name |
|
18
|
|
|
|
|
|
|
# property_name |
|
19
|
|
|
|
|
|
|
# comparison_operator |
|
20
|
|
|
|
|
|
|
# value |
|
21
|
|
|
|
|
|
|
# resolution_code_perl |
|
22
|
|
|
|
|
|
|
# resolution_code_sql |
|
23
|
|
|
|
|
|
|
#/], |
|
24
|
|
|
|
|
|
|
#id_by => ['subject_class_name','logic_string'] |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
266
|
|
|
266
|
|
92551
|
use UR::BoolExpr::Template::PropertyComparison::Equals; |
|
|
266
|
|
|
|
|
510
|
|
|
|
266
|
|
|
|
|
1351
|
|
|
28
|
266
|
|
|
266
|
|
98798
|
use UR::BoolExpr::Template::PropertyComparison::LessThan; |
|
|
266
|
|
|
|
|
504
|
|
|
|
266
|
|
|
|
|
1328
|
|
|
29
|
266
|
|
|
266
|
|
100330
|
use UR::BoolExpr::Template::PropertyComparison::In; |
|
|
266
|
|
|
|
|
518
|
|
|
|
266
|
|
|
|
|
1704
|
|
|
30
|
266
|
|
|
266
|
|
99898
|
use UR::BoolExpr::Template::PropertyComparison::Like; |
|
|
266
|
|
|
|
|
537
|
|
|
|
266
|
|
|
|
|
1400
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub property_name { |
|
33
|
5242
|
|
|
5242
|
0
|
11621
|
(split(' ',$_[0]->logic_detail))[0] |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub comparison_operator { |
|
38
|
0
|
|
|
0
|
0
|
0
|
(split(' ',$_[0]->logic_detail))[1] |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub sub_group { |
|
42
|
376
|
|
|
376
|
0
|
439
|
my $self = shift; |
|
43
|
376
|
|
|
|
|
972
|
my $spec = $self->property_name; |
|
44
|
376
|
50
|
|
|
|
1154
|
if ($spec =~ /-/) { |
|
45
|
|
|
|
|
|
|
#$DB::single = 1; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
376
|
50
|
|
|
|
889
|
if ($spec =~ /^(.*)+\-(\w+)(\?|)(\..+|)/) { |
|
48
|
0
|
|
|
|
|
0
|
return $2 . $3; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
else { |
|
51
|
376
|
|
|
|
|
848
|
return ''; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get_underlying_rules_for_values { |
|
56
|
0
|
|
|
0
|
0
|
0
|
return; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub num_values { |
|
60
|
|
|
|
|
|
|
# Not strictly correct... |
|
61
|
0
|
|
|
0
|
0
|
0
|
return 1; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub evaluate_subject_and_values { |
|
65
|
2099
|
|
|
2099
|
0
|
2091
|
my ($self,$subject,$comparison_value) = @_; |
|
66
|
2099
|
|
|
|
|
3258
|
my @property_values = $subject->__get_attr__($self->property_name); |
|
67
|
2099
|
|
|
|
|
5746
|
return $self->_compare($comparison_value, @property_values); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub resolve_subclass_for_comparison_operator { |
|
71
|
4703
|
|
|
4703
|
0
|
4155
|
my $class = shift; |
|
72
|
4703
|
|
|
|
|
4115
|
my $comparison_operator = shift; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Remove any escape sequence that may have been put in at UR::BoolExpr::resolve() |
|
75
|
4703
|
100
|
|
|
|
7873
|
$comparison_operator =~ s/-.+$// if $comparison_operator; |
|
76
|
|
|
|
|
|
|
|
|
77
|
4703
|
|
|
|
|
10418
|
my $suffix = UR::Util::class_suffix_for_operator($comparison_operator); |
|
78
|
|
|
|
|
|
|
|
|
79
|
4703
|
|
|
|
|
7347
|
my $subclass_name = join('::', $class, $suffix); |
|
80
|
|
|
|
|
|
|
|
|
81
|
4703
|
|
|
|
|
10297
|
my $subclass_meta = UR::Object::Type->get($subclass_name); |
|
82
|
4703
|
50
|
|
|
|
7779
|
unless ($subclass_meta) { |
|
83
|
0
|
|
|
|
|
0
|
Carp::confess("Unknown operator '$comparison_operator'"); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
4703
|
|
|
|
|
6403
|
return $subclass_name; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _get_for_subject_class_name_and_logic_detail { |
|
89
|
4703
|
|
|
4703
|
|
4410
|
my $class = shift; |
|
90
|
4703
|
|
|
|
|
3974
|
my $subject_class_name = shift; |
|
91
|
4703
|
|
|
|
|
4088
|
my $logic_detail = shift; |
|
92
|
|
|
|
|
|
|
|
|
93
|
4703
|
|
|
|
|
8725
|
my ($property_name, $comparison_operator) = split(' ',$logic_detail, 2); |
|
94
|
4703
|
|
|
|
|
8336
|
my $subclass_name = $class->resolve_subclass_for_comparison_operator($comparison_operator); |
|
95
|
4703
|
|
|
|
|
15617
|
my $id = $subclass_name->__meta__->resolve_composite_id_from_ordered_values($subject_class_name, 'PropertyComparison', $logic_detail); |
|
96
|
|
|
|
|
|
|
|
|
97
|
4703
|
|
|
|
|
12249
|
return $subclass_name->get($id); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub comparison_value_and_escape_character_to_regex { |
|
101
|
150
|
|
|
150
|
0
|
3638
|
my ($class, $value, $escape) = @_; |
|
102
|
|
|
|
|
|
|
|
|
103
|
150
|
100
|
|
|
|
388
|
return '' unless defined($value); |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# anyone who uses the % as an escape character deserves to suffer |
|
106
|
134
|
100
|
|
|
|
328
|
if ($value eq '%') { |
|
107
|
16
|
|
|
|
|
39
|
return '^.+$'; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
118
|
|
|
|
|
154
|
my $regex = $value; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# Escape all special characters in the regex. |
|
113
|
118
|
|
|
|
|
295
|
$regex =~ s/([\(\)\[\]\{\}\+\*\.\?\|\^\$\-])/\\$1/g; |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# Handle the escape sequence |
|
116
|
118
|
100
|
|
|
|
228
|
if (defined $escape) |
|
117
|
|
|
|
|
|
|
{ |
|
118
|
26
|
|
|
|
|
64
|
$escape =~ s/\\/\\\\/g; # replace \ with \\ |
|
119
|
26
|
|
|
|
|
185
|
$regex =~ s/(?
|
|
120
|
26
|
|
|
|
|
63
|
$regex =~ s/(?
|
|
121
|
|
|
|
|
|
|
#LSF: Take away the escape characters. |
|
122
|
26
|
|
|
|
|
47
|
$regex =~ s/$escape\%/\%/g; |
|
123
|
26
|
|
|
|
|
98
|
$regex =~ s/$escape\_/\_/g; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
else |
|
126
|
|
|
|
|
|
|
{ |
|
127
|
92
|
|
|
|
|
277
|
$regex =~ s/\%/\.\*/g; |
|
128
|
92
|
|
|
|
|
159
|
$regex =~ s/\_/\./g; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# Wrap the regex in delimiters. |
|
132
|
118
|
|
|
|
|
236
|
$regex = "^${regex}\$"; |
|
133
|
|
|
|
|
|
|
|
|
134
|
118
|
|
|
|
|
125
|
my $exception = do { |
|
135
|
118
|
|
|
|
|
137
|
local $@; |
|
136
|
118
|
|
|
|
|
143
|
$regex = eval { qr($regex) }; |
|
|
118
|
|
|
|
|
1084
|
|
|
137
|
118
|
|
|
|
|
208
|
$@; |
|
138
|
|
|
|
|
|
|
}; |
|
139
|
118
|
50
|
|
|
|
262
|
if ($exception) { |
|
140
|
0
|
|
|
|
|
0
|
Carp::confess($exception); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
118
|
|
|
|
|
263
|
return $regex; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 NAME |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
UR::BoolExpr::Template::PropertyComparison - implements logic for rules with a logic_type of "PropertyComparison" |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
UR::Object(3), UR::BoolExpr::Temmplate(3), UR::BoolExpr(3), UR::BoolExpr::Template::PropertyComparison::* |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
|
157
|
|
|
|
|
|
|
|