line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PICA::Store; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$PICA::Store::VERSION = '0.585'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
#ABSTRACT: CRUD interface to a L storage |
6
|
4
|
|
|
4
|
|
68314
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
130
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
3969
|
use Config::Simple; |
|
4
|
|
|
|
|
58347
|
|
|
4
|
|
|
|
|
545
|
|
9
|
4
|
|
|
4
|
|
4547
|
use PICA::SOAPClient; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use PICA::SQLiteStore; |
11
|
|
|
|
|
|
|
use Carp qw(croak); |
12
|
|
|
|
|
|
|
use Cwd qw(cwd abs_path); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
|
|
|
|
|
|
my ($class, %params) = (@_); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
readconfigfile( \%params, $ENV{PICASTORE} ) |
20
|
|
|
|
|
|
|
if exists $params{config} or exists $params{conf} ; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return PICA::SOAPClient->new( %params ) if defined $params{webcat}; |
23
|
|
|
|
|
|
|
return PICA::SQLiteStore->new( %params ) if defined $params{SQLite}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
croak('please specify a store type (webcat/SQLite) - possibly in a config file'); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub get { |
30
|
|
|
|
|
|
|
croak('abstract method "get" is not implemented'); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub create { |
35
|
|
|
|
|
|
|
croak('abstract method "create" is not implemented'); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub update { |
40
|
|
|
|
|
|
|
croak('abstract method "update" is not implemented'); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub delete { |
45
|
|
|
|
|
|
|
croak('abstract method "delete" is not implemented'); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub access { |
50
|
|
|
|
|
|
|
my ($self, %params) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
for my $key (qw(userkey password dbsid language)) { |
53
|
|
|
|
|
|
|
# do nothing |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub about { |
61
|
|
|
|
|
|
|
my $self = shift; |
62
|
|
|
|
|
|
|
return ref($self); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub readconfigfile { |
67
|
|
|
|
|
|
|
my ($params, $defaultfile) = @_; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
return unless exists $params->{conf} or exists $params->{config}; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$params->{config} = $params->{conf} unless defined $params->{config}; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
if ( not defined $params->{config} ) { |
74
|
|
|
|
|
|
|
if ( $defaultfile ) { |
75
|
|
|
|
|
|
|
$params->{config} = $defaultfile; |
76
|
|
|
|
|
|
|
} elsif (-e cwd.'/pica.conf' ) { |
77
|
|
|
|
|
|
|
$params->{config} = cwd.'/pica.conf' ; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $cfile = $params->{config}; |
82
|
|
|
|
|
|
|
return unless defined $cfile; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my %config; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
croak("config file not found: $cfile") unless -e $cfile; |
87
|
|
|
|
|
|
|
Config::Simple->import_from( $cfile, \%config) |
88
|
|
|
|
|
|
|
or croak( "Failed to parse config file $cfile" ); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
while (my ($key, $value) = each %config) { |
91
|
|
|
|
|
|
|
$key =~ s/default.//; # remove default namespace |
92
|
|
|
|
|
|
|
# TODO: add support of blocks/namespaces in config file |
93
|
|
|
|
|
|
|
$params->{$key} = $value unless exists $params->{$key}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |