lib/SeeAlso/Source/BeaconAggregator/Maintenance.pm

filter: Statementstmt 77.9% 639 / 820 Branchbran 59.8% 456 / 762 Conditioncond 50.9% 136 / 267 MC/DCmcdc 24.6% 38 / 154 Subroutinesub 100% 34 / 34 Podpod 86.9% 20 / 23 totaltotal 64.2% 1323 / 2060 CC 484 SCAR 59.8
CC
484
Cov
67%
loadFile
967.2
processbeaconheader
429.1
update
414.6
CRAP 395.3
« script/sasbactrl ↑ Summary lib/SeeAlso/Source/BeaconAggregator.pm »
1 package SeeAlso::Source::BeaconAggregator::Maintenance;
2 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 37 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
6 37 ▶ use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 37 ▶ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 37 $VERSION = '0.2_92';
9 37 @ISA = qw(Exporter);
10 #Give a hoot don't pollute, do not export more than needed by default
11 37 @EXPORT = qw();
12 37 @EXPORT_OK = qw();
13 37 %EXPORT_TAGS = ();
14 }
15  
16 37 ▶use base ("SeeAlso::Source::BeaconAggregator");
Subroutine BEGIN: called CC=1 SCAR=0.0
17 37 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 37 ▶use HTTP::Date; # not perfect, but the module is commonly installed...
Subroutine BEGIN: called CC=1 SCAR=0.0
19 37 ▶use HTTP::Request;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 37 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 37 ▶use File::Temp;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 =head1 NAME
24  
25 sasbactrl.pl - command line interface to SeeAlso::Source::BeaconAggregator and
26 auxiliary classes
27  
28 =head1 SYNOPSIS
29  
30  
31 =head1 DESCRIPTION
32  
33 This Module allows a collection of BEACON files (cf. http://de.wikipedia.org/wiki/Wikipedia:BEACON)
34 to be used as SeeAlso::Source (probably in the context of an SeeAlso::Server application).
35 Therefore it implements the four methods documented in SeeAlso::Source
36  
37 The BEACON files (lists of non-local identifiers of a certain type documenting the coverage of a given
38 online database plus means for access) are imported by the methods provided by
39 SeeAlso::Source::BeaconAggregator::Maintenance.pm, usually by employing the script sasbactrl.pl
40 as command line client.
41  
42 Serving other formats than SeeAlso or providing a BEACON file with respect to this
43 SeeAlso service is achieved by using SeeAlso::Source::BeaconAggregator::Publisher.
44  
45  
46 =head1 USAGE
47  
48 Use the C<new()> method inherited from C<SeeAlso::Source::BeaconAggregator> to
49 access an existing database or create a new one.
50  
51  
52 =head2 Database Methods
53  
54 =head3 init( [ %options] )
55  
56 Sets up and initializes the database structure for the object.
57 This has to be done once after creating a new database and after
58 upgrading this module.
59  
60 Valid options include:
61  
62 =over 8
63  
64 =item verbose
65  
66 =item prepareRedirs
67  
68 =item identifierClass
69  
70 =back
71  
72  
73 The I<repos> table contains as columns all valid beacon fields plus
74 the following administrative fields which have to be prefixed with
75 "_" in the interface:
76  
77 =over 8
78  
79 =item seqno
80  
81 Sequence number: Is incremented on any successfull load
82  
83 =item alias
84  
85 Unique key: On update older seqences with the same alias are
86 automatically discarded. Most methods take an alias as
87 argument thus obliterating the need to determine the sequence
88 number.
89  
90 =item sort
91  
92 optional sort key
93  
94  
95 =item uri
96  
97 Overrides the #FEED header for updates
98  
99 =item ruri
100  
101 Real uri from which the last instance was loaded
102  
103  
104 =item ftime
105  
106 Fetch time: Timestamp as to when this instance was loaded
107  
108 Clear this or mtime to force automatic reload.
109  
110 =item fstat
111  
112 Short statistics line of last successful reload on update.
113  
114  
115 =item mtime
116  
117 Modification time: Timestamp of the file / HTTP object from which this instance was loaded.
118 Identical to ftime if no timestamp is provided
119  
120 Clear this or ftime to force automatic reload on update.
121  
122  
123 =item utime
124  
125 Timestamp of last update attempt
126  
127 =item ustat
128  
129 Short status line of last update attempt.
130  
131  
132 =item counti
133  
134 Identifier count
135  
136 =item countu
137  
138 Unique identifier count
139  
140  
141 =item admin
142  
143 Just to store some remarks.
144  
145 =back
146  
147 The I<beacons> table stores the individual beacon entries from the input files.
148 Its columns are:
149  
150 =over 8
151  
152 =item hash
153  
154 Identifier. If a (subclass of) C<SeeAlso::Source::Identifier> instance is provided,
155 this will be transformed by the C<hash()> method.
156  
157 =item seqno
158  
159 Sequence number of the beacon file in the database
160  
161 =item altid
162  
163 optional identifier from an alternative identifier system for use
164 with ALTTARGET templates.
165  
166 =item hits
167  
168 optional number of hits for this identifier in the given resource
169  
170 =item info
171  
172 optional information text
173  
174 =item link
175  
176 optional explicit URL
177  
178 =back
179  
180  
181 The I<osd> table contains C<key>, C<val> pairs for various metadata
182 concerning the collection as such, notably the values needed for
183 the Open Search Description and the Header fields needed in case
184 of publishing a beacon file for this collection.
185  
186 The I<admin> table stores (unique) C<key>, C<val> pairs for
187 general persistent data. Currently the following keys are defined:
188  
189 =over 8
190  
191 =item DATA_VERSION
192  
193 Integer version number to migrate database layout.
194  
195 =item IDENTIFIER_CLASS
196  
197 Name of the Identifier class to be used.
198  
199 =item REDIRECTION_INDEX
200  
201 Control creation of an additional index for the I<altid> column
202 (facialiates reverse lookups as needed for clustering).
203  
204 =back
205  
206  
207 =cut
208  
209 9 ▶sub init {
Subroutine init: called CC=51 SCAR=53.6
Pod documented
210 9 my ($self, %options) = @_;
211 9 ▶ $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options{"verbose"} 9 0 9
212  
213 9 my @fieldlist = SeeAlso::Source::BeaconAggregator->beaconfields();
214 9 my @bf = map{ join(" ", @{[SeeAlso::Source::BeaconAggregator->beaconfields($_)]}[0..1]) } @fieldlist;
215 9 ▶ my $hdl = $self->{dbh} or croak("no database handle?");
Branch: 1 branch
BranchTrueFalseTotal
my $hdl = $self->{"dbh"} or croak("no database handle?") 9 0 9
216  
217 9 local($") = ",\n";
218 9 ▶ $hdl->do(<<"XxX"
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE TABLE IF NOT EXISTS repos (\n seqno INTEGER PRIMARY KEY AUTOINCREMENT,\n alias TEXT,\n sort TEXT,\n uri VARCHAR(512),\n ruri VARCHAR(512),\n mtime INTEGER,\n utime INTEGER,\n ftime INTEGER,\n counti INTEGER DEFAULT 0,\n countu INTEGER DEFAULT 0,\n fstat TEXT,\n ustat TEXT,\n admin VARCHAR(512),\n @bf\n);\n") or croak('Setup error: ' . $hdl->errstr) 9 0 9
219 CREATE TABLE IF NOT EXISTS repos (
220 seqno INTEGER PRIMARY KEY AUTOINCREMENT,
221 alias TEXT,
222 sort TEXT,
223 uri VARCHAR(512),
224 ruri VARCHAR(512),
225 mtime INTEGER,
226 utime INTEGER,
227 ftime INTEGER,
228 counti INTEGER DEFAULT 0,
229 countu INTEGER DEFAULT 0,
230 fstat TEXT,
231 ustat TEXT,
232 admin VARCHAR(512),
233 @bf
234 );
235 XxX
236 ) or croak("Setup error: ".$hdl->errstr);
237  
238 9 ▶ $hdl->do("CREATE UNIQUE INDEX IF NOT EXISTS seqnos ON repos(seqno);") or croak("Setup error: ".$hdl->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE UNIQUE INDEX IF NOT EXISTS seqnos ON repos(seqno);") or croak('Setup error: ' . $hdl->errstr) 9 0 9
239 9 ▶ $hdl->do("CREATE INDEX IF NOT EXISTS aliases ON repos(alias);") or croak("Setup error: ".$hdl->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE INDEX IF NOT EXISTS aliases ON repos(alias);") or croak('Setup error: ' . $hdl->errstr) 9 0 9
240  
241 9 ▶ $hdl->do(<<"XxX"
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE TABLE IF NOT EXISTS beacons (\n hash CHARACTER(64) NOT NULL,\n seqno INTEGER REFERENCES repos(seqno) ON DELETE CASCADE,\n altid TEXT,\n hits INTEGER,\n info VARCHAR(255),\n link VARCHAR(1024) \n);\n") or croak('Setup error: ' . $hdl->errstr) 9 0 9
242 CREATE TABLE IF NOT EXISTS beacons (
243 hash CHARACTER(64) NOT NULL,
244 seqno INTEGER REFERENCES repos(seqno) ON DELETE CASCADE,
245 altid TEXT,
246 hits INTEGER,
247 info VARCHAR(255),
248 link VARCHAR(1024)
249 );
250 XxX
251 ) or croak("Setup error: ".$hdl->errstr);
252  
253  
254 # Faciliate lookups
255 9 ▶ $hdl->do("CREATE INDEX IF NOT EXISTS lookup ON beacons(hash);") or croak("Setup error: ".$hdl->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE INDEX IF NOT EXISTS lookup ON beacons(hash);") or croak('Setup error: ' . $hdl->errstr) 9 0 9
256 # maintenance and enforce constraints
257 # (Problem: Dupes w/o altid but differing in link *and* info fields should be legitimate, too)
258 9 ▶ $hdl->do("CREATE UNIQUE INDEX IF NOT EXISTS mntnce ON beacons(seqno, hash, altid);") or croak("Setup error: ".$hdl->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE UNIQUE INDEX IF NOT EXISTS mntnce ON beacons(seqno, hash, altid);") or croak('Setup error: ' . $hdl->errstr) 9 0 9
259  
260 # foreign key on cascade does not work?
261  
262 9 ▶ $hdl->do(<<"XxX"
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE TRIGGER IF NOT EXISTS on_delete_seqno BEFORE DELETE ON repos FOR EACH ROW\n BEGIN\n DELETE FROM beacons WHERE seqno=OLD.seqno;\n END;\n") or croak('Setup error: ' . $hdl->errstr) 9 0 9
263 CREATE TRIGGER IF NOT EXISTS on_delete_seqno BEFORE DELETE ON repos FOR EACH ROW
264 BEGIN
265 DELETE FROM beacons WHERE seqno=OLD.seqno;
266 END;
267 XxX
268 ) or croak("Setup error: ".$hdl->errstr);
269  
270 # OpenSearchDescription
271 9 ▶ $hdl->do(<<"XxX"
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE TABLE IF NOT EXISTS osd (\n key CHAR(20) NOT NULL,\n val VARCHAR(1024)\n);\n") or croak('Setup error: ' . $hdl->errstr) 9 0 9
272 CREATE TABLE IF NOT EXISTS osd (
273 key CHAR(20) NOT NULL,
274 val VARCHAR(1024)
275 );
276 XxX
277 ) or croak("Setup error: ".$hdl->errstr);
278 9 ▶ $hdl->do("CREATE INDEX IF NOT EXISTS OSDKeys ON osd(key);") or croak("Setup error: ".$hdl->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE INDEX IF NOT EXISTS OSDKeys ON osd(key);") or croak('Setup error: ' . $hdl->errstr) 9 0 9
279  
280 # Admin Stuff
281 9 ▶ $hdl->do(<<"XxX"
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE TABLE IF NOT EXISTS admin (\n key CHAR(20) PRIMARY KEY NOT NULL,\n val VARCHAR(1024)\n);\n") or croak('Setup error: ' . $hdl->errstr) 9 0 9
282 CREATE TABLE IF NOT EXISTS admin (
283 key CHAR(20) PRIMARY KEY NOT NULL,
284 val VARCHAR(1024)
285 );
286 XxX
287 ) or croak("Setup error: ".$hdl->errstr);
288  
289 9 ▶ $hdl->do("CREATE UNIQUE INDEX IF NOT EXISTS ADMKeys ON admin(key);") or croak("Setup error: ".$hdl->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE UNIQUE INDEX IF NOT EXISTS ADMKeys ON admin(key);") or croak('Setup error: ' . $hdl->errstr) 9 0 9
290  
291 9 my $admref = $self->admhash();
292  
293 9 my $verkey = "DATA_VERSION";
294 9 my $goalver = $SeeAlso::Source::BeaconAggregator::DATA_VERSION;
295 9 ▶ my $dbver = $admref->{$verkey} || 0;
Condition100%2/2
$admref->{$verkey} || 0
l!l
81
MC/DC100%1/1
$admref->{$verkey} || 0
$admref->{$verkey}
Truth table100%2/2
A
A= $admref->{$verkey}
Aresult
11
00
296 9 ▶ if ( $dbver != $goalver ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($dbver != $goalver) { } 1 8 9
elsif ($options{'verbose'}) { } 0 8 8
297 1 print "NOTICE: Database version $dbver: Upgrading to $goalver\n";
298 # alter tables here
299 1 ▶ if ( $dbver < 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dbver < 2) 1 0 1
300 # my ($at, $type) = SeeAlso::Source::BeaconAggregator->beaconfields("COUNT");
301 # $hdl->do("ALTER TABLE repos ADD COLUMN $at $type;");
302 # ($at, $type) = SeeAlso::Source::BeaconAggregator->beaconfields("REMARK");
303 # $hdl->do("ALTER TABLE repos ADD COLUMN $at $type;");
304 };
305 }
306 elsif ( $options{'verbose'} ) {
307 0 print "INFO: Database version $dbver is current\n"};
308  
309 9 ▶ unless ( $dbver == $goalver) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dbver == $goalver) 1 8 9
310 1 my $verh = $self->stmtHdl("INSERT OR REPLACE INTO admin VALUES (?, ?);", "update version statement");
311 1 ▶ $verh->execute($verkey, $goalver)
Branch: 1 branch
BranchTrueFalseTotal
$verh->execute($verkey, $goalver) or croak('Could not execute update version statement: ' . $verh->errstr) 1 0 1
312 or croak("Could not execute update version statement: ".$verh->errstr);
313 };
314  
315 9 ▶ unless ( exists $options{'identifierClass'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $options{"identifierClass"}) 3 6 9
316 3 ▶ $options{'identifierClass'} = $self->{'identifierClass'} if exists $self->{'identifierClass'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"identifierClass"} 1 2 3
317 };
318  
319 9 my $ickey = "IDENTIFIER_CLASS";
320 9 ▶ if ( (exists $options{identifierClass}) and (my $wanttype = ref($options{'identifierClass'})) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $options{'identifierClass'} and my $wanttype = ref $options{'identifierClass'}) { } 5 4 9
elsif (exists $options{'identifierClass'} and not $options{'identifierClass'}) { } 2 4 6
Condition100%3/3
exists $options{"identifierClass"} and my $wanttype = ref $options{"identifierClass"}
!ll&&!rl&&r
225
MC/DC100%2/2
exists $options{"identifierClass"} and my $wanttype = ref $options{"identifierClass"}
exists $options{"identifierClass"} my $wanttype = ref $options{"identifierClass"}
Truth table100%3/3
A and B
A= exists $options{"identifierClass"}B= my $wanttype = ref $options{"identifierClass"}
ABresult
0X0
100
111
321 5 ▶ if ( (exists $self->{identifierClass}) && (ref($self->{identifierClass}) ne $wanttype) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"identifierClass"} and ref $self->{"identifierClass"} ne $wanttype) 1 4 5
Condition100%3/3
exists $self->{"identifierClass"} and ref $self->{"identifierClass"} ne $wanttype
!ll&&!rl&&r
221
MC/DC100%2/2
exists $self->{"identifierClass"} and ref $self->{"identifierClass"} ne $wanttype
exists $self->{"identifierClass"} ref $self->{"identifierClass"} ne $wanttype
Truth table100%3/3
A and B
A= exists $self->{"identifierClass"}B= ref $self->{"identifierClass"} ne $wanttype
ABresult
0X0
100
111
322 1 croak("Cannot override identifierClass set on new()")};
323 4 ▶ if ( my $oldtype = $admref->{$ickey} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $oldtype = $admref->{$ickey}) { } 2 2 4
324 2 ▶ croak ("Identifier mismatch: Cannot set to $wanttype since database already branded to $oldtype")
Branch: 1 branch
BranchTrueFalseTotal
unless $oldtype eq $wanttype 0 2 2
325 unless($oldtype eq $wanttype);
326 }
327 else {
328 2 ▶ print "fixing identifierClass as $wanttype\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 2 2
329 2 my $ichdl = $self->stmtHdl("INSERT INTO admin VALUES (?, ?);", "fix identifier class statement");
330 2 ▶ $ichdl->execute($ickey, $wanttype)
Branch: 1 branch
BranchTrueFalseTotal
$ichdl->execute($ickey, $wanttype) or croak('Could not execute fix identifier class statement: ' . $ichdl->errstr) 2 0 2
331 or croak("Could not execute fix identifier class statement: ".$ichdl->errstr);
332 2 $self->{identifierClass} = $options{identifierClass};
333 };
334 }
335 ▶ elsif ( (exists $options{identifierClass}) and (not $options{identifierClass}) ) {
Condition66%2/3
exists $options{"identifierClass"} and not $options{"identifierClass"}
!ll&&!rl&&r
202
MC/DC50%1/2
exists $options{"identifierClass"} and not $options{"identifierClass"}
exists $options{"identifierClass"} not $options{"identifierClass"}
Truth table66%2/3
A and not(B)
A= exists $options{"identifierClass"}B= not $options{"identifierClass"}
ABresult
0X0
100
111
336 2 ▶ print "removing fixed identifierClass from admin table\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 2 2
337 2 my $ichdl = $self->stmtHdl("DELETE FROM admin WHERE key=?;", "identifier class statement");
338 2 ▶ $ichdl->execute($ickey)
Branch: 1 branch
BranchTrueFalseTotal
$ichdl->execute($ickey) or croak('Could not execute remove identifier class statement: ' . $ichdl->errstr) 2 0 2
339 or croak("Could not execute remove identifier class statement: ".$ichdl->errstr);
340 2 delete $self->{identifierClass};
341 };
342  
343 8 my $rikey = "REDIRECTION_INDEX";
344 8 ▶ if ( exists $options{prepareRedirs} or exists $admref->{$rikey} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $options{"prepareRedirs"} or exists $admref->{$rikey}) 0 8 8
Condition33%1/3
exists $options{"prepareRedirs"} or exists $admref->{$rikey}
l!l&&r!l&&!r
008
MC/DC0%0/2
exists $options{"prepareRedirs"} or exists $admref->{$rikey}
exists $options{"prepareRedirs"} exists $admref->{$rikey}
Truth table33%1/3
A or B
A= exists $options{"prepareRedirs"}B= exists $admref->{$rikey}
ABresult
1X1
011
000
345 0 my $rihdl = $self->stmtHdl("INSERT OR REPLACE INTO admin VALUES (?, ?);", "fix redirection index statement");
346 0 ▶ if ( $options{prepareRedirs} or ( $admref->{$rikey} and not exists $options{prepareRedirs} ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($options{'prepareRedirs'} or $admref->{$rikey} and not exists $options{'prepareRedirs'}) { } 0 0 0
elsif (not $admref->{$rikey} && ($options{'prepareRedirs'} || !exists $options{'prepareRedirs'})) { } 0 0 0
Condition0%0/6
$options{"prepareRedirs"} or $admref->{$rikey} and not exists $options{"prepareRedirs"}
l!l&&r!l&&!r
000
$admref->{$rikey} and not exists $options{"prepareRedirs"}
!ll&&!rl&&r
000
MC/DC0%0/3
$options{"prepareRedirs"} or $admref->{$rikey} and not exists $options{"prepareRedirs"}
$options{"prepareRedirs"} $admref->{$rikey} not exists $options{"prepareRedirs"}
Truth table0%0/4
A or B and not(C)
A= $options{"prepareRedirs"}B= $admref->{$rikey}C= not exists $options{"prepareRedirs"}
ABCresult
1XX1
0111
00X0
0100
347 0 ▶ print "creating redirection index\n" if $options{prepareRedirs} and $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"prepareRedirs"} and $options{"verbose"} 0 0 0
Condition0%0/3
$options{"prepareRedirs"} and $options{"verbose"}
!ll&&!rl&&r
000
MC/DC0%0/2
$options{"prepareRedirs"} and $options{"verbose"}
$options{"prepareRedirs"} $options{"verbose"}
Truth table0%0/3
A and B
A= $options{"prepareRedirs"}B= $options{"verbose"}
ABresult
0X0
100
111
348 0 ▶ $hdl->do("CREATE INDEX IF NOT EXISTS redir ON beacons(altid,seqno);") or croak("Setup error: ".$hdl->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("CREATE INDEX IF NOT EXISTS redir ON beacons(altid,seqno);") or croak('Setup error: ' . $hdl->errstr) 0 0 0
349 0 ▶ $rihdl->execute($rikey, 1)
Branch: 1 branch
BranchTrueFalseTotal
$rihdl->execute($rikey, 1) or croak('Could not execute fix redirection index: ' . $rihdl->errstr) 0 0 0
350 or croak("Could not execute fix redirection index: ".$rihdl->errstr);
351 }
352 ▶ elsif ( not( $admref->{$rikey} and ($options{prepareRedirs} or (not exists $options{prepareRedirs})) ) ) {
Condition0%0/6
$admref->{$rikey} && ($options{'prepareRedirs'} || !exists $options{'prepareRedirs'})
!ll&&!rl&&r
000
$options{"prepareRedirs"} or not exists $options{"prepareRedirs"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$admref->{$rikey} && ($options{'prepareRedirs'} || !exists $options{'prepareRedirs'})
$admref->{$rikey} $options{"prepareRedirs"} not exists $options{"prepareRedirs"}
Truth table0%0/4
A && B or not(C)
A= $admref->{$rikey}B= $options{"prepareRedirs"}C= not exists $options{"prepareRedirs"}
ABCresult
0XX0
1000
11X1
1011
353 0 ▶ print "dropping redirection index\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 0 0
354 0 ▶ $hdl->do("DROP INDEX IF EXISTS redir;") or croak("Setup error: ".$hdl->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("DROP INDEX IF EXISTS redir;") or croak('Setup error: ' . $hdl->errstr) 0 0 0
355 0 ▶ $rihdl->execute($rikey, 0)
Branch: 1 branch
BranchTrueFalseTotal
$rihdl->execute($rikey, 0) or croak('Could not execute fix redirection index: ' . $rihdl->errstr) 0 0 0
356 or croak("Could not execute fix redirection index: ".$rihdl->errstr);
357 };
358 # $admref = $self->admhash();
359 }
360  
361 8 ▶ print "[ANALYZE ..." if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 8 8
362 8 $hdl->do("ANALYZE;");
363 8 ▶ print "]\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 8 8
364 8 return 1; # o.k.
365 };
366  
367  
368 =head3 deflate()
369  
370 Maintenance action: performs VACCUUM, REINDEX and ANALYZE on the database
371  
372 =cut
373  
374 1 ▶sub deflate {
Subroutine deflate: called CC=5 SCAR=16.6
Pod documented
375 1 my ($self) = @_;
376 1 ▶ my $hdl = $self->{dbh} or croak("no handle?");
Branch: 1 branch
BranchTrueFalseTotal
my $hdl = $self->{"dbh"} or croak("no handle?") 1 0 1
377 1 local $hdl->{AutoCommit} = 1;
378 1 print "VACUUM\n";
379 1 ▶ $hdl->do("VACUUM") or carp("could not VACUUM: Skipping...");
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("VACUUM") or carp("could not VACUUM: Skipping...") 1 0 1
380 1 print "REINDEX\n";
381 1 ▶ $hdl->do("REINDEX") or croak("could not REINDEX: Abort");
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("REINDEX") or croak("could not REINDEX: Abort") 1 0 1
382 1 print "ANALYZE\n";
383 1 ▶ $hdl->do("ANALYZE;") or croak("could not ANALYZE: Abort");
Branch: 1 branch
BranchTrueFalseTotal
$hdl->do("ANALYZE;") or croak("could not ANALYZE: Abort") 1 0 1
384 1 return 1;
385 }
386  
387  
388 =head2 Handling of beacon files
389  
390 =head3 loadFile ( $file, $fields, %options )
391  
392 Reads a physical beacon file and stores it with a new Sequence number in the
393 database.
394  
395 Returns a triple:
396  
397 my ($seqno, $rec_ok, $message) = loadFile ( $file, $fields, %options )
398  
399 $seqno is undef on error
400  
401 $seqno and $rec_ok are zero with $message containing an explanation in case
402 of no action taken.
403  
404 $seqno is an positive integer if something was loaded: The L<Sequence Number>
405 (internal unique identifier) for the representation of the beacon file in
406 the database.
407  
408 =over 8
409  
410 =item $file
411  
412 File to read: Must be a beacon file
413  
414 =item $fields
415  
416 Hashref with additional meta and admin fields to store
417  
418 =item Supported options:
419  
420 verbose => (0|1)
421 force => (0|1) process unconditionally without timestamp comparison
422 nostat => (0|1) don't refresh global identifier counters
423  
424 =back
425  
426 If the file does not contain a minimal correct header (eg. is an empty file
427 or an HTML error page accidentaly caught) no action is performed.
428  
429 Otherwise, a fresh SeqNo (sequence number) is generated and meta and
430 BEACON-Lines are stored in the appropriate tables in the database.
431  
432 If the _alias field is provided, existing database entries for this
433 Alias are updated, identifiers not accounted for any more are
434 eventually discarded.
435  
436 =cut
437  
438 14 ▶sub loadFile {
Subroutine loadFile: called CC=132 SCAR=68.7
Pod documented
439 14 my ($self, $file, $fields, %options) = @_;
440 14 ▶ $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options{"verbose"} 1 13 14
441 14 ▶ $options{'verbose'} ||= 0;
Condition100%2/2
$options{"verbose"} ||= 0
l!l
95
MC/DC100%1/1
$options{"verbose"} ||= 0
$options{"verbose"}
Truth table100%2/2
A
A= $options{"verbose"}
Aresult
11
00
442  
443 14 ▶ if ( ! $file ) {
Branch: 4 branches
BranchTrueFalseTotal
if (not $file) { } 0 14 14
elsif (not -e $file) { } 0 14 14
elsif (not -r _) { } 0 14 14
elsif (-z _) { } 0 14 14
444 0 croak("Missing file argument")}
445 elsif ( ! -e $file ) {
446 0 ▶ print "ERROR: no such file $file\n" && return undef}
Condition0%0/2
"ERROR: no such file $file\n" && (return undef)
!ll
00
MC/DC0%0/1
"ERROR: no such file $file\n" && (return undef)
"ERROR: no such file $file\n"
Truth table0%0/2
A
A= "ERROR: no such file $file\n"
Aresult
00
11
447 elsif ( ! -r _ ) {
448 0 ▶ print "ERROR: no read permissions for $file\n" && return undef}
Condition0%0/2
"ERROR: no read permissions for $file\n" && (return undef)
!ll
00
MC/DC0%0/1
"ERROR: no read permissions for $file\n" && (return undef)
"ERROR: no read permissions for $file\n"
Truth table0%0/2
A
A= "ERROR: no read permissions for $file\n"
Aresult
00
11
449 elsif ( -z _ ) {
450 0 print "WARNING: empty file $file\n";
451 0 return (0,0, "empty file: Will not process");
452 }
453 14 my $mtime = (stat(_))[9];
454 14 ▶ open(BKN, "<:utf8", $file) or (print "ERROR: cannot read $file\n", return undef);
Branch: 1 branch
BranchTrueFalseTotal
open BKN, "<:utf8", $file or print "ERROR: cannot read $file\n", (return undef) 14 0 14
455 14 local($.) = 0;
456  
457 14 ▶ unless ( defined $self->{identifierClass} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"identifierClass"}) 14 0 14
458 14 my $package = $self->autoIdentifier();
459 14 ▶ $options{'verbose'} && ref($package) && print "Assuming identifiers of type ".ref($package)."\n";
Branch: 1 branch
BranchTrueFalseTotal
$options{"verbose"} and ref $package and print 'Assuming identifiers of type ' . ref($package) . "\n" 0 14 14
Condition66%2/3
$options{"verbose"} and ref $package
!ll&&!rl&&r
590
MC/DC0%0/2
$options{"verbose"} and ref $package
$options{"verbose"} ref $package
Truth table66%2/3
A and B
A= $options{"verbose"}B= ref $package
ABresult
0X0
100
111
460 };
461  
462 14 ▶ $fields = {} unless $fields;
Branch: 1 branch
BranchTrueFalseTotal
unless $fields 0 14 14
463 14 ▶ $fields->{'_ftime'} ||= time();
Condition50%1/2
$fields->{"_ftime"} ||= time
l!l
014
MC/DC0%0/1
$fields->{"_ftime"} ||= time
$fields->{"_ftime"}
Truth table50%1/2
A
A= $fields->{"_ftime"}
Aresult
11
00
464 14 ▶ $fields->{'_mtime'} ||= $mtime;
Condition66%2/3
$fields->{"_mtime"} ||= $mtime
l!l&&r!l&&!r
1220
MC/DC0%0/2
$fields->{"_mtime"} ||= $mtime
$fields->{"_mtime"} $mtime
Truth table66%2/3
A ||= B
A= $fields->{"_mtime"}B= $mtime
ABresult
1X1
011
000
465 14 ▶ delete $fields->{_uri} unless $fields->{_uri};
Branch: 1 branch
BranchTrueFalseTotal
unless $fields->{"_uri"} 1 13 14
466 14 ▶ delete $fields->{_alias} unless $fields->{_alias};
Branch: 1 branch
BranchTrueFalseTotal
unless $fields->{"_alias"} 0 14 14
467 14 ▶ my $autopurge = $fields->{_alias} || "";
Condition50%1/2
$fields->{'_alias'} || ''
l!l
140
MC/DC0%0/1
$fields->{'_alias'} || ''
$fields->{'_alias'}
Truth table50%1/2
A
A= $fields->{'_alias'}
Aresult
11
00
468 14 ▶ my $showme = $fields->{_alias} || $fields->{_uri} || $file;
Condition33%2/6
$fields->{'_alias'} || $fields->{'_uri'} || $file
l!l&&r!l&&!r
1400
$fields->{"_alias"} or $fields->{"_uri"}
l!l&&r!l&&!r
1400
MC/DC0%0/3
$fields->{'_alias'} || $fields->{'_uri'} || $file
$fields->{"_alias"} $fields->{"_uri"} $file
Truth table25%1/4
A or B || C
A= $fields->{"_alias"}B= $fields->{"_uri"}C= $file
ABCresult
1XX1
01X1
0011
0000
469  
470 14 ▶ if ( $options{'verbose'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"verbose"}) 9 5 14
471 9 ▶ printf("* Loading %s from URI %s\n", $fields->{_alias} || "<no alias>", $fields->{_uri} || "<direct file>");
Condition50%2/4
$fields->{'_alias'} || '<no alias>'
l!l
90
$fields->{'_uri'} || '<direct file>'
l!l
90
MC/DC0%0/1
$fields->{'_alias'} || '<no alias>'
$fields->{'_alias'}
MC/DC0%0/1
$fields->{'_uri'} || '<direct file>'
$fields->{'_uri'}
Truth table50%1/2
A
A= $fields->{'_alias'}
Aresult
11
00
Truth table50%1/2
A
A= $fields->{'_uri'}
Aresult
11
00
472 9 printf("* local input %s (%s)\n", $file, SeeAlso::Source::BeaconAggregator::tToISO($mtime));
473 };
474  
475 14 my ($collno, $inserthandle, $replacehandle, $err, $format);
476 14 my ($linecount, $headerseen, $oseq) = (0, 0, 0);
477 14 my ($reccount, $recill, $recign, $recnil, $recupd, $recnew, $recdupl, $recdel) = (0, 0, 0, 0, 0, 0, 0, 0);
478 14 local($_);
479 lines:
480 14 ▶ while ( <BKN> ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline BKN)) 174 14 188
481 188 s/[ \x0d\x0a]+$//;
482 188 ▶ unless ( $linecount++ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($linecount++) 14 174 188
483 14 ▶ if ( s/^\x{FEFF}// ) { # BOM-Character
Branch: 2 branches
BranchTrueFalseTotal
if (s/^\x{FEFF}//) { } 0 14 14
elsif (s/^\xef\xbb\xbf//) { } 0 14 14
484 }
485 elsif ( s/^\xef\xbb\xbf// ) { # BOM-Bytes
486 0 print "ERROR: cannot cope with doubly UTF-8 encoded $file\n";
487 0 return (undef, undef, "encoding trouble")};
488 14 ▶ if ( /^\s*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^\s*$/) 0 14 14
489 0 print "WARNING: Discarding blank line before beacon header [$showme l.$.]\n";
490 0 next;
491 };
492 };
493 188 ▶ if ( not defined $collno ) { # $collno used as flag: "still in header"
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $collno) { } 103 85 188
494 103 ▶ if ( /^#\s*([A-Z][\w-]*):\s*(.*)$/ ) {
Branch: 4 branches
BranchTrueFalseTotal
if (/^#\s*([A-Z][\w-]*):\s*(.*)$/) { } 87 16 103
elsif (/^(#[^:\s]+)/) { } 0 16 16
elsif (/^\s*$/) { } 2 14 16
elsif (not $headerseen) { } 0 14 14
495 87 $headerseen++;
496 87 my ($field, $data) = ($1, $2);
497 87 ▶ $field =~ s/^DATE$/TIMESTAMP/ && print "WARNING: corrected DATE to TIMESTAMP in Beacon-Header [$showme l.$.]\n";
Branch: 1 branch
BranchTrueFalseTotal
$field =~ s/^DATE$/TIMESTAMP/ and print "WARNING: corrected DATE to TIMESTAMP in Beacon-Header [$showme l.$.]\n" 0 87 87
498 87 $data =~ s/\s+$//;
499 87 ▶ next if $data =~ /^\s*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $data =~ /^\s*$/ 0 87 87
500 87 ▶ if ( SeeAlso::Source::BeaconAggregator->beaconfields($field) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ('SeeAlso::Source::BeaconAggregator'->beaconfields($field)) { } 81 6 87
501 81 ▶ if ( $fields->{$field} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fields->{$field}) { } 0 81 81
502 0 print "WARNING: Skipping already set $field [$showme l.$.]\n"}
503 else {
504 81 $fields->{$field} = $data}
505 }
506 else {
507 6 print "WARNING: Ignoring unknown $field [$data] [$showme l.$.]\n";
508 };
509 }
510 elsif ( /^(#[^:\s]+)/ ) {
511 0 print "WARNING: Discarding unparseable line >$1...< in beacon header context [$showme l.$.]\n"}
512 elsif ( /^\s*$/ ) {
513 2 ▶ print "NOTICE: Discarding blank line in beacon header context [$showme l.$.]\n" if $options{'verbose'}}
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 2 0 2
514 elsif ( ! $headerseen ) {
515 0 print "ERROR: no header fields [$showme l.$.]\n";
516 0 return (0, 0, "no header fields: Will not proceed");
517 }
518 else {
519 14 ($collno, $err, $format, $inserthandle, $replacehandle, $oseq) = $self->processbeaconheader($fields, %options);
520 14 ▶ unless ( $collno ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($collno) 0 14 14
521 0 print "ERROR: metadata error [$showme l.$.]\n";
522 0 return (0, 0, "metadata error: $err");
523 };
524 14 $self->{dbh}->{AutoCommit} = 0;
525 14 $linecount --;
526 14 redo lines;
527 }
528 }
529 else {
530 85 s/^\s+//; s/\s+$//;
531 85 my ($id, $altid, @rest);
532 85 ($id, @rest) = split(/\s*\|\s*/, $_, 4);
533 85 ▶ ($id, $altid) = split(/\s*=\s*/, $id, 2) if $id;
Branch: 1 branch
BranchTrueFalseTotal
if $id 85 0 85
534 85 ▶ $id || ($recnil++, next);
Branch: 1 branch
BranchTrueFalseTotal
$id or ++$recnil, next 85 0 85
535  
536 85 ▶ if ( $options{'filter'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"filter"}) 28 57 85
537 28 ($id, $altid) = &{$options{'filter'}}($id, $altid, @rest);
538 28 ▶ unless ( $id ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($id) 14 14 28
539 14 $recign ++;
540 14 ▶ unless ( ++$reccount % 10000 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (++$reccount % 10000) 0 14 14
541 0 $self->{dbh}->{AutoCommit} = 1;
542 0 ▶ print "$reccount\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 0 0
543 0 $self->{dbh}->{AutoCommit} = 0;
544 };
545 14 next lines;
546 };
547 };
548 71 ▶ $altid ||= "";
Condition100%2/2
$altid ||= ""
l!l
2744
MC/DC100%1/1
$altid ||= ""
$altid
Truth table100%2/2
A
A= $altid
Aresult
11
00
549  
550 71 my($hits, $info, $link);
551 71 ▶ if ( @rest && ($rest[$#rest] =~ m!^\S+://\S+$!) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@rest and $rest[$#rest] =~ m[^\S+://\S+$]) { } 27 44 71
elsif (defined $rest[2]) { } 0 44 44
Condition100%3/3
@rest and $rest[$#rest] =~ m[^\S+://\S+$]
!ll&&!rl&&r
113327
MC/DC100%2/2
@rest and $rest[$#rest] =~ m[^\S+://\S+$]
@rest $rest[$#rest] =~ m[^\S+://\S+$]
Truth table100%3/3
A and B
A= @restB= $rest[$#rest] =~ m[^\S+://\S+$]
ABresult
0X0
100
111
552 27 $link = pop @rest}
553 elsif ( defined $rest[2] ) {
554 0 print "WARNING: unparseable link content >$rest[2]< [$showme l.$.]"};
555  
556 71 ▶ if ( @rest && ($rest[0] =~ /^\d*$/) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (@rest and $rest[0] =~ /^\d*$/) { } 13 58 71
elsif (defined $rest[1]) { } 2 56 58
elsif (defined $rest[0]) { } 45 11 56
Condition100%3/3
@rest and $rest[0] =~ /^\d*$/
!ll&&!rl&&r
114713
MC/DC100%2/2
@rest and $rest[0] =~ /^\d*$/
@rest $rest[0] =~ /^\d*$/
Truth table100%3/3
A and B
A= @restB= $rest[0] =~ /^\d*$/
ABresult
0X0
100
111
557 13 $hits = shift @rest;
558 # really disregard hits with explicit 0?
559 13 ▶ if ( (!$altid) and (!$link) and ($format =~ /\baltTARGET\b/) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $altid || $link and $format =~ /\baltTARGET\b/) { } 2 11 13
Condition83%5/6
not $altid || $link and $format =~ /\baltTARGET\b/
!ll&&!rl&&r
922
$altid || $link
l!l&&r!l&&!r
094
MC/DC66%2/3
not $altid || $link and $format =~ /\baltTARGET\b/
$altid $link $format =~ /\baltTARGET\b/
Truth table75%3/4
not(A || B) and C
A= $altidB= $linkC= $format =~ /\baltTARGET\b/
ABCresult
1XX0
01X0
0000
0011
560 2 ▶ $altid = shift @rest || "";
Condition50%1/2
shift @rest || ''
l!l
20
MC/DC0%0/1
shift @rest || ''
shift @rest
Truth table50%1/2
A
A= shift @rest
Aresult
11
00
561 }
562 else {
563 11 ▶ $info = shift @rest || "";
Condition100%2/2
shift @rest || ''
l!l
92
MC/DC100%1/1
shift @rest || ''
shift @rest
Truth table100%2/2
A
A= shift @rest
Aresult
11
00
564 };
565 }
566 elsif ( defined $rest[1] ) {
567 2 $hits = "";
568 2 ▶ if ( (!$altid) and (!$link) and ($format =~ /\baltTARGET\b/) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $altid || $link and $format =~ /\baltTARGET\b/) { } 2 0 2
Condition33%2/6
not $altid || $link and $format =~ /\baltTARGET\b/
!ll&&!rl&&r
002
$altid || $link
l!l&&r!l&&!r
002
MC/DC0%0/3
not $altid || $link and $format =~ /\baltTARGET\b/
$altid $link $format =~ /\baltTARGET\b/
Truth table25%1/4
not(A || B) and C
A= $altidB= $linkC= $format =~ /\baltTARGET\b/
ABCresult
1XX0
01X0
0000
0011
569 2 $info = shift @rest;
570 2 $altid = shift @rest;
571 }
572 else {
573 0 shift @rest;
574 0 $info = shift @rest;
575 };
576 }
577 elsif ( defined $rest[0] ) {
578 45 $hits = "";
579 45 $info = shift @rest;
580 };
581 71 ▶ if ( @rest ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@rest) 0 71 71
582 0 print "WARNING: unparseable content >$_< [$showme l.$.]"};
583  
584 71 ▶ unless ( $link ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($link) 44 27 71
585 44 ▶ if ( ($format =~ /\bhasTARGET\b/) ) { # ok
Branch: 3 branches
BranchTrueFalseTotal
if ($format =~ /\bhasTARGET\b/) { } 40 4 44
elsif ($format =~ /\baltTARGET\b/) { } 4 0 4
elsif ($format =~ /\bnoTARGET\b/) { } 0 0 0
586 }
587 elsif ( $format =~ /\baltTARGET\b/ ) {
588 4 ▶ if ( $altid ) { # also ok
Branch: 2 branches
BranchTrueFalseTotal
if ($altid) { } 4 0 4
elsif ($info) { } 0 0 0
589 }
590 elsif ( $info ) { # too strange
591 0 ▶ print "WARNING: discarding >$id<".(defined $hits ? " ($hits)" : "")." for $info without link [$showme l.$.] (assertion failed)\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $hits ? : 0 0 0
592 0 $recill++;
593 0 next lines;
594 }
595 else { # feed id as altid
596 0 $altid = $id}
597 }
598 elsif ( $format =~ /\bnoTARGET\b/ ) {
599 0 ▶ print "NOTICE: discarding >$id<".(defined $hits ? " ($hits)" : "")." without link [$showme l.$.]\n" if $options{'verbose'} > 1;
Branch: 2 branches
BranchTrueFalseTotal
if $options{"verbose"} > 1 0 0 0
defined $hits ? : 0 0 0
600 0 $recill++;
601 0 next lines;
602 }
603 else {
604 0 ▶ print "WARNING: discarding >$id<".(defined $hits ? " ($hits)" : "")." without link [$showme l.$.] (assertion failed)\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $hits ? : 0 0 0
605 0 $recill++;
606 0 next lines;
607 }
608 };
609  
610 71 ▶ if ( $format !~ /\baltTARGET\b/ ) { # Allow certain duplicates (force disambiguisation)
Branch: 1 branch
BranchTrueFalseTotal
unless ($format =~ /\baltTARGET\b/) 4 67 71
611 4 ▶ $altid ||= $info || $link}
Condition33%2/6
$altid ||= $info || $link
l!l&&r!l&&!r
004
$info || $link
l!l&&r!l&&!r
004
MC/DC0%0/3
$altid ||= $info || $link
$altid $info $link
Truth table0%0/4
A ||= B || C
A= $altidB= $infoC= $link
ABCresult
1XX1
01X1
0011
0000
612  
613 71 ▶ $hits = "" unless defined $hits;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $hits 11 60 71
614 71 ▶ ($hits =~ /^0+/) && ($recnil++, next); # Explizit "0" => raus
Branch: 1 branch
BranchTrueFalseTotal
$hits =~ /^0+/ and ++$recnil, next 0 71 71
615 71 ▶ $hits = 0 if $hits eq "";
Branch: 1 branch
BranchTrueFalseTotal
if $hits eq "" 60 11 71
616 71 ▶ $altid ||= "";
Condition100%2/2
$altid ||= ""
l!l
3140
MC/DC100%1/1
$altid ||= ""
$altid
Truth table100%2/2
A
A= $altid
Aresult
11
00
617 71 my $hash;
618 71 ▶ if ( defined $self->{identifierClass} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'identifierClass'}) { } 0 71 71
619 0 $self->{identifierClass}->value($id);
620 0 ▶ unless ( $self->{identifierClass}->valid ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"identifierClass"}->valid) 0 0 0
621 0 ▶ print "NOTICE: invalid identifier >$id< ($hits) [$showme l.$.]\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 0 0
622 0 $recill++;
623 0 next lines;
624 };
625 0 $hash = $self->{identifierClass}->hash();
626 }
627 else {
628 71 $hash = $id};
629 71 my $did;
630 71 ▶ if ( $replacehandle && ($did = $replacehandle->execute($hits, $info, $link, $hash, $altid)) ) { # UPDATE OR FAIL old record
Branch: 3 branches
BranchTrueFalseTotal
if ($replacehandle and $did = $replacehandle->execute($hits, $info, $link, $hash, $altid)) { } 40 31 71
elsif ($did = $inserthandle->execute($hash, $altid, $hits, $info, $link)) { } 31 0 31
elsif ($inserthandle->errstr =~ /constraint/) { } 0 0 0
Condition66%2/3
$replacehandle and $did = $replacehandle->execute($hits, $info, $link, $hash, $altid)
!ll&&!rl&&r
31040
MC/DC50%1/2
$replacehandle and $did = $replacehandle->execute($hits, $info, $link, $hash, $altid)
$replacehandle $did = $replacehandle->execute($hits, $info, $link, $hash, $altid)
Truth table66%2/3
A and B
A= $replacehandleB= $did = $replacehandle->execute($hits, $info, $link, $hash, $altid)
ABresult
0X0
100
111
631 40 ▶ if ( $replacehandle->err ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($replacehandle->err) { } 0 40 40
elsif ($did eq '0E0') { } 28 12 40
632 0 carp("update in trouble: $replacehandle->errstring [$showme l.$.]");
633 0 $recdupl++;
634 }
635 elsif ( $did eq "0E0" ) { # not found, try insert
636 28 $did = $inserthandle->execute($hash, $altid, $hits, $info, $link);
637 28 ▶ if ( $did eq "0E0" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($did eq '0E0') { } 10 18 28
638 10 $recdupl++;
639 10 ▶ if ( $altid ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($altid) { } 0 10 10
640 0 ▶ print "INFO: did not insert duplicate Id >$id< = >$altid< ($hits) [$showme l.$.]\n" if $options{'verbose'}}
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 0 0
641 else {
642 10 ▶ print "INFO: did not insert duplicate Id >$id< ($hits) [$showme l.$.]\n" if $options{'verbose'} > 1};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} > 1 0 10 10
643 }
644 else {
645 18 $recnew++};
646 }
647 else {
648 12 $recupd++};
649 }
650 elsif ( $did = $inserthandle->execute($hash, $altid, $hits, $info, $link) ) { # INSERT OR IGNORE new record
651 31 ▶ if ( $did eq "0E0" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($did eq '0E0') { } 9 22 31
652 9 $recdupl++;
653 9 ▶ print "INFO: did not insert duplicate Id $id ($hits) [$showme l.$.]\n" if $options{'verbose'} > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} > 1 0 9 9
654 }
655 else {
656 22 $recnew++};
657 }
658 elsif ( $inserthandle->errstr =~ /constraint/ ) {
659 0 $recdupl++;
660 0 ▶ print "INFO: duplicate Id $id ($hits): not inserting [$showme l.$.]\n" if $options{'verbose'} > 1;
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} > 1 0 0 0
661 }
662 else {
663 0 croak("Could not insert: ($id, $hits, $info, $link): ".$inserthandle->errstr)};
664  
665 71 ▶ unless ( ++$reccount % 10000 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (++$reccount % 10000) 0 71 71
666 0 $self->{dbh}->{AutoCommit} = 1;
667 0 ▶ print "$reccount\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 0 0
668 0 $self->{dbh}->{AutoCommit} = 0;
669 };
670 }
671 };
672 14 ▶ if ( not defined $collno ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $collno) 0 14 14
673 0 ▶ if ( $headerseen ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($headerseen) { } 0 0 0
elsif ($.) { } 0 0 0
674 0 ($collno, $err, $format, $inserthandle, $replacehandle, $oseq) = $self->processbeaconheader($fields, %options);
675 0 ▶ if ( $collno ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($collno) { } 0 0 0
676 0 print "WARNING: no idn content in file [$showme l.$.]\n"}
677 else {
678 0 print "ERROR: metadata error [$showme l.$.]\n";
679 0 return (0,0, "metadata error: $err");
680 };
681 }
682 elsif ( $. ) {
683 0 print "ERROR: no header fields [$showme l.$.]\n";
684 0 return (0, 0, "no header fields: Will not proceed");
685 }
686 else {
687 0 print "WARNING: empty file [$showme]\n";
688 0 return (0,0, "empty file");
689 };
690 }
691 14 $self->{dbh}->{AutoCommit} = 1;
692  
693 14 ▶ if ( $autopurge ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($autopurge) 14 0 14
694 14 $self->{dbh}->{AutoCommit} = 0;
695 14 ▶ if ( $oseq ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($oseq) 8 6 14
696 8 my ($bcdelh, $bcdelexpl) = $self->stmtHdl("DELETE FROM beacons WHERE seqno==?");
697 8 ▶ $self->stmtExplain($bcdelexpl, $oseq) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 8 8
698 8 ▶ my $rows = $bcdelh->execute($oseq) or croak("Could not execute >".$bcdelh->{Statement}."<: ".$bcdelh->errstr);
Branch: 1 branch
BranchTrueFalseTotal
my $rows = $bcdelh->execute($oseq) or croak('Could not execute >' . $bcdelh->{"Statement"} . '<: ' . $bcdelh->errstr) 8 0 8
699 8 $self->{dbh}->{AutoCommit} = 1;
700 8 ▶ printf("INFO: Purged %s surplus identifiers from old sequence %u\n", $rows, $oseq) if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 4 4 8
701 8 ▶ $rows = "0" if $rows eq "0E0";
Branch: 1 branch
BranchTrueFalseTotal
if $rows eq "0E0" 5 3 8
702 8 $recdel += $rows;
703 };
704  
705 14 $self->{dbh}->{AutoCommit} = 0;
706 14 my ($rpdelh, $rpdelexpl) = $self->stmtHdl("DELETE FROM repos WHERE (alias=?) AND (seqno<?);");
707 14 ▶ $self->stmtExplain($rpdelexpl, $autopurge, $collno) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 14 14
708 14 ▶ my $rows = $rpdelh->execute($autopurge, $collno) or croak("Could not execute >".$rpdelh->{Statement}."<: ".$rpdelh->errstr);
Branch: 1 branch
BranchTrueFalseTotal
my $rows = $rpdelh->execute($autopurge, $collno) or croak('Could not execute >' . $rpdelh->{"Statement"} . '<: ' . $rpdelh->errstr) 14 0 14
709 14 $self->{dbh}->{AutoCommit} = 1;
710 14 ▶ $rows = "0" if $rows eq "0E0";
Branch: 1 branch
BranchTrueFalseTotal
if $rows eq "0E0" 6 8 14
711 14 ▶ printf("INFO: %u old sequences discarded\n", $rows) if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 9 5 14
712 }
713  
714 14 ▶ printf "NOTICE: New sequence %u for %s: processed %u Records from %u lines\n",
Condition50%1/2
$autopurge || '???'
l!l
140
MC/DC0%0/1
$autopurge || '???'
$autopurge
Truth table50%1/2
A
A= $autopurge
Aresult
11
00
715 $collno, $autopurge || "???", $reccount, $linecount;
716 14 my $statline = sprintf "%u replaced, %u new, %u deleted, %u duplicate, %u nil, %u invalid, %u ignored",
717 $recupd, $recnew, $recdel, $recdupl, $recnil, $recill, $recign;
718 14 print " ($statline)\n";
719  
720 14 my $recok = $recupd + $recnew;
721 14 ▶ my $numchg = ($recnew or $recdel) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$recnew || $recdel ? : 12 2 14
Condition100%3/3
$recnew or $recdel
l!l&&r!l&&!r
1112
MC/DC100%2/2
$recnew or $recdel
$recnew $recdel
Truth table100%3/3
A or B
A= $recnewB= $recdel
ABresult
1X1
011
000
722  
723 # my $ct1hdl = $self->stmtHdl("SELECT COUNT(*) FROM beacons WHERE seqno==? LIMIT 1;");
724 # $ct1hdl->execute($collno) or croak("could not execute live count: ".$ct1hdl->errstr);
725 # my $ct1ref = $ct1hdl->fetchrow_arrayref();
726 # my $counti = $ct1ref->[0] || 0;
727  
728 # my $ct2hdl = $self->stmtHdl("SELECT COUNT(DISTINCT hash) FROM beacons WHERE seqno==?");
729 # using subquery to trick SQLite into using indices
730 # my $ct2hdl = $self->stmtHdl("SELECT COUNT(*) FROM (SELECT DISTINCT hash FROM beacons WHERE seqno==?) LIMIT 1;");
731 # $ct2hdl->execute($collno) or croak("could not execute live count: ".$ct2hdl->errstr);
732 # my $ct2ref = $ct2hdl->fetchrow_arrayref();
733 # my $countu = $ct2ref->[0] || 0;
734  
735 # combined query turned out as not as efficient
736 # my $ct0hdl = $self->stmtHdl("SELECT COUNT(*), COUNT(DISTINCT hash) FROM beacons WHERE seqno==? LIMIT 1;");
737 # $ct0hdl->execute($collno) or croak("could not execute live count: ".$ct0hdl->errstr);
738 # my $ct0ref = $ct0hdl->fetchrow_arrayref();
739 # my ($counti, $countu) = ($ct0ref->[0] || 0, $ct0ref->[1] || 0);
740  
741 14 my ($updh, $updexpl) = $self->stmtHdl(<<"XxX");
742 UPDATE OR FAIL repos SET counti=?,countu=?,fstat=?,utime=?,ustat=?,sort=? WHERE seqno==?;
743 XxX
744  
745 14 ▶ my $counti = $self->idStat($collno, 'distinct' => 0) || 0;
Condition50%1/2
$self->idStat($collno, 'distinct', 0) || 0
l!l
140
MC/DC0%0/1
$self->idStat($collno, 'distinct', 0) || 0
$self->idStat($collno, 'distinct', 0)
Truth table50%1/2
A
A= $self->idStat($collno, 'distinct', 0)
Aresult
11
00
746 14 ▶ printf("WARNING: expected %u valid records, counted %u\n", $recok, $counti) if $recok != $counti;
Branch: 1 branch
BranchTrueFalseTotal
if $recok != $counti 0 14 14
747 14 ▶ unless ( $numchg ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($numchg) 2 12 14
748 2 ▶ $fields->{'_counti'} ||= 0;
Condition50%1/2
$fields->{"_counti"} ||= 0
l!l
20
MC/DC0%0/1
$fields->{"_counti"} ||= 0
$fields->{"_counti"}
Truth table50%1/2
A
A= $fields->{"_counti"}
Aresult
11
00
749 2 ▶ printf("WARNING: expected unchanged number %u valid records, counted %u\n", $fields->{'_counti'}, $counti) if $fields->{'_counti'} != $counti;
Branch: 1 branch
BranchTrueFalseTotal
if $fields->{"_counti"} != $counti 0 2 2
750 };
751  
752 14 ▶ my $sort = $fields->{'_sort'} || "";
Condition50%1/2
$fields->{'_sort'} || ''
l!l
014
MC/DC0%0/1
$fields->{'_sort'} || ''
$fields->{'_sort'}
Truth table50%1/2
A
A= $fields->{'_sort'}
Aresult
11
00
753 my $countu = $numchg ? ( $self->idStat($collno, 'distinct' => 1) || 0 )
754 14 ▶ : ( $fields->{'_countu'} || $self->idStat($collno, 'distinct' => 1) || 0 );
Branch: 1 branch
BranchTrueFalseTotal
$numchg ? : 12 2 14
Condition42%3/7
$self->idStat($collno, "distinct", 1) or 0
l!l
120
$fields->{"_countu"} or $self->idStat($collno, "distinct", 1) or 0
l!l
20
$fields->{"_countu"} or $self->idStat($collno, "distinct", 1)
l!l&&r!l&&!r
200
MC/DC0%0/1
$self->idStat($collno, "distinct", 1) or 0
$self->idStat($collno, "distinct", 1)
MC/DC0%0/2
$fields->{"_countu"} or $self->idStat($collno, "distinct", 1) or 0
$fields->{"_countu"} $self->idStat($collno, "distinct", 1)
Truth table50%1/2
A
A= $self->idStat($collno, "distinct", 1)
Aresult
11
00
Truth table33%1/3
A or B
A= $fields->{"_countu"}B= $self->idStat($collno, "distinct", 1)
ABresult
1X1
011
000
755 14 ▶ $self->stmtExplain($updexpl, $counti, $countu, $statline, time(), "successfully loaded", $sort, $collno) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 14 14
756 $updh->execute($counti, $countu, $statline, time(), "successfully loaded", $sort, $collno)
757 14 ▶ or croak("Could not execute >".$updh->{Statement}."<: ".$updh->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$updh->execute($counti, $countu, $statline, time, "successfully loaded", $sort, $collno) or croak('Could not execute >' . $updh->{"Statement"} . '<: ' . $updh->errstr) 14 0 14
758 14 close(BKN);
759  
760 14 ▶ if ( $numchg or $options{'force'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($numchg or $options{"force"}) 14 0 14
Condition66%2/3
$numchg or $options{"force"}
l!l&&r!l&&!r
1220
MC/DC0%0/2
$numchg or $options{"force"}
$numchg $options{"force"}
Truth table66%2/3
A or B
A= $numchgB= $options{"force"}
ABresult
1X1
011
000
761 # if ( $options{'force'} ) {
762 # print "[ANALYZE ..." if $options{'verbose'};
763 # $self->{dbh}->do("ANALYZE;");
764 # print "]\n" if $options{'verbose'};
765 # };
766  
767 14 ▶ if ( $options{'nostat'} ) { # invalidate since they might have changed
Branch: 1 branch
BranchTrueFalseTotal
if ($options{'nostat'}) { } 0 14 14
768 0 $self->admin('gcounti', undef);
769 0 $self->admin('gcountu', undef);
770 }
771 else {
772 14 ▶ $self->admin('gcounti', $self->idStat(undef, 'distinct' => 0) || 0);
Condition50%1/2
$self->idStat(undef, 'distinct', 0) || 0
l!l
140
MC/DC0%0/1
$self->idStat(undef, 'distinct', 0) || 0
$self->idStat(undef, 'distinct', 0)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 0)
Aresult
11
00
773 14 ▶ $self->admin('gcountu', $self->idStat(undef, 'distinct' => 1) || 0);
Condition50%1/2
$self->idStat(undef, 'distinct', 1) || 0
l!l
140
MC/DC0%0/1
$self->idStat(undef, 'distinct', 1) || 0
$self->idStat(undef, 'distinct', 1)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 1)
Aresult
11
00
774 }
775 };
776  
777 14 return ($collno, $recok, undef);
778 }
779  
780  
781 =head4 processbeaconheader($self, $fieldref, [ %options] )
782  
783 Internal subroutine used by C<loadFile()>.
784  
785 =over 8
786  
787 =item $fieldref
788  
789 Hash with raw fields.
790  
791 =item Supported options:
792  
793 verbose => (0|1)
794  
795 Show seqnos of old instances which are met by the alias
796  
797 =back
798  
799  
800 =cut
801  
802 14 ▶sub processbeaconheader {
Subroutine processbeaconheader: called CC=76 SCAR=60.6
Pod documented
803 14 my ($self, $fieldref, %options) = @_;
804 14 my $osq = 0;
805 14 my @carp;
806  
807 14 ▶ if ( my $alias = $fieldref->{_alias} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $alias = $fieldref->{"_alias"}) 14 0 14
808 14 my $stampfield = SeeAlso::Source::BeaconAggregator->beaconfields("TIMESTAMP");
809 14 my ($listh, $listexpl) = $self->stmtHdl("SELECT seqno, $stampfield, mtime, counti, countu FROM repos WHERE alias=?;");
810 14 ▶ $self->stmtExplain($listexpl, $alias) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 14 14
811 14 ▶ $listh->execute($alias) or croak("Could not execute >".$listh->{Statement}."<: ".$listh->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$listh->execute($alias) or croak('Could not execute >' . $listh->{"Statement"} . '<: ' . $listh->errstr) 14 0 14
812 14 my ($rowcnt, $ocounti, $ocountu);
813 14 ▶ while ( my($row) = $listh->fetchrow_arrayref ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my($row) = $listh->fetchrow_arrayref) 22 0 22
814 22 ▶ last unless defined $row;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $row 14 8 22
815 8 $rowcnt ++;
816 8 ($ocounti, $ocountu) = ($row->[3], $row->[4]);
817 8 ▶ if ( $options{'verbose'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{'verbose'}) { } 4 4 8
818 4 ▶ print "* Old Instances for $alias:\n" unless $osq;
Branch: 1 branch
BranchTrueFalseTotal
unless $osq 4 0 4
819 4 $osq = $row->[0];
820 4 ▶ print "+\t#$osq ", SeeAlso::Source::BeaconAggregator::tToISO($row->[1] || $row->[2]), " (", $row->[3] || "???", ")\n";
Condition60%3/5
$row->[1] || $row->[2]
l!l&&r!l&&!r
130
$row->[3] || '???'
l!l
40
MC/DC0%0/2
$row->[1] || $row->[2]
$row->[1] $row->[2]
MC/DC0%0/1
$row->[3] || '???'
$row->[3]
Truth table66%2/3
A || B
A= $row->[1]B= $row->[2]
ABresult
1X1
011
000
Truth table50%1/2
A
A= $row->[3]
Aresult
11
00
821 }
822 else {
823 4 $osq = $row->[0]};
824 }
825 14 ▶ if ( $rowcnt && ($rowcnt == 1) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rowcnt and $rowcnt == 1) 8 6 14
Condition66%2/3
$rowcnt and $rowcnt == 1
!ll&&!rl&&r
608
MC/DC50%1/2
$rowcnt and $rowcnt == 1
$rowcnt $rowcnt == 1
Truth table66%2/3
A and B
A= $rowcntB= $rowcnt == 1
ABresult
0X0
100
111
826 8 ▶ $fieldref->{_counti} ||= $ocounti if $ocounti;
Branch: 1 branch
BranchTrueFalseTotal
if $ocounti 6 2 8
Condition33%1/3
$fieldref->{"_counti"} ||= $ocounti
l!l&&r!l&&!r
060
MC/DC0%0/2
$fieldref->{"_counti"} ||= $ocounti
$fieldref->{"_counti"} $ocounti
Truth table33%1/3
A ||= B
A= $fieldref->{"_counti"}B= $ocounti
ABresult
1X1
011
000
827 8 ▶ $fieldref->{_countu} ||= $ocountu if $ocountu;
Branch: 1 branch
BranchTrueFalseTotal
if $ocountu 6 2 8
Condition33%1/3
$fieldref->{"_countu"} ||= $ocountu
l!l&&r!l&&!r
060
MC/DC0%0/2
$fieldref->{"_countu"} ||= $ocountu
$fieldref->{"_countu"} $ocountu
Truth table33%1/3
A ||= B
A= $fieldref->{"_countu"}B= $ocountu
ABresult
1X1
011
000
828 }
829 };
830  
831 14 my $format = "";
832 14 ▶ if ( $fieldref->{'FORMAT'} && $self->{accept}->{'FORMAT'} ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($fieldref->{'FORMAT'} and $self->{'accept'}{'FORMAT'}) { } 4 10 14
elsif ($fieldref->{'FORMAT'}) { } 8 2 10
elsif ($fieldref->{'VERSION'} or $fieldref->{'TARGET'} or $fieldref->{'PREFIX'} or $fieldref->{'MESSAGE'}) { } 2 0 2
elsif ($self->{'accept'}{'FORMAT'}) { } 0 0 0
Condition100%3/3
$fieldref->{"FORMAT"} and $self->{"accept"}{"FORMAT"}
!ll&&!rl&&r
284
MC/DC100%2/2
$fieldref->{"FORMAT"} and $self->{"accept"}{"FORMAT"}
$fieldref->{"FORMAT"} $self->{"accept"}{"FORMAT"}
Truth table100%3/3
A and B
A= $fieldref->{"FORMAT"}B= $self->{"accept"}{"FORMAT"}
ABresult
0X0
100
111
833 4 ▶ if ( $fieldref->{'FORMAT'} =~ $self->{accept}->{'FORMAT'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fieldref->{'FORMAT'} =~ /$self->{'accept'}{'FORMAT'}/) { } 4 0 4
834 4 $format = $fieldref->{'FORMAT'}}
835 else {
836 0 push(@carp, "ERROR: only FORMAT '".$self->{accept}->{'FORMAT'}."' are supported, this is ".$fieldref->{'FORMAT'})}
837 }
838 elsif ( $fieldref->{'FORMAT'} ) {
839 8 $format = $fieldref->{'FORMAT'}}
840 ▶ elsif ( $fieldref->{'VERSION'} or $fieldref->{'TARGET'} or $fieldref->{'PREFIX'} or $fieldref->{'MESSAGE'} ) {
Condition33%3/9
$fieldref->{"VERSION"} or $fieldref->{"TARGET"} or $fieldref->{"PREFIX"} or $fieldref->{"MESSAGE"}
l!l&&r!l&&!r
200
$fieldref->{"VERSION"} or $fieldref->{"TARGET"} or $fieldref->{"PREFIX"}
l!l&&r!l&&!r
200
$fieldref->{"VERSION"} or $fieldref->{"TARGET"}
l!l&&r!l&&!r
020
MC/DC0%0/4
$fieldref->{"VERSION"} or $fieldref->{"TARGET"} or $fieldref->{"PREFIX"} or $fieldref->{"MESSAGE"}
$fieldref->{"VERSION"} $fieldref->{"TARGET"} $fieldref->{"PREFIX"} $fieldref->{"MESSAGE"}
Truth table20%1/5
A or B or C or D
A= $fieldref->{"VERSION"}B= $fieldref->{"TARGET"}C= $fieldref->{"PREFIX"}D= $fieldref->{"MESSAGE"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
841 2 push(@carp, "WARNING: header line #FORMAT: BEACON should be supplied")}
842 elsif ( $self->{accept}->{'FORMAT'} ) {
843 0 push(@carp, "ERROR: header line #FORMAT is missing")}
844 else {
845 0 push(@carp, "WARNING: header line #FORMAT: BEACON should be supplied")};
846  
847 14 ▶ if ( $fieldref->{'FORMAT'} && ($fieldref->{'FORMAT'} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fieldref->{"FORMAT"} and $fieldref->{"FORMAT"} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i) 0 14 14
Condition66%2/3
$fieldref->{"FORMAT"} and $fieldref->{"FORMAT"} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i
!ll&&!rl&&r
2120
MC/DC0%0/2
$fieldref->{"FORMAT"} and $fieldref->{"FORMAT"} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i
$fieldref->{"FORMAT"} $fieldref->{"FORMAT"} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i
Truth table66%2/3
A and B
A= $fieldref->{"FORMAT"}B= $fieldref->{"FORMAT"} =~ /v(?:ersion)?\s*(\d+(?:\.\d*)?)/i
ABresult
0X0
100
111
848 0 ▶ $fieldref->{'VERSION'} ||= $1};
Condition0%0/3
$fieldref->{"VERSION"} ||= $1
l!l&&r!l&&!r
000
MC/DC0%0/2
$fieldref->{"VERSION"} ||= $1
$fieldref->{"VERSION"} $1
Truth table0%0/3
A ||= B
A= $fieldref->{"VERSION"}B= $1
ABresult
1X1
011
000
849 14 ▶ unless ( $fieldref->{'VERSION'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fieldref->{"VERSION"}) 3 11 14
850 3 ▶ $fieldref->{'VERSION'} = $fieldref->{'FORMAT'} ? "0.1" : "1.0";
Branch: 1 branch
BranchTrueFalseTotal
$fieldref->{'FORMAT'} ? : 1 2 3
851 3 push(@carp, "NOTICE: added header field #VERSION as '".$fieldref->{'VERSION'}."'");
852 };
853 14 ▶ if ( $self->{accept}->{'VERSION'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"accept"}{"VERSION"}) 5 9 14
854 ($fieldref->{'VERSION'} =~ $self->{accept}->{'VERSION'})
855 5 ▶ || push(@carp, "ERROR: only VERSION '".$self->{accept}->{'VERSION'}."' is supported, this is ".$fieldref->{'VERSION'});
Branch: 1 branch
BranchTrueFalseTotal
$fieldref->{"VERSION"} =~ /$self->{"accept"}{"VERSION"}/ or push @carp, q[ERROR: only VERSION '] . $self->{"accept"}{"VERSION"} . q[' is supported, this is ] . $fieldref->{"VERSION"} 5 0 5
856 };
857  
858 14 ▶ if ( $fieldref->{'ALTTARGET'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fieldref->{"ALTTARGET"}) 11 3 14
859 11 ▶ $fieldref->{'ALTTARGET'} = "" unless defined $fieldref->{'ALTTARGET'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fieldref->{"ALTTARGET"} 0 11 11
860 11 my $parsed = hDecode($fieldref, 'ALTTARGET');
861 11 ▶ if ( $parsed && ($parsed =~ /(^|[^%])(%.)*%\d\$s/) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/) { } 11 0 11
elsif ($parsed) { } 0 0 0
Condition33%1/3
$parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/
!ll&&!rl&&r
0011
MC/DC0%0/2
$parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/
$parsed $parsed =~ /(^|[^%])(%.)*%\d\$s/
Truth table33%1/3
A and B
A= $parsedB= $parsed =~ /(^|[^%])(%.)*%\d\$s/
ABresult
0X0
100
111
862 11 $fieldref->{'ALTTARGET'} = $parsed;
863 11 $format =~ s/\s*-altTARGET//;
864 11 $format .= " -altTARGET";
865 11 ▶ ($parsed =~ /(^|[^%])(%.)*%2\$s/) or
Branch: 1 branch
BranchTrueFalseTotal
$parsed =~ /(^|[^%])(%.)*%2\$s/ or push @carp, "WARNING: header field #ALTTARGET should contain placeholder {ALTID}" 11 0 11
866 push(@carp, "WARNING: header field #ALTTARGET should contain placeholder {ALTID}");
867 }
868 elsif ( $parsed ) {
869 0 push(@carp, "ERROR: header field #ALTTARGET must contain placeholder {ALTID} (or {ID})");
870 0 delete $fieldref->{'ALTTARGET'};
871 }
872 else {
873 0 push(@carp, "ERROR: could not parse header field #ALTTARGET: '".$fieldref->{'ALTTARGET'}."'");
874 0 delete $fieldref->{'ALTTARGET'};
875 }
876 };
877  
878 14 ▶ if ( $fieldref->{'IMGTARGET'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fieldref->{"IMGTARGET"}) 0 14 14
879 0 ▶ $fieldref->{'IMGTARGET'} = "" unless defined $fieldref->{'IMGTARGET'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fieldref->{"IMGTARGET"} 0 0 0
880 0 my $parsed = hDecode($fieldref, 'IMGTARGET');
881 0 ▶ if ( $parsed && ($parsed =~ /(^|[^%])(%.)*%\d\$s/) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/) { } 0 0 0
elsif ($parsed) { } 0 0 0
Condition0%0/3
$parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/
!ll&&!rl&&r
000
MC/DC0%0/2
$parsed and $parsed =~ /(^|[^%])(%.)*%\d\$s/
$parsed $parsed =~ /(^|[^%])(%.)*%\d\$s/
Truth table0%0/3
A and B
A= $parsedB= $parsed =~ /(^|[^%])(%.)*%\d\$s/
ABresult
0X0
100
111
882 0 $fieldref->{'IMGTARGET'} = $parsed;
883 0 $format =~ s/\s*-imgTARGET//;
884 0 $format .= " -imgTARGET";
885 }
886 elsif ( $parsed ) {
887 0 push(@carp, "WARNING: header field #IMGTARGET should contain placeholders {ID} or {ALTID}")}
888 else {
889 0 push(@carp, "ERROR: could not parse header field #IMGTARGET: '".$fieldref->{'IMGTARGET'}."'");
890 0 delete $fieldref->{'IMGTARGET'};
891 }
892 };
893  
894 14 ▶ if ( exists $fieldref->{'TARGET'} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $fieldref->{'TARGET'}) { } 14 0 14
elsif ($format =~ /^BEACON/) { } 0 0 0
895 14 ▶ $fieldref->{'TARGET'} = "" unless defined $fieldref->{'TARGET'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fieldref->{"TARGET"} 0 14 14
896 14 my $parsed = hDecode($fieldref, 'TARGET');
897 14 ▶ if ( $parsed && ($parsed =~ /(^|[^%])(%.)*%1\$s/) && ($parsed !~ /(^|[^%])(%.)*%[2-9]\$s/) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($parsed and $parsed =~ /(^|[^%])(%.)*%1\$s/ and not $parsed =~ /(^|[^%])(%.)*%[2-9]\$s/) { } 12 2 14
elsif ($parsed) { } 2 0 2
Condition66%4/6
$parsed and $parsed =~ /(^|[^%])(%.)*%1\$s/ and not $parsed =~ /(^|[^%])(%.)*%[2-9]\$s/
!ll&&!rl&&r
2012
$parsed and $parsed =~ /(^|[^%])(%.)*%1\$s/
!ll&&!rl&&r
0212
MC/DC33%1/3
$parsed and $parsed =~ /(^|[^%])(%.)*%1\$s/ and not $parsed =~ /(^|[^%])(%.)*%[2-9]\$s/
$parsed $parsed =~ /(^|[^%])(%.)*%1\$s/ not $parsed =~ /(^|[^%])(%.)*%[2-9]\$s/
Truth table50%2/4
A and B and not(C)
A= $parsedB= $parsed =~ /(^|[^%])(%.)*%1\$s/C= not $parsed =~ /(^|[^%])(%.)*%[2-9]\$s/
ABCresult
0XX0
10X0
1100
1111
898 12 $fieldref->{'TARGET'} = $parsed;
899 12 $format .= " -hasTARGET";
900 }
901 elsif ( $parsed ) {
902 2 ▶ if ( exists $fieldref->{'ALTTARGET'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fieldref->{'ALTTARGET'}) { } 0 2 2
903 0 push(@carp, "ERROR: header field #TARGET must contain placeholder {ID} only");
904 }
905 else {
906 2 push(@carp, "WARNING: Adding implicit {ID} to #TARGET as #ALTTARGET");
907 2 $fieldref->{'ALTTARGET'} = $parsed."%2\$s";
908 2 $format .= " -altTARGET";
909 }
910 2 delete $fieldref->{'TARGET'};
911 }
912 else {
913 0 push(@carp, "ERROR: could not parse header field #TARGET: '".$fieldref->{'TARGET'}."'");
914 0 delete $fieldref->{'TARGET'};
915 }
916 }
917 elsif ( $format =~ /^BEACON/ ) {
918 0 push(@carp, "WARNING: header field #TARGET not set: ALL beacon lines will have to provide their link by other means!");
919 0 $format =~ s/\s*-noTARGET//;
920 0 $format .= " -noTARGET";
921 }
922 else {
923 0 push(@carp, "ERROR: header field #TARGET is mandatory")};
924  
925  
926 14 ▶ $fieldref->{'MESSAGE'} = hDecode($fieldref, 'MESSAGE') if $fieldref->{'MESSAGE'};
Branch: 1 branch
BranchTrueFalseTotal
if $fieldref->{"MESSAGE"} 0 14 14
927  
928 14 ▶ if ( $fieldref->{'TIMESTAMP'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fieldref->{'TIMESTAMP'}) { } 2 12 14
929 2 ▶ if ( my $parsed = hDecode($fieldref, 'TIMESTAMP') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parsed = hDecode($fieldref, 'TIMESTAMP')) { } 2 0 2
930 2 ▶ printf("* %-30s %s\n", "Beacon Timestamp:", hEncode($parsed, 'TIMESTAMP')) if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 2 0 2
931 2 $fieldref->{'TIMESTAMP'} = $parsed;
932 }
933 else { # unparseable => use current
934 0 push(@carp, "WARNING: cannot parse TIMESTAMP '".$fieldref->{'TIMESTAMP'}."', using current time");
935 0 $fieldref->{'TIMESTAMP'} = $^T;
936 };
937 }
938 else {
939 # $fieldref->{'TIMESTAMP'} = $fieldref->{'_mtime'} || $^T;
940 12 push(@carp, "NOTICE: no header field #TIMESTAMP detected");
941 };
942  
943 14 ▶ if ( $fieldref->{'REVISIT'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fieldref->{'REVISIT'}) { } 0 14 14
944 0 ▶ if ( my $parsed = hDecode($fieldref, 'REVISIT') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parsed = hDecode($fieldref, 'REVISIT')) { } 0 0 0
945 0 ▶ if ( $parsed < $^T ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed < $^T) { } 0 0 0
946 0 printf("* %-30s %s [%s]\n", "STALE Revisit hint parsed as", hEncode($parsed, 'REVISIT'), $fieldref->{'REVISIT'})} # if $options{'verbose'}
947 else {
948 0 ▶ printf("* %-30s %s\n", "Revisit hint parsed as", hEncode($parsed, 'REVISIT')) if $options{'verbose'}};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 0 0
949 0 $fieldref->{'REVISIT'} = $parsed;
950 }
951 else { # unparseable => discard
952 0 push(@carp, "WARNING: cannot parse #REVISIT '".$fieldref->{'REVISIT'}."', discarding");
953 0 delete $fieldref->{'REVISIT'};
954 };
955 }
956 else {
957 14 push(@carp, "INFO: no header field #REVISIT detected");
958 };
959  
960 14 my $cancontinue = 1;
961 14 my $err = "";
962 14 foreach ( @carp ) {
963 33 print "$_\n";
964 33 ▶ if ( s/^ERROR: // ) {
Branch: 1 branch
BranchTrueFalseTotal
if (s/^ERROR: //) 0 33 33
965 0 $cancontinue = 0;
966 0 ▶ $err .= " | " if $err;
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 0 0
967 0 $err .= $_;
968 };
969 }
970 14 ▶ unless ( $cancontinue or $options{'ignore-header-errors'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cancontinue or $options{"ignore-header-errors"}) 0 14 14
Condition33%1/3
$cancontinue or $options{"ignore-header-errors"}
l!l&&r!l&&!r
1400
MC/DC0%0/2
$cancontinue or $options{"ignore-header-errors"}
$cancontinue $options{"ignore-header-errors"}
Truth table33%1/3
A or B
A= $cancontinueB= $options{"ignore-header-errors"}
ABresult
1X1
011
000
971 0 print "CRITICAL: Aborting because of Header Errors\n";
972 0 return (undef, $err, $format);
973 };
974  
975 14 ▶ $fieldref->{'_uri'} ||= $fieldref->{'FEED'};
Condition66%2/3
$fieldref->{"_uri"} ||= $fieldref->{"FEED"}
l!l&&r!l&&!r
1301
MC/DC50%1/2
$fieldref->{"_uri"} ||= $fieldref->{"FEED"}
$fieldref->{"_uri"} $fieldref->{"FEED"}
Truth table66%2/3
A ||= B
A= $fieldref->{"_uri"}B= $fieldref->{"FEED"}
ABresult
1X1
011
000
976 14 ▶ delete $fieldref->{'_uri'} unless $fieldref->{'_uri'};
Branch: 1 branch
BranchTrueFalseTotal
unless $fieldref->{"_uri"} 1 13 14
977  
978 14 ▶ $fieldref->{'_alias'} ||= $fieldref->{'FEED'} || $fieldref->{'TARGET'};
Condition16%1/6
$fieldref->{"_alias"} ||= $fieldref->{"FEED"} || $fieldref->{"TARGET"}
l!l&&r!l&&!r
1400
$fieldref->{'FEED'} || $fieldref->{'TARGET'}
l!l&&r!l&&!r
000
MC/DC0%0/3
$fieldref->{"_alias"} ||= $fieldref->{"FEED"} || $fieldref->{"TARGET"}
$fieldref->{"_alias"} $fieldref->{'FEED'} $fieldref->{'TARGET'}
Truth table0%0/4
A ||= B || C
A= $fieldref->{"_alias"}B= $fieldref->{'FEED'}C= $fieldref->{'TARGET'}
ABCresult
1XX1
01X1
0011
0000
979  
980 14 my (@fn, @fd);
981 14 ▶ while ( my ($key, $val) = each %$fieldref ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$fieldref) 175 14 189
982 175 ▶ next unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 4 171 175
983 171 my $dbkey = "";
984 171 ▶ if ( $dbkey = SeeAlso::Source::BeaconAggregator->beaconfields($key) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($dbkey = 'SeeAlso::Source::BeaconAggregator'->beaconfields($key)) { } 84 87 171
elsif ($key =~ /_(\w+)$/) { } 87 0 87
985 84 push(@fn, $dbkey)}
986 elsif ( $key =~ /_(\w+)$/ ) {
987 87 push(@fn, $1)}
988 else {
989 0 next};
990 171 my $myval = $val;
991 171 ▶ unless ( $myval =~ /^\d+$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($myval =~ /^\d+$/) 129 42 171
992 129 $myval =~ s/'/''/g;
993 129 $myval = "'".$myval."'";
994 };
995 171 push(@fd, $myval);
996 };
997 14 local($") = ",\n";
998 14 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
999 INSERT INTO repos ( seqno, @fn ) VALUES ( NULL, @fd );
1000 XxX
1001 14 ▶ $self->stmtExplain($sthexpl) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 14 14
1002 14 ▶ $sth->execute() or croak("Could not execute >".$sth->{Statement}."<:".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute or croak('Could not execute >' . $sth->{"Statement"} . '<:' . $sth->errstr) 14 0 14
1003 14 my $collno = $self->{dbh}->last_insert_id("", "", "", "");
1004  
1005 14 my $rhandle;
1006 14 ▶ if ( $osq ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($osq) 8 6 14
1007 8 $rhandle = $self->stmtHdl(<<"XxX");
1008 UPDATE OR FAIL beacons SET seqno=$collno, hits=?, info=?, link=? WHERE hash=? AND seqno==$osq AND altid=?;
1009 XxX
1010 };
1011 14 my $ihandle = $self->stmtHdl(<<"XxX");
1012 INSERT OR IGNORE INTO beacons ( hash, seqno, altid, hits, info, link ) VALUES (?, $collno, ?, ?, ?, ?);
1013 XxX
1014 14 return ($collno, "", $format, $ihandle, $rhandle, $osq);
1015 }
1016  
1017  
1018  
1019  
1020 37 my ($lwpcarp817, $lwpcarp827);
1021  
1022 =head3 update ($sq_or_alias, $params, %options)
1023  
1024 Loads a beacon file into the database, possibly replacing a previous instance.
1025  
1026 Some magic is employed to autoconvert ISO-8859-1 or doubly UTF-8 encoded files
1027 back to UTF-8.
1028  
1029 Returns undef, if something goes wrong, or the file was not modified since,
1030 otherwise returns a pair (new seqence number, number of lines imported).
1031  
1032  
1033 =over 8
1034  
1035  
1036 =item $sq_or_alias
1037  
1038 Sequence number or alias: Used to determine an existing instance.
1039  
1040  
1041 =item $params
1042  
1043 Hashref, containing
1044  
1045 agent => LWP::UserAgent to use
1046 _uri => Feed URL to load from
1047  
1048 =item %options
1049  
1050 Hash, propagated to C<loadFile()>
1051  
1052 verbose => (0|1)
1053 force => (0|1) process unconditionally without timestamp comparison
1054 nostat => (0|1) don't refresh global identifier counters
1055  
1056 =back
1057  
1058 Incorporates a new beacon source from a URI in the database or updates an existing one.
1059 For HTTP URIs care is taken not to reload an unmodified BEACON feed (unless the 'force'
1060 option is provided).
1061  
1062 If the feed appears to be newer than the previously loaded version it is fetched,
1063 some UTF-8 adjustments are performed if necessary, then it is stored to a temporary file
1064 and from there finally processed by the C<loadFile()> method above.
1065  
1066 The URI to load is determined by the following order of precedence:
1067  
1068 =over 8
1069  
1070 =item 1
1071  
1072 _uri Option
1073  
1074 =item 2
1075  
1076 admin field uri stored in the database
1077  
1078 =item 3
1079  
1080 meta field #FEED taken from the database
1081  
1082 =back
1083  
1084 Typical use is with an alias, not with a sequence number:
1085  
1086 $db->update('whatever');
1087  
1088 Can be used to initially load beacon files from URIs:
1089  
1090 $db->update("new_alias", {_uri => $file_uri} );
1091  
1092 =cut
1093  
1094 13 ▶sub update {
Subroutine update: called CC=67 SCAR=60.3
Pod documented
1095 13 my ($self, $sq_or_alias, $params, %options) = @_;
1096 13 ▶ $params = {} unless $params;
Branch: 1 branch
BranchTrueFalseTotal
unless $params 2 11 13
1097 13 ▶ $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options{"verbose"} 5 8 13
1098  
1099 13 my $ua = $params->{'agent'};
1100 13 ▶ unless ( $ua ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ua) 13 0 13
1101 13 require LWP::UserAgent;
1102 13 ▶ $ua = LWP::UserAgent->new(agent => "SA-S-BeaconAggregator ", # end with space to get default agent appended
Branch: 1 branch
BranchTrueFalseTotal
$ua = "LWP::UserAgent"->new("agent", "SA-S-BeaconAggregator ", "env_proxy", 1, "timeout", 300) or croak("cannot create UserAgent") 13 0 13
1103 env_proxy => 1,
1104 timeout => 300,
1105 ) or croak("cannot create UserAgent");
1106 };
1107  
1108 13 my ($cond, @cval) = SeeAlso::Source::BeaconAggregator::mkConstraint($sq_or_alias);
1109 13 ▶ my $alias = ($sq_or_alias =~ /^\d+$/) ? "" : $sq_or_alias;
Branch: 1 branch
BranchTrueFalseTotal
$sq_or_alias =~ /^\d+$/ ? : 1 12 13
1110 13 my $feedname = SeeAlso::Source::BeaconAggregator->beaconfields("FEED");
1111 13 my ($ssth, $ssthexpl) = $self->stmtHdl(<<"XxX");
1112 SELECT seqno, uri, alias, $feedname, ftime, mtime, sort FROM repos $cond;
1113 XxX
1114 13 ▶ $self->stmtExplain($ssthexpl, @cval) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 13 13
1115 13 ▶ $ssth->execute(@cval) or croak("Could not execute >".$ssth->{Statement}."<: ".$ssth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$ssth->execute(@cval) or croak('Could not execute >' . $ssth->{"Statement"} . '<: ' . $ssth->errstr) 13 0 13
1116 13 ▶ croak("Select old instance error: ".$ssth->errstr) if $ssth->err;
Branch: 1 branch
BranchTrueFalseTotal
if $ssth->err 0 13 13
1117 13 my $aryref = $ssth->fetchrow_arrayref;
1118 13 ▶ my ($osq, $ouri, $oalias, $feed, $fetchtime, $modtime, $osort) = $aryref ? @$aryref : ();
Branch: 1 branch
BranchTrueFalseTotal
$aryref ? : 9 4 13
1119  
1120 13 ▶ my $uri = $params->{'_uri'} || $ouri || $feed;
Condition50%3/6
$params->{'_uri'} || $ouri || $feed
l!l&&r!l&&!r
1300
$params->{"_uri"} or $ouri
l!l&&r!l&&!r
580
MC/DC0%0/3
$params->{'_uri'} || $ouri || $feed
$params->{"_uri"} $ouri $feed
Truth table50%2/4
A or B || C
A= $params->{"_uri"}B= $ouriC= $feed
ABCresult
1XX1
01X1
0011
0000
1121 13 ▶ croak("Cannot update $sq_or_alias: URI not given nor determinable from previous content") unless $uri;
Branch: 1 branch
BranchTrueFalseTotal
unless $uri 0 13 13
1122 13 $uri =~ s/\s$//;
1123 13 ▶ $alias ||= $oalias || "";
Condition60%3/5
$alias ||= $oalias || ""
l!l&&r!l&&!r
1210
$oalias || ''
l!l
10
MC/DC0%0/2
$alias ||= $oalias || ""
$alias $oalias
Truth table66%2/3
A ||= B
A= $aliasB= $oalias
ABresult
1X1
011
000
1124  
1125 13 ▶ print "Requesting $uri\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 8 5 13
1126 13 ▶ my $rq = HTTP::Request->new('GET', $uri, ['Accept' => 'text/*']) or croak("could not construct request from $uri");
Branch: 1 branch
BranchTrueFalseTotal
my $rq = "HTTP::Request"->new("GET", $uri, ["Accept", "text/*"]) or croak("could not construct request from $uri") 13 0 13
1127 13 ▶ if ( $fetchtime && $modtime && !$options{'force'} ) { # allow force-reload by deleting _ftime or _mtime
Branch: 1 branch
BranchTrueFalseTotal
if ($fetchtime and $modtime and not $options{"force"}) 1 12 13
Condition100%6/6
$fetchtime and $modtime and not $options{"force"}
!ll&&!rl&&r
571
$fetchtime and $modtime
!ll&&!rl&&r
418
MC/DC100%3/3
$fetchtime and $modtime and not $options{"force"}
$fetchtime $modtime not $options{"force"}
Truth table100%4/4
A and B and not(C)
A= $fetchtimeB= $modtimeC= not $options{"force"}
ABCresult
0XX0
10X0
1100
1111
1128 1 ▶ printf(" %-30s %s\n", "Old instance stamped", scalar localtime($modtime)) if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 1 1
1129 1 $rq->header('If-Modified-Since', HTTP::Date::time2str($modtime));
1130 };
1131 13 ▶ if ( $rq->can("accept_decodable") ) { # LWP 5.817 and newer
Branch: 1 branch
BranchTrueFalseTotal
if ($rq->can('accept_decodable')) { } 13 0 13
1132 13 $rq->accept_decodable}
1133 else {
1134 0 ▶ carp("please upgrade to LWP >= 5.817 for compression negotiation") if $options{'verbose'} && (!$lwpcarp817++)};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} and not $lwpcarp817++ 0 0 0
Condition0%0/3
$options{"verbose"} and not $lwpcarp817++
!ll&&!rl&&r
000
MC/DC0%0/2
$options{"verbose"} and not $lwpcarp817++
$options{"verbose"} not $lwpcarp817++
Truth table0%0/3
A and not(B)
A= $options{"verbose"}B= not $lwpcarp817++
ABresult
0X0
100
111
1135  
1136 13 my $response = $ua->request($rq); # Well, we hoggishly slurp everything into memory,
1137 # however explicit decompression of an already dumped result would be PITA
1138 13 my $nuri = ($response->request)->uri;
1139 13 ▶ print "NOTICE: Differing result URI: $nuri\n" if $uri ne $nuri;
Branch: 1 branch
BranchTrueFalseTotal
if $uri ne $nuri 0 13 13
1140 13 ▶ if ( $response->is_success ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($response->is_success) { } 12 1 13
elsif ($response->code == 304) { } 1 0 1
1141 12 ▶ print $osq ? "INFO: refreshing $alias sq $osq from $uri\n"
Branch: 1 branch
BranchTrueFalseTotal
$osq ? : 8 4 12
1142 : "INFO: importing previously unseen $alias from $uri\n";
1143 12 my $charset;
1144 12 ▶ if ( $response->can("content_charset") ) { # LWP 5.827 and above
Branch: 1 branch
BranchTrueFalseTotal
if ($response->can('content_charset')) { } 12 0 12
1145 12 $charset = $response->content_charset;
1146 12 ▶ print "DEBUG: Content charset is $charset\n" if $charset && $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $charset and $options{"verbose"} 8 4 12
Condition66%2/3
$charset and $options{"verbose"}
!ll&&!rl&&r
048
MC/DC50%1/2
$charset and $options{"verbose"}
$charset $options{"verbose"}
Truth table66%2/3
A and B
A= $charsetB= $options{"verbose"}
ABresult
0X0
100
111
1147 }
1148 else {
1149 0 ▶ carp("please upgrade to LWP >= 5.827 for better detection of content_charset") if $options{'verbose'} && (!$lwpcarp827++)};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} and not $lwpcarp827++ 0 0 0
Condition0%0/3
$options{"verbose"} and not $lwpcarp827++
!ll&&!rl&&r
000
MC/DC0%0/2
$options{"verbose"} and not $lwpcarp827++
$options{"verbose"} not $lwpcarp827++
Truth table0%0/3
A and not(B)
A= $options{"verbose"}B= not $lwpcarp827++
ABresult
0X0
100
111
1150 12 ▶ $charset ||= "UTF-8";
Condition50%1/2
$charset ||= "UTF-8"
l!l
120
MC/DC0%0/1
$charset ||= "UTF-8"
$charset
Truth table50%1/2
A
A= $charset
Aresult
11
00
1151  
1152 12 my $lm = $response->last_modified;
1153 12 ▶ printf(" %-30s %s\n", "Last modified", scalar localtime($lm)) if $lm && $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $lm and $options{"verbose"} 8 4 12
Condition66%2/3
$lm and $options{"verbose"}
!ll&&!rl&&r
048
MC/DC50%1/2
$lm and $options{"verbose"}
$lm $options{"verbose"}
Truth table66%2/3
A and B
A= $lmB= $options{"verbose"}
ABresult
0X0
100
111
1154 12 ▶ $lm ||= $^T;
Condition33%1/3
$lm ||= $^T
l!l&&r!l&&!r
1200
MC/DC0%0/2
$lm ||= $^T
$lm $^T
Truth table33%1/3
A ||= B
A= $lmB= $^T
ABresult
1X1
011
000
1155  
1156 12 my $vt = $response->fresh_until(h_min => 1800, h_max => 30 * 86400);
1157 12 ▶ printf(" %-30s %s\n", "Should be valid until", scalar localtime($vt)) if $vt && $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $vt and $options{"verbose"} 8 4 12
Condition66%2/3
$vt and $options{"verbose"}
!ll&&!rl&&r
048
MC/DC50%1/2
$vt and $options{"verbose"}
$vt $options{"verbose"}
Truth table66%2/3
A and B
A= $vtB= $options{"verbose"}
ABresult
0X0
100
111
1158 12 ▶ $vt ||= 0;
Condition50%1/2
$vt ||= 0
l!l
120
MC/DC0%0/1
$vt ||= 0
$vt
Truth table50%1/2
A
A= $vt
Aresult
11
00
1159  
1160 # temporary file for dumped contents
1161 12 ▶ my ($tmpfh, $tmpfile) = File::Temp::tempfile("BeaconAggregator-XXXXXXXX", SUFFIX => ".txt", TMPDIR => 1) or croak("Could not acquire temporary file for storage");
Branch: 1 branch
BranchTrueFalseTotal
() = File::Temp::tempfile("BeaconAggregator-XXXXXXXX", "SUFFIX", ".txt", "TMPDIR", 1) or croak("Could not acquire temporary file for storage") 12 0 12
1162 12 my $contref; # reference to content buffer
1163 12 ▶ if ( ! $response->content_is_text ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($response->content_is_text) 0 12 12
1164 0 my $ct = $response->content_type;
1165 0 print "WARNING: Response content is $ct, not text/*\n";
1166 0 ▶ if ( my $ce = $response->content_encoding ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ce = $response->content_encoding) 0 0 0
1167 0 print "NOTICE: Response is also Content-encoded: $ce\n"}
1168 0 my $ctt = join("|", $response->decodable());
1169 0 ▶ if ( $ct =~ s!^(.+\/)?($ctt)$!$2! ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ct =~ s[^(.+\/)?($ctt)$][$2]) 0 0 0
1170 # yes: decode anyway since it could be a gzip-encoded .txt.gz file!
1171 0 my $cr = $response->decoded_content( raise_error => 1, ref => 1); # method exists since LWP 5.802 (2004-11-30)
1172 0 $response->remove_content_headers;
1173 0 my $newresp = HTTP::Response->new($response->code, $response->message, $response->headers);
1174 0 $newresp->content_type("text/plain; charset: $charset");
1175 0 $newresp->content_encoding($ct);
1176 0 $newresp->content_ref($cr);
1177 0 $response = $newresp;
1178 }
1179 };
1180 12 $contref = $response->decoded_content( raise_error => 1, ref => 1); # method exists since LWP 5.802 (2004-11-30)
1181  
1182 12 ▶ if ( $$contref =~ /^\x{FFEF}/ ) { # properly encoded BOM => put Characters to file
Branch: 4 branches
BranchTrueFalseTotal
if ($$contref =~ /^\x{FFEF}/) { } 0 12 12
elsif ($$contref =~ s/^\xef\xbb\xbf//) { } 0 12 12
elsif (utf8::is_utf8($$contref)) { } 10 2 12
elsif (utf8::decode($$contref)) { } 2 0 2
1183 0 binmode($tmpfh, ":utf8");
1184 0 print "INFO: properly encoded BOM detected: Groked UTF8\n"; # if $options{'verbose'};
1185 }
1186 elsif ( $$contref =~ s/^\xef\xbb\xbf// ) { # BOM Bytes => put Bytes to file, re-read as UTF-8
1187 0 print "INFO: Byte coded BOM detected: trying to restitute character semantics\n"; # if $options{'verbose'};
1188 0 ▶ print "INFO: Length is ", length($$contref), " ", (utf8::is_utf8($$contref) ? "characters" : "bytes"), "\n";
Branch: 1 branch
BranchTrueFalseTotal
utf8::is_utf8($$contref) ? : 0 0 0
1189 0 binmode($tmpfh, ":bytes");
1190 0 ▶ utf_deduplicate($contref) && binmode($tmpfh, ":utf8");
Branch: 1 branch
BranchTrueFalseTotal
utf_deduplicate($contref) and binmode $tmpfh, ":utf8" 0 0 0
1191 }
1192 elsif ( utf8::is_utf8($$contref) ) { # already Upgraded strings should be written as utf-8
1193 10 ▶ print "INFO: UTF8-ness already established\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 6 4 10
1194 10 binmode($tmpfh, ":utf8");
1195 10 utf_deduplicate($contref); # but don't trust it (older LWP with file URLs, ...)
1196 }
1197 elsif ( utf8::decode($$contref) ) { # everything in character semantics now
1198 2 ▶ print "INFO: Could decode bytes to UTF8-characters\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 2 0 2
1199 2 binmode($tmpfh, ":utf8");
1200 }
1201 else { # leave it alone
1202 0 print "WARNING: No clue about character encoding: Assume ISO 8859-1\n"; # if $options{'verbose'};
1203 0 binmode($tmpfh, ":utf8");
1204 };
1205 12 print $tmpfh $$contref;
1206 12 close($tmpfh);
1207 # early cleanup since everything might be huge....
1208 12 $contref = $response = undef;
1209  
1210 12 my ($collno, $count, $statref) = $self->loadFile($tmpfile, {_alias => $alias, _uri => $uri, _ruri => $nuri, _mtime => $lm, _sort => $osort}, %options);
1211 12 ▶ if ( ! $collno && $osq ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $collno and $osq) 0 12 12
Condition33%1/3
not $collno and $osq
!ll&&!rl&&r
1200
MC/DC0%0/2
not $collno and $osq
not $collno $osq
Truth table33%1/3
not(A) and B
A= not $collnoB= $osq
ABresult
0X0
100
111
1212 0 my ($usth, $usthexpl) = $self->stmtHdl(<<"XxX");
1213 UPDATE OR FAIL repos SET utime=?,ustat=? WHERE seqno==?;
1214 XxX
1215 0 ▶ $self->stmtExplain($usthexpl, time(), ($statref ? "load error: $statref" : "internal error"), $osq) if $ENV{'DBI_PROFILE'};
Branch: 2 branches
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 0 0
$statref ? : 0 0 0
1216 $usth->execute(time(), ($statref ? "load error: $statref" : "internal error"), $osq)
1217 0 ▶ or croak("Could not execute >".$usth->{Statement}."<: ".$usth->errstr);
Branch: 2 branches
BranchTrueFalseTotal
$usth->execute(time, $statref ? "load error: $statref" : "internal error", $osq) or croak('Could not execute >' . $usth->{"Statement"} . '<: ' . $usth->errstr) 0 0 0
$statref ? : 0 0 0
1218 };
1219  
1220 12 ▶ unlink($tmpfile) if -f $tmpfile;
Branch: 1 branch
BranchTrueFalseTotal
if -f $tmpfile 12 0 12
1221 12 ▶ return $collno ? ($collno, $count) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$collno ? : 12 0 12
1222 }
1223 elsif ( $response->code == 304 ) {
1224 1 ▶ print "INFO: $alias not modified since ".HTTP::Date::time2str($modtime)."\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 1 1
1225 1 my $vt = $response->fresh_until(h_min => 1800, h_max => 6 * 86400);
1226 1 ▶ printf(" %-30s %s\n", "Will not try again before", scalar localtime($vt)) if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 1 1
1227 1 my ($usth, $usthexpl) = $self->stmtHdl(<<"XxX");
1228 UPDATE OR FAIL repos SET utime=?,ustat=?,ruri=? WHERE seqno==?;
1229 XxX
1230 1 ▶ $self->stmtExplain($usthexpl, time(), $response->status_line, $nuri, $osq) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 1 1
1231 $usth->execute(time(), $response->status_line, $nuri, $osq)
1232 1 ▶ or croak("Could not execute >".$usth->{Statement}."<: ".$usth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$usth->execute(time, $response->status_line, $nuri, $osq) or croak('Could not execute >' . $usth->{"Statement"} . '<: ' . $usth->errstr) 1 0 1
1233 1 return undef;
1234 }
1235 else {
1236 0 print "WARNING: No access to $uri for $alias [".$response->status_line."]\n";
1237 0 print $response->headers_as_string, "\n";
1238 0 ▶ return undef unless $osq;
Branch: 1 branch
BranchTrueFalseTotal
unless $osq 0 0 0
1239 0 my ($usth, $usthexpl) = $self->stmtHdl(<<"XxX");
1240 UPDATE OR FAIL repos SET utime=?,ustat=?,ruri=? WHERE seqno==?;
1241 XxX
1242 0 ▶ $self->stmtExplain($usthexpl, time(), $response->status_line, $nuri, $osq) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 0 0
1243 $usth->execute(time(), $response->status_line, $nuri, $osq)
1244 0 ▶ or croak("Could not execute >".$usth->{Statement}."<: ".$usth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$usth->execute(time, $response->status_line, $nuri, $osq) or croak('Could not execute >' . $usth->{"Statement"} . '<: ' . $usth->errstr) 0 0 0
1245 0 return undef;
1246 };
1247 }
1248  
1249  
1250  
1251 10 ▶sub utf_deduplicate {
Subroutine utf_deduplicate: called CC=6 SCAR=26.0
Pod undocumented
1252 10 my ($success, $stringref) = (0, @_);
1253 10 ▶ if ( utf8::downgrade($$stringref, 1) ) { # 1 = FAIL_OK
Branch: 1 branch
BranchTrueFalseTotal
if (utf8::downgrade($$stringref, 1)) { } 10 0 10
1254 10 my $prevlength = length($$stringref);
1255 10 ▶ print "INFO: Downgrade was possible, length now $prevlength ", (utf8::is_utf8($$stringref) ? "characters" : "bytes"), "\n";
Branch: 1 branch
BranchTrueFalseTotal
utf8::is_utf8($$stringref) ? : 0 10 10
1256 10 ▶ while ( utf8::decode($$stringref) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (utf8::decode($$stringref)) 0 10 10
1257 0 $success ++;
1258 0 my $newlength = length($$stringref);
1259 0 ▶ print "DEBUG: Reassembling as UTF-8 succeeded, length now $newlength ", (utf8::is_utf8($$stringref) ? "characters" : "bytes"), "\n";
Branch: 1 branch
BranchTrueFalseTotal
utf8::is_utf8($$stringref) ? : 0 0 0
1260 0 ▶ last if $newlength == $prevlength;
Branch: 1 branch
BranchTrueFalseTotal
if $newlength == $prevlength 0 0 0
1261 0 $prevlength = $newlength;
1262 # last unless utf8::downgrade($$stringref, 1);
1263 }
1264 }
1265 else {
1266 0 print "WARNING: no downgrade possible, proceed with byte semantics";
1267 };
1268 10 return $success;
1269 }
1270  
1271 =head3 unload ( [ $seqno_or_alias, %options ] )
1272  
1273 Deletes the sequence(s).
1274  
1275 =over 8
1276  
1277 =item $seqno_or_alias
1278  
1279 numeric sequence number, Alias or SQL pattern.
1280  
1281 =item Supported options:
1282  
1283 force => (0|1)
1284  
1285 Needed to purge the complete database ($seqno_or_alias empty) or to purge
1286 more than one sequence ($seqno_or_alias yields more than one seqno).
1287  
1288 =back
1289  
1290  
1291 =cut
1292  
1293 3 ▶sub unload {
Subroutine unload: called CC=23 SCAR=46.6
Pod documented
1294 3 my ($self, $seqno_or_alias, %options) = @_;
1295 3 ▶ $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options{"verbose"} 3 0 3
1296  
1297 3 my @seqnos = ();
1298 3 ▶ if ( $seqno_or_alias && ($seqno_or_alias =~ /^\d+$/) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($seqno_or_alias and $seqno_or_alias =~ /^\d+$/) { } 0 3 3
elsif ($seqno_or_alias or $options{'force'}) { } 3 0 3
Condition33%1/3
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
!ll&&!rl&&r
030
MC/DC0%0/2
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
$seqno_or_alias $seqno_or_alias =~ /^\d+$/
Truth table33%1/3
A and B
A= $seqno_or_aliasB= $seqno_or_alias =~ /^\d+$/
ABresult
0X0
100
111
1299 0 @seqnos = ($seqno_or_alias)}
1300 ▶ elsif ( $seqno_or_alias || $options{'force'} ) {
Condition33%1/3
$seqno_or_alias or $options{"force"}
l!l&&r!l&&!r
300
MC/DC0%0/2
$seqno_or_alias or $options{"force"}
$seqno_or_alias $options{"force"}
Truth table33%1/3
A or B
A= $seqno_or_aliasB= $options{"force"}
ABresult
1X1
011
000
1301 3 ▶ @seqnos = $self->Seqnos('_alias', $seqno_or_alias ? ($seqno_or_alias) : ());
Branch: 1 branch
BranchTrueFalseTotal
$seqno_or_alias ? : 3 0 3
1302 3 ▶ unless ( @seqnos ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@seqnos) 0 3 3
1303 0 carp("no Seqnos selected by $seqno_or_alias");
1304 0 return 0;
1305 };
1306 3 ▶ unless ( $options{'force'} or (@seqnos == 1) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($options{"force"} or @seqnos == 1) 0 3 3
Condition33%1/3
$options{"force"} or @seqnos == 1
l!l&&r!l&&!r
030
MC/DC0%0/2
$options{"force"} or @seqnos == 1
$options{"force"} @seqnos == 1
Truth table33%1/3
A or B
A= $options{"force"}B= @seqnos == 1
ABresult
1X1
011
000
1307 0 carp("Use --force to purge more than one sequence (@seqnos)");
1308 0 return 0;
1309 };
1310 }
1311 else {
1312 0 carp("Use --force to purge the complete database");
1313 0 return 0;
1314 };
1315  
1316 3 ▶ if ( $options{'force'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"force"}) 0 3 3
1317 0 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1318 DELETE FROM beacons WHERE seqno==?;
1319 XxX
1320 0 foreach my $seqno ( @seqnos ) {
1321 0 ▶ $self->stmtExplain($sthexpl, $seqno_or_alias) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 0 0
1322 0 ▶ my $rows = $sth->execute($seqno_or_alias) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
my $rows = $sth->execute($seqno_or_alias) or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 0 0 0
1323 0 ▶ print "INFO: $rows forced for $seqno\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 0 0
1324 };
1325 };
1326  
1327 3 my ($cond, @cval) = SeeAlso::Source::BeaconAggregator::mkConstraint($seqno_or_alias);
1328 3 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1329 DELETE FROM repos $cond;
1330 XxX
1331 3 ▶ $self->stmtExplain($sthexpl, @cval) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 3 3
1332 3 ▶ my $rows = $sth->execute(@cval) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
my $rows = $sth->execute(@cval) or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 3 0 3
1333 3 ▶ $rows = 0 if $rows eq "0E0";
Branch: 1 branch
BranchTrueFalseTotal
if $rows eq "0E0" 0 3 3
1334  
1335 3 ▶ if ( $rows or $options{'force'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rows or $options{"force"}) 3 0 3
Condition33%1/3
$rows or $options{"force"}
l!l&&r!l&&!r
300
MC/DC0%0/2
$rows or $options{"force"}
$rows $options{"force"}
Truth table33%1/3
A or B
A= $rowsB= $options{"force"}
ABresult
1X1
011
000
1336 # if ( $options{'force'} ) {
1337 # print "[ANALYZE ..." if $options{'verbose'};
1338 # $self->{dbh}->do("ANALYZE;");
1339 # print "]\n" if $options{'verbose'};
1340 # };
1341  
1342 3 ▶ if ( $options{'nostat'} ) { # invalidate since they might have changed
Branch: 1 branch
BranchTrueFalseTotal
if ($options{'nostat'}) { } 0 3 3
1343 0 $self->admin('gcounti', undef);
1344 0 $self->admin('gcountu', undef);
1345 }
1346 else {
1347 3 ▶ $self->admin('gcounti', $self->idStat(undef, 'distinct' => 0) || 0);
Condition50%1/2
$self->idStat(undef, 'distinct', 0) || 0
l!l
30
MC/DC0%0/1
$self->idStat(undef, 'distinct', 0) || 0
$self->idStat(undef, 'distinct', 0)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 0)
Aresult
11
00
1348 3 ▶ $self->admin('gcountu', $self->idStat(undef, 'distinct' => 1) || 0);
Condition50%1/2
$self->idStat(undef, 'distinct', 1) || 0
l!l
30
MC/DC0%0/1
$self->idStat(undef, 'distinct', 1) || 0
$self->idStat(undef, 'distinct', 1)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 1)
Aresult
11
00
1349 }
1350 };
1351  
1352 3 return $rows;
1353 }
1354  
1355  
1356 =head3 purge ( $seqno_or_alias[, %options ] )
1357  
1358 Deletes all identifiers from the database to the given pattern,
1359 but leaves the stored header information intact, such that it
1360 can be updated automatically.
1361  
1362 =over 8
1363  
1364 =item $seqno_or_alias
1365  
1366 Pattern
1367  
1368 =item Supported options:
1369  
1370 force => (0|1)
1371  
1372 Allow purging of more than one sequence.
1373  
1374 =back
1375  
1376  
1377 =cut
1378  
1379 2 ▶sub purge {
Subroutine purge: called CC=22 SCAR=41.2
Pod documented
1380 2 my ($self, $seqno_or_alias, %options) = @_;
1381 2 ▶ $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options{"verbose"} 2 0 2
1382 2 my @seqnos;
1383 2 ▶ if ( $seqno_or_alias && ($seqno_or_alias =~ /^\d+$/) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($seqno_or_alias and $seqno_or_alias =~ /^\d+$/) { } 0 2 2
elsif ($seqno_or_alias or $options{'force'}) { } 2 0 2
Condition33%1/3
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
!ll&&!rl&&r
020
MC/DC0%0/2
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
$seqno_or_alias $seqno_or_alias =~ /^\d+$/
Truth table33%1/3
A and B
A= $seqno_or_aliasB= $seqno_or_alias =~ /^\d+$/
ABresult
0X0
100
111
1384 0 @seqnos = ($seqno_or_alias)}
1385 ▶ elsif ( $seqno_or_alias || $options{'force'} ) {
Condition33%1/3
$seqno_or_alias or $options{"force"}
l!l&&r!l&&!r
200
MC/DC0%0/2
$seqno_or_alias or $options{"force"}
$seqno_or_alias $options{"force"}
Truth table33%1/3
A or B
A= $seqno_or_aliasB= $options{"force"}
ABresult
1X1
011
000
1386 2 ▶ @seqnos = $self->Seqnos('_alias', $seqno_or_alias ? ($seqno_or_alias) : ());
Branch: 1 branch
BranchTrueFalseTotal
$seqno_or_alias ? : 2 0 2
1387 2 ▶ unless ( @seqnos ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@seqnos) 0 2 2
1388 0 carp("no Seqnos selected by $seqno_or_alias");
1389 0 return 0;
1390 };
1391 2 ▶ unless ( $options{'force'} or (@seqnos == 1) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($options{"force"} or @seqnos == 1) 0 2 2
Condition33%1/3
$options{"force"} or @seqnos == 1
l!l&&r!l&&!r
020
MC/DC0%0/2
$options{"force"} or @seqnos == 1
$options{"force"} @seqnos == 1
Truth table33%1/3
A or B
A= $options{"force"}B= @seqnos == 1
ABresult
1X1
011
000
1392 0 carp("Use --force to purge more than one sequence (@seqnos)");
1393 0 return 0;
1394 };
1395 }
1396 else {
1397 0 carp("Use --force to purge the complete database");
1398 0 return 0;
1399 };
1400 2 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1401 DELETE FROM beacons WHERE seqno==?;
1402 XxX
1403 2 my ($usth, $usthexpl) = $self->stmtHdl(<<"XxX");
1404 UPDATE OR FAIL repos SET counti=?,countu=?,utime=?,ustat=? WHERE seqno==?;
1405 XxX
1406 2 my $trows = 0;
1407 2 foreach my $seqno ( @seqnos ) {
1408 2 ▶ $self->stmtExplain($sthexpl, $seqno) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 2 2
1409 2 ▶ my $rows = $sth->execute($seqno) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
my $rows = $sth->execute($seqno) or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 2 0 2
1410 2 ▶ $rows = "0" if $rows eq "0E0";
Branch: 1 branch
BranchTrueFalseTotal
if $rows eq "0E0" 0 2 2
1411 2 ▶ print "INFO: $rows purged for $seqno\n" if $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"verbose"} 0 2 2
1412 2 $trows += $rows;
1413 2 ▶ $self->stmtExplain($usthexpl, 0, 0, time, "purged", $seqno) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 2 2
1414 $usth->execute(0, 0, time, "purged", $seqno)
1415 2 ▶ or croak("Could not execute >".$usth->{Statement}."<: ".$usth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$usth->execute(0, 0, time, "purged", $seqno) or croak('Could not execute >' . $usth->{"Statement"} . '<: ' . $usth->errstr) 2 0 2
1416 };
1417  
1418 2 ▶ if ( $trows or $options{'force'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($trows or $options{"force"}) 2 0 2
Condition33%1/3
$trows or $options{"force"}
l!l&&r!l&&!r
200
MC/DC0%0/2
$trows or $options{"force"}
$trows $options{"force"}
Truth table33%1/3
A or B
A= $trowsB= $options{"force"}
ABresult
1X1
011
000
1419 # if ( $options{'force'} ) {
1420 # print "[ANALYZE ..." if $options{'verbose'};
1421 # $self->{dbh}->do("ANALYZE;");
1422 # print "]\n" if $options{'verbose'};
1423 # };
1424  
1425 2 ▶ if ( $options{'nostat'} ) { # invalidate since they might have changed
Branch: 1 branch
BranchTrueFalseTotal
if ($options{'nostat'}) { } 0 2 2
1426 0 $self->admin('gcounti', undef);
1427 0 $self->admin('gcountu', undef);
1428 }
1429 else {
1430 2 ▶ $self->admin('gcounti', $self->idStat(undef, 'distinct' => 0) || 0);
Condition50%1/2
$self->idStat(undef, 'distinct', 0) || 0
l!l
20
MC/DC0%0/1
$self->idStat(undef, 'distinct', 0) || 0
$self->idStat(undef, 'distinct', 0)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 0)
Aresult
11
00
1431 2 ▶ $self->admin('gcountu', $self->idStat(undef, 'distinct' => 1) || 0);
Condition50%1/2
$self->idStat(undef, 'distinct', 1) || 0
l!l
20
MC/DC0%0/1
$self->idStat(undef, 'distinct', 1) || 0
$self->idStat(undef, 'distinct', 1)
Truth table50%1/2
A
A= $self->idStat(undef, 'distinct', 1)
Aresult
11
00
1432 }
1433 };
1434  
1435 2 return $trows;
1436 }
1437  
1438  
1439 =head2 Methods for headers
1440  
1441 =head3 ($rows, @oldvalues) = headerfield ( $sq_or_alias, $key [, $value] )
1442  
1443 Gets or sets an meta or admin Entry for the constituent file indicated by $sq_or_alias
1444  
1445 =cut
1446  
1447 9 ▶sub headerfield {
Subroutine headerfield: called CC=14 SCAR=30.0
Pod documented
1448 9 my ($self, $sq_or_alias, $key, $value) = @_;
1449  
1450 9 my $dbkey = "";
1451 9 ▶ if ( $dbkey = SeeAlso::Source::BeaconAggregator->beaconfields($key) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($dbkey = 'SeeAlso::Source::BeaconAggregator'->beaconfields($key)) { } 4 5 9
elsif ($key =~ /_(\w+)$/) { } 5 0 5
1452 }
1453 elsif ( $key =~ /_(\w+)$/ ) {
1454 5 $dbkey = $1}
1455 else {
1456 0 carp "Field $key not known";
1457 0 return undef;
1458 };
1459  
1460 9 my ($cond, @cval) = SeeAlso::Source::BeaconAggregator::mkConstraint($sq_or_alias);
1461  
1462 9 my ($osth, $osthexpl) = $self->stmtHdl(<<"XxX");
1463 SELECT $dbkey FROM repos $cond;
1464 XxX
1465 9 ▶ $self->stmtExplain($osthexpl, @cval) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 9 9
1466 9 ▶ $osth->execute(@cval) or croak("Could not execute >".$osth->{Statement}."<:".$osth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$osth->execute(@cval) or croak('Could not execute >' . $osth->{"Statement"} . '<:' . $osth->errstr) 9 0 9
1467 9 my $tmpval = $osth->fetchall_arrayref();
1468 9 ▶ my @oval = map { hEncode($_, $key) } map { (defined $_->[0]) ? ($_->[0]) : () } @$tmpval;
Branch: 1 branch
BranchTrueFalseTotal
defined $_->[0] ? : 7 2 9
1469 9 my $rows = scalar @oval;
1470  
1471 9 ▶ if ( (defined $value) and ($value ne "") ) { # set
Branch: 2 branches
BranchTrueFalseTotal
if (defined $value and $value ne '') { } 3 6 9
elsif (defined $value) { } 0 6 6
Condition66%2/3
defined $value and $value ne ""
!ll&&!rl&&r
603
MC/DC50%1/2
defined $value and $value ne ""
defined $value $value ne ""
Truth table66%2/3
A and B
A= defined $valueB= $value ne ""
ABresult
0X0
100
111
1472 3 my ($usth, $usthexpl) = $self->stmtHdl(<<"XxX");
1473 UPDATE OR FAIL repos SET $dbkey=? $cond;
1474 XxX
1475 3 ▶ $value = hDecode($value, $key) || "";
Condition100%2/2
hDecode($value, $key) || ''
l!l
21
MC/DC100%1/1
hDecode($value, $key) || ''
hDecode($value, $key)
Truth table100%2/2
A
A= hDecode($value, $key)
Aresult
11
00
1476 3 ▶ $self->stmtExplain($usthexpl, $value, @cval) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 3 3
1477 3 ▶ $rows = $usth->execute($value, @cval) or croak("Could not execute >".$usth->{Statement}."<:".$usth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$rows = $usth->execute($value, @cval) or croak('Could not execute >' . $usth->{"Statement"} . '<:' . $usth->errstr) 3 0 3
1478 }
1479 elsif ( defined $value ) { # clear
1480 0 my ($dsth, $dsthexpl) = $self->stmtHdl(<<"XxX");
1481 UPDATE OR FAIL repos SET $dbkey=? $cond;
1482 XxX
1483 0 ▶ $self->stmtExplain($dsthexpl, undef, @cval) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 0 0
1484 0 ▶ $rows = $dsth->execute(undef, @cval) or croak("Could not execute >".$dsth->{Statement}."<:".$dsth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$rows = $dsth->execute(undef, @cval) or croak('Could not execute >' . $dsth->{"Statement"} . '<:' . $dsth->errstr) 0 0 0
1485 }
1486 else { # read
1487 }
1488  
1489 9 return ($rows, @oval);
1490 }
1491  
1492 =head3 ($resultref, $metaref) = headers ( [ $seqno_or_alias ] )
1493  
1494 Iterates over all
1495  
1496 For each iteration returns two hash references:
1497  
1498 =over 8
1499  
1500 =item 1
1501 all official beacon fields
1502  
1503 =item 2
1504 all administrative fields (_alias, ...)
1505  
1506 =back
1507  
1508 =cut
1509  
1510 5 ▶sub headers {
Subroutine headers: called CC=10 SCAR=23.2
Pod documented
1511 5 my ($self, $seqno_or_alias) = @_;
1512  
1513 5 ▶ unless ( $self->{_iterator_info} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_iterator_info"}) 1 4 5
1514 1 my ($constraint, @cval) = SeeAlso::Source::BeaconAggregator::mkConstraint($seqno_or_alias);
1515 1 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1516 SELECT * FROM repos $constraint;
1517 XxX
1518 1 ▶ $self->stmtExplain($sthexpl, @cval) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 1 1
1519 1 ▶ $sth->execute(@cval) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute(@cval) or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 1 0 1
1520 1 $self->{_iterator_info} = $sth;
1521 };
1522  
1523 5 my $info = $self->{_iterator_info}->fetchrow_hashref;
1524 5 ▶ unless ( defined $info ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $info) 1 4 5
1525 1 ▶ croak("Error listing Collections: $self->{_iterator_info}->errstr") if $self->{_iterator_info}->err;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_iterator_info"}->err 0 1 1
1526 1 delete $self->{_iterator_info};
1527 1 return undef;
1528 }
1529  
1530 4 ▶ my $collno = $info->{seqno} || $seqno_or_alias;
Condition33%1/3
$info->{'seqno'} || $seqno_or_alias
l!l&&r!l&&!r
400
MC/DC0%0/2
$info->{'seqno'} || $seqno_or_alias
$info->{'seqno'} $seqno_or_alias
Truth table33%1/3
A || B
A= $info->{'seqno'}B= $seqno_or_alias
ABresult
1X1
011
000
1531 4 my %meta = (_seqno => $collno);
1532 4 my %result = ();
1533 4 ▶ while ( my($key, $val) = each %$info ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$info) 136 4 140
1534 136 ▶ next unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 65 71 136
1535 71 my $pval = hEncode($val, $key);
1536  
1537 71 ▶ if ( $key =~ /^bc(\w+)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^bc(\w+)$/) { } 25 46 71
1538 25 $result{$1} = $pval}
1539 else {
1540 46 $meta{"_$key"} = $pval};
1541 }
1542 4 return \%result, \%meta;
1543 }
1544  
1545 =head3 listCollections ( [ $seqno_or_alias ] )
1546  
1547 Iterates over all Sequences and returns on each call an array of
1548  
1549 Seqno, Alias, Uri, Modification time, Identifier Count and Unique identifier count
1550  
1551 Returns undef if done.
1552  
1553 =cut
1554  
1555 31 ▶sub listCollections {
Subroutine listCollections: called CC=6 SCAR=18.0
Pod documented
1556 31 my ($self, $seqno_or_alias) = @_;
1557  
1558 31 ▶ unless ( $self->{_iterator_listCollections} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_iterator_listCollections"}) 8 23 31
1559 8 my ($constraint, @cval) = SeeAlso::Source::BeaconAggregator::mkConstraint($seqno_or_alias);
1560 8 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1561 SELECT seqno, alias, uri, mtime, counti, countu FROM repos $constraint;
1562 XxX
1563 8 ▶ $self->stmtExplain($sthexpl, @cval) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 8 8
1564 8 ▶ $sth->execute(@cval) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute(@cval) or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 8 0 8
1565 8 $self->{_iterator_listCollections} = $sth;
1566 };
1567 31 my $onerow = $self->{_iterator_listCollections}->fetchrow_arrayref;
1568 31 ▶ unless ( $onerow ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($onerow) 8 23 31
1569 8 ▶ croak("Error listing Collections: $self->{_iterator_listCollections}->errstr") if $self->{_iterator_listCollections}->err;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_iterator_listCollections"}->err 0 8 8
1570 8 delete $self->{_iterator_listCollections};
1571 8 return ();
1572 };
1573 23 return @$onerow;
1574 }
1575  
1576 =head2 Statistics
1577  
1578 =head3 idStat ( [ $seqno_or_alias, %options ] )
1579  
1580 Count identifiers for the given pattern.
1581  
1582 =over 8
1583  
1584 =item Supported options:
1585  
1586 distinct => (0|1)
1587  
1588 Count multiple occurences only once
1589  
1590 verbose => (0|1)
1591  
1592 =back
1593  
1594  
1595 =cut
1596  
1597 82 ▶sub idStat {
Subroutine idStat: called CC=10 SCAR=23.5
Pod documented
1598 82 my ($self, $seqno_or_alias, %options) = @_;
1599 82 ▶ $options{'verbose'} = $self->{'verbose'} unless exists $options{'verbose'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options{"verbose"} 80 2 82
1600 82 my $cond = "";
1601 82 ▶ if ( $seqno_or_alias && ($seqno_or_alias =~ /^\d+$/) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($seqno_or_alias and $seqno_or_alias =~ /^\d+$/) { } 26 56 82
elsif ($seqno_or_alias) { } 5 51 56
Condition100%3/3
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
!ll&&!rl&&r
51526
MC/DC100%2/2
$seqno_or_alias and $seqno_or_alias =~ /^\d+$/
$seqno_or_alias $seqno_or_alias =~ /^\d+$/
Truth table100%3/3
A and B
A= $seqno_or_aliasB= $seqno_or_alias =~ /^\d+$/
ABresult
0X0
100
111
1602 26 $cond = "WHERE seqno==$seqno_or_alias"}
1603 elsif ( $seqno_or_alias ) {
1604 5 my @seqnos = $self->Seqnos('_alias', $seqno_or_alias);
1605 5 ▶ if ( @seqnos ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@seqnos) { } 5 0 5
1606 5 $cond = "WHERE seqno IN (".join(",", @seqnos).")"}
1607 else {
1608 0 carp("no Seqnos selected by $seqno_or_alias");
1609 0 return 0;
1610 };
1611 };
1612 # my $count_what = $options{'distinct'} ? "DISTINCT hash" : "*";
1613 # will not be optimized by SQLite or mySQL: SELECT COUNT($count_what) FROM beacons $cond;
1614 # my $sth= $self->stmtHdl("SELECT COUNT($count_what) FROM beacons $cond LIMIT 1;");
1615 82 ▶ my $from = $options{'distinct'} ? "(SELECT DISTINCT hash FROM beacons $cond)"
Branch: 1 branch
BranchTrueFalseTotal
$options{'distinct'} ? : 38 44 82
1616 : "beacons $cond";
1617 82 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1618 SELECT COUNT(*) FROM $from LIMIT 1;
1619 XxX
1620 82 ▶ $self->stmtExplain($sthexpl) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 82 82
1621 82 ▶ $sth->execute() or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 82 0 82
1622 82 my $hits = $sth->fetchrow_arrayref;
1623  
1624 82 ▶ return $hits->[0] || 0;
Condition50%1/2
$hits->[0] || 0
l!l
820
MC/DC0%0/1
$hits->[0] || 0
$hits->[0]
Truth table50%1/2
A
A= $hits->[0]
Aresult
11
00
1625 };
1626  
1627  
1628 =head3 idCounts ( [ $pattern, %options ] )
1629  
1630 Iterates through the entries according to the optional id filter expression.
1631  
1632 For each iteration the call returns a triple consisting of (identifier,
1633 number of rows, and sum of all individual counts).
1634  
1635 =over 8
1636  
1637 =item Supported options:
1638  
1639 distinct => (0|1)
1640  
1641 Count multiple occurences in one beacon file only once.
1642  
1643 =back
1644  
1645 =cut
1646  
1647 76 ▶sub idCounts {
Subroutine idCounts: called CC=14 SCAR=26.5
Pod documented
1648 76 my ($self, $pattern, %options) = @_;
1649 76 ▶ my $cond = $pattern ? qq!WHERE hash LIKE "$pattern"! : "";
Branch: 1 branch
BranchTrueFalseTotal
$pattern ? : 4 72 76
1650 76 ▶ my $count_what = $options{'distinct'} ? "DISTINCT seqno" : "seqno";
Branch: 1 branch
BranchTrueFalseTotal
$options{'distinct'} ? : 40 36 76
1651 76 ▶ unless ( $self->{_iterator_idCounts} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_iterator_idCounts"}) 10 66 76
1652 10 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1653 SELECT hash, COUNT($count_what), SUM(hits) FROM beacons $cond GROUP BY hash ORDER BY hash;
1654 XxX
1655 10 ▶ $self->stmtExplain($sthexpl) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 10 10
1656 10 ▶ $sth->execute() or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 10 0 10
1657 10 $self->{_iterator_idCounts} = $sth;
1658 10 ▶ unless ( defined $self->{identifierClass} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"identifierClass"}) 4 6 10
1659 4 my $package = $self->autoIdentifier();
1660 4 ▶ $options{'verbose'} && ref($package) && carp "Assuming identifiers of type ".ref($package)."\n";
Branch: 1 branch
BranchTrueFalseTotal
$options{"verbose"} and ref $package and carp('Assuming identifiers of type ' . ref($package) . "\n") 0 4 4
Condition66%2/3
$options{"verbose"} and ref $package
!ll&&!rl&&r
220
MC/DC0%0/2
$options{"verbose"} and ref $package
$options{"verbose"} ref $package
Truth table66%2/3
A and B
A= $options{"verbose"}B= ref $package
ABresult
0X0
100
111
1661 }
1662 };
1663 76 my $onerow = $self->{_iterator_idCounts}->fetchrow_arrayref;
1664 76 ▶ unless ( $onerow ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($onerow) 10 66 76
1665 10 ▶ croak("Error listing Collections: $self->{_iterator_idCounts}->errstr") if $self->{_iterator_idCounts}->err;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_iterator_idCounts"}->err 0 10 10
1666 10 delete $self->{_iterator_idCounts};
1667 10 return ();
1668 };
1669 66 ▶ if ( defined $self->{identifierClass} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"identifierClass"}) 42 24 66
1670 42 my $c = $self->{identifierClass};
1671 # compat: hash might not take an argument, must resort to value, has to be cleared before...
1672 42 $c->value("");
1673 42 ▶ my $did = $c->hash($onerow->[0]) || $c->value($onerow->[0]);
Condition100%3/3
$c->hash($onerow->[0]) || $c->value($onerow->[0])
l!l&&r!l&&!r
12282
MC/DC100%2/2
$c->hash($onerow->[0]) || $c->value($onerow->[0])
$c->hash($onerow->[0]) $c->value($onerow->[0])
Truth table100%3/3
A || B
A= $c->hash($onerow->[0])B= $c->value($onerow->[0])
ABresult
1X1
011
000
1674 42 ▶ $onerow->[0] = $c->can("pretty") ? $c->pretty() : $c->value();
Branch: 1 branch
BranchTrueFalseTotal
$c->can('pretty') ? : 14 28 42
1675 };
1676 66 return @$onerow;
1677 };
1678  
1679  
1680 =head3 idList ( [ $pattern ] )
1681  
1682 Iterates through the entries according to the optional selection.
1683  
1684 For each iteration the call returns a tuple consisting of identifier and an
1685 list of array references (Seqno, Hits, Info, explicit Link, AltId) or the emtpy list
1686 if finished.
1687  
1688 Hits, Info, Link and AltId are normalized to the empty string if undefined (or < 2 for hits).
1689  
1690 It is important to finish all iterations before calling this method for "new" arguments:
1691  
1692 1 while $db->idList(); # flush pending results
1693  
1694 =cut
1695  
1696 62 ▶sub idList {
Subroutine idList: called CC=22 SCAR=31.2
Pod documented
1697 62 my ($self, $pattern) = @_;
1698 62 ▶ my $cond = $pattern ? ($pattern =~ /%/ ? "WHERE hash LIKE ?" : qq"WHERE hash=?")
Branch: 2 branches
BranchTrueFalseTotal
$pattern ? : 22 40 62
$pattern =~ /%/ ? : 22 0 22
1699 : "";
1700 62 ▶ unless ( $self->{_iterator_idList_handle} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_iterator_idList_handle"}) 11 51 62
1701 11 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1702 SELECT hash, seqno, hits, info, link, altid FROM beacons $cond ORDER BY hash, seqno, altid;
1703 XxX
1704 11 ▶ $self->stmtExplain($sthexpl, ($pattern ? ($pattern) : () )) if $ENV{'DBI_PROFILE'};
Branch: 2 branches
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 11 11
$pattern ? : 0 0 0
1705 11 ▶ $sth->execute(($pattern ? ($pattern) : () )) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 2 branches
BranchTrueFalseTotal
$sth->execute($pattern ? $pattern : ()) or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 11 0 11
$pattern ? : 6 5 11
1706 11 $self->{_iterator_idList_handle} = $sth;
1707 11 $self->{_iterator_idList_crosscheck} = $self->RepoCols("ALTTARGET");
1708 11 $self->{_iterator_idList_prefetch} = undef;
1709 11 ▶ $self->autoIdentifier() unless defined $self->{identifierClass};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"identifierClass"} 5 6 11
1710 };
1711 62 ▶ unless ( exists $self->{_iterator_idList_prefetch} ) { # deferred exit
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_iterator_idList_prefetch"}) 11 51 62
1712 11 delete $self->{_iterator_idList_handle};
1713 11 delete $self->{_iterator_idList_crosscheck};
1714 11 return ();
1715 };
1716 51 my $pf = $self->{_iterator_idList_prefetch};
1717 51 ▶ while ( my $onerow = $self->{_iterator_idList_handle}->fetchrow_arrayref ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $onerow = $self->{"_iterator_idList_handle"}->fetchrow_arrayref) 71 11 82
1718 # $onerow->[2] = "" unless $self->{_iterator_idList_crosscheck}->{$onerow->[1]}; # kill artefacts
1719 71 ▶ $onerow->[2] = "" unless $onerow->[2]; # kill artefacts
Branch: 1 branch
BranchTrueFalseTotal
unless $onerow->[2] 51 20 71
1720 71 ▶ $onerow->[3] = "" unless defined $onerow->[3]; # kill artefacts
Branch: 1 branch
BranchTrueFalseTotal
unless defined $onerow->[3] 18 53 71
1721 71 ▶ $onerow->[4] = "" unless defined $onerow->[4]; # kill artefacts
Branch: 1 branch
BranchTrueFalseTotal
unless defined $onerow->[4] 65 6 71
1722 71 ▶ $onerow->[5] = "" unless defined $onerow->[5]; # kill artefacts
Branch: 1 branch
BranchTrueFalseTotal
unless defined $onerow->[5] 0 71 71
1723 71 ▶ if ( defined $self->{identifierClass} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"identifierClass"}) 36 35 71
1724 36 my $c = $self->{identifierClass};
1725 # compat: hash might not take an argument, must resort to value, has to be cleared before...
1726 36 $c->value("");
1727 36 ▶ my $did = $c->hash($onerow->[0]) || $c->value($onerow->[0]);
Condition100%3/3
$c->hash($onerow->[0]) || $c->value($onerow->[0])
l!l&&r!l&&!r
11241
MC/DC100%2/2
$c->hash($onerow->[0]) || $c->value($onerow->[0])
$c->hash($onerow->[0]) $c->value($onerow->[0])
Truth table100%3/3
A || B
A= $c->hash($onerow->[0])B= $c->value($onerow->[0])
ABresult
1X1
011
000
1728 36 ▶ $onerow->[0] = $c->can("pretty") ? $c->pretty() : $c->value();
Branch: 1 branch
BranchTrueFalseTotal
$c->can('pretty') ? : 12 24 36
1729 };
1730 71 ▶ if ( $pf ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pf) { } 60 11 71
1731 60 ▶ if ( $pf->[0] eq $onerow->[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pf->[0] eq $onerow->[0]) { } 20 40 60
1732 20 push(@$pf, [@$onerow[1..@$onerow-1]]);
1733 20 next;
1734 }
1735 else {
1736 40 $self->{_iterator_idList_prefetch} = [$onerow->[0], [@$onerow[1..@$onerow-1]]];
1737 40 return @$pf;
1738 }
1739 }
1740 else {
1741 11 $pf = [$onerow->[0], [@$onerow[1..@$onerow-1]]]};
1742 };
1743
1744 11 ▶ if ( $self->{_iterator_idList_handle}->err ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_iterator_idList_handle"}->err) 0 11 11
1745 0 croak("Error listing Collections: $self->{_iterator_idList_handle}->errstr");
1746 };
1747 11 delete $self->{_iterator_idList_prefetch};
1748 11 ▶ return $pf ? @$pf : ();
Branch: 1 branch
BranchTrueFalseTotal
$pf ? : 11 0 11
1749 };
1750  
1751  
1752 =head2 Manipulation of global metadata: Open Search Description
1753  
1754 =head3 setOSD ( $field, @values }
1755  
1756 Sets the field $field of the OpenSearchDescription to @value(s).
1757  
1758 =cut
1759  
1760 20 ▶sub setOSD {
Subroutine setOSD: called CC=3 SCAR=11.0
Pod documented
1761 20 my ($self) = shift;
1762 20 ▶ $self->clearOSD($_[0]) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->clearOSD($_[0]) or return undef 18 2 20
1763 18 ▶ return (defined $_[1]) ? $self->addOSD(@_) : 0; # value(s) to set
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 12 6 18
1764 };
1765  
1766 =head3 clearOSD ( $field }
1767  
1768 Clears the field $field of the OpenSearchDescription.
1769  
1770 =cut
1771  
1772 27 ▶sub clearOSD {
Subroutine clearOSD: called CC=5 SCAR=16.2
Pod documented
1773 27 my ($self, $field) = @_;
1774 27 ▶ $field || (carp("no OSD field name provided"), return undef);
Branch: 1 branch
BranchTrueFalseTotal
$field or carp("no OSD field name provided"), (return undef) 25 2 27
1775 25 ▶ defined $self->osdKeys($field) || (carp("no valid OSD field '$field'"), return undef);
Branch: 1 branch
BranchTrueFalseTotal
defined $self->osdKeys($field) or carp("no valid OSD field '${field}'"), (return undef) 23 2 25
1776 23 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1777 DELETE FROM osd WHERE key=?;
1778 XxX
1779 23 ▶ $self->stmtExplain($sthexpl, $field) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 23 23
1780 23 ▶ $sth->execute($field) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($field) or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 23 0 23
1781 23 return 1;
1782 }
1783  
1784 =head3 addOSD ( $field, @values }
1785  
1786 Adds more @value(s) as (repeatable) field $field of the OpenSearchDescription.
1787  
1788 =cut
1789  
1790 24 ▶sub addOSD {
Subroutine addOSD: called CC=6 SCAR=18.0
Pod documented
1791 24 my ($self, $field, @values) = @_;
1792 24 ▶ $field || (carp("no OSD field name provided"), return undef);
Branch: 1 branch
BranchTrueFalseTotal
$field or carp("no OSD field name provided"), (return undef) 23 1 24
1793 23 ▶ return 0 unless @values;
Branch: 1 branch
BranchTrueFalseTotal
unless @values 1 22 23
1794 22 ▶ defined $self->osdKeys($field) || (carp("no valid OSD field '$field'"), return undef);
Branch: 1 branch
BranchTrueFalseTotal
defined $self->osdKeys($field) or carp("no valid OSD field '${field}'"), (return undef) 21 1 22
1795 21 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1796 INSERT INTO osd ( key, val ) VALUES ( ?, ? );
1797 XxX
1798 21 ▶ $self->stmtExplain($sthexpl, $field, $values[0]) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 21 21
1799 21 my $tstatus = [];
1800 21 ▶ my $tuples = $sth->execute_array({ArrayTupleStatus => $tstatus}, $field, \@values) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
my $tuples = $sth->execute_array({"ArrayTupleStatus", $tstatus}, $field, \@values) or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 21 0 21
1801 21 return $tuples;
1802 }
1803  
1804 =head2 Manipulation of global metadata: Beacon Metadata
1805  
1806 These headers are used when you will be publishing a beacon file for the collection.
1807  
1808 =head3 setBeaconMeta ( $field, $value )
1809  
1810 Sets the field $field of the Beacon meta table (used to generate a BEACON file for this
1811 service) to $value.
1812  
1813 =cut
1814  
1815 4 ▶sub setBeaconMeta {
Subroutine setBeaconMeta: called CC=3 SCAR=11.0
Pod documented
1816 4 my ($self) = shift;
1817 4 ▶ $self->clearBeaconMeta(@_) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->clearBeaconMeta(@_) or return undef 2 2 4
1818 2 ▶ return (defined $_[1]) ? $self->addBeaconMeta(@_) : 0; # value to set
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 1 1 2
1819 };
1820  
1821 =head3 clearBeaconMeta ( $field }
1822  
1823 Deletes the field $field of the Beacon meta table.
1824  
1825 =cut
1826  
1827 7 ▶sub clearBeaconMeta {
Subroutine clearBeaconMeta: called CC=5 SCAR=16.2
Pod documented
1828 7 my ($self, $rfield) = @_;
1829 7 ▶ $rfield || (carp("no Beacon field name provided"), return undef);
Branch: 1 branch
BranchTrueFalseTotal
$rfield or carp("no Beacon field name provided"), (return undef) 5 2 7
1830 5 ▶ my $field = $self->beaconfields($rfield) or (carp("no valid Beacon field '$rfield'"), return undef);
Branch: 1 branch
BranchTrueFalseTotal
my $field = $self->beaconfields($rfield) or carp("no valid Beacon field '${rfield}'"), (return undef) 3 2 5
1831 3 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1832 DELETE FROM osd WHERE key=?;
1833 XxX
1834 3 ▶ $self->stmtExplain($sthexpl, $field) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 3 3
1835 3 ▶ $sth->execute($field) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($field) or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 3 0 3
1836 3 return 1;
1837 }
1838  
1839 =head3 addBeaconMeta ( $field, $value )
1840  
1841 Appends $value to the field $field of the BEACON meta table
1842  
1843 =cut
1844 7 ▶sub addBeaconMeta {
Subroutine addBeaconMeta: called CC=5 SCAR=16.2
Pod documented
1845 7 my ($self, $rfield, $value) = @_;
1846 7 ▶ $rfield || (carp("no Beacon field name provided"), return undef);
Branch: 1 branch
BranchTrueFalseTotal
$rfield or carp("no Beacon field name provided"), (return undef) 6 1 7
1847 6 ▶ my $field = $self->beaconfields($rfield) or (carp("no valid Beacon field '$rfield'"), return undef);
Branch: 1 branch
BranchTrueFalseTotal
my $field = $self->beaconfields($rfield) or carp("no valid Beacon field '${rfield}'"), (return undef) 5 1 6
1848 5 my ($sth, $sthexpl) = $self->stmtHdl(<<"XxX");
1849 INSERT INTO osd ( key, val ) VALUES ( ?, ? );
1850 XxX
1851 5 ▶ $self->stmtExplain($sthexpl, $field, $value) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 5 5
1852 5 ▶ $sth->execute($field, $value) or croak("Could not execute >".$sth->{Statement}."<: ".$sth->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$sth->execute($field, $value) or croak('Could not execute >' . $sth->{"Statement"} . '<: ' . $sth->errstr) 5 0 5
1853 5 return 1;
1854 }
1855  
1856 =head3 admin ( [$field, [$value]] )
1857  
1858 Manipulates the admin table.
1859  
1860 Yields a hashref to the admin table if called without arguments.
1861  
1862 If called with $field, returns the current value, and sets the
1863 table entry to $value if defined.
1864  
1865  
1866 =cut
1867  
1868 54 ▶sub admin {
Subroutine admin: called CC=6 SCAR=18.0
Pod documented
1869 54 my ($self, $field, $value) = @_;
1870 54 my $admref = $self->admhash();
1871 54 ▶ return $admref unless $field;
Branch: 1 branch
BranchTrueFalseTotal
unless $field 3 51 54
1872 51 my $retval = $admref->{$field};
1873 51 ▶ return $retval unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 11 40 51
1874  
1875 40 my ($admh, $admexpl) = $self->stmtHdl("INSERT OR REPLACE INTO admin VALUES (?, ?);");
1876 40 ▶ $self->stmtExplain($admexpl, $field, $value) if $ENV{'DBI_PROFILE'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"DBI_PROFILE"} 0 40 40
1877 40 ▶ $admh->execute($field, $value)
Branch: 1 branch
BranchTrueFalseTotal
$admh->execute($field, $value) or croak('Could not execute update to admin table: ' . $admh->errstr) 40 0 40
1878 or croak("Could not execute update to admin table: ".$admh->errstr);
1879 40 ▶ return defined($retval) ? $retval : "";
Branch: 1 branch
BranchTrueFalseTotal
defined $retval ? : 37 3 40
1880 }
1881  
1882  
1883 # on-the-fly conversions
1884  
1885 30 ▶sub hDecode { # external time to numeric timestamp, printf placeholders
Subroutine hDecode: called CC=9 SCAR=23.4
Pod undocumented
1886 30 my ($val, $fnam) = @_;
1887 30 ▶ return $val unless $fnam;
Branch: 1 branch
BranchTrueFalseTotal
unless $fnam 0 30 30
1888 30 ▶ local($_) = (ref $val) ? $val->{$fnam} : $val;
Branch: 1 branch
BranchTrueFalseTotal
ref $val ? : 27 3 30
1889 30 ▶ return undef unless defined $_;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 30 30
1890  
1891 30 ▶ if ( $fnam =~ /target$/i ) { s/%/%%/g; s/(\{id\}|\$PND)/%1\$s/gi; s/(\{altid\}|\$PND)/%2\$s/gi; }
Branch: 3 branches
BranchTrueFalseTotal
if ($fnam =~ /target$/i) { } 25 5 30
elsif ($fnam =~ /message$/i) { } 0 5 5
elsif ($fnam =~ /time|revisit/i) { } 3 2 5
1892 0 elsif ( $fnam =~ /message$/i ) { s/%/%%/g; s/\{hits?\}/%s/gi; }
1893 elsif ( $fnam =~ /time|revisit/i ) {
1894 3 ▶ if ( /^\d+$/ ) { # legacy UNIX timestamp
Branch: 2 branches
BranchTrueFalseTotal
if (/^\d+$/) { } 1 2 3
elsif (my $p = &HTTP::Date::str2time($_, 'GMT')) { } 2 0 2
1895 }
1896 elsif ( my $p = HTTP::Date::str2time($_, "GMT") ) { # all unqualified times are GMT
1897 2 $_ = $p}
1898 else {
1899 0 carp("could not parse value '$_' as time in field $fnam");
1900 0 return undef;
1901 };
1902 }
1903 30 return $_;
1904 }
1905  
1906 80 ▶sub hEncode { # timestamp to beacon format
Subroutine hEncode: called CC=6 SCAR=18.0
Pod undocumented
1907 80 my ($val, $fnam) = @_;
1908 80 ▶ local($_) = (ref $val) ? $val->{$fnam} : $val;
Branch: 1 branch
BranchTrueFalseTotal
ref $val ? : 0 80 80
1909 80 ▶ return undef unless defined $_;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 80 80
1910 80 ▶ if ( $fnam =~ /time|revisit/i ) { $_ = SeeAlso::Source::BeaconAggregator::tToISO($_) }
Branch: 3 branches
BranchTrueFalseTotal
if ($fnam =~ /time|revisit/i) { } 16 64 80
elsif ($fnam =~ /message/i) { } 2 62 64
elsif ($fnam =~ /target/i) { } 6 56 62
1911 2 elsif ( $fnam =~ /message/i ) { s/%s/{hits}/; s/%%/%/g; }
1912 6 elsif ( $fnam =~ /target/i ) { s/%s/{ID}/; s/%1\$s/{ID}/; s/%2\$s/{ALTID}/; s/%%/%/g; };
1913 80 return $_;
1914 }
1915  
1916 =head1 AUTHOR
1917  
1918 Thomas Berger
1919 CPAN ID: THB
1920 gymel.com
1921 THB@cpan.org
1922  
1923 =head1 COPYRIGHT
1924  
1925 This program is free software; you can redistribute
1926 it and/or modify it under the same terms as Perl itself.
1927  
1928 The full text of the license can be found in the
1929 LICENSE file included with this module.
1930  
1931 =cut
1932  
1933 37 1;
1934  
« script/sasbactrl ↑ Summary lib/SeeAlso/Source/BeaconAggregator.pm »