[OPEN-ILS-DEV] PATCHES: OpenNCIP (Attn: David) and OpenILS::SIP

Brandon W. Uhlman brandon.uhlman at bclibrary.ca
Wed Jun 18 05:20:27 EDT 2008


Hi, all.

Attached are two patches for SIP2 support in Evergreen -- one to the  
OpenNCIP server module that speaks to external services, and one to  
OpenILS::SIP, Evergreen's connecting glue between OpenNCIP and the  
OpenSRF-y underbelly.

First, due_dates.patch makes some relatively trivial changes to  
MsgType.pm in OpenNCIP.

Due dates being returned by the ACS to the SC outside the  
handle_checkout() method were in a different format than those being  
returned by handle_checkout(). Specifically, handle_checkout()  
returned the due_date result direct from the SIP interface (in our  
case, Evergreen). The other due_dates (for example, in handle_renew)  
were trying to be parsed through SIP::timestamp(), which expects a  
Unix timestamp, and was getting an EG due date string. It would fail  
being parsed, and the SC would get a duedate of 1969-12-31 (or so)  
back instead.

The SIP2 standard specifically says that the ACS 'can send this date  
field in any format it wishes'. Since the format currently being  
returned by Evergreen and used in handle_checkout seems to be working  
with most SCs, and since I like consistency, I elect to use that  
format. Larry Wall once said about Perl, "it generally does what you  
want, unless what you want is consistency." We can do better. :)

My second patch resolves a problem where some SCs expect message 64,  
the Patron Information Request, to return item barcodes instead of  
item titles when asking for a list of charged/overdue items, so that  
the results can be used in an Item Information Request to ask the ACS  
for more information about the item.

This patch introduces a new configuration stanza, <options> in the  
implementation_config of an institution in oils_sip.xml. Currently,  
the only option is 'msg64_summary_datatype', which can have a value of  
'barcode', which causes message 64 responses to return item barcodes  
instead of item titles, the previously default behaviour in  
Evergreen's SIP2 implementation. Setting any value other than  
'barcode', or not setting this value at all will result in message 64  
returning titles.

The patch updates both the sample oils_sip.xml configuration file, and  
Patron.pm in the SIP2 implementation, where the charged_items()  
lookups are made.

These patches may not qualify as SIP2-fu, but they are little steps  
toward making the default shipping configuration of Evergreen a little  
bit more humane, which I think is a desirable thing.

DCO included, just in case these aren't trivial.

Thanks,

Brandon

======================================
Brandon W. Uhlman, Systems Consultant
Public Library Services Branch
Ministry of Education
Government of British Columbia
605 Robson Street, 5th Floor
Vancouver, BC  V6B 5J3

Phone: (604) 660-2972
E-mail: brandon.uhlman at gov.bc.ca
         brandon.uhlman at bclibrary.ca

~~~~~~~~~~~~~~~~~~~~~~~~

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
     have the right to submit it under the open source license
     indicated in the file; or

(b) The contribution is based upon previous work that, to the best
     of my knowledge, is covered under an appropriate open source
     license and I have the right under that license to submit that
     work with modifications, whether created in whole or in part
     by me, under the same open source license (unless I am
     permitted to submit under a different license), as indicated
     in the file; or

(c) The contribution was provided directly to me by some other
     person who certified (a), (b) or (c) and I have not modified
     it.

(d) I understand and agree that this project and the contribution
     are public and that a record of the contribution (including all
     personal information I submit with it, including my sign-off) is
     maintained indefinitely and may be redistributed consistent with
     this project or the open source license(s) involved.

Signed-off-by: Brandon Uhlman (brandon.uhlman at bclibrary.ca)



