From 02f4a902f74eb6db87d00b0d6bc553a04afa9bd5 Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sat, 16 Aug 2014 22:42:43 -0400 Subject: [PATCH] Fill out NCIP::User and friends. Signed-off-by: Jason Stephenson --- lib/NCIP/StructuredAddress.pm | 49 +++++++- lib/NCIP/StructuredPersonalUserName.pm | 70 +++++++++++ lib/NCIP/User.pm | 30 +++-- lib/NCIP/User/AddressInformation.pm | 49 ++++++++ lib/NCIP/User/BlockOrTrap.pm | 54 ++++++++ lib/NCIP/User/Id.pm | 46 +++++++ lib/NCIP/User/OptionalFields.pm | 82 ++++++++++++ lib/NCIP/User/Privilege.pm | 60 +++++++++ lib/NCIP/User/PrivilegeStatus.pm | 48 ++++++++ templates/includes/LookupUserResponse.inc | 144 ++++++++++++++++------ 10 files changed, 577 insertions(+), 55 deletions(-) create mode 100644 lib/NCIP/StructuredPersonalUserName.pm create mode 100644 lib/NCIP/User/AddressInformation.pm create mode 100644 lib/NCIP/User/BlockOrTrap.pm create mode 100644 lib/NCIP/User/Id.pm create mode 100644 lib/NCIP/User/OptionalFields.pm create mode 100644 lib/NCIP/User/Privilege.pm create mode 100644 lib/NCIP/User/PrivilegeStatus.pm diff --git a/lib/NCIP/StructuredAddress.pm b/lib/NCIP/StructuredAddress.pm index cbcc363..bbadd22 100644 --- a/lib/NCIP/StructuredAddress.pm +++ b/lib/NCIP/StructuredAddress.pm @@ -19,11 +19,50 @@ package NCIP::StructuredAddress; use parent qw(Class::Accessor); -# This a "StructuredAddress" 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. -NCIP::StructuredAddress->mk_accessors(qw(line1 line2 locality region postalcode - country)); +=head1 NAME + +StructuredAddress - A "StructuredAddress" as defined by Z39.83-1-2012 + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + +This a "StructuredAddress" 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 Line1 + +First line of the address. + +=head2 Line2 + +Second line of the address. + +=head2 Locality + +Locality of the address, typically a city. + +=head2 Region + +Region of the address, typically a state, province, or department. + +=head2 PostalCode + +The postal (or zip) code of the address. + +=head2 Country + +The country of the address. + +=cut + +NCIP::StructuredAddress->mk_accessors(qw(Line1 Line2 Locality Region PostalCode + Country)); 1; diff --git a/lib/NCIP/StructuredPersonalUserName.pm b/lib/NCIP/StructuredPersonalUserName.pm new file mode 100644 index 0000000..6118c0c --- /dev/null +++ b/lib/NCIP/StructuredPersonalUserName.pm @@ -0,0 +1,70 @@ +# --------------------------------------------------------------- +# 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::StructuredPersonalUserName; + +use parent qw(Class:Accessor); + +# The name of this class is a bit unwieldy, but comes directly from +# the standard. I wonder if we shouldn't rename for our own sanity. + +=head1 NAME + +StructuredPersonalUserName - Object to hold name information + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + +=head1 FIELDS + +The fields are text strings. + +=head2 Prefix + +Optional field to hold the user's name prefix. + +=head2 GivenName + +Optional field to hold the user's given, or first, name. + +=head2 Surname + +Required field to hold the user's surname. This is the user's family +name. + +This field is required by the standard and also so the code may tell +the difference from an unstructured name if we ever support it. + +=head2 Initials + +Optional field for the user's name initials. + +=head2 Suffix + +Optional field for the user's name suffix, if any. + +=cut + +NCIP::StructuredPersonalUserName->mk_accessors( + qw(Prefix GivenName Surname Initials Suffix) +); + +1; diff --git a/lib/NCIP/User.pm b/lib/NCIP/User.pm index 44f443f..79f0b76 100644 --- a/lib/NCIP/User.pm +++ b/lib/NCIP/User.pm @@ -20,18 +20,26 @@ package NCIP::User; use parent qw(Class::Accessor); -# User Object needs -# Authentication Input -# Block Or Trap -# Date Of Birth -# Name Information -# Previous User Id(s) -# User Address Information -# User Language -# User Privilege -# User Id +=head1 NAME + +User - An object for user information + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + +=head1 FIELDS + +=head2 UserId + +=head2 UserOptionalFields + +=cut + # Make accessors for the ones that makes sense -NCIP::User->mk_accessors(qw(userid ils userdata)); +NCIP::User->mk_accessors(qw(UserId UserOptionalFields)); 1; diff --git a/lib/NCIP/User/AddressInformation.pm b/lib/NCIP/User/AddressInformation.pm new file mode 100644 index 0000000..abf1c6a --- /dev/null +++ b/lib/NCIP/User/AddressInformation.pm @@ -0,0 +1,49 @@ +# --------------------------------------------------------------- +# 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::User::AddressInformation; + +use parent qw(Class::Accessor); + +=head1 NAME + +AddressInformation - A user's Address Information + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + +=head1 FIELDS + +=head2 UserAddressRoleType + +A text string to indicate the role of the address. + +=head2 PhysicalAddress + +A physical address stored in a StructuredAddress. + +=cut + +NCIP::User::AddressInformation->mk_accessors( + qw(UserAddressRoleType PhysicalAddress) +); + +1; diff --git a/lib/NCIP/User/BlockOrTrap.pm b/lib/NCIP/User/BlockOrTrap.pm new file mode 100644 index 0000000..5f9a8e5 --- /dev/null +++ b/lib/NCIP/User/BlockOrTrap.pm @@ -0,0 +1,54 @@ +# --------------------------------------------------------------- +# 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::User::BlockOrTrap; + +use parent qw(Class::Accessor); + +=head1 NAME + +BlockOrTrap - as defined in Z39.83-1-2012 + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + +=head1 FIELDS + +=head2 AgencyId + +=head2 BlockOrTrapType + +=head2 ValidFromDate + +=head2 ValidToDate + +=cut + +NCIP::User::BlockOrTrap->mk_accessors( + qw( + AgencyId + BlockOrTrapType + ValidFromDate + ValidToDate + ) +); + +1; diff --git a/lib/NCIP/User/Id.pm b/lib/NCIP/User/Id.pm new file mode 100644 index 0000000..1c0eeef --- /dev/null +++ b/lib/NCIP/User/Id.pm @@ -0,0 +1,46 @@ +# --------------------------------------------------------------- +# 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::User::Id; + +use parent qw(Class::Accessor); + +=head1 NAME + +Id - + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + +=head1 FIELDS + +=head2 AgencyId + +=head2 UserIdentifierType + +=head2 UserIdentifierValue + +=cut + +NCIP::User::Id->mk_accessors(qw(AgencyId UserIdentifierType + UserIdentifierValue)); + +1; diff --git a/lib/NCIP/User/OptionalFields.pm b/lib/NCIP/User/OptionalFields.pm new file mode 100644 index 0000000..d015a0d --- /dev/null +++ b/lib/NCIP/User/OptionalFields.pm @@ -0,0 +1,82 @@ +# --------------------------------------------------------------- +# 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::User::OptionalFields; + +use parent qw(Class::Accessor); + +=head1 NAME + +OptionalFields - Data class for the UserOptionalFields + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + +This data class holds the information for the UserOptionalFields. Most +of the fields of this class all hold array refs of data objects as +defined below. The one exception is NameInformation which only appears +once. + +All of the fields are optional. + +=head1 FIELDS + +=head2 NameInformation + +This field holds the name information for the user. Currently, the +templates ony support StructuredPersonalUserName. + +=head2 UserAddressInformation + +This is an array reference that contains +NCIP::User::AddressInformation objects for the user's addresses. We +currently only support StructuredAddress for physical addresses. + +=head2 UserLanguage + +A array of text strings indicating the user's languages. + +=head2 BlockOrTrap + +An array of NCIP::User::BlockOrTrap. + +=head2 UserPrivilege + +An array of NCIP::User::Privilege. + +=head2 PreviousUserId + +Not presently implemented. + +=cut + +NCIP::User::OptionalFields->mk_accessors( + qw( + NameInformation + UserAddressInformation + UserLanguage + BlockOrTrap + UserPrivilege + PreviousUserId + ) +); + +1; diff --git a/lib/NCIP/User/Privilege.pm b/lib/NCIP/User/Privilege.pm new file mode 100644 index 0000000..b875871 --- /dev/null +++ b/lib/NCIP/User/Privilege.pm @@ -0,0 +1,60 @@ +# --------------------------------------------------------------- +# 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::User::Privilege; + +use parent qw(Class::Accessor); + +=head1 NAME + +Privilege - + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + +=head1 FIELDS + +=head2 AgencyId + +=head2 AgencyUserPrivilegeType + +=head2 ValidFromDate + +=head2 ValidToDate + +=head2 UserPrivilegeStatus + +=head2 UserPrivilegeDescription + +=cut + +NCIP::User::Privilege->mk_accessors( + qw( + AgencyId + AgencyUserPrivilegeType + ValidFromDate + ValidToDate + UserPrivilegeStatus + UserPrivilegeDescription + ) +); + +1; diff --git a/lib/NCIP/User/PrivilegeStatus.pm b/lib/NCIP/User/PrivilegeStatus.pm new file mode 100644 index 0000000..cb3f258 --- /dev/null +++ b/lib/NCIP/User/PrivilegeStatus.pm @@ -0,0 +1,48 @@ +# --------------------------------------------------------------- +# 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::User::PrivilegeStatus; + +use parent qw(Class::Accessor); + +=head1 NAME + +PrivilegeStatus - + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + +=head1 FIELDS + +=head2 UserPrivilegeStatusType + +=head2 DateOfUserPrivilegeStatus + +=cut + +NCIP::User::PrivilegeStatus->mk_accessors( + qw( + UserPrivilegeStatusType + DateOfUserPrivilegeStatus + ) +); + +1; diff --git a/templates/includes/LookupUserResponse.inc b/templates/includes/LookupUserResponse.inc index a9c4057..f9b64b1 100644 --- a/templates/includes/LookupUserResponse.inc +++ b/templates/includes/LookupUserResponse.inc @@ -1,49 +1,115 @@ - -[% user.userdata.cardnumber | xml %] + +[% data.UserId.UserIdentifierValue | xml %] + +[% IF data.UserId.UserIdentifierType -%] + +[% data.UserId.UserIdentifierType | xml %] + +[% END -%] +[% IF data.UserId.AgencyId -%] + +[% data.UserId.AgencyId %] + +[% END -%] -[%# -LoanedItemsCount -LoanedItem -RequestedItemsCount -RequestedItem -%] +[% IF data.UserOptionalFields -%] -[% FOREACH element IN elements %] - [% IF element.textContent == 'User Address Information' %] - - Primary Address - - - [% user.userdata.streetnumber | xml %] [% user.userdata.address | xml %] - [% IF user.userdata.address2 %] - [% user.userdata.address2 | xml %] - [% END %] - [% IF user.userdata.city %] - [% user.userdata.city | xml %] - [% END %] - [% IF user.userdata.state %] - [% user.userdata.state | xml %] - [% END %] - [% IF user.userdata.zipcode %] - [% user.userdata.zipcode | xml %] - [% END %] - [% IF user.userdata.country %] - [% user.userdata.country | xml %] - [% END %] - - - - [% END %] - [% IF element.textContent == 'Name Information' %] + [% IF data.UserOptionalFields.NameInformation -%] - [% user.userdata.firstname | xml %] - [% user.userdata.surname | xml %] + [% IF data.UserOptionalFields.NameInformation.GivenName -%] + [% data.UserOptionalFields.NameInformation.GivenName | xml %] + [% END -%] + [% data.UserOptionalFields.NameInformation.Surname | xml %] + [% IF data.UserOptionalFields.NameInformation.Prefix -%] + [% data.UserOptionalFields.NameInformation.Prefix %] + [% END -%] + [% IF data.UserOptionalFields.NameInformation.Suffix -%] + [% data.UserOptionalFields.NameInformation.Suffix %] + [% END -%] + [% IF data.UserOptionalFields.NameInformation.Initials -%] + [% data.UserOptionalFields.NameInformation.Initials %] + [% END -%] - [% END %] -[% END %] + [% END -%] +[% IF data.UserOptionalFields.UserAddressInformation -%] + [% FOREACH element IN data.UserOptionalFields.UserAddressInformation -%] + + [% element.AddressRoleType %] + + + [% element.PhysicalAddress.Line1 | xml %] + [% IF element.PhysicalAddress.Line2 -%] + [% element.PhysicalAddress.Line2 | xml %] + [% END -%] + [% IF element.PhysicalAddress.Locality -%] + [% element.PhysicalAddress.Locality | xml %] + [% END -%] + [% IF element.PhysicalAddress.Region -%] + [% element.PhysicalAddress.Region | xml %] + [% END -%] + [% IF element.PhysicalAddress.PostalCode -%] + [% element.PhysicalAddress.PostalCode | xml %] + [% END -%] + [% IF element.PhysicalAddress.Country -%] + [% element.PhysicalAddress.Country | xml %] + [% END -%] + + + + [% END -%] +[% END -%] +[% IF data.UserOptionalFields.UserPrivilege -%] +[% FOREACH privilege IN data.UserOptionalFields.UserPrivilege -%] + + [% privilege.AgencyId | xml -%] + [% privilege.AgencyUserPrivilegeType | xml %] + [% IF privilege.ValidFromDate -%] + [% privilege.ValidFromDate | xml %] + [% END -%] + [% IF privilege.ValidToDate -%] + [% privilege.ValidToDate | xml %] + [% END -%] + [% IF privilege.UserPrivilegeDescription -%] + [% privilege.UserPrivilegeDescription | xml %] + [% END -%] + [% IF privilege.UserPrivilegeStatus -%] + + + [% privilege.UserPrivilegeStatus.UserPrivilegeStatusType | xml %] + + [% IF privilege.UserPrivilegeStatus.DateOfUserPrivilegeStatus -%] + + [% privilege.UserPrivilegeStatus.DateOfUserPrivilegeStatus | xml %] + + [% END -%] + + [% END -%] + +[% END -%] +[% END -%] +[% IF data.UserOptionalFields.UserLanguage -%] +[% FOREACH language IN data.UserOptionalFields.UserLanguage -%] + [% language | xml %] +[% END -%] +[% END -%] +[% IF data.UserOptionalFields.BlockOrTrap -%] +[% FOREACH block IN data.UserOptionalFields.BlockOrTrap -%] + + [% block.AgencyId | xml %] + [% block.BlockOrTrapType | xml %] + [% IF block.ValidFromDate -%] + [% block.ValidFromDate %] + [% END -%] + [% IF block.ValidToDate -%] + [% block.ValidToDate %] + [% END %] + +[% END -%] +[% END -%] +[% END -%] -- 2.43.2