line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::AlephX; |
2
|
4
|
|
|
4
|
|
82568
|
use Catmandu::Sane; |
|
4
|
|
|
|
|
158473
|
|
|
4
|
|
|
|
|
22
|
|
3
|
4
|
|
|
4
|
|
668
|
use Carp qw(confess); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
200
|
|
4
|
4
|
|
|
4
|
|
19
|
use Moo; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
18
|
|
5
|
4
|
|
|
4
|
|
1134
|
use Catmandu::Util qw(:check :is); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
10849
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "1.071"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has url => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
isa => sub { $_[0] =~ /^https?:\/\//o or die("url must be a valid web url\n"); }, |
12
|
|
|
|
|
|
|
required => 1 |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
has default_args => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
isa => sub { check_hash_ref($_[0]); }, |
17
|
|
|
|
|
|
|
lazy => 1, |
18
|
|
|
|
|
|
|
default => sub { +{}; } |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
has ua => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
lazy => 1, |
23
|
|
|
|
|
|
|
builder => '_build_ua' |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
sub _build_ua { |
26
|
0
|
|
|
0
|
|
|
require Catmandu::AlephX::UserAgent::LWP; |
27
|
0
|
|
|
|
|
|
Catmandu::AlephX::UserAgent::LWP->new(url => $_[0]->url(),default_args => $_[0]->default_args()); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Catmandu::AlephX - Low level client for Aleph X-Services |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $aleph = Catmandu::AlephX->new(url => "http://localhost/X"); |
36
|
|
|
|
|
|
|
my $item_data = $aleph->item_data(base => "rug01",doc_number => "001484477"); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
#all public methods return a Catmandu::AlephX::Response |
40
|
|
|
|
|
|
|
# 'is_success' means that the xml-response did not contain the element 'error' |
41
|
|
|
|
|
|
|
# most methods return only one 'error', but some (like update_doc) multiple. |
42
|
|
|
|
|
|
|
# other errors are thrown (xml parse error, no connection ..) |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
if($item_data->is_success){ |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
say "valid response from aleph x server"; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
}else{ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
say "aleph x server returned error-response: ".join("\n",@{$item_data->errors}); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 item-data |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head3 documentation from AlephX |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
The service retrieves the document number from the user. |
62
|
|
|
|
|
|
|
For each of the document's items it retrieves: |
63
|
|
|
|
|
|
|
Item information (From Z30). |
64
|
|
|
|
|
|
|
Loan information (from Z36). |
65
|
|
|
|
|
|
|
An indication whether the request is on-hold |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head3 example |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $item_data = $aleph->item_data(base => "rug01",doc_number => "001484477"); |
70
|
|
|
|
|
|
|
if($item_data->is_success){ |
71
|
|
|
|
|
|
|
for my $item(@{ $item_data->items() }){ |
72
|
|
|
|
|
|
|
print Dumper($item); |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
}else{ |
75
|
|
|
|
|
|
|
print STDERR join("\n",@{$item_data->errors})."\n"; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head3 remarks |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This method is equivalent to 'op' = 'item-data' |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
sub item_data { |
84
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
85
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::ItemData; |
86
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::ItemData->op(); |
87
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
88
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::ItemData->parse($res->content_ref(),\%args); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
=head2 item-data-multi |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head3 documentation from AlephX |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This service takes a document number from the user and for each of the document's items retrieves the following: |
95
|
|
|
|
|
|
|
Item information (from Z30) |
96
|
|
|
|
|
|
|
Loan information (from Z36) |
97
|
|
|
|
|
|
|
An indication of whether or not the item is on hold, has hold requests, or is expected (that is, has not arrived yet but is expected) |
98
|
|
|
|
|
|
|
It is similar to the item_data X-service, except for the parameter START_POINT, which enables the retrieval of information for documents with more than 1000 items. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head3 example |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $item_data_m = $aleph->item_data_multi(base => "rug01",doc_number => "001484477",start_point => '000000990'); |
103
|
|
|
|
|
|
|
if($item_data_m->is_success){ |
104
|
|
|
|
|
|
|
for my $item(@{ $item_data_m->items() }){ |
105
|
|
|
|
|
|
|
print Dumper($item); |
106
|
|
|
|
|
|
|
}; |
107
|
|
|
|
|
|
|
}else{ |
108
|
|
|
|
|
|
|
print STDERR join("\n",@{$item_data_m->errors})."\n"; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
say "items retrieved, starting at ".$item_data_m->start_point() if $item_data_m->start_point(); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head3 remarks |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This method is equivalent to 'op' = 'item-data-multi' |
116
|
|
|
|
|
|
|
The attribute 'start_point' only supplies a value, if the document has over 990 items |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |
119
|
|
|
|
|
|
|
sub item_data_multi { |
120
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
121
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::ItemDataMulti; |
122
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::ItemDataMulti->op(); |
123
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
124
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::ItemDataMulti->parse($res->content_ref(),\%args); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
=head2 read_item |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head3 documentation from AlephX |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
The service retrieves a requested item's record from a given ADM library in case such an item does exist in that ADM library. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head3 example |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my $readitem = $aleph->read_item(library=>"usm50",item_barcode=>293); |
135
|
|
|
|
|
|
|
if($readitem->is_success){ |
136
|
|
|
|
|
|
|
for my $z30(@{ $readitem->z30 }){ |
137
|
|
|
|
|
|
|
print Dumper($z30); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
}else{ |
140
|
|
|
|
|
|
|
say STDERR join("\n",@{$readitem->errors}); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head3 remarks |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This method is equivalent to 'op' = 'read-item' |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub read_item { |
150
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
151
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::ReadItem; |
152
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::ReadItem->op(); |
153
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
154
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::ReadItem->parse($res->content_ref(),\%args); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 find |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This service retrieves a set number and the number of records answering a search request inserted by the user. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head3 example |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
my $find = $aleph->find(request => 'wrd=(art)',base=>'rug01'); |
166
|
|
|
|
|
|
|
if($find->is_success){ |
167
|
|
|
|
|
|
|
say "set_number: ".$find->set_number; |
168
|
|
|
|
|
|
|
say "no_records: ".$find->no_records; |
169
|
|
|
|
|
|
|
say "no_entries: ".$find->no_entries; |
170
|
|
|
|
|
|
|
}else{ |
171
|
|
|
|
|
|
|
say STDERR join("\n",@{$find->errors}); |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head3 remarks |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
This method is equivalent to 'op' = 'find' |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head3 arguments |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
request - search request |
181
|
|
|
|
|
|
|
adjacent - if 'Y' then the documents should contain all the search words adjacent to each other, otherwise 'N' |
182
|
|
|
|
|
|
|
=cut |
183
|
|
|
|
|
|
|
sub find { |
184
|
0
|
|
|
0
|
1
|
|
my($self,%args)=@_; |
185
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::Find; |
186
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::Find->op(); |
187
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
188
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::Find->parse($res->content_ref(),\%args); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 find_doc |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head3 documentation from AlephX |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
This service retrieves the OAI XML format of an expanded document as given by the user. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head3 example |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
my $find = $aleph->find_doc(base=>'rug01',doc_num=>'000000444',format=>'marc'); |
200
|
|
|
|
|
|
|
if($find->is_success){ |
201
|
|
|
|
|
|
|
say Dumper($find->record); |
202
|
|
|
|
|
|
|
}else{ |
203
|
|
|
|
|
|
|
say STDERR join("\n",@{$find->errors}); |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head3 remarks |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
This method is equivalent to 'op' = 'find-doc' |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |
211
|
|
|
|
|
|
|
sub find_doc { |
212
|
0
|
|
|
0
|
1
|
|
my($self,%args)=@_; |
213
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::FindDoc; |
214
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::FindDoc->op(); |
215
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
216
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::FindDoc->parse($res->content_ref(),\%args); |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=head2 present |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
This service retrieves OAI XML format of expanded documents. |
224
|
|
|
|
|
|
|
You can view documents according to the locations within a specific set number. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head3 example |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
my $set_number = $aleph->find(request => "wrd=(BIB.AFF)",base => "rug01")->set_number; |
229
|
|
|
|
|
|
|
my $present = $aleph->present( |
230
|
|
|
|
|
|
|
set_number => $set_number, |
231
|
|
|
|
|
|
|
set_entry => "000000001-000000003" |
232
|
|
|
|
|
|
|
); |
233
|
|
|
|
|
|
|
if($present->is_success){ |
234
|
|
|
|
|
|
|
for my $record(@{ $present->records() }){ |
235
|
|
|
|
|
|
|
say "doc_number: ".$record->doc_number; |
236
|
|
|
|
|
|
|
say "\tmetadata: ".$record->metadata->type; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
}else{ |
239
|
|
|
|
|
|
|
say STDERR join("\n",@{$present->errors}); |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head3 remarks |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
This method is equivalent to 'op' = 'present' |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=cut |
247
|
|
|
|
|
|
|
sub present { |
248
|
0
|
|
|
0
|
1
|
|
my($self,%args)=@_; |
249
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::Present; |
250
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::Present->op(); |
251
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
252
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::Present->parse($res->content_ref(),\%args); |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head2 ill_get_doc_short |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
The service retrieves the doc number and the XML of the short document (Z13). |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head3 example |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
my $result = $aleph->ill_get_doc_short(doc_number => "000000001",library=>"usm01"); |
264
|
|
|
|
|
|
|
if($result->is_success){ |
265
|
|
|
|
|
|
|
for my $z30(@{ $result->z13 }){ |
266
|
|
|
|
|
|
|
print Dumper($z30); |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
}else{ |
269
|
|
|
|
|
|
|
say STDERR join("\n",@{$result->errors}); |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head3 remarks |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
This method is equivalent to 'op' = 'ill-get-doc-short' |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=cut |
277
|
|
|
|
|
|
|
sub ill_get_doc_short { |
278
|
0
|
|
|
0
|
1
|
|
my($self,%args)=@_; |
279
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::IllGetDocShort; |
280
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::IllGetDocShort->op(); |
281
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
282
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::IllGetDocShort->parse($res->content_ref(),\%args); |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
=head2 bor_auth |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
This service retrieves the Global record (Z303), Local record (Z305) and the Data record (Z304) for a given Patron if the given ID and verification code match. |
289
|
|
|
|
|
|
|
Otherwise, an error message is returned. |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head3 example |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
my %args = ( |
294
|
|
|
|
|
|
|
library => $library, |
295
|
|
|
|
|
|
|
bor_id => $bor_id, |
296
|
|
|
|
|
|
|
verification => $verification |
297
|
|
|
|
|
|
|
); |
298
|
|
|
|
|
|
|
my $auth = $aleph->bor_auth(%args); |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
if($auth->is_success){ |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
for my $type(qw(z303 z304 z305)){ |
303
|
|
|
|
|
|
|
say "$type:"; |
304
|
|
|
|
|
|
|
my $data = $auth->$type(); |
305
|
|
|
|
|
|
|
for my $key(keys %$data){ |
306
|
|
|
|
|
|
|
say "\t$key : $data->{$key}->[0]"; |
307
|
|
|
|
|
|
|
} |
308
|
|
|
|
|
|
|
} |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
}else{ |
311
|
|
|
|
|
|
|
say STDERR "error: ".join("\n",@{$auth->errors}); |
312
|
|
|
|
|
|
|
exit 1; |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=cut |
316
|
|
|
|
|
|
|
sub bor_auth { |
317
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
318
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::BorAuth; |
319
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::BorAuth->op(); |
320
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
321
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::BorAuth->parse($res->content_ref(),\%args); |
322
|
|
|
|
|
|
|
} |
323
|
|
|
|
|
|
|
=head2 bor_info |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
This service retrieves all information related to a given Patron: Global and Local records, Loan records, Loaned items records, Short doc record, Cash record, and so on, if the ID and verification code provided match. |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
If not, an error message is returned. Since the bor-info X-Service retrieves a very large amount of data, and not all of it may be relevant, you can choose to receive a part of the data, based on your needs. |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=head3 example |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
my %args = ( |
334
|
|
|
|
|
|
|
library => $library, |
335
|
|
|
|
|
|
|
bor_id => $bor_id, |
336
|
|
|
|
|
|
|
verification => $verification, |
337
|
|
|
|
|
|
|
loans => 'P' |
338
|
|
|
|
|
|
|
); |
339
|
|
|
|
|
|
|
my $info = $aleph->bor_info(%args); |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
if($info->is_success){ |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
for my $type(qw(z303 z304 z305)){ |
344
|
|
|
|
|
|
|
say "$type:"; |
345
|
|
|
|
|
|
|
my $data = $info->$type(); |
346
|
|
|
|
|
|
|
for my $key(keys %$data){ |
347
|
|
|
|
|
|
|
say "\t$key : $data->{$key}->[0]"; |
348
|
|
|
|
|
|
|
} |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
say "fine:"; |
351
|
|
|
|
|
|
|
for my $fine(@{ $info->fine() }){ |
352
|
|
|
|
|
|
|
for my $type(qw(z13 z30 z31)){ |
353
|
|
|
|
|
|
|
say "\t$type:"; |
354
|
|
|
|
|
|
|
my $data = $fine->{$type}->[0]; |
355
|
|
|
|
|
|
|
for my $key(keys %$data){ |
356
|
|
|
|
|
|
|
say "\t\t$key : $data->{$key}->[0]"; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
} |
359
|
|
|
|
|
|
|
} |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
}else{ |
362
|
|
|
|
|
|
|
say STDERR "error: ".join("\n",@{$info->errors}); |
363
|
|
|
|
|
|
|
exit 1; |
364
|
|
|
|
|
|
|
} |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=cut |
367
|
|
|
|
|
|
|
sub bor_info { |
368
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
369
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::BorInfo; |
370
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::BorInfo->op(); |
371
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
372
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::BorInfo->parse($res->content_ref(),\%args); |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
=head2 ill_bor_info |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
This service retrieves Z303, Z304, Z305 and Z308 records for a given borrower ID / barcode. |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
=head3 example |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
=cut |
384
|
|
|
|
|
|
|
sub ill_bor_info { |
385
|
0
|
|
|
0
|
1
|
|
my($self,%args)=@_; |
386
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::IllBorInfo; |
387
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::IllBorInfo->op(); |
388
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
389
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::IllBorInfo->parse($res->content_ref(),\%args); |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
sub ill_loan_info { |
393
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
394
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::IllLoanInfo; |
395
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::IllLoanInfo->op(); |
396
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
397
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::IllLoanInfo->parse($res->content_ref(),\%args); |
398
|
|
|
|
|
|
|
} |
399
|
|
|
|
|
|
|
=head2 circ_status |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
The service retrieves the circulation status for each document number entered by the user. |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
Item information (From Z30). |
406
|
|
|
|
|
|
|
Loan information (from Z36). |
407
|
|
|
|
|
|
|
Loan Status (Tab15), Due Date, Due Hour etc. |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
=head3 example |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=cut |
412
|
|
|
|
|
|
|
sub circ_status { |
413
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
414
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::CircStatus; |
415
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::CircStatus->op(); |
416
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
417
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::CircStatus->parse($res->content_ref(),\%args); |
418
|
|
|
|
|
|
|
} |
419
|
|
|
|
|
|
|
=head2 circ_stat_m |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
The service retrieves the circulation status for each document number entered by the user (suitable for documents with more than 1000 items). |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
Item information (From Z30). |
426
|
|
|
|
|
|
|
Loan information (from Z36). |
427
|
|
|
|
|
|
|
Loan Status (Tab15), Due Date, Due Hour etc. |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
This service is similar to circ-status X-service, except for the parameter START_POINT which enables to retrieve information for documents with more than 1000 items. |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
=head3 example |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
=cut |
434
|
|
|
|
|
|
|
sub circ_stat_m { |
435
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
436
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::CircStatM; |
437
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::CircStatM->op(); |
438
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
439
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::CircStatM->parse($res->content_ref(),\%args); |
440
|
|
|
|
|
|
|
} |
441
|
|
|
|
|
|
|
=head2 publish_avail |
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
This service supplies the current availability status of a document. |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
The X-Server does not change any data. |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
=head3 example |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
my $publish = $aleph->publish_avail(doc_num => '000196220,001313162,001484478,001484538,001317121,000000000',library=>'rug01'); |
452
|
|
|
|
|
|
|
if($publish->is_success){ |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
#format for $publish->list() : [ [<id>,<marc-array>], .. ] |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
for my $item(@{ $publish->list }){ |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
say "id: $item->[0]"; |
459
|
|
|
|
|
|
|
if($item->[1]){ |
460
|
|
|
|
|
|
|
say "marc array:"; |
461
|
|
|
|
|
|
|
say Dumper($item->[1]); |
462
|
|
|
|
|
|
|
}else{ |
463
|
|
|
|
|
|
|
say "nothing for $item->[0]"; |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
say "\n---"; |
467
|
|
|
|
|
|
|
} |
468
|
|
|
|
|
|
|
}else{ |
469
|
|
|
|
|
|
|
say STDERR join("\n",@{$publish->errors}); |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
=head3 remarks |
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
The parameter 'doc_num' supports multiple values, separated by ','. |
475
|
|
|
|
|
|
|
Compare this to ill_get_doc, that does not support this. |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
=cut |
478
|
|
|
|
|
|
|
sub publish_avail { |
479
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
480
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::PublishAvail; |
481
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::PublishAvail->op(); |
482
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
483
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::PublishAvail->parse($res->content_ref(),\%args); |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
=head2 ill_get_doc |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
This service takes a document number and the library where the corresponding document is located and generates the XML of the requested document as it appears in the library given. |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=head3 example |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
my $illgetdoc = $aleph->ill_get_doc(doc_number => '001317121',library=>'rug01'); |
494
|
|
|
|
|
|
|
if($illgetdoc->is_success){ |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
if($illgetdoc->record){ |
497
|
|
|
|
|
|
|
say "data: ".to_json($illgetdoc->record,{ pretty => 1 }); |
498
|
|
|
|
|
|
|
} |
499
|
|
|
|
|
|
|
else{ |
500
|
|
|
|
|
|
|
say "nothing found"; |
501
|
|
|
|
|
|
|
} |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
}else{ |
504
|
|
|
|
|
|
|
say STDERR join("\n",@{$illgetdoc->errors}); |
505
|
|
|
|
|
|
|
} |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=cut |
508
|
|
|
|
|
|
|
sub ill_get_doc { |
509
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
510
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::IllGetDoc; |
511
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::IllGetDoc->op(); |
512
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
513
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::IllGetDoc->parse($res->content_ref(),\%args); |
514
|
|
|
|
|
|
|
} |
515
|
|
|
|
|
|
|
=head2 renew |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
This service renews the loan of a given item for a given patron. |
520
|
|
|
|
|
|
|
The X-Service renews the loan only if it can be done. If, for example, there is a delinquency on the patron, the service does not renew the loan. |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
=head3 example |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=cut |
525
|
|
|
|
|
|
|
sub renew { |
526
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
527
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::Renew; |
528
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::Renew->op(); |
529
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
530
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::Renew->parse($res->content_ref(),\%args); |
531
|
|
|
|
|
|
|
} |
532
|
|
|
|
|
|
|
=head2 hold_req |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
The service creates a hold-request record (Z37) for a given item after performing initial checks. |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
=head3 example |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
=cut |
541
|
|
|
|
|
|
|
sub hold_req { |
542
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
543
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::HoldReq; |
544
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::HoldReq->op(); |
545
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
546
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::HoldReq->parse($res->content_ref(),\%args); |
547
|
|
|
|
|
|
|
} |
548
|
|
|
|
|
|
|
sub hold_req_cancel { |
549
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
550
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::HoldReqCancel; |
551
|
0
|
|
|
|
|
|
$args{'op'} = Catmandu::AlephX::Op::HoldReqCancel->op(); |
552
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
553
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::HoldReqCancel->parse($res->content_ref(),\%args); |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
sub user_auth { |
556
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
557
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::UserAuth; |
558
|
0
|
|
|
|
|
|
$args{op} = Catmandu::AlephX::Op::UserAuth->op(); |
559
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args); |
560
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::UserAuth->parse($res->content_ref(),\%args); |
561
|
|
|
|
|
|
|
} |
562
|
|
|
|
|
|
|
=head2 update_doc |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
The service performs actions (Update / Insert / Delete) related to the update of a document. |
567
|
|
|
|
|
|
|
(The service uses pc_cat_c0203 which updates a document via the GUI). |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
=head3 notes |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
When executing an update request, most of the 'errors' will be warnings instead of real errors. |
572
|
|
|
|
|
|
|
This happens because AlephX performs an 'UPDATE-CHK' before trying to execute an 'UPDATE', |
573
|
|
|
|
|
|
|
and stores all warnings during that check in the xml attribute 'error'. |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
Therefore the method 'is_success' of the Catmandu::AlephX::Response is not very usefull in this case. |
576
|
|
|
|
|
|
|
Search for the last 'error', and check wether it contains 'updated successfully'. |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
=head3 warnings |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
An updates replaces the WHOLE record. So if you fail to supply 'xml_full_req' (or indirectly 'marc'), |
581
|
|
|
|
|
|
|
the record will be deleted! |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
To be sure, please use the full xml response of 'find-doc', change the fields inside 'oai_marc', and |
584
|
|
|
|
|
|
|
supply this xml as xml_full_req. |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
Every updates adds a CAT-field to the record. Your updates can be recognized by CAT$$a == "WWW-X". |
587
|
|
|
|
|
|
|
When updating a record you need to include the old CAT fields (default), otherwise these fields will be deleted |
588
|
|
|
|
|
|
|
(and all history will be lost). |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
"Unlike other X-Services, the parameters can include XML up to 20,000 characters in length" |
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
When you update often (and therefore add a lot of CAT fields), this can lead to the error 'Server closed connection'. |
593
|
|
|
|
|
|
|
This is due to the maximum of characters allowed in an XML request. |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
Possible solution: |
596
|
|
|
|
|
|
|
1. retrieve record by 'find_doc' |
597
|
|
|
|
|
|
|
2. get marc record: |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
my $marc = $res->record->metadata->data |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
3. filter out your CAT fields ($a == "WWW-X") to shorten the XML: |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
$marc = [grep { !( $_->[0] eq "CAT" && $_->[4] eq "WWW-X" ) } @$marc]; |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
4. update $marc |
606
|
|
|
|
|
|
|
5. send |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
$aleph->update_doc(library => 'usm01',doc_action => 'UPDATE',doc_number => $doc_number,marc => $marc); |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
=> your xml will now contain one CAT field with subfield 'a' equal to 'WWW-X'. |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
=head3 example |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
my $aleph = Catmandu::AlephX->new(url => "http://localhost/X"); |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
my $doc_number = '000000444'; |
617
|
|
|
|
|
|
|
my $find_doc = $aleph->find_doc( |
618
|
|
|
|
|
|
|
doc_num => $doc_number, |
619
|
|
|
|
|
|
|
base => "usm01" |
620
|
|
|
|
|
|
|
); |
621
|
|
|
|
|
|
|
my $marc = $find_doc->record->metadata->data; |
622
|
|
|
|
|
|
|
my $content_ref = $find_doc->content_ref; |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
my %args = ( |
625
|
|
|
|
|
|
|
'library' => 'usm01', |
626
|
|
|
|
|
|
|
'doc_action' => 'UPDATE', |
627
|
|
|
|
|
|
|
'doc_number' => $doc_number, |
628
|
|
|
|
|
|
|
xml_full_req => $$content_ref |
629
|
|
|
|
|
|
|
); |
630
|
|
|
|
|
|
|
my $u = $aleph->update_doc(%args); |
631
|
|
|
|
|
|
|
if($u->is_success){ |
632
|
|
|
|
|
|
|
say "all ok"; |
633
|
|
|
|
|
|
|
}else{ |
634
|
|
|
|
|
|
|
say STDERR join("\n",@{$u->errors}); |
635
|
|
|
|
|
|
|
} |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
=head3 special support for catmandu marc records |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
when you supply the argument 'marc', an xml document will be created for you, |
640
|
|
|
|
|
|
|
and stored in the argument 'xml_full_req'. 'marc' must be an array of arrays. |
641
|
|
|
|
|
|
|
When you already supplied 'xml_full_req', it will be overwritten. |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
=cut |
644
|
|
|
|
|
|
|
sub update_doc { |
645
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
646
|
|
|
|
|
|
|
|
647
|
0
|
|
0
|
|
|
|
my $doc_num = $args{doc_num} || $args{doc_number}; |
648
|
0
|
|
|
|
|
|
delete $args{$_} for qw(doc_number doc_num); |
649
|
0
|
|
|
|
|
|
$args{doc_num} = $self->format_doc_num($doc_num); |
650
|
|
|
|
|
|
|
|
651
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::UpdateDoc; |
652
|
0
|
|
|
|
|
|
$args{op} = Catmandu::AlephX::Op::UpdateDoc->op(); |
653
|
|
|
|
|
|
|
|
654
|
0
|
0
|
0
|
|
|
|
if($args{marc}){ |
|
|
0
|
0
|
|
|
|
|
655
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Metadata::MARC::Aleph; |
656
|
0
|
|
|
|
|
|
my $m = Catmandu::AlephX::Metadata::MARC::Aleph->to_xml($args{marc}); |
657
|
0
|
|
|
|
|
|
my $xml = <<EOF; |
658
|
|
|
|
|
|
|
<?xml version = "1.0" encoding = "UTF-8"?> |
659
|
|
|
|
|
|
|
<find-doc><record><metadata>$m</metadata></record></find-doc> |
660
|
|
|
|
|
|
|
EOF |
661
|
0
|
0
|
|
|
|
|
if(length($xml) > 20000){ |
662
|
0
|
|
|
|
|
|
confess "xml_full_req cannot be longer than 20000 characters"; |
663
|
|
|
|
|
|
|
} |
664
|
0
|
|
|
|
|
|
$args{xml_full_req} = $xml; |
665
|
0
|
|
|
|
|
|
delete $args{marc}; |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
}elsif(is_string($args{doc_action}) && $args{doc_action} eq "DELETE" && !is_string($args{xml_full_req})){ |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
#although this is a delete action, determined by 'doc_num', AlephX still needs an xml_full_req, even when empty |
670
|
0
|
|
|
|
|
|
$args{xml_full_req} = <<EOF; |
671
|
|
|
|
|
|
|
<?xml version = "1.0" encoding = "UTF-8"?> |
672
|
|
|
|
|
|
|
<find-doc></find-doc> |
673
|
|
|
|
|
|
|
EOF |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
} |
676
|
|
|
|
|
|
|
|
677
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args,"POST"); |
678
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::UpdateDoc->parse($res->content_ref(),\%args); |
679
|
|
|
|
|
|
|
} |
680
|
|
|
|
|
|
|
=head2 update_item |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
The service updates an existing item in the required ADM library after performing all relevant initial checks prior to that action. |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
=head3 notes |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
AlephX stores not only errors in 'errors', but also the success message. |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
Therefore the method 'is_success' of the Catmandu::AlephX::Response is not very usefull in this case. |
691
|
|
|
|
|
|
|
Search for the last 'error', and check wether it contains 'updated successfully'. |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
The result of 'read_item' often contains translations, instead of the real values. But these |
694
|
|
|
|
|
|
|
translation cannot be used when updating items. |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
e.g. z30-item-status contains 'Regular loan' instead of '001'. |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
=head3 example |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
my $alephx = Catmandu::AlephX->new(url => "http://localhost/X"); |
701
|
|
|
|
|
|
|
my $item_barcode = '32044044980076'; |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
my %args = ( |
704
|
|
|
|
|
|
|
'library' => 'usm50', |
705
|
|
|
|
|
|
|
'item_barcode' => $item_barcode, |
706
|
|
|
|
|
|
|
); |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
my $z30 = $alephx->read_item(%args)->z30(); |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
my $xml = XMLout($z30,,RootName=>"z30",NoAttr => 1); |
711
|
|
|
|
|
|
|
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".$xml; |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
$args{xml_full_req} = $xml; |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
my $u = alephx->update_item(%args); |
716
|
|
|
|
|
|
|
if($u->is_success){ |
717
|
|
|
|
|
|
|
say "all ok"; |
718
|
|
|
|
|
|
|
}else{ |
719
|
|
|
|
|
|
|
say STDERR join("\n",@{$u->errors}); |
720
|
|
|
|
|
|
|
} |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
=cut |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
sub update_item { |
725
|
0
|
|
|
0
|
0
|
|
my($self,%args)=@_; |
726
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::UpdateItem; |
727
|
0
|
|
|
|
|
|
$args{op} = Catmandu::AlephX::Op::UpdateItem->op(); |
728
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args,"POST"); |
729
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::UpdateItem->parse($res->content_ref(),\%args); |
730
|
|
|
|
|
|
|
} |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=head2 create_item |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
=head3 documentation from Aleph X |
735
|
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
The service creates a new item in the required ADM library after performing all relevant initial checks prior to that action. |
737
|
|
|
|
|
|
|
|
738
|
|
|
|
|
|
|
The item can be created for a bib record when no ADM record is linked to it yet, or it can be created to an ADM record with existing items. |
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
=head3 notes |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
=head3 example |
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
my $alephx = Catmandu::AlephX->new(url => "http://localhost/X"); |
746
|
|
|
|
|
|
|
my $item_barcode = '32044044980076'; |
747
|
|
|
|
|
|
|
|
748
|
|
|
|
|
|
|
my %args = ( |
749
|
|
|
|
|
|
|
'adm_library' => 'rug50', |
750
|
|
|
|
|
|
|
'bib_library' => 'rug01', |
751
|
|
|
|
|
|
|
'bib_doc_number' => '231843137', |
752
|
|
|
|
|
|
|
); |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
my $xml = <<EOF; |
755
|
|
|
|
|
|
|
<?xml version="1.0" encoding="UTF-8" ?> |
756
|
|
|
|
|
|
|
<z30> |
757
|
|
|
|
|
|
|
<z30-doc-number>15</z30-doc-number> |
758
|
|
|
|
|
|
|
<z30-item-sequence>10</z30-item-sequence> |
759
|
|
|
|
|
|
|
<z30-barcode>32044003924339</z30-barcode> |
760
|
|
|
|
|
|
|
<z30-sub-library>WID</z30-sub-library> |
761
|
|
|
|
|
|
|
<z30-material>BOOK</z30-material> |
762
|
|
|
|
|
|
|
<z30-item-status>01</z30-item-status> |
763
|
|
|
|
|
|
|
<z30-open-date>19980804</z30-open-date> |
764
|
|
|
|
|
|
|
<z30-update-date>20020708</z30-update-date> |
765
|
|
|
|
|
|
|
<z30-cataloger>EXLIBRIS</z30-cataloger> |
766
|
|
|
|
|
|
|
<z30-date-last-return>20080607</z30-date-last-return> |
767
|
|
|
|
|
|
|
<z30-hour-last-return>1631</z30-hour-last-return> |
768
|
|
|
|
|
|
|
<z30-ip-last-return>CONV</z30-ip-last-return> |
769
|
|
|
|
|
|
|
<z30-no-loans>011</z30-no-loans> |
770
|
|
|
|
|
|
|
<z30-alpha>L</z30-alpha> |
771
|
|
|
|
|
|
|
<z30-collection>GEN</z30-collection> |
772
|
|
|
|
|
|
|
<z30-call-no-type>7</z30-call-no-type> |
773
|
|
|
|
|
|
|
<z30-call-no>Heb 2106.385.5</z30-call-no> |
774
|
|
|
|
|
|
|
<z30-call-no-key>7 selected</z30-call-no-key> |
775
|
|
|
|
|
|
|
<z30-call-no-2-type /> |
776
|
|
|
|
|
|
|
<z30-call-no-2 /> |
777
|
|
|
|
|
|
|
<z30-call-no-2-key /> |
778
|
|
|
|
|
|
|
<z30-description>v.1</z30-description> |
779
|
|
|
|
|
|
|
<z30-note-opac /> |
780
|
|
|
|
|
|
|
<z30-note-circulation /> |
781
|
|
|
|
|
|
|
<z30-note-internal /> |
782
|
|
|
|
|
|
|
<z30-order-number /> |
783
|
|
|
|
|
|
|
<z30-inventory-number /> |
784
|
|
|
|
|
|
|
<z30-inventory-number-date /> |
785
|
|
|
|
|
|
|
<z30-last-shelf-report-date>00000000</z30-last-shelf-report-date> |
786
|
|
|
|
|
|
|
<z30-price /> |
787
|
|
|
|
|
|
|
<z30-shelf-report-number /> |
788
|
|
|
|
|
|
|
<z30-on-shelf-date>00000000</z30-on-shelf-date> |
789
|
|
|
|
|
|
|
<z30-on-shelf-seq>000000</z30-on-shelf-seq> |
790
|
|
|
|
|
|
|
<z30-doc-number-2>000000015</z30-doc-number-2> |
791
|
|
|
|
|
|
|
<z30-schedule-sequence-2>00000</z30-schedule-sequence-2> |
792
|
|
|
|
|
|
|
<z30-copy-sequence-2>00000</z30-copy-sequence-2> |
793
|
|
|
|
|
|
|
<z30-vendor-code /> |
794
|
|
|
|
|
|
|
<z30-invoice-number /> |
795
|
|
|
|
|
|
|
<z30-line-number>00000</z30-line-number> |
796
|
|
|
|
|
|
|
<z30-pages /> |
797
|
|
|
|
|
|
|
<z30-issue-date /> |
798
|
|
|
|
|
|
|
<z30-expected-arrival-date /> |
799
|
|
|
|
|
|
|
<z30-arrival-date /> |
800
|
|
|
|
|
|
|
<z30-item-statistic /> |
801
|
|
|
|
|
|
|
<z30-item-process-status>XX</z30-item-process-status> |
802
|
|
|
|
|
|
|
<z30-copy-id>1</z30-copy-id> |
803
|
|
|
|
|
|
|
<z30-hol-doc-number>000000046</z30-hol-doc-number> |
804
|
|
|
|
|
|
|
<z30-temp-location>No</z30-temp-location> |
805
|
|
|
|
|
|
|
<z30-enumeration-a /> |
806
|
|
|
|
|
|
|
<z30-enumeration-b /> |
807
|
|
|
|
|
|
|
<z30-enumeration-c /> |
808
|
|
|
|
|
|
|
<z30-enumeration-d /> |
809
|
|
|
|
|
|
|
<z30-enumeration-e /> |
810
|
|
|
|
|
|
|
<z30-enumeration-f /> |
811
|
|
|
|
|
|
|
<z30-enumeration-g /> |
812
|
|
|
|
|
|
|
<z30-enumeration-h /> |
813
|
|
|
|
|
|
|
<z30-chronological-i /> |
814
|
|
|
|
|
|
|
<z30-chronological-j /> |
815
|
|
|
|
|
|
|
<z30-chronological-k /> |
816
|
|
|
|
|
|
|
<z30-chronological-l /> |
817
|
|
|
|
|
|
|
<z30-chronological-m /> |
818
|
|
|
|
|
|
|
<z30-supp-index-o /> |
819
|
|
|
|
|
|
|
<z30-85x-type /> |
820
|
|
|
|
|
|
|
<z30-depository-id /> |
821
|
|
|
|
|
|
|
<z30-linking-number>000000000</z30-linking-number> |
822
|
|
|
|
|
|
|
<z30-gap-indicator /> |
823
|
|
|
|
|
|
|
<z30-maintenance-count>007</z30-maintenance-count> |
824
|
|
|
|
|
|
|
<z30-process-status-date>20080408</z30-process-status-date> |
825
|
|
|
|
|
|
|
</z30> |
826
|
|
|
|
|
|
|
EOF |
827
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
$args{xml_full_req} = $xml; |
829
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
my $u = alephx->create_item(%args); |
831
|
|
|
|
|
|
|
if($u->is_success){ |
832
|
|
|
|
|
|
|
say "all ok"; |
833
|
|
|
|
|
|
|
}else{ |
834
|
|
|
|
|
|
|
say STDERR join("\n",@{$u->errors}); |
835
|
|
|
|
|
|
|
} |
836
|
|
|
|
|
|
|
|
837
|
|
|
|
|
|
|
=cut |
838
|
|
|
|
|
|
|
sub create_item { |
839
|
0
|
|
|
0
|
1
|
|
my($self,%args)=@_; |
840
|
0
|
|
|
|
|
|
require Catmandu::AlephX::Op::CreateItem; |
841
|
0
|
|
|
|
|
|
$args{op} = Catmandu::AlephX::Op::CreateItem->op(); |
842
|
0
|
|
|
|
|
|
my $res = $self->ua->request(\%args,"POST"); |
843
|
0
|
|
|
|
|
|
Catmandu::AlephX::Op::CreateItem->parse($res->content_ref(),\%args); |
844
|
|
|
|
|
|
|
} |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
sub format_doc_num { |
847
|
0
|
|
|
0
|
0
|
|
my($class,$doc_num)=@_; |
848
|
0
|
|
|
|
|
|
$doc_num = sprintf("%-9.9d",int($doc_num)); |
849
|
|
|
|
|
|
|
|
850
|
|
|
|
|
|
|
#alephx only reads first |
851
|
0
|
|
|
|
|
|
substr($doc_num,0,9); |
852
|
|
|
|
|
|
|
} |
853
|
|
|
|
|
|
|
|
854
|
|
|
|
|
|
|
=head1 AUTHOR |
855
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
Nicolas Franck, C<< <nicolas.franck at ugent.be> >> |
857
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
859
|
|
|
|
|
|
|
|
860
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
861
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
862
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
863
|
|
|
|
|
|
|
|
864
|
|
|
|
|
|
|
See L<http://dev.perl.org/licenses/> for more information. |
865
|
|
|
|
|
|
|
|
866
|
|
|
|
|
|
|
=cut |
867
|
|
|
|
|
|
|
|
868
|
|
|
|
|
|
|
# ABSTRACT: turns baubles into trinkets |
869
|
|
|
|
|
|
|
1; |