Add ISSN support to Syndetic AC handler
authorJeff Godin <jgodin@tadl.org>
Thu, 19 Sep 2013 18:17:33 +0000 (14:17 -0400)
committerBen Shum <bshum@biblio.org>
Thu, 26 Sep 2013 17:56:21 +0000 (13:56 -0400)
Add ISSN support to OpenILS::WWW::AddedContent::Syndetic added
content handler to take advantage of new support from upstream
provider.

Signed-off-by: Jeff Godin <jgodin@tadl.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/extras/install/Makefile.debian-squeeze
Open-ILS/src/extras/install/Makefile.debian-wheezy
Open-ILS/src/extras/install/Makefile.fedora
Open-ILS/src/extras/install/Makefile.ubuntu-lucid
Open-ILS/src/extras/install/Makefile.ubuntu-precise
Open-ILS/src/perlmods/Build.PL
Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Syndetic.pm

index 3bc586a..8439fde 100644 (file)
@@ -15,6 +15,7 @@ export DEBS = \
        libbusiness-creditcard-perl\
        libbusiness-isbn-data-perl\
        libbusiness-isbn-perl\
+       libbusiness-issn-perl\
        libbusiness-onlinepayment-authorizenet-perl\
        libbusiness-onlinepayment-perl\
        libdatetime-format-builder-perl\
index fb18745..b641fee 100644 (file)
@@ -9,6 +9,7 @@ export DEBS = \
        libbusiness-creditcard-perl\
        libbusiness-isbn-data-perl\
        libbusiness-isbn-perl\
+       libbusiness-issn-perl\
        libbusiness-onlinepayment-authorizenet-perl\
        libbusiness-onlinepayment-perl\
        libdatetime-format-builder-perl\
index 91363cb..2a40209 100644 (file)
@@ -59,6 +59,7 @@ FEDORA_RPMS = \
        yaz
 
 export CPAN_MODULES = \
+       Business::ISSN \
        Net::Z3950::ZOOM \
        Net::Z3950::Simple2ZOOM \
        Template::Plugin::POSIX \
index eb00b54..02829b3 100644 (file)
@@ -62,6 +62,7 @@ export DEB_APACHE_DISMODS = \
     deflate
 
 export CPAN_MODULES = \
+       Business::ISSN \
        Business::OnlinePayment::PayPal \
        Library::CallNumber::LC \
        MARC::Record \
index 24b9b44..9ab56a9 100644 (file)
@@ -10,6 +10,7 @@ export DEBS = \
        libbusiness-edi-perl \
        libbusiness-isbn-data-perl\
        libbusiness-isbn-perl\
+       libbusiness-issn-perl\
        libbusiness-onlinepayment-authorizenet-perl\
        libbusiness-onlinepayment-perl\
        libdatetime-format-builder-perl\
index c78af11..e09a8b0 100644 (file)
@@ -17,6 +17,7 @@ my $build = Module::Build->new(
         'APR::Table' => '0',
         'Business::CreditCard' => '0',
         'Business::ISBN' => '0',
+        'Business::ISSN' => '0',
         'Business::OnlinePayment' => '0',
         'Carp' => '0',
         'CGI' => '0',
index f3c81ae..e1c0bf0 100644 (file)
@@ -21,6 +21,7 @@ use LWP::UserAgent;
 use MIME::Base64;
 
 use Business::ISBN;
+use Business::ISSN;
 
 my $AC = __PACKAGE__;
 
@@ -138,7 +139,8 @@ sub handler {
     } else {
         my $key_data = get_rec_keys($keyvalue);
         my @isbns = grep {$_->{tag} eq '020'} @$key_data;
-        my @upcs = grep {$_->{tag} eq '024'} @$key_data;
+        my @issns = grep {$_->{tag} eq '022'} @$key_data;
+        my @upcs  = grep {$_->{tag} eq '024'} @$key_data;
 
         map {
             my $isbn_obj = Business::ISBN->new($_->{value});
@@ -148,13 +150,22 @@ sub handler {
             undef $_ if !defined($_->{value});
         } @isbns;
 
+        map {
+            my $issn_obj = Business::ISSN->new($_->{value});
+            my $issn_str;
+            $issn_str = $issn_obj->as_string() if defined($issn_obj && $issn_obj->is_valid);
+            $_->{value} = $issn_str;
+            undef $_ if !defined($_->{value});
+        } @issns;
+
         $keyhash = {
             isbn => [map {$_->{value}} @isbns],
-            upc => [map {$_->{value}} @upcs]
+            issn => [map {$_->{value}} @issns],
+            upc  => [map {$_->{value}} @upcs]
         };
     }
 
-    return Apache2::Const::NOT_FOUND unless @{$keyhash->{isbn}} || @{$keyhash->{upc}};
+    return Apache2::Const::NOT_FOUND unless @{$keyhash->{isbn}} || @{$keyhash->{issn}} || @{$keyhash->{upc}};
 
     try {
         if ($handler->can('expects_keyhash') && $handler->expects_keyhash() eq 1) {
@@ -202,6 +213,11 @@ sub get_rec_keys {
                     ]
                 }, {
                     '-and' => [
+                        {tag => '022'},
+                        {subfield => 'a'}
+                    ]
+                }, {
+                    '-and' => [
                         {tag => '024'},
                         {subfield => 'a'},
                         {ind1 => 1}
index 1c39733..ad908ef 100644 (file)
@@ -288,14 +288,16 @@ sub fetch_response {
     my( $self, $page, $keys, $notype ) = @_;
     my $uname = $self->userid;
 
-    # Fetch single isbn and single upc
+    # Fetch single isbn, upc, and issn
     my $isbn = $keys->{isbn}[0];
-    my $upc = $keys->{upc}[0];
+    my $upc  = $keys->{upc}[0];
+    my $issn = $keys->{issn}[0];
 
     $isbn = '' if !defined($isbn);
-    $upc = '' if !defined($upc);
+    $upc  = '' if !defined($upc);
+    $issn = '' if !defined($issn);
 
-    my $url = $self->base_url . "?isbn=$isbn/$page&upc=$upc&client=$uname" . (($notype) ? '' : "&type=rw12");
+    my $url = $self->base_url . "?isbn=$isbn/$page&upc=$upc&issn=$issn&client=$uname" . (($notype) ? '' : "&type=rw12");
     return $AC->get_url($url);
 }