[open-ils-commits] r18087 - in branches/rel_2_0/Open-ILS: examples src/perlmods/OpenILS src/perlmods/OpenILS/SIP src/perlmods/OpenILS/SIP/Transaction (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Sep 28 15:34:22 EDT 2010
Author: erickson
Date: 2010-09-28 15:34:17 -0400 (Tue, 28 Sep 2010)
New Revision: 18087
Modified:
branches/rel_2_0/Open-ILS/examples/oils_sip.xml.example
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP.pm
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm
Log:
backport 18084: sip override checkins, bug fixes
Modified: branches/rel_2_0/Open-ILS/examples/oils_sip.xml.example
===================================================================
--- branches/rel_2_0/Open-ILS/examples/oils_sip.xml.example 2010-09-28 19:33:20 UTC (rev 18086)
+++ branches/rel_2_0/Open-ILS/examples/oils_sip.xml.example 2010-09-28 19:34:17 UTC (rev 18087)
@@ -105,6 +105,15 @@
-->
</options>
+ <checkin_override>
+ <event>COPY_ALERT_MESSAGE</event>
+ <event>COPY_BAD_STATUS</event>
+ <event>COPY_STATUS_MISSING</event>
+ <!--
+ <event>COPY_STATUS_LOST</event>
+ -->
+ </checkin_override>
+
<!-- If uncommented, overrides the legacy_script_support value in opensrf.xml for SIP. -->
<!--
<legacy_script_support>false</legacy_script_support>
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm 2010-09-28 19:33:20 UTC (rev 18086)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm 2010-09-28 19:34:17 UTC (rev 18087)
@@ -41,46 +41,49 @@
if ($key ne 'usr' and $key ne 'barcode') {
syslog("LOG_ERROR", "Patron (card) lookup requested by illegeal key '$key'");
- return;
+ return undef;
}
+ unless(defined $patron_id) {
+ syslog("LOG_WARNING", "No patron ID provided to ILS::Patron->new");
+ return undef;
+ }
+
my $type = ref($class) || $class;
my $self = {};
syslog("LOG_DEBUG", "OILS: new OpenILS Patron(%s => %s): searching...", $key, $patron_id);
my $e = OpenILS::SIP->editor();
+
+ my $user_id = $patron_id;
+ if($key eq 'barcode') {
+ my $card = $e->search_actor_card({barcode => $patron_id})->[0];
+ unless($card) {
+ syslog("LOG_WARNING", "No such patron barcode: $patron_id");
+ return undef;
+ }
+ $user_id = $card->usr;
+ }
- my $c = $e->search_actor_card({$key => $patron_id}, {idlist=>1});
- my $user;
+ my $user = $e->retrieve_actor_user([
+ $user_id,
+ {
+ flesh => 2,
+ flesh_fields => {
+ au => [
+ "card",
+ "standing_penalties",
+ "addresses",
+ "billing_address",
+ "mailing_address",
+ 'profile',
+ ],
+ ausp => ['standing_penalty']
+ }
+ }
+ ]);
- if( @$c ) {
-
- $user = $e->search_actor_user(
- [
- { card => $$c[0] },
- {
- flesh => 2,
- flesh_fields => {
- "au" => [
- #"cards",
- "card",
- "standing_penalties",
- "addresses",
- "billing_address",
- "mailing_address",
- #"stat_cat_entries",
- 'profile',
- ],
- ausp => ['standing_penalty']
- }
- }
- ]
- );
-
- $user = (@$user) ? $$user[0] : undef;
- }
-
if(!$user) {
syslog("LOG_WARNING", "OILS: Unable to find patron %s => %s", $key, $patron_id);
return undef;
@@ -227,7 +230,7 @@
sub check_password {
my ($self, $pwd) = @_;
syslog('LOG_DEBUG', 'OILS: Patron->check_password()');
- return md5_hex($pwd) eq $self->{user}->passwd;
+ return $pwd and (md5_hex($pwd) eq $self->{user}->passwd);
}
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm 2010-09-28 19:33:20 UTC (rev 18086)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm 2010-09-28 19:34:17 UTC (rev 18087)
@@ -44,6 +44,8 @@
@{$self}{keys %fields} = values %fields; # copying defaults into object
+ $self->load_override_events;
+
return bless $self, $class;
}
@@ -53,6 +55,16 @@
return !$self->{item}->magnetic;
}
+my %override_events;
+sub load_override_events {
+ return if %override_events;
+ my $override = OpenILS::SIP->config->{implementation_config}->{checkin_override};
+ return unless $override;
+ my $events = $override->{event};
+ $events = [$events] unless ref $events eq 'ARRAY';
+ $override_events{$_} = 1 for @$events;
+}
+
my %org_sn_cache;
sub do_checkin {
my $self = shift;
@@ -90,25 +102,37 @@
$args->{circ_lib} = $phys_location = $org_id if defined $org_id;
}
- my $resp = $U->simplereq(
- 'open-ils.circ',
- 'open-ils.circ.checkin',
- $self->{authtoken}, $args
- );
+ my $override = 0;
+ my ($resp, $txt, $code);
- if ($debug) {
- my $s = Dumper($resp);
- $s =~ s/\n//mog;
- syslog('LOG_INFO', "OILS: Checkin response: $s");
- }
+ while(1) {
- # In oddball cases, we can receive an array of events.
- # The first event received should be treated as the main result.
- $resp = $$resp[0] if ref($resp) eq 'ARRAY';
+ my $method = 'open-ils.circ.checkin';
+ $method .= '.override' if $override;
- my $code = $U->event_code($resp);
- my $txt = (defined $code) ? $resp->{textcode} : '';
+ $resp = $U->simplereq('open-ils.circ', $method, $self->{authtoken}, $args);
+ if ($debug) {
+ my $s = Dumper($resp);
+ $s =~ s/\n//mog;
+ syslog('LOG_INFO', "OILS: Checkin response: $s");
+ }
+
+ # In oddball cases, we can receive an array of events.
+ # The first event received should be treated as the main result.
+ $resp = $$resp[0] if ref($resp) eq 'ARRAY';
+ $code = $U->event_code($resp);
+ $txt = (defined $code) ? $resp->{textcode} : '';
+
+ last if $override;
+
+ if ( $override_events{$txt} ) {
+ $override = 1;
+ } else {
+ last;
+ }
+ }
+
syslog('LOG_INFO', "OILS: Checkin resulted in event: $txt, phys_location: $phys_location");
$resp->{org} &&= OpenILS::SIP::shortname_from_id($resp->{org}); # Convert id to shortname
@@ -126,13 +150,21 @@
my $payload = $resp->{payload} || {};
- # Two places to look for hold data. These are more important and more definitive than above.
- if ($payload->{remote_hold}) {
- # actually only used for checkin at non-owning branch w/ hold at same branch
- $self->item->hold($payload->{remote_hold});
+ my ($circ, $copy);
- } elsif ($payload->{hold}) {
- $self->item->hold($payload->{hold});
+ if(ref $payload eq 'HASH') {
+
+ # Two places to look for hold data. These are more important and more definitive than above.
+ if ($payload->{remote_hold}) {
+ # actually only used for checkin at non-owning branch w/ hold at same branch
+ $self->item->hold($payload->{remote_hold});
+
+ } elsif ($payload->{hold}) {
+ $self->item->hold($payload->{hold});
+ }
+
+ $circ = $resp->{payload}->{circ} || '';
+ $copy = $resp->{payload}->{copy} || '';
}
if ($self->item->hold) {
@@ -149,10 +181,8 @@
$self->alert(1) if defined $self->alert_type; # alert_type could be "00", hypothetically
- my $circ = $resp->{payload}->{circ} || '';
- my $copy = $resp->{payload}->{copy} || '';
-
if ( $circ ) {
+ $self->{circ_user_id} = $circ->usr;
$self->ok(1);
} elsif ($txt eq 'NO_CHANGE' or $txt eq 'SUCCESS' or $txt eq 'ROUTE_ITEM') {
$self->ok(1); # NO_CHANGE means it wasn't checked out anyway, no problem
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP.pm 2010-09-28 19:33:20 UTC (rev 18086)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/SIP.pm 2010-09-28 19:34:17 UTC (rev 18087)
@@ -381,7 +381,7 @@
$xact->do_checkin( $self, $inst_id, $trans_date, $return_date, $current_loc, $item_props );
if ($xact->ok) {
- $xact->patron($self->find_patron($item->{patron}));
+ $xact->patron($self->find_patron(usr => $xact->{circ_user_id})) if $xact->{circ_user_id};
delete $item->{patron};
delete $item->{due_date};
syslog('LOG_INFO', "OILS: Checkin succeeded");
More information about the open-ils-commits
mailing list