From c2bc1dd9c806861c19f8ca2b0ac95486d6c19f55 Mon Sep 17 00:00:00 2001 From: atz Date: Wed, 23 Jun 2010 17:56:45 +0000 Subject: [PATCH] SIP Callnumber extensions, POD Use org_unit shortname everywhere, no owning_lib. Checkin response and Item Info response now return callnumber w/ current SIP code. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16789 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/SIP/Item.pm | 72 ++++++++++++++++--- .../OpenILS/SIP/Transaction/Checkin.pm | 5 -- 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm b/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm index c2805691a7..a8e23bd2de 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm @@ -22,9 +22,9 @@ my %item_db; my %fields = ( id => 0, - # sip_media_type => 0, +# sip_media_type => 0, sip_item_properties => 0, - # magnetic_media => 0, +# magnetic_media => 0, permanent_location => 0, current_location => 0, # print_line => 1, @@ -104,7 +104,7 @@ sub new { } my ($circ) = $U->fetch_open_circulation($copy->id); - if($circ) { + if ($circ) { # if i am checked out, set $self->{patron} to the user's barcode my $user = $e->retrieve_actor_user( [ @@ -120,11 +120,33 @@ sub new { syslog('LOG_DEBUG', "OILS: Open circulation exists on $item_id : user = $bc"); } - $self->{id} = $item_id; - $self->{copy} = $copy; - $self->{volume} = $copy->call_number; - $self->{record} = $copy->call_number->record; - $self->{mods} = $U->record_to_mvr($self->{record}) if $self->{record}->marc; + $self->{id} = $item_id; + $self->{copy} = $copy; + $self->{volume} = $copy->call_number; + $self->{record} = $copy->call_number->record; + $self->{call_number} = $copy->call_number->label; + $self->{mods} = $U->record_to_mvr($self->{record}) if $self->{record}->marc; + + if ($copy->status->id == OILS_COPY_STATUS_IN_TRANSIT) { + my $transit = $e->search_action_transit_copy([ + { + target_copy => $copy->id, # NOT barcode ($self->id) + dest_recv_time => undef + }, + { + flesh => 1, + flesh_fields => { + atc => [ 'dest' ] + } + } + ]); + # warn "Item transit: " . Dumper($transit) . "\nItem transit->dest: " . Dumper($transit->dest);; + if ($transit) { + $self->{destination_loc} = $transit->[0]->dest->shortname; + } else { + syslog('LOG_WARNING', "OILS: Item('$item_id') status is In Transit, but no action.transit_copy found!"); + } + } syslog("LOG_DEBUG", "OILS: Item('$item_id'): found with title '%s'", $self->title_id); @@ -228,12 +250,12 @@ sub title_id { sub permanent_location { my $self = shift; - return OpenILS::SIP::clean_text($self->{volume}->owning_lib->name); + return OpenILS::SIP::clean_text($self->{copy}->circ_lib->shortname); } sub current_location { my $self = shift; - return OpenILS::SIP::clean_text($self->{copy}->circ_lib->name); + return OpenILS::SIP::clean_text($self->{copy}->circ_lib->shortname); } @@ -289,7 +311,7 @@ sub fee_currency { sub owner { my $self = shift; - return OpenILS::SIP::clean_text($self->{volume}->owning_lib->name); + return OpenILS::SIP::clean_text($self->{copy}->circ_lib->shortname); } sub hold_queue { @@ -367,3 +389,31 @@ sub available { 1; +__END__ + +=head1 NAME + +OpenILS::SIP::Item - SIP abstraction layer for OpenILS Items. + +=head1 DESCRIPTION + +=head2 owning_lib vs. circ_lib + +In Evergreen, owning_lib is the org unit that purchased the item, the place to which the item +should return after it's done rotating/floating to other branches (via staff intervention), +or some combination of those. The owning_lib, however, is not necessarily where the item +should be going "right now" or where it should return to by default. That would be the copy +circ_lib or the transit destination. (In fact, the item may B go to the owning_lib for +its entire existence). In the context of SIP, the circ_lib more accurately describes the item's +permanent location, i.e. where it needs to be sent if it's not en route to somewhere else. + +This confusion extends also to the SIP extension field of "owner". It means that the SIP owner does not +correspond to EG's asset.volume.owning_lib, mainly because owning_lib is effectively the "ultimate +owner" but not necessarily the "current owner". Because we populate SIP fields with circ_lib, the +owning_lib is unused by SIP. + +=head1 TODO + +Holds queue logic + +=cut diff --git a/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm b/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm index b466a73abf..7b802b113c 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm @@ -113,11 +113,6 @@ sub do_checkin { my $circ = $resp->{payload}->{circ} || ''; my $copy = $resp->{payload}->{copy} || ''; - if ($copy) { - ref($copy->call_number) and $self->item->call_number( $copy->call_number->label ); - # ref($copy->location ) and $self->item->collection_code($copy->location->name); - # This is misleading because if there is a hold we don't want to point back to the owning library OR its location. - } if ( $circ ) { # $self->item->{patron} = OpenILS::SIP::patron_barcode_from_id($circ->usr); # Item.pm already does this for us! -- 2.43.2