[open-ils-commits] r10475 -
trunk/Open-ILS/src/perlmods/OpenILS/Application
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Aug 29 11:14:15 EDT 2008
Author: erickson
Date: 2008-08-29 11:14:13 -0400 (Fri, 29 Aug 2008)
New Revision: 10475
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
Log:
added use strict/warnings. fixed some missing variable declerations. cstoreeditor->create returns the new object, updated to accomodate those. exit spool method early on record create failure and return event
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2008-08-29 14:35:03 UTC (rev 10474)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Vandelay.pm 2008-08-29 15:14:13 UTC (rev 10475)
@@ -1,4 +1,5 @@
package OpenILS::Application::Vandelay;
+use strict; use warnings;
use OpenILS::Application;
use base qw/OpenILS::Application/;
@@ -61,14 +62,12 @@
$queue->name( $name );
$queue->owner( $owner );
$queue->queue_type( $type ) if ($type);
- $queue->queue_purpose( $purpose ) if ($purpose);
- my $new_id = $e->create_vandelay_bib_queue( $queue );
- $e->die_event unless ($new_id);
+ my $new_q = $e->create_vandelay_bib_queue( $queue );
+ return $e->die_event unless ($new_q);
$e->commit;
- $queue->id($new_id);
- return $queue;
+ return $new_q;
}
__PACKAGE__->register_method(
api_name => "open-ils.vandelay.bib_queue.create",
@@ -95,14 +94,12 @@
$queue->name( $name );
$queue->owner( $owner );
$queue->queue_type( $type ) if ($type);
- $queue->queue_purpose( $purpose ) if ($purpose);
- my $new_id = $e->create_vandelay_authority_queue( $queue );
- $e->die_event unless ($new_id);
+ my $new_q = $e->create_vandelay_authority_queue( $queue );
+ $e->die_event unless ($new_q);
$e->commit;
- $queue->id($new_id);
- return $queue;
+ return $new_q;
}
__PACKAGE__->register_method(
api_name => "open-ils.vandelay.authority_queue.create",
@@ -128,13 +125,11 @@
($e->allowed('CREATE_BIB_IMPORT_QUEUE', undef, $queue) ||
$e->allowed('CREATE_BIB_IMPORT_QUEUE', $queue->owner));
- my $new_id = _add_bib_rec($e, $marc, $queue->id, $purpose);
+ my $new_rec = _add_bib_rec($e, $marc, $queue->id, $purpose);
- $e->die_event unless ($new_id);
+ return $e->die_event unless ($new_rec);
$e->commit;
-
- $rec->id($new_id);
- return $rec;
+ return $new_rec;
}
__PACKAGE__->register_method(
api_name => "open-ils.vandelay.queued_bib_record.create",
@@ -174,13 +169,11 @@
($e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE', undef, $queue) ||
$e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE', $queue->owner));
- my $new_id = _add_auth_rec($e, $marc, $queue->id, $purpose);
+ my $new_rec = _add_auth_rec($e, $marc, $queue->id, $purpose);
- $e->die_event unless ($new_id);
+ return $e->die_event unless ($new_rec);
$e->commit;
-
- $rec->id($new_id);
- return $rec;
+ return $new_rec;
}
__PACKAGE__->register_method(
api_name => "open-ils.vandelay.queued_authority_record.create",
@@ -193,6 +186,7 @@
my $e = shift;
my $marc = shift;
my $queue = shift;
+ my $purpose = shift;
my $rec = new Fieldmapper::vandelay::queued_authority_record();
$rec->marc( $marc );
@@ -211,7 +205,9 @@
my $e = new_editor(authtoken => $auth, xact => 1);
- if ($self->{record_type} eq 'bib') {
+ my $type = ($self->api_name =~ /auth/) ? 'auth' : 'bib';
+
+ if ($type eq 'bib') {
return $e->die_event unless $e->checkauth;
return $e->die_event unless
($e->allowed('CREATE_BIB_IMPORT_QUEUE', undef, $queue) ||
@@ -223,7 +219,7 @@
$e->allowed('CREATE_AUTHORITY_IMPORT_QUEUE', $queue->owner));
}
- my $method = 'open-ils.vandelay.queued_'.$self->{record_type}.'_record.create';
+ my $method = "open-ils.vandelay.queued_${type}_record.create";
$method = $self->method_lookup( $method );
my $cache = new OpenSRF::Utils::Cache();
@@ -240,7 +236,7 @@
my $count = 0;
while (my $r = $batch->next) {
try {
- (my $xml = $rec->as_xml_record()) =~ s/\n//sog;
+ (my $xml = $r->as_xml_record()) =~ s/\n//sog;
$xml =~ s/^<\?xml.+\?\s*>//go;
$xml =~ s/>\s+</></go;
$xml =~ s/\p{Cc}//go;
@@ -248,9 +244,9 @@
$xml =~ s/[\x00-\x1f]//go;
if ($self->{record_type} eq 'bib') {
- _add_bib_rec( $e, $xml, $queue, $purpose );
+ _add_bib_rec( $e, $xml, $queue, $purpose ) or return $e->die_event;
} else {
- _add_auth_rec( $e, $xml, $queue, $purpose );
+ _add_auth_rec( $e, $xml, $queue, $purpose ) or return $e->die_event;
}
$count++;
More information about the open-ils-commits
mailing list