-------------- next part --------------
Index: MsgType.pm
===================================================================
RCS file: /cvsroot/openncip/src/Sip/MsgType.pm,v
retrieving revision 1.44
diff -r1.44 MsgType.pm
1118c1118
< 	    $resp .= add_field(FID_DUE_DATE, Sip::timestamp($i));
---
> 	    $resp .= add_field(FID_DUE_DATE, $i);
1121c1121
< 	    $resp .= add_field(FID_RECALL_DATE, Sip::timestamp($i));
---
> 	    $resp .= add_field(FID_RECALL_DATE, $i);
1124c1124
< 	    $resp .= add_field(FID_HOLD_PICKUP_DATE, Sip::timestamp($i));
---
> 	    $resp .= add_field(FID_HOLD_PICKUP_DATE, $i);
1356c1356
< 	$resp .= add_field(FID_DUE_DATE, Sip::timestamp($item->due_date));
---
> 	$resp .= add_field(FID_DUE_DATE, $item->due_date);
-------------- next part --------------
Index: src/perlmods/OpenILS/SIP/Patron.pm
===================================================================
--- src/perlmods/OpenILS/SIP/Patron.pm	(revision 9845)
+++ src/perlmods/OpenILS/SIP/Patron.pm	(working copy)
@@ -415,9 +415,17 @@
 
 	my @o;
 	syslog('LOG_DEBUG', "OILS: overdue_items() fleshing circs @overdues");
+	
+	
+	my @return_datatype = grep { $_->{name} eq 'msg64_summary_datatype' } @{$self->{config}->{implementation_config}->{options}->{option}};
+	
 	for my $circid (@overdues) {
 		next unless $circid;
-		push( @o, __circ_to_title($self->{editor}, $circid) );
+		if($return_datatype[0]->{value} ne 'title') {
+			push( @o, __circ_to_barcode($self->{editor}, $circid));
+		} else {
+			push( @o, __circ_to_title($self->{editor}, $circid));
+		}
 	}
 	@overdues = @o;
 
@@ -425,6 +433,14 @@
 		[ $overdues[($start-1)..($end-1)] ] : \@overdues;
 }
 
+sub __circ_to_barcode {
+	my ($e, $circ) = @_;
+	return unless $circ;
+	$circ = $e->retrieve_action_circulation($circ);
+	my $copy = $e->retrieve_asset_copy($circ->target_copy);
+	return $copy->barcode;
+}
+
 sub __circ_to_title {
 	my( $e, $circ ) = @_;
 	return unless $circ;
@@ -447,10 +463,18 @@
 
 	my @c;
 	syslog('LOG_DEBUG', "OILS: charged_items() fleshing circs @charges");
+
+	my @return_datatype = grep { $_->{name} eq 'msg64_summary_datatype' } @{$self->{config}->{implementation_config}->{options}->{option}};
+
 	for my $circid (@charges) {
 		next unless $circid;
-		push( @c, __circ_to_title($self->{editor}, $circid) );
+		if($return_datatype[0]->{value} ne 'title') {
+			push( @c, __circ_to_barcode($self->{editor}, $circid));
+		} else {
+			push( @c, __circ_to_title($self->{editor}, $circid));
+		}
 	}
+
 	@charges = @c;
 
 	return (defined $start and defined $end) ? 
Index: examples/oils_sip.xml.example
===================================================================
--- examples/oils_sip.xml.example	(revision 9845)
+++ examples/oils_sip.xml.example	(working copy)
@@ -78,7 +78,17 @@
 					<item name='renew' value='true'/>
 					<item name='renew all' value='false'/>
 				</supports>
-
+				<options>
+					<!-- msg64, the patron information request can be
+					  made to return patron barcodes by setting
+					  the option 'msg64_summary_datatype' to 'barcode'
+					  as below. Any other value, or no value at all
+					  will cause OpenILS::SIP to return the title
+					  in response to a message 64 request, which was the
+					  default behaviour in previous versions of Evergreen.
+					-->
+					<option name='msg64_summary_datatype' value='barcode' />
+				</option>
 				<scripts>
 					<path>/openils/var/</path>
                     <path>/openils/var/catalog/</path>


More information about the Open-ils-dev mailing list