[open-ils-commits] r10578 -
trunk/Open-ILS/src/perlmods/OpenILS/Application
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Sep 10 21:57:19 EDT 2008
Author: erickson
Date: 2008-09-10 21:57:18 -0400 (Wed, 10 Sep 2008)
New Revision: 10578
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
Log:
added authority import/overlay and external entityize
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2008-09-11 01:55:58 UTC (rev 10577)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2008-09-11 01:57:18 UTC (rev 10578)
@@ -29,20 +29,6 @@
sub initialize {}
sub child_init {}
-sub entityize {
- my $stuff = shift;
- my $form = shift || '';
-
- if ($form eq 'D') {
- $stuff = NFD($stuff);
- } else {
- $stuff = NFC($stuff);
- }
-
- $stuff =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
- return $stuff;
-}
-
# --------------------------------------------------------------------------------
# Biblio ingest
@@ -247,7 +233,7 @@
$xml =~ s/^<\?xml.+\?\s*>//go;
$xml =~ s/>\s+</></go;
$xml =~ s/\p{Cc}//go;
- $xml = entityize($xml);
+ $xml = $U->entityize($xml);
$xml =~ s/[\x00-\x1f]//go;
if ($type eq 'bib') {
@@ -300,6 +286,30 @@
record_type => 'auth'
);
+__PACKAGE__->register_method(
+ api_name => "open-ils.vandelay.bib_queue.records.matches.retrieve",
+ method => 'retrieve_queue',
+ api_level => 1,
+ argc => 2,
+ stream => 1,
+ record_type => 'bib',
+ signature => {
+ desc => q/Only retrieve queued bib records that have matches against existing records/
+ }
+);
+__PACKAGE__->register_method(
+ api_name => "open-ils.vandelay.auth_queue.records.matches.retrieve",
+ method => 'retrieve_queue',
+ api_level => 1,
+ argc => 2,
+ stream => 1,
+ record_type => 'auth',
+ signature => {
+ desc => q/Only retrieve queued authority records that have matches against existing records/
+ }
+
+);
+
sub retrieve_queue {
my($self, $conn, $auth, $queue_id, $options) = @_;
my $e = new_editor(authtoken => $auth);
@@ -316,8 +326,10 @@
return $evt if $evt;
my $class = ($type eq 'bib') ? 'vqbr' : 'vqar';
- my $search = ($type eq 'bib') ? 'search_vandelay_queued_bib_record' : 'search_vandelay_queued_authority_record';
- my $retrieve = ($type eq 'bib') ? 'retrieve_vandelay_queued_bib_record' : 'retrieve_vandelay_queued_authority_record';
+ my $search = ($type eq 'bib') ?
+ 'search_vandelay_queued_bib_record' : 'search_vandelay_queued_authority_record';
+ my $retrieve = ($type eq 'bib') ?
+ 'retrieve_vandelay_queued_bib_record' : 'retrieve_vandelay_queued_authority_record';
my $record_ids = $e->$search({queue => $queue_id}, {idlist => 1});
for my $rec_id (@$record_ids) {
@@ -328,6 +340,7 @@
}
]);
$rec->clear_marc if $$options{clear_marc};
+ next if $self->api_name =~ /matches/ and not @{$rec->matches};
$conn->respond($rec);
}
return undef;
@@ -417,6 +430,37 @@
$rec->imported_as($record->id);
$rec->import_time('now');
$e->update_vandelay_queued_bib_record($rec) or return $e->die_event;
+
+ } else { # authority
+
+ my $rec = $e->retrieve_vandelay_queued_authority_record($rec_id)
+ or return $e->die_event;
+
+ $queues{$rec->queue} = 1;
+
+ my $record;
+ if(defined $overlay_map->{$rec_id}) {
+ $logger->info("vl: overlaying record $rec_id");
+ $record = $U->simplereq(
+ 'open-ils.cat',
+ 'open-ils.cat.authority.record.overlay',
+ $auth, $overlay_map->{$rec_id}, $rec->marc); #$rec->bib_source);
+ } else {
+ $logger->info("vl: importing new record");
+ $record = $U->simplereq(
+ 'open-ils.cat',
+ 'open-ils.cat.authority.record.import',
+ $auth, $rec->marc); #$rec->bib_source);
+ }
+
+ if($U->event_code($record)) {
+ $e->rollback;
+ return $record;
+ }
+
+ $rec->imported_as($record->id);
+ $rec->import_time('now');
+ $e->update_vandelay_queued_authority_record($rec) or return $e->die_event;
}
$conn->respond({total => $total, progress => ++$count, imported => $rec_id});
@@ -434,6 +478,16 @@
$e->update_vandelay_bib_queue($queue) or return $e->die_event;
}
}
+ } else {
+ my $remaining = $e->search_vandelay_queued_authority_record(
+ {queue => $q_id, import_time => undef}, {idlist => 1});
+ unless(@$remaining) {
+ my $queue = $e->retrieve_vandelay_authority_queue($q_id);
+ unless($U->is_true($queue->complete)) {
+ $queue->complete('t');
+ $e->update_vandelay_authority_queue($queue) or return $e->die_event;
+ }
+ }
}
}
@@ -462,7 +516,7 @@
my($self, $conn, $auth, $owner_id) = @_;
my $e = new_editor(authtoken => $auth);
return $e->die_event unless $e->checkauth;
- $owner_id = $e->requestor->id; # XXX add support for viewing other's queues
+ $owner_id = $e->requestor->id; # XXX add support for viewing other's queues?
my $queues;
if($self->{record_type} eq 'bib') {
$queues = $e->search_vandelay_bib_queue(
More information about the open-ils-commits
mailing list