| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Lingua::Ogmios::Annotations::Level; |
|
2
|
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
64
|
use strict; |
|
|
16
|
|
|
|
|
23
|
|
|
|
16
|
|
|
|
|
1055
|
|
|
4
|
16
|
|
|
16
|
|
69
|
use warnings; |
|
|
16
|
|
|
|
|
20
|
|
|
|
16
|
|
|
|
|
62787
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
|
7
|
0
|
|
|
0
|
0
|
|
my ($class, $fields) = @_; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# if (defined $fields) { |
|
10
|
|
|
|
|
|
|
# TO UNCOMMENT LATER |
|
11
|
|
|
|
|
|
|
# if (!defined($fields->{'XML_order'})) { |
|
12
|
|
|
|
|
|
|
# die 'No XML order defined'; |
|
13
|
|
|
|
|
|
|
# } |
|
14
|
|
|
|
|
|
|
# } |
|
15
|
|
|
|
|
|
|
# if (!defined($fields->{'name'})) { |
|
16
|
|
|
|
|
|
|
# die 'name order defined'; |
|
17
|
|
|
|
|
|
|
# } |
|
18
|
|
|
|
|
|
|
# } |
|
19
|
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $level = { |
|
21
|
|
|
|
|
|
|
'name' => $fields->{'name'}, |
|
22
|
|
|
|
|
|
|
'id' => 0, |
|
23
|
|
|
|
|
|
|
'log_id' => -1, |
|
24
|
|
|
|
|
|
|
'comments' => undef, |
|
25
|
|
|
|
|
|
|
'elements' => [], |
|
26
|
|
|
|
|
|
|
'indexfields' => ['id', 'token'], |
|
27
|
|
|
|
|
|
|
'indexes' => {'id' => {}, 'token' => {}}, |
|
28
|
|
|
|
|
|
|
'XML_order' => [], |
|
29
|
|
|
|
|
|
|
}; |
|
30
|
0
|
|
|
|
|
|
bless $level, $class; |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if (defined $fields) { |
|
33
|
0
|
0
|
|
|
|
|
if (defined $fields->{'indexes'}) { |
|
34
|
0
|
|
|
|
|
|
$level->addIndex($fields->{'indexes'}); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
0
|
0
|
|
|
|
|
if (defined($fields->{'XML_order'})) { |
|
37
|
0
|
|
|
|
|
|
$level->setXMLorder($fields->{'XML_order'}); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
|
41
|
0
|
|
|
|
|
|
return $level; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub setName { |
|
46
|
0
|
|
|
0
|
0
|
|
my ($self, $name) = @_; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$self->{'name'} = $name; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub getName { |
|
52
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return($self->{'name'}); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub setXMLorder { |
|
58
|
0
|
|
|
0
|
0
|
|
my ($self, $xml_order) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
push @{$self->getXMLorder}, @$xml_order; |
|
|
0
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub getXMLorder { |
|
65
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
return($self->{'XML_order'}); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub resetIndexes { |
|
72
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
73
|
0
|
|
|
|
|
|
my $field; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
foreach $field (@{$self->getIndexfields}) { |
|
|
0
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$self->getIndexes->{$field} = {}; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub getIndexfields { |
|
81
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
return($self->{indexfields}); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub getIndexes { |
|
87
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return($self->{'indexes'}); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub getElement { |
|
93
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
return($self->getIndexes->{'id'}->{$id}); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub existsElement { |
|
99
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return(exists($self->getIndexes->{'id'}->{$id})); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub getElementFromIndex { |
|
105
|
0
|
|
|
0
|
0
|
|
my ($self, $indexfield, $id) = @_; |
|
106
|
0
|
|
|
|
|
|
my $element; |
|
107
|
|
|
|
|
|
|
my %elements; |
|
108
|
0
|
|
|
|
|
|
my @elts; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# return($self->getIndexes->{$indexfield}->{$id}); |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# warn "$indexfield : $id\n"; |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
0
|
|
|
|
|
if ($self->existsElementFromIndex($indexfield,$id)) { |
|
115
|
0
|
|
|
|
|
|
foreach $element (@{$self->getIndexes->{$indexfield}->{$id}}) { |
|
|
0
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# warn $element->getId . "\n"; |
|
117
|
0
|
|
|
|
|
|
$elements{$element->getId} = $element; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
0
|
|
|
|
|
|
@elts = values(%elements); |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# warn join(" : ", @elts) . "\n"; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
0
|
|
|
|
|
|
return(\@elts); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub getElementFromIndex2 { |
|
127
|
0
|
|
|
0
|
0
|
|
my ($self, $indexfield, $searchedElement) = @_; |
|
128
|
0
|
|
|
|
|
|
my $element; |
|
129
|
|
|
|
|
|
|
my %elements; |
|
130
|
0
|
|
|
|
|
|
my @elts; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# return($self->getIndexes->{$indexfield}->{$id}); |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# warn "$indexfield : $searchedElement " . $searchedElement->getId . "\n"; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
foreach $element (@{$self->getIndexes->{$indexfield}->{$searchedElement->getId}}) { |
|
|
0
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# warn ref($element) . "\n"; |
|
138
|
|
|
|
|
|
|
# warn "\t" . ref($element->_getField($indexfield)->{$element->_getField($indexfield)->{"reference"}}->[0]) . "\n"; |
|
139
|
0
|
0
|
|
|
|
|
if (ref($searchedElement) eq ref($element->_getField($indexfield)->{$element->_getField($indexfield)->{"reference"}}->[0])) { |
|
140
|
0
|
|
|
|
|
|
$elements{$element->getId} = $element; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
} |
|
143
|
0
|
|
|
|
|
|
@elts = values(%elements); |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# warn join(" : ", @elts) . "\n";; |
|
146
|
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
return(\@elts); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub existsElementFromIndex { |
|
151
|
0
|
|
|
0
|
0
|
|
my ($self, $indexfield, $id) = @_; |
|
152
|
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
return(exists($self->getIndexes->{$indexfield}->{$id})); |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub existsElementFromIndex2 { |
|
158
|
0
|
|
|
0
|
0
|
|
my ($self, $indexfield, $searchedElement) = @_; |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
|
0
|
|
|
|
return((exists($self->getIndexes->{$indexfield}->{$searchedElement->getId})) && (ref($searchedElement) eq ref($self->getIndexes->{$indexfield}->{$searchedElement->getId}))); |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub existsElementFromReference { |
|
165
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
|
if (exists $element->{'reference'}) { |
|
168
|
0
|
|
|
|
|
|
my @ref = @{$element->getReference}; |
|
|
0
|
|
|
|
|
|
|
|
169
|
0
|
0
|
|
|
|
|
if ($self->existsElementFromIndex("list_refid_token", $ref[0]->getId)) { |
|
170
|
0
|
|
|
|
|
|
my $ne = $self->getElementFromIndex("list_refid_token", $ref[0]->getId)->[0]; |
|
171
|
0
|
|
|
|
|
|
my @ref_ne = @{$ne->getReference}; |
|
|
0
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
my $i = 0; |
|
173
|
|
|
|
|
|
|
|
|
174
|
0
|
|
0
|
|
|
|
while(($i < scalar(@{$ne->getReference})) && ($i < scalar(@ref)) && |
|
|
0
|
|
0
|
|
|
|
|
|
175
|
|
|
|
|
|
|
($ref_ne[$i]->equals($ref[$i]))) { |
|
176
|
0
|
|
|
|
|
|
$i++ |
|
177
|
|
|
|
|
|
|
}; |
|
178
|
0
|
0
|
|
|
|
|
if ($i < scalar(@ref)) { |
|
179
|
0
|
|
|
|
|
|
return(0); |
|
180
|
|
|
|
|
|
|
} else { |
|
181
|
0
|
|
|
|
|
|
return(1); |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# return(exists($self->getIndexes->{$indexfield}->{$id})); |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub printIndex { |
|
194
|
0
|
|
|
0
|
0
|
|
my ($self, $indexfield) = @_; |
|
195
|
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
my $elt; |
|
197
|
|
|
|
|
|
|
my $idx; |
|
198
|
0
|
|
|
|
|
|
my $item; |
|
199
|
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
foreach $idx (keys %{$self->getIndex($indexfield)}) { |
|
|
0
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
print STDERR "$idx:\n"; |
|
202
|
0
|
|
|
|
|
|
print STDERR "\t" . $self->getIndex($indexfield)->{$idx} . "\n"; |
|
203
|
0
|
0
|
|
|
|
|
if (ref($self->getIndex($indexfield)->{$idx}) eq "ARRAY") { |
|
204
|
0
|
|
|
|
|
|
foreach $item (@{$self->getIndex($indexfield)->{$idx}}) { |
|
|
0
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
|
print STDERR "\t (" . ref($item) . ") " . $item->getId . "\n"; |
|
206
|
|
|
|
|
|
|
# print STDERR "\t (" . ref($item) . ") " . $item->_getField($indexfield) . " : " . $item->getForm . "\n"; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
} else { |
|
209
|
0
|
|
|
|
|
|
print STDERR "\t (" . ref($item) . ") " . $self->getIndex($indexfield)->{$idx}->getId . "\n"; |
|
210
|
|
|
|
|
|
|
# print STDERR "\t (" . ref($item) . ") " . $self->getIndex($indexfield)->{$idx}->_getField($indexfield) . " : " . $item->getForm . "\n"; |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub getIndex { |
|
216
|
0
|
|
|
0
|
0
|
|
my ($self, $indexfield) = @_; |
|
217
|
|
|
|
|
|
|
|
|
218
|
0
|
|
|
|
|
|
return($self->getIndexes->{$indexfield}); |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub existsIndex{ |
|
222
|
0
|
|
|
0
|
0
|
|
my ($self, $indexfield) = @_; |
|
223
|
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
|
return(exists $self->getIndexes->{$indexfield}); |
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
# check if the method as to be generalized |
|
228
|
|
|
|
|
|
|
sub addComponentToList { |
|
229
|
0
|
|
|
0
|
0
|
|
my ($self, $element, $component) = @_; |
|
230
|
|
|
|
|
|
|
|
|
231
|
0
|
0
|
|
|
|
|
if (exists $self->getIndexes->{'list_refid_components'}) { |
|
232
|
0
|
|
|
|
|
|
$element->addComponent($component); |
|
233
|
|
|
|
|
|
|
|
|
234
|
0
|
0
|
|
|
|
|
if (!exists $self->getIndexes->{'list_refid_components'}->{$component->getId}) { |
|
235
|
0
|
|
|
|
|
|
$self->getIndexes->{'list_refid_components'}->{$component->getId} = []; |
|
236
|
|
|
|
|
|
|
} |
|
237
|
0
|
|
|
|
|
|
push @{$self->getIndexes->{'list_refid_components'}->{$component->getId}}, $element; |
|
|
0
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
# $self->getIndexes->{'list_refid_components'}->{$component->getId} = $element; |
|
239
|
|
|
|
|
|
|
} |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub addElementToIndexes { |
|
244
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
|
245
|
0
|
|
|
|
|
|
my $field; |
|
246
|
|
|
|
|
|
|
my $value; |
|
247
|
0
|
|
|
|
|
|
my $val; |
|
248
|
0
|
|
|
|
|
|
my $val_element; |
|
249
|
0
|
|
|
|
|
|
my $component; |
|
250
|
|
|
|
|
|
|
|
|
251
|
0
|
|
|
|
|
|
my @indexfields = @{$self->getIndexfields}; |
|
|
0
|
|
|
|
|
|
|
|
252
|
0
|
|
|
|
|
|
$field = shift @indexfields; |
|
253
|
0
|
|
|
|
|
|
$self->getIndexes->{$field}->{$element->getId} = $element; |
|
254
|
0
|
|
|
|
|
|
$field = shift @indexfields; |
|
255
|
|
|
|
|
|
|
# warn "== $element\n"; |
|
256
|
0
|
|
|
|
|
|
$self->addElementToTokenIndex($element); |
|
257
|
|
|
|
|
|
|
# warn "--\n"; |
|
258
|
0
|
|
|
|
|
|
foreach $field (@indexfields) { |
|
259
|
|
|
|
|
|
|
# warn "... ($field)\n"; |
|
260
|
0
|
|
|
|
|
|
$self->addElementToIndex($element, $field); |
|
261
|
|
|
|
|
|
|
# warn "+++ ($field)\n"; |
|
262
|
|
|
|
|
|
|
} |
|
263
|
|
|
|
|
|
|
} |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
sub addElementToTokenIndex { |
|
266
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
|
267
|
0
|
|
|
|
|
|
my $ref; |
|
268
|
|
|
|
|
|
|
my $elt; |
|
269
|
0
|
|
|
|
|
|
my @refs; |
|
270
|
0
|
|
|
|
|
|
my $i; |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
# warn "ref: " . ref($element) . "\n"; |
|
273
|
|
|
|
|
|
|
|
|
274
|
0
|
0
|
|
|
|
|
if (ref($element) eq "Lingua::Ogmios::Annotations::Token") { |
|
275
|
0
|
0
|
|
|
|
|
if (! exists $self->getIndex('token')->{$element->getId}) { |
|
276
|
0
|
|
|
|
|
|
$self->getIndex('token')->{$element->getId} = []; |
|
277
|
|
|
|
|
|
|
} |
|
278
|
0
|
|
|
|
|
|
push @{$self->getIndex('token')->{$element->getId}}, $element; |
|
|
0
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
} else { |
|
280
|
0
|
|
|
|
|
|
$ref = $element->reference; |
|
281
|
0
|
0
|
|
|
|
|
if (ref($ref) eq "ARRAY") { |
|
282
|
0
|
|
|
|
|
|
@refs = @{$ref}; |
|
|
0
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
} else { |
|
284
|
0
|
|
|
|
|
|
push @refs, $ref; |
|
285
|
|
|
|
|
|
|
} |
|
286
|
0
|
|
|
|
|
|
for($i=0;$i< scalar(@refs);$i++) { |
|
287
|
0
|
|
|
|
|
|
$elt = $refs[$i]; |
|
288
|
0
|
0
|
|
|
|
|
if (ref($elt) eq "Lingua::Ogmios::Annotations::Token") { |
|
289
|
0
|
0
|
|
|
|
|
if (! exists $self->getIndex('token')->{$elt->getId}) { |
|
290
|
0
|
|
|
|
|
|
$self->getIndex('token')->{$elt->getId} = []; |
|
291
|
|
|
|
|
|
|
} |
|
292
|
0
|
|
|
|
|
|
push @{$self->getIndex('token')->{$elt->getId}}, $element; |
|
|
0
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
} else { |
|
294
|
0
|
0
|
0
|
|
|
|
if ((ref($elt) eq "Lingua::Ogmios::Annotations::Word") || |
|
|
|
|
0
|
|
|
|
|
|
295
|
|
|
|
|
|
|
(ref($elt) eq "Lingua::Ogmios::Annotations::Phrase") || |
|
296
|
|
|
|
|
|
|
(ref($elt) eq "Lingua::Ogmios::Annotations::SemanticUnit")# || |
|
297
|
|
|
|
|
|
|
) { |
|
298
|
0
|
|
|
|
|
|
$ref = $elt->reference; |
|
299
|
0
|
0
|
|
|
|
|
if (ref($ref) eq "ARRAY") { |
|
300
|
0
|
|
|
|
|
|
push @refs, @$ref; |
|
301
|
|
|
|
|
|
|
} else { |
|
302
|
0
|
|
|
|
|
|
push @refs, $ref; |
|
303
|
|
|
|
|
|
|
} |
|
304
|
|
|
|
|
|
|
} else { |
|
305
|
|
|
|
|
|
|
# warn "->$elt\n"; |
|
306
|
|
|
|
|
|
|
} |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
} |
|
309
|
|
|
|
|
|
|
# warn join(':', @{$element->reference}) . "\n"; |
|
310
|
|
|
|
|
|
|
} |
|
311
|
|
|
|
|
|
|
} |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
sub addElementToIndex { |
|
314
|
0
|
|
|
0
|
0
|
|
my ($self, $element, $field) = @_; |
|
315
|
0
|
|
|
|
|
|
my $value; |
|
316
|
|
|
|
|
|
|
my $val; |
|
317
|
0
|
|
|
|
|
|
my $val_element; |
|
318
|
0
|
|
|
|
|
|
my $component; |
|
319
|
|
|
|
|
|
|
|
|
320
|
0
|
|
|
|
|
|
$value = $element->_getField($field); |
|
321
|
|
|
|
|
|
|
# warn "$field\n"; |
|
322
|
|
|
|
|
|
|
# warn " ($value)\n"; |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
# if (($field eq "type") && (defined $value)) { |
|
325
|
|
|
|
|
|
|
# warn "$field ($value)\n"; |
|
326
|
|
|
|
|
|
|
# } |
|
327
|
0
|
0
|
|
|
|
|
if (defined $value) { |
|
328
|
0
|
0
|
|
|
|
|
if (ref($value) eq "ARRAY") { |
|
329
|
0
|
|
|
|
|
|
foreach $val (@$value) { |
|
330
|
0
|
|
|
|
|
|
$val_element = $val; |
|
331
|
0
|
0
|
|
|
|
|
if (index(ref($val), "Lingua::Ogmios::Annotations::") == 0) { |
|
332
|
0
|
|
|
|
|
|
$val_element = $val->getId; |
|
333
|
|
|
|
|
|
|
} |
|
334
|
0
|
0
|
|
|
|
|
if (!exists $self->getIndexes->{$field}->{$val_element}) { |
|
335
|
0
|
|
|
|
|
|
$self->getIndexes->{$field}->{$val_element} = []; |
|
336
|
|
|
|
|
|
|
} |
|
337
|
0
|
|
|
|
|
|
push @{$self->getIndexes->{$field}->{$val_element}}, $element; |
|
|
0
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
} else { |
|
340
|
0
|
0
|
|
|
|
|
if (ref($value) eq "HASH") { |
|
341
|
0
|
|
|
|
|
|
foreach $component (keys %$value) { |
|
342
|
0
|
0
|
|
|
|
|
if ($component ne "reference") { |
|
343
|
0
|
|
|
|
|
|
foreach $val (@{$value->{$component}}) { |
|
|
0
|
|
|
|
|
|
|
|
344
|
0
|
|
|
|
|
|
$val_element = $val; |
|
345
|
0
|
0
|
|
|
|
|
if (index(ref($val), "Lingua::Ogmios::Annotations::") == 0) { |
|
346
|
0
|
|
|
|
|
|
$val_element = $val->getId; |
|
347
|
|
|
|
|
|
|
} |
|
348
|
0
|
0
|
|
|
|
|
if (!exists $self->getIndexes->{$field}->{$val_element}) { |
|
349
|
0
|
|
|
|
|
|
$self->getIndexes->{$field}->{$val_element} = []; |
|
350
|
|
|
|
|
|
|
} |
|
351
|
0
|
|
|
|
|
|
push @{$self->getIndexes->{$field}->{$val_element}}, $element; #{$element => $component}; |
|
|
0
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
} |
|
353
|
|
|
|
|
|
|
} |
|
354
|
|
|
|
|
|
|
} |
|
355
|
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
} else { |
|
357
|
0
|
|
|
|
|
|
$val_element = $value; |
|
358
|
0
|
0
|
|
|
|
|
if (index(ref($value), "Lingua::Ogmios::Annotations::") == 0) { |
|
359
|
0
|
|
|
|
|
|
$val_element = $value->getId; |
|
360
|
|
|
|
|
|
|
} |
|
361
|
0
|
0
|
|
|
|
|
if (!exists $self->getIndexes->{$field}->{$val_element}) { |
|
362
|
0
|
|
|
|
|
|
$self->getIndexes->{$field}->{$val_element} = []; |
|
363
|
|
|
|
|
|
|
} |
|
364
|
0
|
|
|
|
|
|
push @{$self->getIndexes->{$field}->{$val_element}}, $element; |
|
|
0
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
} |
|
366
|
|
|
|
|
|
|
} |
|
367
|
|
|
|
|
|
|
# } else { |
|
368
|
|
|
|
|
|
|
# warn "undefined field: $field\n"; |
|
369
|
|
|
|
|
|
|
} |
|
370
|
|
|
|
|
|
|
} |
|
371
|
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
sub delElementToIndexes { |
|
374
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
|
375
|
0
|
|
|
|
|
|
my $field; |
|
376
|
|
|
|
|
|
|
my $value; |
|
377
|
0
|
|
|
|
|
|
my $val; |
|
378
|
0
|
|
|
|
|
|
my $val_element; |
|
379
|
0
|
|
|
|
|
|
my $component; |
|
380
|
0
|
|
|
|
|
|
my $i; |
|
381
|
|
|
|
|
|
|
|
|
382
|
0
|
|
|
|
|
|
my @indexfields = @{$self->getIndexfields}; |
|
|
0
|
|
|
|
|
|
|
|
383
|
0
|
|
|
|
|
|
$field = shift @indexfields; |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
# $value = $element->_getField($field); |
|
386
|
|
|
|
|
|
|
# print STDERR "$field"; |
|
387
|
|
|
|
|
|
|
# warn " : $value\n"; |
|
388
|
|
|
|
|
|
|
|
|
389
|
0
|
|
|
|
|
|
delete $self->getIndexes->{$field}->{$element->getId}; |
|
390
|
|
|
|
|
|
|
# $field = shift @indexfields; |
|
391
|
|
|
|
|
|
|
# $self->delElementToTokenIndex($element); |
|
392
|
|
|
|
|
|
|
|
|
393
|
0
|
|
|
|
|
|
foreach $field (@indexfields) { |
|
394
|
0
|
|
|
|
|
|
$value = $element->_getField($field); |
|
395
|
|
|
|
|
|
|
# print STDERR "$field"; |
|
396
|
|
|
|
|
|
|
# warn " : $value\n"; |
|
397
|
|
|
|
|
|
|
|
|
398
|
0
|
0
|
|
|
|
|
if (defined $value) { |
|
399
|
0
|
0
|
|
|
|
|
if (ref($value) eq "ARRAY") { |
|
400
|
0
|
|
|
|
|
|
foreach $val (@$value) { |
|
401
|
0
|
|
|
|
|
|
$val_element = $val; |
|
402
|
0
|
0
|
|
|
|
|
if (index(ref($val), "Lingua::Ogmios::Annotations::") == 0) { |
|
403
|
0
|
|
|
|
|
|
$val_element = $val->getId; |
|
404
|
|
|
|
|
|
|
} |
|
405
|
0
|
|
|
|
|
|
$self->delElementFromIndex($val_element, $field, $element); |
|
406
|
|
|
|
|
|
|
} |
|
407
|
|
|
|
|
|
|
} else { |
|
408
|
0
|
0
|
|
|
|
|
if (ref($value) eq "HASH") { |
|
409
|
0
|
|
|
|
|
|
$i = 0; |
|
410
|
0
|
|
|
|
|
|
foreach $component (keys %$value) { |
|
411
|
0
|
0
|
|
|
|
|
if ($component ne "reference") { |
|
412
|
0
|
|
|
|
|
|
foreach $val (@{$value->{$component}}) { |
|
|
0
|
|
|
|
|
|
|
|
413
|
0
|
|
|
|
|
|
$val_element = $val; |
|
414
|
0
|
0
|
|
|
|
|
if (index(ref($val), "Lingua::Ogmios::Annotations::") == 0) { |
|
415
|
0
|
|
|
|
|
|
$val_element = $val->getId; |
|
416
|
|
|
|
|
|
|
} |
|
417
|
0
|
|
|
|
|
|
$self->delElementFromIndex($val_element, $component, $element); |
|
418
|
|
|
|
|
|
|
} |
|
419
|
|
|
|
|
|
|
} |
|
420
|
|
|
|
|
|
|
} |
|
421
|
|
|
|
|
|
|
} else { |
|
422
|
0
|
|
|
|
|
|
$val_element = $value; |
|
423
|
0
|
0
|
|
|
|
|
if (index(ref($value), "Lingua::Ogmios::Annotations::") == 0) { |
|
424
|
0
|
|
|
|
|
|
$val_element = $value->getId; |
|
425
|
|
|
|
|
|
|
} |
|
426
|
|
|
|
|
|
|
# warn "====> $val_element\n"; |
|
427
|
|
|
|
|
|
|
|
|
428
|
0
|
|
|
|
|
|
$self->delElementFromIndex($val_element, $field, $element); |
|
429
|
|
|
|
|
|
|
} |
|
430
|
|
|
|
|
|
|
} |
|
431
|
|
|
|
|
|
|
} |
|
432
|
|
|
|
|
|
|
} |
|
433
|
|
|
|
|
|
|
} |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
sub delElementFromIndex { |
|
436
|
0
|
|
|
0
|
0
|
|
my ($self, $value, $field, $element) = @_; |
|
437
|
0
|
|
|
|
|
|
my $i; |
|
438
|
|
|
|
|
|
|
|
|
439
|
0
|
0
|
|
|
|
|
if (exists $self->getIndexes->{$field}->{$value}) { |
|
440
|
|
|
|
|
|
|
# warn "--> $field " . join(":", @{$self->getIndexes->{$field}->{$value}}) . "\n"; |
|
441
|
0
|
|
|
|
|
|
$i = 0; |
|
442
|
0
|
|
0
|
|
|
|
while(($i < scalar(@{$self->getIndexes->{$field}->{$value}})) && |
|
|
0
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
(!($self->getIndexes->{$field}->{$value}->[$i]->equals($element)))) { |
|
444
|
0
|
|
|
|
|
|
$i++; |
|
445
|
|
|
|
|
|
|
} |
|
446
|
0
|
0
|
|
|
|
|
if ($i < scalar(@{$self->getIndexes->{$field}->{$value}})) { |
|
|
0
|
|
|
|
|
|
|
|
447
|
0
|
|
|
|
|
|
splice(@{$self->getIndexes->{$field}->{$value}}, $i, 1); |
|
|
0
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
# warn "--del--\n"; |
|
449
|
|
|
|
|
|
|
} else { |
|
450
|
|
|
|
|
|
|
# warn "value ($value) not found in $field\n"; |
|
451
|
|
|
|
|
|
|
} |
|
452
|
0
|
0
|
|
|
|
|
if (scalar(@{$self->getIndexes->{$field}->{$value}}) == 0) { |
|
|
0
|
|
|
|
|
|
|
|
453
|
0
|
|
|
|
|
|
delete $self->getIndexes->{$field}->{$value}; |
|
454
|
|
|
|
|
|
|
# warn "---del---\n"; |
|
455
|
|
|
|
|
|
|
} |
|
456
|
|
|
|
|
|
|
} |
|
457
|
|
|
|
|
|
|
} |
|
458
|
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
sub addIndex { |
|
461
|
0
|
|
|
0
|
0
|
|
my ($self, $fields) = @_; |
|
462
|
0
|
|
|
|
|
|
my $field; |
|
463
|
|
|
|
|
|
|
|
|
464
|
0
|
|
|
|
|
|
foreach $field (@$fields) { |
|
465
|
0
|
0
|
|
|
|
|
if (!$self->existsIndex($field)) { |
|
466
|
0
|
|
|
|
|
|
push @{$self->getIndexfields}, $field; |
|
|
0
|
|
|
|
|
|
|
|
467
|
0
|
|
|
|
|
|
$self->getIndexes->{$field} = {}; |
|
468
|
|
|
|
|
|
|
} |
|
469
|
|
|
|
|
|
|
} |
|
470
|
|
|
|
|
|
|
} |
|
471
|
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
sub setId { |
|
473
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
|
474
|
|
|
|
|
|
|
|
|
475
|
0
|
|
|
|
|
|
$self->{'id'} = $id; |
|
476
|
|
|
|
|
|
|
} |
|
477
|
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
sub setMaxId { |
|
479
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
|
480
|
|
|
|
|
|
|
|
|
481
|
0
|
0
|
|
|
|
|
if ($id > $self->getId) { |
|
482
|
0
|
|
|
|
|
|
$self->setId($id); |
|
483
|
|
|
|
|
|
|
} |
|
484
|
|
|
|
|
|
|
} |
|
485
|
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
sub getId { |
|
487
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
488
|
|
|
|
|
|
|
|
|
489
|
0
|
|
|
|
|
|
return($self->{'id'}); |
|
490
|
|
|
|
|
|
|
} |
|
491
|
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
sub incrId { |
|
493
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
494
|
|
|
|
|
|
|
|
|
495
|
0
|
|
|
|
|
|
return($self->setId($self->getId + 1)); |
|
496
|
|
|
|
|
|
|
} |
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
sub _decrId { |
|
499
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
500
|
|
|
|
|
|
|
|
|
501
|
0
|
|
|
|
|
|
return($self->setId($self->getId - 1)); |
|
502
|
|
|
|
|
|
|
} |
|
503
|
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
sub getLog_Id { |
|
505
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
506
|
|
|
|
|
|
|
|
|
507
|
0
|
|
|
|
|
|
return($self->{'log_id'}); |
|
508
|
|
|
|
|
|
|
} |
|
509
|
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
sub incrLog_Id { |
|
511
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
512
|
|
|
|
|
|
|
|
|
513
|
0
|
|
|
|
|
|
return($self->setLog_Id($self->getLog_Id + 1)); |
|
514
|
|
|
|
|
|
|
} |
|
515
|
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
sub _decrLog_Id { |
|
517
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
518
|
|
|
|
|
|
|
|
|
519
|
0
|
|
|
|
|
|
return($self->setLog_Id($self->getLog_Id - 1)); |
|
520
|
|
|
|
|
|
|
} |
|
521
|
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
sub resetElements { |
|
524
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
525
|
0
|
|
|
|
|
|
my $field; |
|
526
|
|
|
|
|
|
|
|
|
527
|
0
|
|
|
|
|
|
$self->{'elements'} = []; |
|
528
|
0
|
|
|
|
|
|
$self->resetIndexes; |
|
529
|
|
|
|
|
|
|
} |
|
530
|
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
sub getElements { |
|
532
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
533
|
|
|
|
|
|
|
|
|
534
|
0
|
|
|
|
|
|
return($self->{'elements'}); |
|
535
|
|
|
|
|
|
|
} |
|
536
|
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
sub getSize { |
|
538
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
539
|
|
|
|
|
|
|
|
|
540
|
0
|
|
|
|
|
|
return(scalar(@{$self->getElements})); |
|
|
0
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
} |
|
542
|
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
sub getLastElement { |
|
545
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
546
|
|
|
|
|
|
|
|
|
547
|
0
|
0
|
|
|
|
|
if ($self->getSize != 0) { |
|
548
|
0
|
|
|
|
|
|
return($self->getElements->[$#{$self->getElements}]); |
|
|
0
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
} else { |
|
550
|
0
|
|
|
|
|
|
return(undef); |
|
551
|
|
|
|
|
|
|
} |
|
552
|
|
|
|
|
|
|
# my $elements = $self->getElements; |
|
553
|
|
|
|
|
|
|
# $element->previous($elements->[$#$elements]); |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
# $elements->[$#$elements] |
|
556
|
|
|
|
|
|
|
# return($self->{'elements'}); |
|
557
|
|
|
|
|
|
|
} |
|
558
|
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
sub getFirstElement { |
|
560
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
561
|
|
|
|
|
|
|
|
|
562
|
0
|
|
|
|
|
|
my $i = 0; |
|
563
|
|
|
|
|
|
|
|
|
564
|
0
|
|
0
|
|
|
|
while(($self->getSize != 0) && (!exists($self->getElements->[$i]))) { $i++; }; |
|
|
0
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
|
|
566
|
0
|
0
|
|
|
|
|
if ($self->getSize != 0) { |
|
567
|
0
|
|
|
|
|
|
return($self->getElements->[$i]); |
|
568
|
|
|
|
|
|
|
} else { |
|
569
|
0
|
|
|
|
|
|
return(undef); |
|
570
|
|
|
|
|
|
|
} |
|
571
|
|
|
|
|
|
|
# my $elements = $self->getElements; |
|
572
|
|
|
|
|
|
|
# $element->previous($elements->[$#$elements]); |
|
573
|
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
# $elements->[$#$elements] |
|
575
|
|
|
|
|
|
|
# return($self->{'elements'}); |
|
576
|
|
|
|
|
|
|
} |
|
577
|
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
sub setComments { |
|
580
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
581
|
|
|
|
|
|
|
|
|
582
|
0
|
|
|
|
|
|
$self->{'comments'} = {}; |
|
583
|
|
|
|
|
|
|
} |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
sub getComments { |
|
586
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
587
|
|
|
|
|
|
|
|
|
588
|
0
|
|
|
|
|
|
return($self->{'comments'}); |
|
589
|
|
|
|
|
|
|
} |
|
590
|
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
sub replaceElement { |
|
592
|
0
|
|
|
0
|
0
|
|
my ($self, $oldElement, $newElement) = @_; |
|
593
|
|
|
|
|
|
|
|
|
594
|
0
|
|
|
|
|
|
$newElement->setId($oldElement->getId); |
|
595
|
|
|
|
|
|
|
|
|
596
|
0
|
|
|
|
|
|
$newElement->previous($oldElement->previous); |
|
597
|
0
|
0
|
|
|
|
|
if (defined $oldElement->previous) { |
|
598
|
0
|
|
|
|
|
|
$oldElement->previous->next($newElement); |
|
599
|
|
|
|
|
|
|
} |
|
600
|
0
|
|
|
|
|
|
$newElement->next($oldElement->next); |
|
601
|
0
|
0
|
|
|
|
|
if (defined $oldElement->next) { |
|
602
|
0
|
|
|
|
|
|
$oldElement->next->previous($newElement); |
|
603
|
|
|
|
|
|
|
} |
|
604
|
|
|
|
|
|
|
|
|
605
|
0
|
|
|
|
|
|
$self->delElementToIndexes($oldElement); |
|
606
|
0
|
|
|
|
|
|
$self->addElementToIndexes($newElement); |
|
607
|
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
# $self->delElement($oldElement); |
|
609
|
0
|
|
|
|
|
|
$self->addElementToIndexes($newElement); |
|
610
|
0
|
|
|
|
|
|
$self->delElementToIndexes($oldElement); |
|
611
|
|
|
|
|
|
|
|
|
612
|
0
|
|
|
|
|
|
return($newElement->getId); |
|
613
|
|
|
|
|
|
|
} |
|
614
|
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
sub addElement { |
|
616
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
|
617
|
|
|
|
|
|
|
|
|
618
|
0
|
|
|
|
|
|
my $id; |
|
619
|
|
|
|
|
|
|
|
|
620
|
|
|
|
|
|
|
# warn "++>" . $element->getId . "\n"; |
|
621
|
0
|
0
|
|
|
|
|
if ($element->getId == -1) { |
|
622
|
0
|
|
|
|
|
|
$id = $self->incrId; |
|
623
|
0
|
|
|
|
|
|
$element->setId($id); |
|
624
|
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
} else { |
|
626
|
0
|
|
|
|
|
|
$id = $element->getId; |
|
627
|
0
|
|
|
|
|
|
$self->setMaxId($id); |
|
628
|
|
|
|
|
|
|
# warn "$id already exists (IdElement)\n"; |
|
629
|
|
|
|
|
|
|
} |
|
630
|
0
|
0
|
|
|
|
|
if (defined $self->getLastElement) { |
|
631
|
0
|
|
|
|
|
|
$element->previous($self->getLastElement); |
|
632
|
0
|
|
|
|
|
|
$self->getLastElement->next($element); |
|
633
|
|
|
|
|
|
|
} |
|
634
|
0
|
|
|
|
|
|
push @{$self->getElements}, $element; |
|
|
0
|
|
|
|
|
|
|
|
635
|
0
|
|
|
|
|
|
$self->addElementToIndexes($element); |
|
636
|
0
|
|
|
|
|
|
return($id); |
|
637
|
|
|
|
|
|
|
} |
|
638
|
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
sub delElement { |
|
640
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
|
641
|
|
|
|
|
|
|
|
|
642
|
0
|
0
|
|
|
|
|
if (defined $element->previous) { |
|
643
|
0
|
|
|
|
|
|
$element->previous->next($element->next); |
|
644
|
|
|
|
|
|
|
} |
|
645
|
|
|
|
|
|
|
|
|
646
|
0
|
|
|
|
|
|
my $i = 0; |
|
647
|
|
|
|
|
|
|
|
|
648
|
0
|
|
0
|
|
|
|
while(($i < $self->getSize) && ((!defined($self->getElements->[$i])) || (!$self->getElements->[$i]->equals($element)))) { |
|
|
|
|
0
|
|
|
|
|
|
649
|
0
|
|
|
|
|
|
$i++; |
|
650
|
|
|
|
|
|
|
} |
|
651
|
|
|
|
|
|
|
|
|
652
|
0
|
0
|
|
|
|
|
if ($i < $self->getSize) { |
|
653
|
0
|
|
|
|
|
|
splice(@{$self->getElements},$i,1); |
|
|
0
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
# warn "delElement\n"; |
|
655
|
0
|
|
|
|
|
|
$self->delElementToIndexes($element); |
|
656
|
|
|
|
|
|
|
} |
|
657
|
0
|
|
|
|
|
|
return($element->getId); |
|
658
|
|
|
|
|
|
|
} |
|
659
|
|
|
|
|
|
|
|
|
660
|
|
|
|
|
|
|
sub changeRefFromIndexField { |
|
661
|
0
|
|
|
0
|
0
|
|
my ($self, $indexfield, $oldvalue, $newvalue) = @_; |
|
662
|
0
|
|
|
|
|
|
my $section; |
|
663
|
|
|
|
|
|
|
|
|
664
|
0
|
|
|
|
|
|
foreach $section (@{$self->getElementFromIndex($indexfield, $oldvalue)}) { |
|
|
0
|
|
|
|
|
|
|
|
665
|
0
|
|
|
|
|
|
$section->_setField($indexfield, $newvalue); |
|
666
|
|
|
|
|
|
|
} |
|
667
|
|
|
|
|
|
|
} |
|
668
|
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
sub resetIndex { |
|
670
|
0
|
|
|
0
|
0
|
|
my ($self, $indexfield) = @_; |
|
671
|
|
|
|
|
|
|
|
|
672
|
0
|
|
|
|
|
|
$self->getIndexes->{$indexfield} = {}; |
|
673
|
|
|
|
|
|
|
} |
|
674
|
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
sub rebuildIndex { |
|
676
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
677
|
|
|
|
|
|
|
|
|
678
|
0
|
|
|
|
|
|
my $element; |
|
679
|
|
|
|
|
|
|
my $field; |
|
680
|
0
|
|
|
|
|
|
my $value; |
|
681
|
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
# warn "rebuild Index\n"; |
|
683
|
0
|
|
|
|
|
|
my @indexfields = @{$self->getIndexfields}; |
|
|
0
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
# shift @indexfields; |
|
685
|
|
|
|
|
|
|
# $field = shift @indexfields; |
|
686
|
|
|
|
|
|
|
# $self->getIndexes->{$field}->{$element->getId} = $element; |
|
687
|
0
|
|
|
|
|
|
foreach $field (@indexfields) { |
|
688
|
0
|
|
|
|
|
|
$self->resetIndex($field); |
|
689
|
|
|
|
|
|
|
# warn "field: $field\n"; |
|
690
|
0
|
|
|
|
|
|
foreach $element (@{$self->getElements}) { |
|
|
0
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
# warn "element: $element\n"; |
|
692
|
0
|
|
|
|
|
|
$self->addElementToIndexes($element); |
|
693
|
|
|
|
|
|
|
# $value = $element->_getField($field); |
|
694
|
|
|
|
|
|
|
# if (!exists $self->getIndexes->{$field}->{$value}) { |
|
695
|
|
|
|
|
|
|
# $self->getIndexes->{$field}->{$value} = []; |
|
696
|
|
|
|
|
|
|
# } |
|
697
|
|
|
|
|
|
|
# push @{$self->getIndexes->{$field}->{$value}}, $element; |
|
698
|
|
|
|
|
|
|
} |
|
699
|
|
|
|
|
|
|
} |
|
700
|
|
|
|
|
|
|
} |
|
701
|
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
sub printXML { |
|
703
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
704
|
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
} |
|
707
|
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
sub XMLout { |
|
709
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
710
|
|
|
|
|
|
|
|
|
711
|
0
|
|
|
|
|
|
my $element; |
|
712
|
0
|
|
|
|
|
|
my $name = $self->getName; |
|
713
|
0
|
|
|
|
|
|
my $order = $self->getXMLorder; |
|
714
|
0
|
|
|
|
|
|
my $str; |
|
715
|
|
|
|
|
|
|
|
|
716
|
0
|
|
|
|
|
|
$str = " <$name" . "_level>\n"; |
|
717
|
0
|
|
|
|
|
|
foreach $element (@{$self->getElements}) { |
|
|
0
|
|
|
|
|
|
|
|
718
|
0
|
|
|
|
|
|
$str .= $element->XMLout($order); |
|
719
|
|
|
|
|
|
|
} |
|
720
|
0
|
|
|
|
|
|
$str .= " $name" . "_level>\n"; |
|
721
|
|
|
|
|
|
|
} |
|
722
|
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
# sub getElementFromIndex { |
|
724
|
|
|
|
|
|
|
# my ($self, $indexfield, $id) = @_; |
|
725
|
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
sub startsWith { |
|
727
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
|
728
|
|
|
|
|
|
|
|
|
729
|
0
|
0
|
|
|
|
|
if (exists $self->getIndex('from')->{$element->getFrom}) { |
|
730
|
0
|
|
|
|
|
|
return(1); |
|
731
|
|
|
|
|
|
|
} else { |
|
732
|
0
|
|
|
|
|
|
return(0); |
|
733
|
|
|
|
|
|
|
} |
|
734
|
|
|
|
|
|
|
|
|
735
|
|
|
|
|
|
|
} |
|
736
|
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
sub endsWith { |
|
738
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
|
739
|
|
|
|
|
|
|
|
|
740
|
0
|
0
|
|
|
|
|
if (exists $self->getIndex('to')->{$element->getTo}) { |
|
741
|
0
|
|
|
|
|
|
return(1); |
|
742
|
|
|
|
|
|
|
} else { |
|
743
|
0
|
|
|
|
|
|
return(0); |
|
744
|
|
|
|
|
|
|
} |
|
745
|
|
|
|
|
|
|
} |
|
746
|
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
sub existsElementByToken { |
|
748
|
0
|
|
|
0
|
0
|
|
my ($self, $token) = @_; |
|
749
|
|
|
|
|
|
|
|
|
750
|
0
|
|
|
|
|
|
return(exists($self->getIndex('token')->{$token->getId})); |
|
751
|
|
|
|
|
|
|
} |
|
752
|
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
sub getElementByToken { |
|
754
|
0
|
|
|
0
|
0
|
|
my ($self, $token) = @_; |
|
755
|
|
|
|
|
|
|
|
|
756
|
0
|
|
|
|
|
|
my @refs; |
|
757
|
0
|
|
|
|
|
|
my $elt = $self->getIndex('token')->{$token->getId}; |
|
758
|
0
|
0
|
|
|
|
|
if (defined $elt) { |
|
759
|
0
|
|
|
|
|
|
return($elt); |
|
760
|
|
|
|
|
|
|
} else { |
|
761
|
0
|
|
|
|
|
|
return([]); |
|
762
|
|
|
|
|
|
|
} |
|
763
|
|
|
|
|
|
|
# push @refs, $self->getIndex('token')->{$token->getId}; |
|
764
|
|
|
|
|
|
|
|
|
765
|
|
|
|
|
|
|
# warn scalar(@refs) . "\n"; |
|
766
|
|
|
|
|
|
|
|
|
767
|
|
|
|
|
|
|
# return(\@refs); |
|
768
|
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
# return($self->getElementByOffset($token->getFrom)); |
|
770
|
|
|
|
|
|
|
} |
|
771
|
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
sub getElementByToken1 { |
|
773
|
0
|
|
|
0
|
0
|
|
my ($self, $token) = @_; |
|
774
|
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
# if (exists $self->getElements->[0]->{'reference'}) { |
|
776
|
|
|
|
|
|
|
# # TODO |
|
777
|
|
|
|
|
|
|
# } else { |
|
778
|
|
|
|
|
|
|
# $selt->getElements |
|
779
|
|
|
|
|
|
|
# warn "Search $token in ($self)\n"; |
|
780
|
0
|
|
|
|
|
|
return($self->getElementByOffset($token->getFrom)); |
|
781
|
|
|
|
|
|
|
# } |
|
782
|
|
|
|
|
|
|
} |
|
783
|
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
# this method has to be rewriten correctly |
|
785
|
|
|
|
|
|
|
sub getElementByOffset { |
|
786
|
0
|
|
|
0
|
0
|
|
my ($self, $offset) = @_; |
|
787
|
|
|
|
|
|
|
|
|
788
|
0
|
|
|
|
|
|
my $element; |
|
789
|
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
my $fromOffset; |
|
791
|
0
|
|
|
|
|
|
my $from; |
|
792
|
0
|
|
|
|
|
|
my $toOffset; |
|
793
|
0
|
|
|
|
|
|
my $to; |
|
794
|
|
|
|
|
|
|
|
|
795
|
0
|
|
|
|
|
|
my @elements; |
|
796
|
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
# warn "Search $offset in ($self)\n"; |
|
798
|
|
|
|
|
|
|
|
|
799
|
|
|
|
|
|
|
|
|
800
|
0
|
|
|
|
|
|
foreach $element (@{$self->getElements}) { |
|
|
0
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
# warn "==> $element\n"; |
|
802
|
0
|
0
|
|
|
|
|
if (defined $element) { |
|
803
|
0
|
0
|
0
|
|
|
|
if ((defined $element->{'reference'}) || (defined $element->{'list_refid_components'})){ |
|
804
|
0
|
|
|
|
|
|
$from = $element->start_token; |
|
805
|
0
|
|
|
|
|
|
$to = $element->end_token; |
|
806
|
|
|
|
|
|
|
# warn "go1\n"; |
|
807
|
|
|
|
|
|
|
} else { |
|
808
|
0
|
0
|
|
|
|
|
if (defined $element->{'refid_start_token'}) { |
|
809
|
|
|
|
|
|
|
# warn "go2\n"; |
|
810
|
0
|
|
|
|
|
|
$from = $element->refid_start_token; |
|
811
|
0
|
|
|
|
|
|
$to = $element->refid_end_token; |
|
812
|
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
} else { |
|
814
|
0
|
|
|
|
|
|
$from = $element->getFrom; |
|
815
|
0
|
|
|
|
|
|
$to = $element->getTo; |
|
816
|
|
|
|
|
|
|
} |
|
817
|
|
|
|
|
|
|
} |
|
818
|
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
# warn "ref($from) : " . ref($from) . ";\n"; |
|
820
|
0
|
0
|
|
|
|
|
if (ref($from) eq "") { |
|
821
|
0
|
|
|
|
|
|
$fromOffset = $from; |
|
822
|
|
|
|
|
|
|
} else { |
|
823
|
0
|
|
|
|
|
|
$fromOffset = $from->getFrom; |
|
824
|
|
|
|
|
|
|
} |
|
825
|
|
|
|
|
|
|
# warn "ref($to) : " . ref($to) . "\n"; |
|
826
|
0
|
0
|
|
|
|
|
if (ref($to) eq "") { |
|
827
|
0
|
|
|
|
|
|
$toOffset = $to; |
|
828
|
|
|
|
|
|
|
} else { |
|
829
|
0
|
|
|
|
|
|
$toOffset = $to->getTo; |
|
830
|
|
|
|
|
|
|
} |
|
831
|
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
# warn "\tfrom $fromOffset to $toOffset\n"; |
|
833
|
0
|
0
|
0
|
|
|
|
if (($fromOffset <= $offset) && ($offset <= $toOffset)) { |
|
834
|
|
|
|
|
|
|
# warn "$offset is in the element " . $element->getId . " / " . $element->getForm . "\n"; |
|
835
|
|
|
|
|
|
|
# warn "$offset is in the element " . $element->getId . "\n"; |
|
836
|
0
|
|
|
|
|
|
push @elements, $element; |
|
837
|
|
|
|
|
|
|
} |
|
838
|
|
|
|
|
|
|
} |
|
839
|
|
|
|
|
|
|
} |
|
840
|
|
|
|
|
|
|
# warn "===================\n"; |
|
841
|
0
|
|
|
|
|
|
return(\@elements); |
|
842
|
|
|
|
|
|
|
} |
|
843
|
|
|
|
|
|
|
|
|
844
|
|
|
|
|
|
|
sub getElementById { |
|
845
|
0
|
|
|
0
|
0
|
|
my ($self, $id) = @_; |
|
846
|
|
|
|
|
|
|
|
|
847
|
0
|
|
|
|
|
|
return($self->getElement($id)); |
|
848
|
|
|
|
|
|
|
} |
|
849
|
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
sub contains { |
|
851
|
0
|
|
|
0
|
0
|
|
my ($self, $element) = @_; |
|
852
|
|
|
|
|
|
|
|
|
853
|
|
|
|
|
|
|
# warn "------------------------------------------------------------------------\n"; |
|
854
|
|
|
|
|
|
|
# warn $element->getForm . "\n"; |
|
855
|
0
|
|
|
|
|
|
my $levelElement; |
|
856
|
0
|
|
|
|
|
|
my $token = $element->start_token; |
|
857
|
0
|
|
|
|
|
|
my $offset = $token->getFrom; |
|
858
|
|
|
|
|
|
|
# warn "\t$offset\n\n"; |
|
859
|
|
|
|
|
|
|
|
|
860
|
0
|
|
|
|
|
|
foreach $levelElement (@{$self->getElements}) { |
|
|
0
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
# warn "$levelElement\n"; |
|
862
|
|
|
|
|
|
|
# warn "\t" . $levelElement->start_token->getFrom . "\n"; |
|
863
|
|
|
|
|
|
|
# warn "\t" . $levelElement->end_token->getTo . "\n"; |
|
864
|
0
|
0
|
0
|
|
|
|
if (($levelElement->start_token->getFrom <= $offset) && |
|
865
|
|
|
|
|
|
|
($offset <= $levelElement->end_token->getTo)) { |
|
866
|
|
|
|
|
|
|
# warn "OK\n"; |
|
867
|
0
|
|
|
|
|
|
return($levelElement); |
|
868
|
|
|
|
|
|
|
} |
|
869
|
|
|
|
|
|
|
} |
|
870
|
0
|
|
|
|
|
|
return(undef); |
|
871
|
|
|
|
|
|
|
} |
|
872
|
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
sub getElementsBetweenStartEndTokens { |
|
874
|
0
|
|
|
0
|
0
|
|
my ($self, $start_token, $end_token) = @_; |
|
875
|
|
|
|
|
|
|
|
|
876
|
0
|
|
|
|
|
|
my $token = $start_token; |
|
877
|
0
|
|
|
|
|
|
my %semFs; |
|
878
|
|
|
|
|
|
|
my $elt; |
|
879
|
|
|
|
|
|
|
|
|
880
|
0
|
|
|
|
|
|
foreach $elt (@{$self->getElementByToken($token)}) { |
|
|
0
|
|
|
|
|
|
|
|
881
|
0
|
|
|
|
|
|
$semFs{$elt->getId} = $elt; |
|
882
|
|
|
|
|
|
|
# warn $elt->getId . "\n"; |
|
883
|
|
|
|
|
|
|
} |
|
884
|
|
|
|
|
|
|
|
|
885
|
0
|
|
0
|
|
|
|
while ((defined $token) && (!($token->equals($end_token)))) { |
|
886
|
0
|
|
|
|
|
|
$token = $token->next; |
|
887
|
0
|
0
|
|
|
|
|
if (defined $token) { |
|
888
|
0
|
|
|
|
|
|
foreach $elt (@{$self->getElementByToken($token)}) { |
|
|
0
|
|
|
|
|
|
|
|
889
|
0
|
|
|
|
|
|
$semFs{$elt->getId} = $elt; |
|
890
|
|
|
|
|
|
|
# warn $elt->getId . "\n"; |
|
891
|
|
|
|
|
|
|
} |
|
892
|
|
|
|
|
|
|
} |
|
893
|
|
|
|
|
|
|
} |
|
894
|
|
|
|
|
|
|
|
|
895
|
0
|
|
|
|
|
|
return(values(%semFs)); |
|
896
|
|
|
|
|
|
|
} |
|
897
|
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
sub getElementByStartEndTokens { |
|
899
|
0
|
|
|
0
|
0
|
|
my ($self, $start_token, $end_token) = @_; |
|
900
|
|
|
|
|
|
|
|
|
901
|
0
|
|
|
|
|
|
my $term; |
|
902
|
|
|
|
|
|
|
my @terms; |
|
903
|
|
|
|
|
|
|
|
|
904
|
|
|
|
|
|
|
# warn "$start_token: " . $start_token->getId . "\n"; |
|
905
|
0
|
|
|
|
|
|
foreach $term (@{$self->getElementByToken($start_token)}) { |
|
|
0
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
# warn "$term\n"; |
|
907
|
0
|
0
|
0
|
|
|
|
if (($term->start_token->equals($start_token)) && ($term->end_token->equals($end_token))) { |
|
908
|
0
|
|
|
|
|
|
push @terms, $term; |
|
909
|
|
|
|
|
|
|
} |
|
910
|
|
|
|
|
|
|
} |
|
911
|
0
|
0
|
|
|
|
|
if (scalar(@terms) > 0) { |
|
912
|
0
|
|
|
|
|
|
return($terms[0]); |
|
913
|
|
|
|
|
|
|
} else { |
|
914
|
0
|
|
|
|
|
|
return(undef); |
|
915
|
|
|
|
|
|
|
} |
|
916
|
|
|
|
|
|
|
} |
|
917
|
|
|
|
|
|
|
sub existsElementByStartEndTokens { |
|
918
|
0
|
|
|
0
|
0
|
|
my ($self, $start_token, $end_token) = @_; |
|
919
|
|
|
|
|
|
|
|
|
920
|
0
|
|
|
|
|
|
my $term; |
|
921
|
|
|
|
|
|
|
my @terms; |
|
922
|
|
|
|
|
|
|
|
|
923
|
|
|
|
|
|
|
# warn "$start_token: " . $start_token->getId . "\n"; |
|
924
|
0
|
|
|
|
|
|
foreach $term (@{$self->getElementByToken($start_token)}) { |
|
|
0
|
|
|
|
|
|
|
|
925
|
|
|
|
|
|
|
# warn "$term\n"; |
|
926
|
0
|
0
|
0
|
|
|
|
if (($term->start_token->equals($start_token)) && ($term->end_token->equals($end_token))) { |
|
927
|
0
|
|
|
|
|
|
push @terms, $term; |
|
928
|
|
|
|
|
|
|
} |
|
929
|
|
|
|
|
|
|
} |
|
930
|
0
|
|
|
|
|
|
return(scalar(@terms) > 0); |
|
931
|
|
|
|
|
|
|
} |
|
932
|
|
|
|
|
|
|
|
|
933
|
|
|
|
|
|
|
|
|
934
|
|
|
|
|
|
|
1; |
|
935
|
|
|
|
|
|
|
|
|
936
|
|
|
|
|
|
|
__END__ |