From 9c0ea8aee0eb8cc38616674c97b5144a57761502 Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Thu, 19 Sep 2013 14:17:33 -0400 Subject: [PATCH 1/1] Add ISSN support to Syndetic AC handler 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 Signed-off-by: Ben Shum --- .../extras/install/Makefile.debian-squeeze | 1 + .../src/extras/install/Makefile.debian-wheezy | 1 + Open-ILS/src/extras/install/Makefile.fedora | 1 + .../src/extras/install/Makefile.ubuntu-lucid | 1 + .../extras/install/Makefile.ubuntu-precise | 1 + Open-ILS/src/perlmods/Build.PL | 1 + .../perlmods/lib/OpenILS/WWW/AddedContent.pm | 22 ++++++++++++++++--- .../lib/OpenILS/WWW/AddedContent/Syndetic.pm | 10 +++++---- 8 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/extras/install/Makefile.debian-squeeze b/Open-ILS/src/extras/install/Makefile.debian-squeeze index 3bc586a091..8439fdeb7a 100644 --- a/Open-ILS/src/extras/install/Makefile.debian-squeeze +++ b/Open-ILS/src/extras/install/Makefile.debian-squeeze @@ -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\ diff --git a/Open-ILS/src/extras/install/Makefile.debian-wheezy b/Open-ILS/src/extras/install/Makefile.debian-wheezy index fb18745f68..b641feef88 100644 --- a/Open-ILS/src/extras/install/Makefile.debian-wheezy +++ b/Open-ILS/src/extras/install/Makefile.debian-wheezy @@ -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\ diff --git a/Open-ILS/src/extras/install/Makefile.fedora b/Open-ILS/src/extras/install/Makefile.fedora index 91363cbbc8..2a40209a38 100644 --- a/Open-ILS/src/extras/install/Makefile.fedora +++ b/Open-ILS/src/extras/install/Makefile.fedora @@ -59,6 +59,7 @@ FEDORA_RPMS = \ yaz export CPAN_MODULES = \ + Business::ISSN \ Net::Z3950::ZOOM \ Net::Z3950::Simple2ZOOM \ Template::Plugin::POSIX \ diff --git a/Open-ILS/src/extras/install/Makefile.ubuntu-lucid b/Open-ILS/src/extras/install/Makefile.ubuntu-lucid index eb00b54d06..02829b3d05 100644 --- a/Open-ILS/src/extras/install/Makefile.ubuntu-lucid +++ b/Open-ILS/src/extras/install/Makefile.ubuntu-lucid @@ -62,6 +62,7 @@ export DEB_APACHE_DISMODS = \ deflate export CPAN_MODULES = \ + Business::ISSN \ Business::OnlinePayment::PayPal \ Library::CallNumber::LC \ MARC::Record \ diff --git a/Open-ILS/src/extras/install/Makefile.ubuntu-precise b/Open-ILS/src/extras/install/Makefile.ubuntu-precise index 24b9b4454b..9ab56a9d29 100644 --- a/Open-ILS/src/extras/install/Makefile.ubuntu-precise +++ b/Open-ILS/src/extras/install/Makefile.ubuntu-precise @@ -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\ diff --git a/Open-ILS/src/perlmods/Build.PL b/Open-ILS/src/perlmods/Build.PL index c78af11896..e09a8b0ac3 100644 --- a/Open-ILS/src/perlmods/Build.PL +++ b/Open-ILS/src/perlmods/Build.PL @@ -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', diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm index f3c81ae309..e1c0bf03bb 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent.pm @@ -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) { @@ -200,6 +211,11 @@ sub get_rec_keys { {tag => '020'}, {subfield => 'a'} ] + }, { + '-and' => [ + {tag => '022'}, + {subfield => 'a'} + ] }, { '-and' => [ {tag => '024'}, diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Syndetic.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Syndetic.pm index 1c39733140..ad908ef7e1 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Syndetic.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/Syndetic.pm @@ -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); } -- 2.43.2