From 8393451bb2588616ced9f73818bb29b831c20a1d Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Mon, 18 Nov 2013 15:45:40 +1300 Subject: [PATCH] Continuing work, If you hate the suroutine names now is the time to stop me --- lib/NCIP/Handler/LookupItem.pm | 4 ++++ lib/NCIP/ILS/Koha.pm | 5 +++++ lib/NCIP/Item.pm | 14 +++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/NCIP/Handler/LookupItem.pm b/lib/NCIP/Handler/LookupItem.pm index c101fa2..e5cd8da 100644 --- a/lib/NCIP/Handler/LookupItem.pm +++ b/lib/NCIP/Handler/LookupItem.pm @@ -33,6 +33,10 @@ sub handle { $xmldoc->getElementsByTagNameNS( $self->namespace(), 'ItemIdentifierValue' ); my $item = NCIP::Item->new( { itemid => $item_id->textContent(), ils => $self->ils} ); + my ($itemdata,$error) = $item->itemdata(); + if ($error){ +# handle error here + } warn $item->itemid(); } return $self->type; diff --git a/lib/NCIP/ILS/Koha.pm b/lib/NCIP/ILS/Koha.pm index 51156b1..d14256c 100644 --- a/lib/NCIP/ILS/Koha.pm +++ b/lib/NCIP/ILS/Koha.pm @@ -19,4 +19,9 @@ package NCIP::ILS::Koha; use Modern::Perl; use Object::Tiny qw{ name }; + +sub itemdata { + my $self = shift; + return ( {barcode=>'123',title=>'fish'}, undef); +} 1; diff --git a/lib/NCIP/Item.pm b/lib/NCIP/Item.pm index 3d9105f..93cfcaf 100644 --- a/lib/NCIP/Item.pm +++ b/lib/NCIP/Item.pm @@ -3,6 +3,18 @@ package NCIP::Item; use base qw(Class::Accessor); # Make accessors for the ones that makes sense -NCIP::Item->mk_accessors(qw(itemid)); +NCIP::Item->mk_accessors(qw(itemid ils)); + +# Call the apppropriate subroutine in the ILS specific code and get the data + +sub itemdata { + my $self = shift; + my $ils = $self->ils; + my ( $itemdata, $error ) = $ils->itemdata( $self->itemid ); + +# add anything NCIP specific not handled by the ILS to the itemdata object at this point, if no error + + return $itemdata, $error; +} 1; -- 2.11.0