[Koha-cvs] koha/C4 Biblio.pm

Joshua Ferraro jmf at kados.org
Mon Feb 20 14:26:12 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch: 	
Changes by:	Joshua Ferraro <kados at savannah.gnu.org>	06/02/20 13:26:12

Modified files:
	C4             : Biblio.pm 

Log message:
	A new subroutine to handle Z39.50 extended services. You pass it a
	connection object, service type, service options, and a record, and
	it performs the service and handles any exception found.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/C4/Biblio.pm.diff?tr1=1.142&tr2=1.143&r1=text&r2=text

Patches:
Index: koha/C4/Biblio.pm
diff -u koha/C4/Biblio.pm:1.142 koha/C4/Biblio.pm:1.143
--- koha/C4/Biblio.pm:1.142	Thu Feb 16 20:49:56 2006
+++ koha/C4/Biblio.pm	Mon Feb 20 13:26:11 2006
@@ -182,6 +182,78 @@
 	}
 }
 
+=head
+
+z3950_extended_services can handle any interaction with Zebra's extended serices package.
+
+$Zconn contains the server connection object (which is set before calling this s
+ubroutine)
+
+$service type is one of:
+        itemorder,create,drop,commit,update,xmlupdate
+
+$service_options is a hash of key/value pairs. For instance,
+if service_type is 'update', $service_options should contain:
+
+action => update action, one of specialUpdate, recordInsert, recordReplace, recordDelete, elementUpdate.
+(recordidOpaque => Opaque Record ID (user supplied)
+
+or
+
+recordidNumber => Record ID number (system number))
+record => the record itself
+
+and maybe:
+
+syntax => the record syntax (transfer syntax)
+databaseName = Database from connection object
+
+=cut
+sub z3950_extended_services {
+
+        my ($Zconn,$serviceType,$serviceOptions,$record);
+
+        # create a new package object
+        my $Zpackage = $Zconn->package();
+
+        # set our options
+        $Zpackage->option(action => $serviceOptions->{'action'});
+
+        if ($serviceOptions->{'databaseName'}) {
+                $Zpackage->option(databaseName => $serviceOptions->{'databaseName'});
+        }
+        if ($serviceOptions->{'recordIdNumber'}) {
+                $Zpackage->option(recordIdNumber => $serviceOptions->{'recordIdNumber'});
+        }
+        if ($serviceOptions->{'recordIdOpaque'}) {
+                $Zpackage->option(recordIdOpaque => $serviceOptions->{'recordIdOpaque'});
+        }
+
+        # this is an ILL request (Zebra doesn't support it)
+        if ($serviceType eq 'itemorder') {
+           $Zpackage->option('contact-name' => $serviceOptions->{'contact-name'});
+           $Zpackage->option('contact-phone' => $serviceOptions->{'contact-phone'});
+           $Zpackage->option('contact-email' => $serviceOptions->{'contact-email'});
+           $Zpackage->option('itemorder-item' => $serviceOptions->{'itemorder-item'});
+        }
+
+        if ($record) {
+           $Zpackage->option(record => $record);
+           if ($serviceOptions->{'syntax'}) {
+              $Zpackage->option(syntax => $serviceOptions->{'syntax'});
+           }
+        }
+
+        # send the request, handle any exception encountered
+        eval {  $Zpackage->send($serviceType) };
+        if ($@ && $@->isa("ZOOM::Exception")) {
+                print "Oops!  ", $@->message(), "\n";
+                return $@->code();
+        }
+        # free up package resources
+        $Zpackage->destroy();
+}
+
 =head2 @tagslib = &MARCgettagslib($dbh,1|0,$frameworkcode);
 
 =over 4
@@ -2941,8 +3013,13 @@
 
 =cut
 
-# $Id: Biblio.pm,v 1.142 2006/02/16 20:49:56 kados Exp $
+# $Id: Biblio.pm,v 1.143 2006/02/20 13:26:11 kados Exp $
 # $Log: Biblio.pm,v $
+# Revision 1.143  2006/02/20 13:26:11  kados
+# A new subroutine to handle Z39.50 extended services. You pass it a
+# connection object, service type, service options, and a record, and
+# it performs the service and handles any exception found.
+#
 # Revision 1.142  2006/02/16 20:49:56  kados
 # destroy a connection after we're done -- we really should just have one
 # connection object and not destroy it until the whole transaction is





More information about the Koha-cvs mailing list