|
Lines 288-294
package C4::OAI::GetRecord;
Link Here
|
| 288 |
use strict; |
288 |
use strict; |
| 289 |
use warnings; |
289 |
use warnings; |
| 290 |
use HTTP::OAI; |
290 |
use HTTP::OAI; |
|
|
291 |
use C4::Biblio; |
| 291 |
use C4::OAI::Sets; |
292 |
use C4::OAI::Sets; |
|
|
293 |
use MARC::File::XML; |
| 292 |
|
294 |
|
| 293 |
use base ("HTTP::OAI::GetRecord"); |
295 |
use base ("HTTP::OAI::GetRecord"); |
| 294 |
|
296 |
|
|
Lines 299-329
sub new {
Link Here
|
| 299 |
my $self = HTTP::OAI::GetRecord->new(%args); |
301 |
my $self = HTTP::OAI::GetRecord->new(%args); |
| 300 |
|
302 |
|
| 301 |
my $dbh = C4::Context->dbh; |
303 |
my $dbh = C4::Context->dbh; |
|
|
304 |
my $sth = $dbh->prepare(" |
| 305 |
SELECT timestamp |
| 306 |
FROM biblioitems |
| 307 |
WHERE biblionumber=? " ); |
| 302 |
my $prefix = $repository->{koha_identifier} . ':'; |
308 |
my $prefix = $repository->{koha_identifier} . ':'; |
| 303 |
my ($biblionumber) = $args{identifier} =~ /^$prefix(.*)/; |
309 |
my ($biblionumber) = $args{identifier} =~ /^$prefix(.*)/; |
| 304 |
my ($marcxml, $timestamp); |
310 |
$sth->execute( $biblionumber ); |
| 305 |
my $deleted = 0; |
311 |
my ($timestamp); |
| 306 |
unless ( ($marcxml, $timestamp) = $dbh->selectrow_array(q/ |
312 |
unless ( ($timestamp) = $sth->fetchrow ) { |
| 307 |
SELECT marcxml, timestamp |
313 |
unless ( ($timestamp) = $dbh->selectrow_array(q/ |
| 308 |
FROM biblioitems |
314 |
SELECT timestamp |
| 309 |
WHERE biblionumber=? /, undef, $biblionumber)) { |
315 |
FROM deletedbiblio |
| 310 |
|
316 |
WHERE biblionumber=? /, undef, $biblionumber )) |
| 311 |
unless ( ($marcxml, $timestamp) = $dbh->selectrow_array(q/ |
317 |
{ |
| 312 |
SELECT biblionumber, timestamp |
318 |
return HTTP::OAI::Response->new( |
| 313 |
FROM deletedbiblio |
319 |
requestURL => $repository->self_url(), |
| 314 |
WHERE biblionumber=? /, undef, $biblionumber )) { |
320 |
errors => [ new HTTP::OAI::Error( |
| 315 |
|
|
|
| 316 |
|
| 317 |
return HTTP::OAI::Response->new( |
| 318 |
requestURL => $repository->self_url(), |
| 319 |
errors => [ new HTTP::OAI::Error( |
| 320 |
code => 'idDoesNotExist', |
321 |
code => 'idDoesNotExist', |
| 321 |
message => "There is no biblio record with this identifier", |
322 |
message => "There is no biblio record with this identifier", |
| 322 |
) ] , |
323 |
) ], |
| 323 |
); |
324 |
); |
| 324 |
} else { |
325 |
} |
| 325 |
$deleted = 1; |
326 |
else { |
| 326 |
} |
327 |
$deleted = 1; |
|
|
328 |
} |
| 329 |
} |
| 330 |
|
| 331 |
# We fetch it using this method, rather than the database directly, |
| 332 |
# so it'll include the item data |
| 333 |
my $marcxml; |
| 334 |
unless ($deleted) { |
| 335 |
my $record = GetMarcBiblio($biblionumber, 1); |
| 336 |
$marcxml = $record->as_xml(); |
| 327 |
} |
337 |
} |
| 328 |
my $oai_sets = GetOAISetsBiblio($biblionumber); |
338 |
my $oai_sets = GetOAISetsBiblio($biblionumber); |
| 329 |
my @setSpecs; |
339 |
my @setSpecs; |
|
Lines 332-341
sub new {
Link Here
|
| 332 |
} |
342 |
} |
| 333 |
|
343 |
|
| 334 |
#$self->header( HTTP::OAI::Header->new( identifier => $args{identifier} ) ); |
344 |
#$self->header( HTTP::OAI::Header->new( identifier => $args{identifier} ) ); |
| 335 |
($deleted == 1) ? $self->record( C4::OAI::DeletedRecord->new( |
345 |
$self->record( |
| 336 |
$timestamp, \@setSpecs, %args ) ) |
346 |
$deleted |
| 337 |
: $self->record( C4::OAI::Record->new( |
347 |
? C4::OAI::DeletedRecord->new($timestamp, \@setSpecs, %args) |
| 338 |
$repository, $marcxml, $timestamp, \@setSpecs, %args ) ); |
348 |
: C4::OAI::Record->new($repository, $marcxml, $timestamp, \@setSpecs, %args); |
|
|
349 |
); |
| 339 |
return $self; |
350 |
return $self; |
| 340 |
} |
351 |
} |
| 341 |
|
352 |
|
| 342 |
- |
|
|