line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SIAM::AccessScope; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
947
|
|
4
|
2
|
|
|
2
|
|
16
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
68
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use base 'SIAM::Object'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
447
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1086
|
use SIAM::ScopeMember; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
20
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
SIAM::AccessScope - access scope object class |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 INSTANCE METHODS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 new |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$scope = new SIAM::AccessScope($driver, {'siam.object.id' => $id}) |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Instantiates a new object. The following object IDs are predefined and |
24
|
|
|
|
|
|
|
are not fetched from the driver: |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over 4 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item * SIAM.SCOPE.ALL.CONTRACTS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The access scope with the name I. All contract objects are |
31
|
|
|
|
|
|
|
implicitly included in it. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item * SIAM.SCOPE.ALL.ATTRIBUTES |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
The access scope with the name I. All attribute names are |
36
|
|
|
|
|
|
|
implicitly in it. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=back |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my %match_all_id = |
43
|
|
|
|
|
|
|
('SIAM.SCOPE.ALL.CONTRACTS' => |
44
|
|
|
|
|
|
|
{ |
45
|
|
|
|
|
|
|
'siam.scope.name' => 'AllContracts', |
46
|
|
|
|
|
|
|
'siam.scope.applies_to' => 'SIAM::Contract', |
47
|
|
|
|
|
|
|
}, |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
'SIAM.SCOPE.ALL.ATTRIBUTES' => |
50
|
|
|
|
|
|
|
{ |
51
|
|
|
|
|
|
|
'siam.scope.name' => 'AllAttributes', |
52
|
|
|
|
|
|
|
'siam.scope.applies_to' => 'SIAM::Attribute', |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub new |
58
|
|
|
|
|
|
|
{ |
59
|
13
|
|
|
13
|
1
|
23
|
my $class = shift; |
60
|
13
|
|
|
|
|
19
|
my $driver = shift; |
61
|
13
|
|
|
|
|
20
|
my $id = shift; |
62
|
|
|
|
|
|
|
|
63
|
13
|
100
|
66
|
|
|
82
|
if( defined($id) and defined($match_all_id{$id}) ) |
64
|
|
|
|
|
|
|
{ |
65
|
2
|
|
|
|
|
4
|
my $self = {}; |
66
|
2
|
|
|
|
|
5
|
bless $self, $class; |
67
|
|
|
|
|
|
|
|
68
|
2
|
|
|
|
|
6
|
$self->{'_attr'} = {'siam.object.id' => $id}; |
69
|
2
|
|
|
|
|
3
|
while( my($key, $val) = each %{$match_all_id{$id}} ) |
|
6
|
|
|
|
|
41
|
|
70
|
|
|
|
|
|
|
{ |
71
|
4
|
|
|
|
|
9
|
$self->{'_attr'}{$key} = $val; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
2
|
|
|
|
|
7
|
return $self; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else |
77
|
|
|
|
|
|
|
{ |
78
|
11
|
|
|
|
|
141
|
return $class->SUPER::new( $driver, $id ); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 match_object |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Expects an object as an argument. Returns true if the object matches the scope. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub match_object |
92
|
|
|
|
|
|
|
{ |
93
|
8
|
|
|
8
|
1
|
12
|
my $self = shift; |
94
|
8
|
|
|
|
|
11
|
my $obj = shift; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# siam.scope.applies_to should match the object class |
97
|
8
|
50
|
|
|
|
32
|
if( $obj->objclass ne $self->attr('siam.scope.applies_to') ) |
98
|
|
|
|
|
|
|
{ |
99
|
0
|
|
|
|
|
0
|
return undef; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# check if we are one of the predefined scopes |
103
|
8
|
100
|
|
|
|
24
|
if( defined($match_all_id{$self->id}) ) |
104
|
|
|
|
|
|
|
{ |
105
|
2
|
|
|
|
|
9
|
return 1; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# check if object ID matches one of our members |
109
|
6
|
|
|
|
|
20
|
my $members = $self->get_contained_objects |
110
|
|
|
|
|
|
|
('SIAM::ScopeMember', |
111
|
|
|
|
|
|
|
{'match_attribute' => ['siam.scmember.object_id', [$obj->id()]]}); |
112
|
|
|
|
|
|
|
|
113
|
6
|
100
|
|
|
|
17
|
if( scalar(@{$members}) > 0 ) |
|
6
|
|
|
|
|
18
|
|
114
|
|
|
|
|
|
|
{ |
115
|
4
|
|
|
|
|
32
|
return 1; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
2
|
|
|
|
|
53
|
return undef; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 get_object_ids |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Returns arrayref with all object IDs to which this scope's members point to. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub get_object_ids |
131
|
|
|
|
|
|
|
{ |
132
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
133
|
|
|
|
|
|
|
|
134
|
2
|
|
|
|
|
10
|
my $members = $self->get_contained_objects('SIAM::ScopeMember'); |
135
|
|
|
|
|
|
|
|
136
|
2
|
|
|
|
|
6
|
my $ret = []; |
137
|
2
|
|
|
|
|
4
|
foreach my $member (@{$members}) |
|
2
|
|
|
|
|
5
|
|
138
|
|
|
|
|
|
|
{ |
139
|
2
|
|
|
|
|
3
|
push(@{$ret}, $member->points_to); |
|
2
|
|
|
|
|
9
|
|
140
|
|
|
|
|
|
|
} |
141
|
2
|
|
|
|
|
16
|
return $ret; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 CLASS METHODS |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 matches_all |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Takes an ID of an SIAM::AccessScope object and the object class. |
153
|
|
|
|
|
|
|
Returns true if it's a match-all scope for a given class. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub matches_all |
159
|
|
|
|
|
|
|
{ |
160
|
4
|
|
|
4
|
1
|
9
|
my $class = shift; |
161
|
4
|
|
|
|
|
6
|
my $id = shift; |
162
|
4
|
|
|
|
|
8
|
my $objclass = shift; |
163
|
|
|
|
|
|
|
|
164
|
4
|
|
66
|
|
|
35
|
return( defined($match_all_id{$id}) and |
165
|
|
|
|
|
|
|
$match_all_id{$id}{'siam.scope.applies_to'} eq $objclass ); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# mandatory attributes |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
my $mandatory_attributes = |
173
|
|
|
|
|
|
|
[ 'siam.scope.name', |
174
|
|
|
|
|
|
|
'siam.scope.applies_to' ]; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub _mandatory_attributes |
177
|
|
|
|
|
|
|
{ |
178
|
11
|
|
|
11
|
|
31
|
return $mandatory_attributes; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub _manifest_attributes |
182
|
|
|
|
|
|
|
{ |
183
|
1
|
|
|
1
|
|
3
|
my $ret = []; |
184
|
1
|
|
|
|
|
3
|
push(@{$ret}, @{$mandatory_attributes}, |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
185
|
1
|
|
|
|
|
2
|
@{ SIAM::ScopeMember->_manifest_attributes() }); |
186
|
|
|
|
|
|
|
|
187
|
1
|
|
|
|
|
5
|
return $ret; |
188
|
|
|
|
|
|
|
} |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
1; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# Local Variables: |
194
|
|
|
|
|
|
|
# mode: cperl |
195
|
|
|
|
|
|
|
# indent-tabs-mode: nil |
196
|
|
|
|
|
|
|
# cperl-indent-level: 4 |
197
|
|
|
|
|
|
|
# cperl-continued-statement-offset: 4 |
198
|
|
|
|
|
|
|
# cperl-continued-brace-offset: -4 |
199
|
|
|
|
|
|
|
# cperl-brace-offset: 0 |
200
|
|
|
|
|
|
|
# cperl-label-offset: -2 |
201
|
|
|
|
|
|
|
# End: |