From: Jason Stephenson Date: Fri, 24 Oct 2014 12:29:00 +0000 (-0400) Subject: Add NCIP::PhysicalAddress object. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c3bd361e04fe2be792023195a1203de9a8caecda;p=working%2FNCIPServer.git Add NCIP::PhysicalAddress object. I started to add this to the code last night to make addresses even more abstract and extensible. Instead, I took a short cut. In the light of the new day, I decided to go back and add this class as the right thing to do. We modify NCIP::ILS::Evergreen, NCIP::User::AddressInformation, and the include for UserOptionalFields to make use of the new object. Signed-off-by: Jason Stephenson --- diff --git a/lib/NCIP/ILS/Evergreen.pm b/lib/NCIP/ILS/Evergreen.pm index 87b4a77..4b444bd 100644 --- a/lib/NCIP/ILS/Evergreen.pm +++ b/lib/NCIP/ILS/Evergreen.pm @@ -50,6 +50,7 @@ use NCIP::User::PrivilegeStatus; use NCIP::StructuredPersonalUserName; use NCIP::StructuredAddress; use NCIP::ElectronicAddress; +use NCIP::PhysicalAddress; use NCIP::RequestId; use NCIP::Item::Id; use NCIP::Item::OptionalFields; @@ -1319,14 +1320,21 @@ sub handle_user_elements { foreach my $addr (@{$user->addresses()}) { next if ($U->is_true($addr->pending())); my $address = NCIP::User::AddressInformation->new({UserAddressRoleType=>$addr->address_type()}); - my $physical = NCIP::StructuredAddress->new(); - $physical->Line1($addr->street1()); - $physical->Line2($addr->street2()); - $physical->Locality($addr->city()); - $physical->Region($addr->state()); - $physical->PostalCode($addr->post_code()); - $physical->Country($addr->country()); - $address->PhysicalAddress($physical); + my $structured = NCIP::StructuredAddress->new(); + $structured->Line1($addr->street1()); + $structured->Line2($addr->street2()); + $structured->Locality($addr->city()); + $structured->Region($addr->state()); + $structured->PostalCode($addr->post_code()); + $structured->Country($addr->country()); + $address->PhysicalAddress( + NCIP::PhysicalAddress->new( + { + StructuredAddress => $structured, + Type => 'Postal Address' + } + ) + ); push @$addresses, $address; } diff --git a/lib/NCIP/PhysicalAddress.pm b/lib/NCIP/PhysicalAddress.pm new file mode 100644 index 0000000..61d1d97 --- /dev/null +++ b/lib/NCIP/PhysicalAddress.pm @@ -0,0 +1,55 @@ +# --------------------------------------------------------------- +# Copyright © 2014 Jason J.A. Stephenson +# +# This file is part of NCIPServer. +# +# NCIPServer is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# NCIPServer is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with NCIPServer. If not, see . +# --------------------------------------------------------------- +package NCIP::PhysicalAddress; +use parent qw(Class::Accessor); + + +=head1 NAME + +PhysicalAddress - A "PhysicalAddress" as defined by Z39.83-1-2012 + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + +This a "PhysicalAddress" as defined by Z39.83-1-2012. It is used +for returning user address information when requested. The fields +are as defined in the standard. + +=head1 FIELDS + +=head2 StructuredAddress + +A NCIP::StructuredAddress object to hold the actual address. + +=head2 UnstructuredAddress + +Not presently implemented. + +=head2 Type + +The PhysicalAddressType field. Usually "Postal Address" or "Street Address." + +=cut + +NCIP::PhysicalAddress->mk_accessors(qw(StructuredAddress Type)); + +1; diff --git a/lib/NCIP/User/AddressInformation.pm b/lib/NCIP/User/AddressInformation.pm index c8886ff..dde29ba 100644 --- a/lib/NCIP/User/AddressInformation.pm +++ b/lib/NCIP/User/AddressInformation.pm @@ -42,7 +42,7 @@ A text string to indicate the role of the address. =head2 PhysicalAddress -A physical address stored in a NCIP::StructuredAddress. +A physical address stored in a NCIP::PhysicalAddress. =head2 ElectronicAddress diff --git a/templates/includes/UserOptionalFields.inc b/templates/includes/UserOptionalFields.inc index cf4436d..5ef3dda 100644 --- a/templates/includes/UserOptionalFields.inc +++ b/templates/includes/UserOptionalFields.inc @@ -28,24 +28,24 @@ [% IF element.PhysicalAddress -%] -[% element.PhysicalAddress.Line1 | xml %] -[% IF element.PhysicalAddress.Line2 -%] -[% element.PhysicalAddress.Line2 | xml %] +[% element.PhysicalAddress.StructuredAddress.Line1 | xml %] +[% IF element.PhysicalAddress.StructuredAddress.Line2 -%] +[% element.PhysicalAddress.StructuredAddress.Line2 | xml %] [% END -%] -[% IF element.PhysicalAddress.Locality -%] -[% element.PhysicalAddress.Locality | xml %] +[% IF element.PhysicalAddress.StructuredAddress.Locality -%] +[% element.PhysicalAddress.StructuredAddress.Locality | xml %] [% END -%] -[% IF element.PhysicalAddress.Region -%] -[% element.PhysicalAddress.Region | xml %] +[% IF element.PhysicalAddress.StructuredAddress.Region -%] +[% element.PhysicalAddress.StructuredAddress.Region | xml %] [% END -%] -[% IF element.PhysicalAddress.Country -%] -[% element.PhysicalAddress.Country | xml %] +[% IF element.PhysicalAddress.StructuredAddress.Country -%] +[% element.PhysicalAddress.StructuredAddress.Country | xml %] [% END -%] -[% IF element.PhysicalAddress.PostalCode -%] -[% element.PhysicalAddress.PostalCode | xml %] +[% IF element.PhysicalAddress.StructuredAddress.PostalCode -%] +[% element.PhysicalAddress.StructuredAddress.PostalCode | xml %] [% END -%] -Postal Address +[% element.PhysicalAddress.Type | xml %] [% ELSIF element.ElectronicAddress -%]