line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package METS::Files; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
95810
|
use strict; |
|
3
|
|
|
|
|
21
|
|
|
3
|
|
|
|
|
77
|
|
4
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
81
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
820
|
use Class::Utils qw(set_params); |
|
3
|
|
|
|
|
48672
|
|
|
3
|
|
|
|
|
79
|
|
7
|
3
|
|
|
3
|
|
119
|
use Error::Pure qw(err); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
108
|
|
8
|
3
|
|
|
3
|
|
1270
|
use METS::Parse::Simple; |
|
3
|
|
|
|
|
25811
|
|
|
3
|
|
|
|
|
87
|
|
9
|
3
|
|
|
3
|
|
23
|
use Readonly; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1042
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Readonly::Scalar our $EMPTY_STR => q{}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = 0.02; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Constructor. |
16
|
|
|
|
|
|
|
sub new { |
17
|
3
|
|
|
3
|
1
|
3280
|
my ($class, @params) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Create object. |
20
|
3
|
|
|
|
|
11
|
my $self = bless {}, $class; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# METS Data. |
23
|
3
|
|
|
|
|
13
|
$self->{'mets_data'} = undef; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Process parameters. |
26
|
3
|
|
|
|
|
25
|
set_params($self, @params); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Check METS data. |
29
|
3
|
100
|
|
|
|
48
|
if (! defined $self->{'mets_data'}) { |
30
|
1
|
|
|
|
|
6
|
err "Parameter 'mets_data' is required."; |
31
|
|
|
|
|
|
|
} |
32
|
2
|
|
|
|
|
16
|
$self->{'_mets'} = METS::Parse::Simple->new->parse($self->{'mets_data'}); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Compute prefix. |
35
|
2
|
|
|
|
|
112969
|
$self->{'_prefix'} = $EMPTY_STR; |
36
|
2
|
100
|
|
|
|
12
|
if (exists $self->{'_mets'}->{'xmlns:mets'}) { |
37
|
1
|
|
|
|
|
2
|
$self->{'_prefix'} = 'mets:'; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
34
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Get img files. |
44
|
|
|
|
|
|
|
sub get_use_files { |
45
|
0
|
|
|
0
|
1
|
|
my ($self, $use) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my @files; |
48
|
0
|
0
|
0
|
|
|
|
if (exists $self->{'_mets'}->{$self->{'_prefix'}.'fileSec'} |
49
|
|
|
|
|
|
|
&& exists $self->{'_mets'}->{$self->{'_prefix'}.'fileSec'} |
50
|
|
|
|
|
|
|
->{$self->{'_prefix'}.'fileGrp'}) { |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
foreach my $mets_file_grp_hr (@{$self->{'_mets'} |
53
|
|
|
|
|
|
|
->{$self->{'_prefix'}.'fileSec'} |
54
|
0
|
|
|
|
|
|
->{$self->{'_prefix'}.'fileGrp'}}) { |
55
|
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
if ($mets_file_grp_hr->{'USE'} eq $use) { |
57
|
0
|
|
|
|
|
|
foreach my $file_hr (@{$mets_file_grp_hr |
58
|
0
|
|
|
|
|
|
->{$self->{'_prefix'}.'file'}}) { |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
push @files, $file_hr |
61
|
|
|
|
|
|
|
->{$self->{'_prefix'}.'FLocat'} |
62
|
0
|
|
|
|
|
|
->{'xlink:href'}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return @files; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub get_use_types { |
72
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Get file types. |
75
|
0
|
|
|
|
|
|
my @file_types; |
76
|
0
|
0
|
0
|
|
|
|
if (exists $self->{'_mets'}->{$self->{'_prefix'}.'fileSec'} |
77
|
|
|
|
|
|
|
&& exists $self->{'_mets'}->{$self->{'_prefix'}.'fileSec'} |
78
|
|
|
|
|
|
|
->{$self->{'_prefix'}.'fileGrp'}) { |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
foreach my $mets_file_grp_hr (@{$self->{'_mets'} |
81
|
|
|
|
|
|
|
->{$self->{'_prefix'}.'fileSec'} |
82
|
0
|
|
|
|
|
|
->{$self->{'_prefix'}.'fileGrp'}}) { |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
push @file_types, $mets_file_grp_hr->{'USE'}; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return @file_types; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |