Catmandu-AlephX-1.073/000755 000765 000024 00000000000 14107211622 015372 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/Build.PL000644 000765 000024 00000000264 14107211622 016670 0ustar00njfranckstaff000000 000000 # This Build.PL for Catmandu-AlephX was generated by Dist::Zilla::Plugin::ModuleBuildTiny 0.015. use strict; use warnings; use v5.10.1; use Module::Build::Tiny 0.034; Build_PL(); Catmandu-AlephX-1.073/LICENSE000644 000765 000024 00000043663 14107211622 016413 0ustar00njfranckstaff000000 000000 This software is copyright (c) 2021 by Nicolas Franck. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2021 by Nicolas Franck. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program 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 1, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2021 by Nicolas Franck. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Catmandu-AlephX-1.073/cpanfile000644 000765 000024 00000001316 14107211622 017077 0ustar00njfranckstaff000000 000000 requires 'perl', 'v5.10.1'; on 'test', sub { requires 'Log::Any::Adapter::Log4perl', 0; requires 'Log::Any::Test', '1.03'; requires 'Log::Log4perl' , 0; requires 'Test::Deep', '0.112'; requires 'Test::Exception', '0.43'; requires 'Test::LWP::UserAgent' , 0; requires 'Test::More', '0.99'; requires 'Test::Pod', 0; }; requires 'Clone', '0'; requires 'namespace::clean', '0'; requires 'Carp', '0'; requires 'Catmandu', '0'; requires 'Data::Util', '0'; requires 'LWP::UserAgent', '0'; requires 'Moo', '0'; requires 'Software::License', '0'; requires 'Test::Exception', '0'; requires 'Test::More', '0'; requires 'URI::Escape', '0'; requires 'XML::LibXML', '0'; requires 'XML::LibXML::XPathContext', '0'; Catmandu-AlephX-1.073/Changes000644 000765 000024 00000000604 14107211622 016665 0ustar00njfranckstaff000000 000000 1.073 2021-08-18 16:05:03 CEST - fix empty response giving an exception for hold-req and read-item on error 1.072 2020-10-30 09:24:45 CET - _validate_web_response checks for content_type (http status codes always wrong??) 1.071 2019-10-08 08:55:09 CEST - Added some implicit dependencies, thanks to Mohammad S Anwar 1.07 2018-01-25 14:28:51 CET - Moving to Dist::Milla Catmandu-AlephX-1.073/MANIFEST000644 000765 000024 00000006646 14107211622 016537 0ustar00njfranckstaff000000 000000 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.011. Build.PL Changes LICENSE MANIFEST META.json META.yml README cpanfile dist.ini examples/all.pl examples/bor_auth-sec.pl examples/bor_auth.pl examples/bor_info-sec.pl examples/bor_info.pl examples/circstatm.pl examples/circstatus.pl examples/create_item.pl examples/create_item.xml examples/delete.pl examples/export_all.pl examples/export_doc.pl examples/find.pl examples/finddoc.pl examples/illgetdoc-sample.pl examples/illgetdoc.pl examples/illgetdocshort.pl examples/illloaninfo.pl examples/import.pl examples/import_all.pl examples/import_all_aleph_seq.pl examples/import_all_xml.pl examples/import_transform.pl examples/itemdata.pl examples/itemdatamulti.pl examples/patron-sec.pl examples/patron.pl examples/present.pl examples/publish_avail.pl examples/readitem.pl examples/store1.pl examples/store_add.pl examples/store_get.pl examples/update_doc.pl examples/update_doc2.pl examples/update_doc_delete.pl examples/update_doc_insert.pl examples/update_item.pl examples/update_item2.pl examples/user_auth.pl examples/user_info.pl lib/Catmandu/AlephX.pm lib/Catmandu/AlephX/Metadata.pm lib/Catmandu/AlephX/Metadata/MARC.pm lib/Catmandu/AlephX/Metadata/MARC/Aleph.pm lib/Catmandu/AlephX/Op/BorAuth.pm lib/Catmandu/AlephX/Op/BorInfo.pm lib/Catmandu/AlephX/Op/CircStatM.pm lib/Catmandu/AlephX/Op/CircStatus.pm lib/Catmandu/AlephX/Op/CreateItem.pm lib/Catmandu/AlephX/Op/Find.pm lib/Catmandu/AlephX/Op/FindDoc.pm lib/Catmandu/AlephX/Op/GetHolding.pm lib/Catmandu/AlephX/Op/HoldReq.pm lib/Catmandu/AlephX/Op/HoldReqCancel.pm lib/Catmandu/AlephX/Op/IllBorInfo.pm lib/Catmandu/AlephX/Op/IllGetDoc.pm lib/Catmandu/AlephX/Op/IllGetDocShort.pm lib/Catmandu/AlephX/Op/IllLoanInfo.pm lib/Catmandu/AlephX/Op/ItemData.pm lib/Catmandu/AlephX/Op/ItemDataMulti.pm lib/Catmandu/AlephX/Op/Present.pm lib/Catmandu/AlephX/Op/PublishAvail.pm lib/Catmandu/AlephX/Op/ReadItem.pm lib/Catmandu/AlephX/Op/Renew.pm lib/Catmandu/AlephX/Op/UpdateDoc.pm lib/Catmandu/AlephX/Op/UpdateItem.pm lib/Catmandu/AlephX/Op/UserAuth.pm lib/Catmandu/AlephX/Record.pm lib/Catmandu/AlephX/Record/Present.pm lib/Catmandu/AlephX/Response.pm lib/Catmandu/AlephX/UserAgent.pm lib/Catmandu/AlephX/UserAgent/LWP.pm lib/Catmandu/AlephX/XPath/Helper.pm lib/Catmandu/Importer/AlephX.pm lib/Catmandu/Store/AlephX.pm t/Catmandu/AlephX.t t/Catmandu/AlephX/Metadata.t t/Catmandu/AlephX/Metadata/MARC.t t/Catmandu/AlephX/Metadata/MARC/Aleph.t t/Catmandu/AlephX/Op/BorAuth.t t/Catmandu/AlephX/Op/BorInfo.t t/Catmandu/AlephX/Op/CircStatM.t t/Catmandu/AlephX/Op/CircStatus.t t/Catmandu/AlephX/Op/CreateItem.t t/Catmandu/AlephX/Op/Find.t t/Catmandu/AlephX/Op/FindDoc.t t/Catmandu/AlephX/Op/GetHolding.t t/Catmandu/AlephX/Op/HoldReq.t t/Catmandu/AlephX/Op/HoldReqCancel.t t/Catmandu/AlephX/Op/IllBorInfo.t t/Catmandu/AlephX/Op/IllGetDoc.t t/Catmandu/AlephX/Op/IllGetDocShort.t t/Catmandu/AlephX/Op/IllLoanInfo.t t/Catmandu/AlephX/Op/ItemData.t t/Catmandu/AlephX/Op/ItemDataMulti.t t/Catmandu/AlephX/Op/Present.t t/Catmandu/AlephX/Op/PublishAvail.t t/Catmandu/AlephX/Op/ReadItem.t t/Catmandu/AlephX/Op/Renew.t t/Catmandu/AlephX/Op/UpdateDoc.t t/Catmandu/AlephX/Op/UpdateItem.t t/Catmandu/AlephX/Op/UserAuth.t t/Catmandu/AlephX/Record.t t/Catmandu/AlephX/Record/Present.t t/Catmandu/AlephX/Response.t t/Catmandu/AlephX/UserAgent.t t/Catmandu/AlephX/UserAgent/LWP.t t/Catmandu/AlephX/XPath/Helper.t t/Catmandu/Importer/AlephX.t t/Catmandu/Store/AlephX.t t/author-pod-syntax.t Catmandu-AlephX-1.073/t/000755 000765 000024 00000000000 14107211622 015635 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/README000644 000765 000024 00000044465 14107211622 016267 0ustar00njfranckstaff000000 000000 NAME Catmandu::AlephX - Low level client for Aleph X-Services SYNOPSIS my $aleph = Catmandu::AlephX->new(url => "http://localhost/X"); my $item_data = $aleph->item_data(base => "rug01",doc_number => "001484477"); #all public methods return a Catmandu::AlephX::Response # 'is_success' means that the xml-response did not contain the element 'error' # most methods return only one 'error', but some (like update_doc) multiple. # other errors are thrown (xml parse error, no connection ..) if($item_data->is_success){ say "valid response from aleph x server"; }else{ say "aleph x server returned error-response: ".join("\n",@{$item_data->errors}); } METHODS item-data documentation from AlephX The service retrieves the document number from the user. For each of the document's items it retrieves: Item information (From Z30). Loan information (from Z36). An indication whether the request is on-hold example my $item_data = $aleph->item_data(base => "rug01",doc_number => "001484477"); if($item_data->is_success){ for my $item(@{ $item_data->items() }){ print Dumper($item); }; }else{ print STDERR join("\n",@{$item_data->errors})."\n"; } remarks This method is equivalent to 'op' = 'item-data' item-data-multi documentation from AlephX This service takes a document number from the user and for each of the document's items retrieves the following: Item information (from Z30) Loan information (from Z36) An indication of whether or not the item is on hold, has hold requests, or is expected (that is, has not arrived yet but is expected) It is similar to the item_data X-service, except for the parameter START_POINT, which enables the retrieval of information for documents with more than 1000 items. example my $item_data_m = $aleph->item_data_multi(base => "rug01",doc_number => "001484477",start_point => '000000990'); if($item_data_m->is_success){ for my $item(@{ $item_data_m->items() }){ print Dumper($item); }; }else{ print STDERR join("\n",@{$item_data_m->errors})."\n"; } say "items retrieved, starting at ".$item_data_m->start_point() if $item_data_m->start_point(); remarks This method is equivalent to 'op' = 'item-data-multi' The attribute 'start_point' only supplies a value, if the document has over 990 items read_item documentation from AlephX The service retrieves a requested item's record from a given ADM library in case such an item does exist in that ADM library. example my $readitem = $aleph->read_item(library=>"usm50",item_barcode=>293); if($readitem->is_success){ for my $z30(@{ $readitem->z30 }){ print Dumper($z30); } }else{ say STDERR join("\n",@{$readitem->errors}); } remarks This method is equivalent to 'op' = 'read-item' find documentation from Aleph X This service retrieves a set number and the number of records answering a search request inserted by the user. example my $find = $aleph->find(request => 'wrd=(art)',base=>'rug01'); if($find->is_success){ say "set_number: ".$find->set_number; say "no_records: ".$find->no_records; say "no_entries: ".$find->no_entries; }else{ say STDERR join("\n",@{$find->errors}); } remarks This method is equivalent to 'op' = 'find' arguments request - search request adjacent - if 'Y' then the documents should contain all the search words adjacent to each other, otherwise 'N' find_doc documentation from AlephX This service retrieves the OAI XML format of an expanded document as given by the user. example my $find = $aleph->find_doc(base=>'rug01',doc_num=>'000000444',format=>'marc'); if($find->is_success){ say Dumper($find->record); }else{ say STDERR join("\n",@{$find->errors}); } remarks This method is equivalent to 'op' = 'find-doc' present documentation from Aleph X This service retrieves OAI XML format of expanded documents. You can view documents according to the locations within a specific set number. example my $set_number = $aleph->find(request => "wrd=(BIB.AFF)",base => "rug01")->set_number; my $present = $aleph->present( set_number => $set_number, set_entry => "000000001-000000003" ); if($present->is_success){ for my $record(@{ $present->records() }){ say "doc_number: ".$record->doc_number; say "\tmetadata: ".$record->metadata->type; } }else{ say STDERR join("\n",@{$present->errors}); } remarks This method is equivalent to 'op' = 'present' ill_get_doc_short documentation from Aleph X The service retrieves the doc number and the XML of the short document (Z13). example my $result = $aleph->ill_get_doc_short(doc_number => "000000001",library=>"usm01"); if($result->is_success){ for my $z30(@{ $result->z13 }){ print Dumper($z30); } }else{ say STDERR join("\n",@{$result->errors}); } remarks This method is equivalent to 'op' = 'ill-get-doc-short' bor_auth documentation from Aleph X This service retrieves the Global record (Z303), Local record (Z305) and the Data record (Z304) for a given Patron if the given ID and verification code match. Otherwise, an error message is returned. example my %args = ( library => $library, bor_id => $bor_id, verification => $verification ); my $auth = $aleph->bor_auth(%args); if($auth->is_success){ for my $type(qw(z303 z304 z305)){ say "$type:"; my $data = $auth->$type(); for my $key(keys %$data){ say "\t$key : $data->{$key}->[0]"; } } }else{ say STDERR "error: ".join("\n",@{$auth->errors}); exit 1; } bor_info documentation from Aleph X This service retrieves all information related to a given Patron: Global and Local records, Loan records, Loaned items records, Short doc record, Cash record, and so on, if the ID and verification code provided match. If not, an error message is returned. Since the bor-info X-Service retrieves a very large amount of data, and not all of it may be relevant, you can choose to receive a part of the data, based on your needs. example my %args = ( library => $library, bor_id => $bor_id, verification => $verification, loans => 'P' ); my $info = $aleph->bor_info(%args); if($info->is_success){ for my $type(qw(z303 z304 z305)){ say "$type:"; my $data = $info->$type(); for my $key(keys %$data){ say "\t$key : $data->{$key}->[0]"; } } say "fine:"; for my $fine(@{ $info->fine() }){ for my $type(qw(z13 z30 z31)){ say "\t$type:"; my $data = $fine->{$type}->[0]; for my $key(keys %$data){ say "\t\t$key : $data->{$key}->[0]"; } } } }else{ say STDERR "error: ".join("\n",@{$info->errors}); exit 1; } ill_bor_info documentation from Aleph X This service retrieves Z303, Z304, Z305 and Z308 records for a given borrower ID / barcode. example circ_status documentation from Aleph X The service retrieves the circulation status for each document number entered by the user. Item information (From Z30). Loan information (from Z36). Loan Status (Tab15), Due Date, Due Hour etc. example circ_stat_m documentation from Aleph X The service retrieves the circulation status for each document number entered by the user (suitable for documents with more than 1000 items). Item information (From Z30). Loan information (from Z36). Loan Status (Tab15), Due Date, Due Hour etc. This service is similar to circ-status X-service, except for the parameter START_POINT which enables to retrieve information for documents with more than 1000 items. example publish_avail documentation from Aleph X This service supplies the current availability status of a document. The X-Server does not change any data. example my $publish = $aleph->publish_avail(doc_num => '000196220,001313162,001484478,001484538,001317121,000000000',library=>'rug01'); if($publish->is_success){ #format for $publish->list() : [ [,], .. ] for my $item(@{ $publish->list }){ say "id: $item->[0]"; if($item->[1]){ say "marc array:"; say Dumper($item->[1]); }else{ say "nothing for $item->[0]"; } say "\n---"; } }else{ say STDERR join("\n",@{$publish->errors}); } remarks The parameter 'doc_num' supports multiple values, separated by ','. Compare this to ill_get_doc, that does not support this. ill_get_doc documentation from Aleph X This service takes a document number and the library where the corresponding document is located and generates the XML of the requested document as it appears in the library given. example my $illgetdoc = $aleph->ill_get_doc(doc_number => '001317121',library=>'rug01'); if($illgetdoc->is_success){ if($illgetdoc->record){ say "data: ".to_json($illgetdoc->record,{ pretty => 1 }); } else{ say "nothing found"; } }else{ say STDERR join("\n",@{$illgetdoc->errors}); } renew documentation from Aleph X This service renews the loan of a given item for a given patron. The X-Service renews the loan only if it can be done. If, for example, there is a delinquency on the patron, the service does not renew the loan. example hold_req documentation from Aleph X The service creates a hold-request record (Z37) for a given item after performing initial checks. example update_doc documentation from Aleph X The service performs actions (Update / Insert / Delete) related to the update of a document. (The service uses pc_cat_c0203 which updates a document via the GUI). notes When executing an update request, most of the 'errors' will be warnings instead of real errors. This happens because AlephX performs an 'UPDATE-CHK' before trying to execute an 'UPDATE', and stores all warnings during that check in the xml attribute 'error'. Therefore the method 'is_success' of the Catmandu::AlephX::Response is not very usefull in this case. Search for the last 'error', and check wether it contains 'updated successfully'. warnings An updates replaces the WHOLE record. So if you fail to supply 'xml_full_req' (or indirectly 'marc'), the record will be deleted! To be sure, please use the full xml response of 'find-doc', change the fields inside 'oai_marc', and supply this xml as xml_full_req. Every updates adds a CAT-field to the record. Your updates can be recognized by CAT$$a == "WWW-X". When updating a record you need to include the old CAT fields (default), otherwise these fields will be deleted (and all history will be lost). "Unlike other X-Services, the parameters can include XML up to 20,000 characters in length" When you update often (and therefore add a lot of CAT fields), this can lead to the error 'Server closed connection'. This is due to the maximum of characters allowed in an XML request. Possible solution: 1. retrieve record by 'find_doc' 2. get marc record: my $marc = $res->record->metadata->data 3. filter out your CAT fields ($a == "WWW-X") to shorten the XML: $marc = [grep { !( $_->[0] eq "CAT" && $_->[4] eq "WWW-X" ) } @$marc]; 4. update $marc 5. send $aleph->update_doc(library => 'usm01',doc_action => 'UPDATE',doc_number => $doc_number,marc => $marc); => your xml will now contain one CAT field with subfield 'a' equal to 'WWW-X'. example my $aleph = Catmandu::AlephX->new(url => "http://localhost/X"); my $doc_number = '000000444'; my $find_doc = $aleph->find_doc( doc_num => $doc_number, base => "usm01" ); my $marc = $find_doc->record->metadata->data; my $content_ref = $find_doc->content_ref; my %args = ( 'library' => 'usm01', 'doc_action' => 'UPDATE', 'doc_number' => $doc_number, xml_full_req => $$content_ref ); my $u = $aleph->update_doc(%args); if($u->is_success){ say "all ok"; }else{ say STDERR join("\n",@{$u->errors}); } special support for catmandu marc records when you supply the argument 'marc', an xml document will be created for you, and stored in the argument 'xml_full_req'. 'marc' must be an array of arrays. When you already supplied 'xml_full_req', it will be overwritten. update_item documentation from Aleph X The service updates an existing item in the required ADM library after performing all relevant initial checks prior to that action. notes AlephX stores not only errors in 'errors', but also the success message. Therefore the method 'is_success' of the Catmandu::AlephX::Response is not very usefull in this case. Search for the last 'error', and check wether it contains 'updated successfully'. The result of 'read_item' often contains translations, instead of the real values. But these translation cannot be used when updating items. e.g. z30-item-status contains 'Regular loan' instead of '001'. example my $alephx = Catmandu::AlephX->new(url => "http://localhost/X"); my $item_barcode = '32044044980076'; my %args = ( 'library' => 'usm50', 'item_barcode' => $item_barcode, ); my $z30 = $alephx->read_item(%args)->z30(); my $xml = XMLout($z30,,RootName=>"z30",NoAttr => 1); $xml = "\n".$xml; $args{xml_full_req} = $xml; my $u = alephx->update_item(%args); if($u->is_success){ say "all ok"; }else{ say STDERR join("\n",@{$u->errors}); } create_item documentation from Aleph X The service creates a new item in the required ADM library after performing all relevant initial checks prior to that action. The item can be created for a bib record when no ADM record is linked to it yet, or it can be created to an ADM record with existing items. notes example my $alephx = Catmandu::AlephX->new(url => "http://localhost/X"); my $item_barcode = '32044044980076'; my %args = ( 'adm_library' => 'rug50', 'bib_library' => 'rug01', 'bib_doc_number' => '231843137', ); my $xml = < 15 10 32044003924339 WID BOOK 01 19980804 20020708 EXLIBRIS 20080607 1631 CONV 011 L GEN 7 Heb 2106.385.5 7 selected v.1 00000000 00000000 000000 000000015 00000 00000 00000 XX 1 000000046 No 000000000 007 20080408 EOF $args{xml_full_req} = $xml; my $u = alephx->create_item(%args); if($u->is_success){ say "all ok"; }else{ say STDERR join("\n",@{$u->errors}); } AUTHOR Nicolas Franck, LICENSE AND COPYRIGHT This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. Catmandu-AlephX-1.073/examples/000755 000765 000024 00000000000 14107211622 017210 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/META.yml000644 000765 000024 00000002757 14107211622 016656 0ustar00njfranckstaff000000 000000 --- abstract: 'turns baubles into trinkets' author: - 'Nicolas Franck, C<< >>' build_requires: Log::Any::Adapter::Log4perl: '0' Log::Any::Test: '1.03' Log::Log4perl: '0' Test::Deep: '0.112' Test::Exception: '0.43' Test::LWP::UserAgent: '0' Test::More: '0.99' Test::Pod: '0' configure_requires: Module::Build::Tiny: '0.034' dynamic_config: 0 generated_by: 'Dist::Milla version v1.0.17, Dist::Zilla version 6.011, CPAN::Meta::Converter version 2.150001' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Catmandu-AlephX no_index: directory: - eg - examples - inc - share - t - xt requires: Carp: '0' Catmandu: '0' Clone: '0' Data::Util: '0' LWP::UserAgent: '0' Moo: '0' Software::License: '0' Test::Exception: '0.43' Test::More: '0.99' URI::Escape: '0' XML::LibXML: '0' XML::LibXML::XPathContext: '0' namespace::clean: '0' perl: v5.10.1 resources: bugtracker: https://github.com/LibreCat/Catmandu-AlephX/issues homepage: https://github.com/LibreCat/Catmandu-AlephX repository: https://github.com/LibreCat/Catmandu-AlephX.git version: '1.073' x_contributors: - 'Mohammad S Anwar ' - 'Nicolas Franck ' - 'Nicolas Franck ' - 'Patrick Hochstenbach ' - 'root ' x_serialization_backend: 'YAML::Tiny version 1.69' Catmandu-AlephX-1.073/lib/000755 000765 000024 00000000000 14107211622 016140 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/META.json000644 000765 000024 00000005006 14107211622 017014 0ustar00njfranckstaff000000 000000 { "abstract" : "turns baubles into trinkets", "author" : [ "Nicolas Franck, C<< >>" ], "dynamic_config" : 0, "generated_by" : "Dist::Milla version v1.0.17, Dist::Zilla version 6.011, CPAN::Meta::Converter version 2.150001", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Catmandu-AlephX", "no_index" : { "directory" : [ "eg", "examples", "inc", "share", "t", "xt" ] }, "prereqs" : { "configure" : { "requires" : { "Module::Build::Tiny" : "0.034" } }, "develop" : { "requires" : { "Dist::Milla" : "v1.0.17", "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { "Carp" : "0", "Catmandu" : "0", "Clone" : "0", "Data::Util" : "0", "LWP::UserAgent" : "0", "Moo" : "0", "Software::License" : "0", "Test::Exception" : "0.43", "Test::More" : "0.99", "URI::Escape" : "0", "XML::LibXML" : "0", "XML::LibXML::XPathContext" : "0", "namespace::clean" : "0", "perl" : "v5.10.1" } }, "test" : { "requires" : { "Log::Any::Adapter::Log4perl" : "0", "Log::Any::Test" : "1.03", "Log::Log4perl" : "0", "Test::Deep" : "0.112", "Test::Exception" : "0.43", "Test::LWP::UserAgent" : "0", "Test::More" : "0.99", "Test::Pod" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/LibreCat/Catmandu-AlephX/issues" }, "homepage" : "https://github.com/LibreCat/Catmandu-AlephX", "repository" : { "type" : "git", "url" : "https://github.com/LibreCat/Catmandu-AlephX.git", "web" : "https://github.com/LibreCat/Catmandu-AlephX" } }, "version" : "1.073", "x_contributors" : [ "Mohammad S Anwar ", "Nicolas Franck ", "Nicolas Franck ", "Patrick Hochstenbach ", "root " ], "x_serialization_backend" : "Cpanel::JSON::XS version 3.0225" } Catmandu-AlephX-1.073/dist.ini000644 000765 000024 00000000040 14107211622 017030 0ustar00njfranckstaff000000 000000 name = Catmandu-AlephX [@Milla] Catmandu-AlephX-1.073/lib/Catmandu/000755 000765 000024 00000000000 14107211622 017674 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/lib/Catmandu/Importer/000755 000765 000024 00000000000 14107211622 021475 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/lib/Catmandu/AlephX.pm000644 000765 000024 00000060430 14107211622 021416 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX; use Catmandu::Sane; use Carp qw(confess); use Moo; use Catmandu::Util qw(:check :is); our $VERSION = "1.073"; has url => ( is => 'ro', isa => sub { $_[0] =~ /^https?:\/\//o or die("url must be a valid web url\n"); }, required => 1 ); has default_args => ( is => 'ro', isa => sub { check_hash_ref($_[0]); }, lazy => 1, default => sub { +{}; } ); has ua => ( is => 'ro', lazy => 1, builder => '_build_ua' ); sub _build_ua { require Catmandu::AlephX::UserAgent::LWP; Catmandu::AlephX::UserAgent::LWP->new(url => $_[0]->url(),default_args => $_[0]->default_args()); } =head1 NAME Catmandu::AlephX - Low level client for Aleph X-Services =head1 SYNOPSIS my $aleph = Catmandu::AlephX->new(url => "http://localhost/X"); my $item_data = $aleph->item_data(base => "rug01",doc_number => "001484477"); #all public methods return a Catmandu::AlephX::Response # 'is_success' means that the xml-response did not contain the element 'error' # most methods return only one 'error', but some (like update_doc) multiple. # other errors are thrown (xml parse error, no connection ..) if($item_data->is_success){ say "valid response from aleph x server"; }else{ say "aleph x server returned error-response: ".join("\n",@{$item_data->errors}); } =head1 METHODS =head2 item-data =head3 documentation from AlephX The service retrieves the document number from the user. For each of the document's items it retrieves: Item information (From Z30). Loan information (from Z36). An indication whether the request is on-hold =head3 example my $item_data = $aleph->item_data(base => "rug01",doc_number => "001484477"); if($item_data->is_success){ for my $item(@{ $item_data->items() }){ print Dumper($item); }; }else{ print STDERR join("\n",@{$item_data->errors})."\n"; } =head3 remarks This method is equivalent to 'op' = 'item-data' =cut sub item_data { my($self,%args)=@_; require Catmandu::AlephX::Op::ItemData; $args{'op'} = Catmandu::AlephX::Op::ItemData->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::ItemData->parse($res->content_ref(),\%args); } =head2 item-data-multi =head3 documentation from AlephX This service takes a document number from the user and for each of the document's items retrieves the following: Item information (from Z30) Loan information (from Z36) An indication of whether or not the item is on hold, has hold requests, or is expected (that is, has not arrived yet but is expected) It is similar to the item_data X-service, except for the parameter START_POINT, which enables the retrieval of information for documents with more than 1000 items. =head3 example my $item_data_m = $aleph->item_data_multi(base => "rug01",doc_number => "001484477",start_point => '000000990'); if($item_data_m->is_success){ for my $item(@{ $item_data_m->items() }){ print Dumper($item); }; }else{ print STDERR join("\n",@{$item_data_m->errors})."\n"; } say "items retrieved, starting at ".$item_data_m->start_point() if $item_data_m->start_point(); =head3 remarks This method is equivalent to 'op' = 'item-data-multi' The attribute 'start_point' only supplies a value, if the document has over 990 items =cut sub item_data_multi { my($self,%args)=@_; require Catmandu::AlephX::Op::ItemDataMulti; $args{'op'} = Catmandu::AlephX::Op::ItemDataMulti->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::ItemDataMulti->parse($res->content_ref(),\%args); } =head2 read_item =head3 documentation from AlephX The service retrieves a requested item's record from a given ADM library in case such an item does exist in that ADM library. =head3 example my $readitem = $aleph->read_item(library=>"usm50",item_barcode=>293); if($readitem->is_success){ for my $z30(@{ $readitem->z30 }){ print Dumper($z30); } }else{ say STDERR join("\n",@{$readitem->errors}); } =head3 remarks This method is equivalent to 'op' = 'read-item' =cut sub read_item { my($self,%args)=@_; require Catmandu::AlephX::Op::ReadItem; $args{'op'} = Catmandu::AlephX::Op::ReadItem->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::ReadItem->parse($res->content_ref(),\%args); } =head2 find =head3 documentation from Aleph X This service retrieves a set number and the number of records answering a search request inserted by the user. =head3 example my $find = $aleph->find(request => 'wrd=(art)',base=>'rug01'); if($find->is_success){ say "set_number: ".$find->set_number; say "no_records: ".$find->no_records; say "no_entries: ".$find->no_entries; }else{ say STDERR join("\n",@{$find->errors}); } =head3 remarks This method is equivalent to 'op' = 'find' =head3 arguments request - search request adjacent - if 'Y' then the documents should contain all the search words adjacent to each other, otherwise 'N' =cut sub find { my($self,%args)=@_; require Catmandu::AlephX::Op::Find; $args{'op'} = Catmandu::AlephX::Op::Find->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::Find->parse($res->content_ref(),\%args); } =head2 find_doc =head3 documentation from AlephX This service retrieves the OAI XML format of an expanded document as given by the user. =head3 example my $find = $aleph->find_doc(base=>'rug01',doc_num=>'000000444',format=>'marc'); if($find->is_success){ say Dumper($find->record); }else{ say STDERR join("\n",@{$find->errors}); } =head3 remarks This method is equivalent to 'op' = 'find-doc' =cut sub find_doc { my($self,%args)=@_; require Catmandu::AlephX::Op::FindDoc; $args{'op'} = Catmandu::AlephX::Op::FindDoc->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::FindDoc->parse($res->content_ref(),\%args); } =head2 present =head3 documentation from Aleph X This service retrieves OAI XML format of expanded documents. You can view documents according to the locations within a specific set number. =head3 example my $set_number = $aleph->find(request => "wrd=(BIB.AFF)",base => "rug01")->set_number; my $present = $aleph->present( set_number => $set_number, set_entry => "000000001-000000003" ); if($present->is_success){ for my $record(@{ $present->records() }){ say "doc_number: ".$record->doc_number; say "\tmetadata: ".$record->metadata->type; } }else{ say STDERR join("\n",@{$present->errors}); } =head3 remarks This method is equivalent to 'op' = 'present' =cut sub present { my($self,%args)=@_; require Catmandu::AlephX::Op::Present; $args{'op'} = Catmandu::AlephX::Op::Present->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::Present->parse($res->content_ref(),\%args); } =head2 ill_get_doc_short =head3 documentation from Aleph X The service retrieves the doc number and the XML of the short document (Z13). =head3 example my $result = $aleph->ill_get_doc_short(doc_number => "000000001",library=>"usm01"); if($result->is_success){ for my $z30(@{ $result->z13 }){ print Dumper($z30); } }else{ say STDERR join("\n",@{$result->errors}); } =head3 remarks This method is equivalent to 'op' = 'ill-get-doc-short' =cut sub ill_get_doc_short { my($self,%args)=@_; require Catmandu::AlephX::Op::IllGetDocShort; $args{'op'} = Catmandu::AlephX::Op::IllGetDocShort->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::IllGetDocShort->parse($res->content_ref(),\%args); } =head2 bor_auth =head3 documentation from Aleph X This service retrieves the Global record (Z303), Local record (Z305) and the Data record (Z304) for a given Patron if the given ID and verification code match. Otherwise, an error message is returned. =head3 example my %args = ( library => $library, bor_id => $bor_id, verification => $verification ); my $auth = $aleph->bor_auth(%args); if($auth->is_success){ for my $type(qw(z303 z304 z305)){ say "$type:"; my $data = $auth->$type(); for my $key(keys %$data){ say "\t$key : $data->{$key}->[0]"; } } }else{ say STDERR "error: ".join("\n",@{$auth->errors}); exit 1; } =cut sub bor_auth { my($self,%args)=@_; require Catmandu::AlephX::Op::BorAuth; $args{'op'} = Catmandu::AlephX::Op::BorAuth->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::BorAuth->parse($res->content_ref(),\%args); } =head2 bor_info =head3 documentation from Aleph X This service retrieves all information related to a given Patron: Global and Local records, Loan records, Loaned items records, Short doc record, Cash record, and so on, if the ID and verification code provided match. If not, an error message is returned. Since the bor-info X-Service retrieves a very large amount of data, and not all of it may be relevant, you can choose to receive a part of the data, based on your needs. =head3 example my %args = ( library => $library, bor_id => $bor_id, verification => $verification, loans => 'P' ); my $info = $aleph->bor_info(%args); if($info->is_success){ for my $type(qw(z303 z304 z305)){ say "$type:"; my $data = $info->$type(); for my $key(keys %$data){ say "\t$key : $data->{$key}->[0]"; } } say "fine:"; for my $fine(@{ $info->fine() }){ for my $type(qw(z13 z30 z31)){ say "\t$type:"; my $data = $fine->{$type}->[0]; for my $key(keys %$data){ say "\t\t$key : $data->{$key}->[0]"; } } } }else{ say STDERR "error: ".join("\n",@{$info->errors}); exit 1; } =cut sub bor_info { my($self,%args)=@_; require Catmandu::AlephX::Op::BorInfo; $args{'op'} = Catmandu::AlephX::Op::BorInfo->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::BorInfo->parse($res->content_ref(),\%args); } =head2 ill_bor_info =head3 documentation from Aleph X This service retrieves Z303, Z304, Z305 and Z308 records for a given borrower ID / barcode. =head3 example =cut sub ill_bor_info { my($self,%args)=@_; require Catmandu::AlephX::Op::IllBorInfo; $args{'op'} = Catmandu::AlephX::Op::IllBorInfo->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::IllBorInfo->parse($res->content_ref(),\%args); } sub ill_loan_info { my($self,%args)=@_; require Catmandu::AlephX::Op::IllLoanInfo; $args{'op'} = Catmandu::AlephX::Op::IllLoanInfo->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::IllLoanInfo->parse($res->content_ref(),\%args); } =head2 circ_status =head3 documentation from Aleph X The service retrieves the circulation status for each document number entered by the user. Item information (From Z30). Loan information (from Z36). Loan Status (Tab15), Due Date, Due Hour etc. =head3 example =cut sub circ_status { my($self,%args)=@_; require Catmandu::AlephX::Op::CircStatus; $args{'op'} = Catmandu::AlephX::Op::CircStatus->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::CircStatus->parse($res->content_ref(),\%args); } =head2 circ_stat_m =head3 documentation from Aleph X The service retrieves the circulation status for each document number entered by the user (suitable for documents with more than 1000 items). Item information (From Z30). Loan information (from Z36). Loan Status (Tab15), Due Date, Due Hour etc. This service is similar to circ-status X-service, except for the parameter START_POINT which enables to retrieve information for documents with more than 1000 items. =head3 example =cut sub circ_stat_m { my($self,%args)=@_; require Catmandu::AlephX::Op::CircStatM; $args{'op'} = Catmandu::AlephX::Op::CircStatM->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::CircStatM->parse($res->content_ref(),\%args); } =head2 publish_avail =head3 documentation from Aleph X This service supplies the current availability status of a document. The X-Server does not change any data. =head3 example my $publish = $aleph->publish_avail(doc_num => '000196220,001313162,001484478,001484538,001317121,000000000',library=>'rug01'); if($publish->is_success){ #format for $publish->list() : [ [,], .. ] for my $item(@{ $publish->list }){ say "id: $item->[0]"; if($item->[1]){ say "marc array:"; say Dumper($item->[1]); }else{ say "nothing for $item->[0]"; } say "\n---"; } }else{ say STDERR join("\n",@{$publish->errors}); } =head3 remarks The parameter 'doc_num' supports multiple values, separated by ','. Compare this to ill_get_doc, that does not support this. =cut sub publish_avail { my($self,%args)=@_; require Catmandu::AlephX::Op::PublishAvail; $args{'op'} = Catmandu::AlephX::Op::PublishAvail->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::PublishAvail->parse($res->content_ref(),\%args); } =head2 ill_get_doc =head3 documentation from Aleph X This service takes a document number and the library where the corresponding document is located and generates the XML of the requested document as it appears in the library given. =head3 example my $illgetdoc = $aleph->ill_get_doc(doc_number => '001317121',library=>'rug01'); if($illgetdoc->is_success){ if($illgetdoc->record){ say "data: ".to_json($illgetdoc->record,{ pretty => 1 }); } else{ say "nothing found"; } }else{ say STDERR join("\n",@{$illgetdoc->errors}); } =cut sub ill_get_doc { my($self,%args)=@_; require Catmandu::AlephX::Op::IllGetDoc; $args{'op'} = Catmandu::AlephX::Op::IllGetDoc->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::IllGetDoc->parse($res->content_ref(),\%args); } =head2 renew =head3 documentation from Aleph X This service renews the loan of a given item for a given patron. The X-Service renews the loan only if it can be done. If, for example, there is a delinquency on the patron, the service does not renew the loan. =head3 example =cut sub renew { my($self,%args)=@_; require Catmandu::AlephX::Op::Renew; $args{'op'} = Catmandu::AlephX::Op::Renew->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::Renew->parse($res->content_ref(),\%args); } =head2 hold_req =head3 documentation from Aleph X The service creates a hold-request record (Z37) for a given item after performing initial checks. =head3 example =cut sub hold_req { my($self,%args)=@_; require Catmandu::AlephX::Op::HoldReq; $args{'op'} = Catmandu::AlephX::Op::HoldReq->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::HoldReq->parse($res->content_ref(),\%args); } sub hold_req_cancel { my($self,%args)=@_; require Catmandu::AlephX::Op::HoldReqCancel; $args{'op'} = Catmandu::AlephX::Op::HoldReqCancel->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::HoldReqCancel->parse($res->content_ref(),\%args); } sub user_auth { my($self,%args)=@_; require Catmandu::AlephX::Op::UserAuth; $args{op} = Catmandu::AlephX::Op::UserAuth->op(); my $res = $self->ua->request(\%args); Catmandu::AlephX::Op::UserAuth->parse($res->content_ref(),\%args); } =head2 update_doc =head3 documentation from Aleph X The service performs actions (Update / Insert / Delete) related to the update of a document. (The service uses pc_cat_c0203 which updates a document via the GUI). =head3 notes When executing an update request, most of the 'errors' will be warnings instead of real errors. This happens because AlephX performs an 'UPDATE-CHK' before trying to execute an 'UPDATE', and stores all warnings during that check in the xml attribute 'error'. Therefore the method 'is_success' of the Catmandu::AlephX::Response is not very usefull in this case. Search for the last 'error', and check wether it contains 'updated successfully'. =head3 warnings An updates replaces the WHOLE record. So if you fail to supply 'xml_full_req' (or indirectly 'marc'), the record will be deleted! To be sure, please use the full xml response of 'find-doc', change the fields inside 'oai_marc', and supply this xml as xml_full_req. Every updates adds a CAT-field to the record. Your updates can be recognized by CAT$$a == "WWW-X". When updating a record you need to include the old CAT fields (default), otherwise these fields will be deleted (and all history will be lost). "Unlike other X-Services, the parameters can include XML up to 20,000 characters in length" When you update often (and therefore add a lot of CAT fields), this can lead to the error 'Server closed connection'. This is due to the maximum of characters allowed in an XML request. Possible solution: 1. retrieve record by 'find_doc' 2. get marc record: my $marc = $res->record->metadata->data 3. filter out your CAT fields ($a == "WWW-X") to shorten the XML: $marc = [grep { !( $_->[0] eq "CAT" && $_->[4] eq "WWW-X" ) } @$marc]; 4. update $marc 5. send $aleph->update_doc(library => 'usm01',doc_action => 'UPDATE',doc_number => $doc_number,marc => $marc); => your xml will now contain one CAT field with subfield 'a' equal to 'WWW-X'. =head3 example my $aleph = Catmandu::AlephX->new(url => "http://localhost/X"); my $doc_number = '000000444'; my $find_doc = $aleph->find_doc( doc_num => $doc_number, base => "usm01" ); my $marc = $find_doc->record->metadata->data; my $content_ref = $find_doc->content_ref; my %args = ( 'library' => 'usm01', 'doc_action' => 'UPDATE', 'doc_number' => $doc_number, xml_full_req => $$content_ref ); my $u = $aleph->update_doc(%args); if($u->is_success){ say "all ok"; }else{ say STDERR join("\n",@{$u->errors}); } =head3 special support for catmandu marc records when you supply the argument 'marc', an xml document will be created for you, and stored in the argument 'xml_full_req'. 'marc' must be an array of arrays. When you already supplied 'xml_full_req', it will be overwritten. =cut sub update_doc { my($self,%args)=@_; my $doc_num = $args{doc_num} || $args{doc_number}; delete $args{$_} for qw(doc_number doc_num); $args{doc_num} = $self->format_doc_num($doc_num); require Catmandu::AlephX::Op::UpdateDoc; $args{op} = Catmandu::AlephX::Op::UpdateDoc->op(); if($args{marc}){ require Catmandu::AlephX::Metadata::MARC::Aleph; my $m = Catmandu::AlephX::Metadata::MARC::Aleph->to_xml($args{marc}); my $xml = < $m EOF if(length($xml) > 20000){ confess "xml_full_req cannot be longer than 20000 characters"; } $args{xml_full_req} = $xml; delete $args{marc}; }elsif(is_string($args{doc_action}) && $args{doc_action} eq "DELETE" && !is_string($args{xml_full_req})){ #although this is a delete action, determined by 'doc_num', AlephX still needs an xml_full_req, even when empty $args{xml_full_req} = < EOF } my $res = $self->ua->request(\%args,"POST"); Catmandu::AlephX::Op::UpdateDoc->parse($res->content_ref(),\%args); } =head2 update_item =head3 documentation from Aleph X The service updates an existing item in the required ADM library after performing all relevant initial checks prior to that action. =head3 notes AlephX stores not only errors in 'errors', but also the success message. Therefore the method 'is_success' of the Catmandu::AlephX::Response is not very usefull in this case. Search for the last 'error', and check wether it contains 'updated successfully'. The result of 'read_item' often contains translations, instead of the real values. But these translation cannot be used when updating items. e.g. z30-item-status contains 'Regular loan' instead of '001'. =head3 example my $alephx = Catmandu::AlephX->new(url => "http://localhost/X"); my $item_barcode = '32044044980076'; my %args = ( 'library' => 'usm50', 'item_barcode' => $item_barcode, ); my $z30 = $alephx->read_item(%args)->z30(); my $xml = XMLout($z30,,RootName=>"z30",NoAttr => 1); $xml = "\n".$xml; $args{xml_full_req} = $xml; my $u = alephx->update_item(%args); if($u->is_success){ say "all ok"; }else{ say STDERR join("\n",@{$u->errors}); } =cut sub update_item { my($self,%args)=@_; require Catmandu::AlephX::Op::UpdateItem; $args{op} = Catmandu::AlephX::Op::UpdateItem->op(); my $res = $self->ua->request(\%args,"POST"); Catmandu::AlephX::Op::UpdateItem->parse($res->content_ref(),\%args); } =head2 create_item =head3 documentation from Aleph X The service creates a new item in the required ADM library after performing all relevant initial checks prior to that action. The item can be created for a bib record when no ADM record is linked to it yet, or it can be created to an ADM record with existing items. =head3 notes =head3 example my $alephx = Catmandu::AlephX->new(url => "http://localhost/X"); my $item_barcode = '32044044980076'; my %args = ( 'adm_library' => 'rug50', 'bib_library' => 'rug01', 'bib_doc_number' => '231843137', ); my $xml = < 15 10 32044003924339 WID BOOK 01 19980804 20020708 EXLIBRIS 20080607 1631 CONV 011 L GEN 7 Heb 2106.385.5 7 selected v.1 00000000 00000000 000000 000000015 00000 00000 00000 XX 1 000000046 No 000000000 007 20080408 EOF $args{xml_full_req} = $xml; my $u = alephx->create_item(%args); if($u->is_success){ say "all ok"; }else{ say STDERR join("\n",@{$u->errors}); } =cut sub create_item { my($self,%args)=@_; require Catmandu::AlephX::Op::CreateItem; $args{op} = Catmandu::AlephX::Op::CreateItem->op(); my $res = $self->ua->request(\%args,"POST"); Catmandu::AlephX::Op::CreateItem->parse($res->content_ref(),\%args); } sub format_doc_num { my($class,$doc_num)=@_; $doc_num = sprintf("%-9.9d",int($doc_num)); #alephx only reads first substr($doc_num,0,9); } =head1 AUTHOR Nicolas Franck, C<< >> =head1 LICENSE AND COPYRIGHT This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See L for more information. =cut # ABSTRACT: turns baubles into trinkets 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/000755 000765 000024 00000000000 14107211622 021055 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/lib/Catmandu/Store/000755 000765 000024 00000000000 14107211622 020770 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/lib/Catmandu/Store/AlephX.pm000644 000765 000024 00000021467 14107211622 022521 0ustar00njfranckstaff000000 000000 package Catmandu::Store::AlephX; =head1 NAME Catmandu::Store::AlephX - A Catmandu AlephX service implemented as Catmandu::Store =head1 SYNOPSIS use Catmandu::Store::AlephX; my $store = Catmandu::Store::AlephX->new(url => 'http://aleph.ugent.be/X' , username => 'XXX' , password => 'XXX'); $store->bag('usm01')->each(sub { }); =cut use namespace::clean; use Catmandu::Sane; use Catmandu::Util qw(:is :check); use Catmandu::AlephX; use Moo; our $VERSION = "1.073"; with 'Catmandu::Store'; has url => (is => 'ro', required => 1); has username => ( is => 'ro' ); has password => ( is => 'ro' ); has skip_deleted => ( is => 'ro' , default => sub { 0 } ); has alephx => ( is => 'ro', init_arg => undef, lazy => 1, builder => '_build_alephx', ); around default_bag => sub { 'usm01'; }; sub _build_alephx { my $self = $_[0]; my %args = (url => $self->url()); if(is_string($self->username) && is_string($self->password)){ $args{default_args} = { user_name => $self->username, user_password => $self->password }; } Catmandu::AlephX->new(%args); } package Catmandu::Store::AlephX::Bag; use Catmandu::Sane; use Moo; use Catmandu::AlephX; use Catmandu::Util qw(:check :is); use Catmandu::Hits; use Clone qw(clone); use Carp qw(confess); with 'Catmandu::Bag'; with 'Catmandu::Searchable'; #override automatic id generation from Catmandu::Bag before add => sub { check_catmandu_marc($_[1]); $_[1] = clone($_[1]); if(is_string($_[1]->{_id})){ $_[1]->{_id} =~ /^\d{9}$/o or confess("invalid _id ".$_[1]->{_id}); }else{ $_[1]->{_id} = Catmandu::AlephX->format_doc_num(0); } }; sub check_catmandu_marc { my $r = $_[0]; check_hash_ref($r); check_array_ref($r->{record}); check_array_ref($_) for @{ $r->{record} }; } sub check_deleted { my $r = $_[0]; return 1 unless defined $r; for (@{$r->{record}}) { return 1 if ($_->[0] eq 'DEL'); } return 0; } =head1 METHODS =head2 get($id) Retrieves a record from the Aleph database. Requires a record identifier. Returns a Catmandu MARC record when found and undef on failure. =cut sub get { my($self,$id)=@_; my $alephx = $self->store->alephx; my $find_doc = $alephx->find_doc( format => 'marc', doc_num => $id, base => $self->name, #override user_name to disable user check user_name => "" ); return undef unless($find_doc->is_success); my $doc = $find_doc->record->metadata->data; return undef if $self->store->skip_deleted && check_deleted($doc); return $doc; } =head2 add($catmandu_marc) Adds or updates a record to the Aleph database. Requires a Catmandu type MARC record and a _id field containing the Aleph record number. This method with throw an error when an add cant be executed. =head3 example #add new record. WARNING: Aleph will ignore the 001 field, my $new_record = eval { $bag->add({ record => [ [ 'FMT', '', '', '_', 'SE' ], [ 'LDR', '', '', '_', '00000cas^^2200385^a^4500' ], [ '001', '', '', '_', '000000444' ], [ '005', '', '', '_', '20140212095615.0' ] .. ] }); }; if ($@) { die "add failed $@"; } say "new record:".$record->{_id}; =cut sub add { my($self,$data)=@_; my $alephx = $self->store->alephx; #insert/update my $update_doc = $alephx->update_doc( library => $self->name, doc_action => 'UPDATE', doc_number => $data->{_id}, marc => $data ); #_id not given: new record explicitely requested if(int($data->{_id}) == 0){ if($update_doc->errors()->[-1] =~ /Document: (\d{9}) was updated successfully/i){ $data->{_id} = $1; }else{ confess($update_doc->errors()->[-1]); } } #_id given: update when exists, insert when not else{ #error given, can have several reasons: real error or just warnings + success message unless($update_doc->is_success){ #document does not exist (yet) if($update_doc->errors()->[-1] =~ /Doc number given does not exist/i){ #'If you want to insert a new document, then the doc_number you supply should be all zeroes' my $new_doc_num = Catmandu::AlephX->format_doc_num(0); #last error should be 'Document: 000050105 was updated successfully.' $update_doc = $alephx->update_doc( library => $self->name, doc_action => 'UPDATE', doc_number => $new_doc_num, marc => $data ); if($update_doc->errors()->[-1] =~ /Document: (\d{9}) was updated successfully/i){ $data->{_id} = $1; }else{ confess $update_doc->errors()->[-1]; } } #update ok elsif($update_doc->errors()->[-1] =~ /updated successfully/i){ #all ok } #other severe errors (permissions, format..) else{ confess $update_doc->errors()->[-1]; } } #no errors given: strange else{ #when does this happen? confess "how did you end up here?"; } } #record is ALWAYS changed by Aleph, so fetch it again $self->get($data->{_id}); } =head2 delete($id) Deletes a record from the Aleph database. Requires a record identifier. Returns a true value when the record is deleted. =cut sub delete { my($self,$id)= @_; $id = Catmandu::AlephX->format_doc_num($id); my $xml_full_req = < $id EOF #insert/update my $update_doc = $self->store->alephx->update_doc( library => $self->name, doc_action => 'DELETE', doc_number => $id, xml_full_req => $xml_full_req ); #last error: 'Document: 000050124 was updated successfully.' (scalar(@{ $update_doc->errors() })) && ($update_doc->errors()->[-1] =~ /Document: $id was updated successfully./); } =head2 each(callback) Loops over all records in the Aleph database executing callback for every record. =cut sub generator { my $self = $_[0]; #TODO: in some cases, deleted records are really removed from the database # in these cases, it does not make sense to interpret a failing 'find-doc' as the end of the database. # to compete with these 'holes', the size of the hole need to be defined (how big before thinking this is the end) sub { state $count = 1; state $base = $self->name; state $alephx = $self->store->alephx; my $doc; do { my $doc_num = Catmandu::AlephX->format_doc_num($count++); my $find_doc = $alephx->find_doc(base => $base,doc_num => $doc_num,user_name => ""); return unless $find_doc->is_success; $doc = { record => $find_doc->record->metadata->data->{record}, _id => $doc_num }; } while ($self->store->skip_deleted && check_deleted($doc) == 1); return $doc; }; } =head2 search(query => $query, start => 0 , limit => 20); =cut #warning: no_entries is the maximum number of entries to be retrieved (always lower or equal to no_records) # specifying a set_entry higher than this, has no use, and leads to the error 'There is no entry number: in set number given' sub search { my($self,%args)=@_; my $query = delete $args{query}; my $start = delete $args{start}; $start = is_natural($start) ? $start : 0; my $limit = delete $args{limit}; $limit = is_natural($limit) ? $limit : 20; my $alephx = $self->store->alephx; my $find = $alephx->find( request => $query, base => $self->name, user_name => "" ); my @results = (); if ($find->is_success) { my $no_records = int($find->no_records); my $no_entries = int($find->no_entries); my $s = Catmandu::AlephX->format_doc_num($start + 1); my $l = $start + $limit; my $e = Catmandu::AlephX->format_doc_num($l > $no_entries ? $no_entries : $l); my $set_entry = "$s-$e"; my $present = $alephx->present(set_number => $find->set_number,set_entry => $set_entry,format => 'marc',user_name => ""); @results = map { $_->metadata->data; } @{ $present->records() } if $present->is_success; } my $total = $find->no_records; $total = 0 unless defined $total && $total =~ /\d+/; Catmandu::Hits->new({ limit => $limit, start => $start, total => int($total), hits => \@results, }); } =head2 searcher() Not implemented =cut sub searcher { die("not implemented"); } =head2 delete_all() Not implemented =cut sub delete_all { die("not supported"); } =head2 delete_by_query() Not implemented =cut sub delete_by_query { die("not supported"); } sub translate_sru_sortkeys { die("not supported"); } sub translate_cql_query { die("not supported"); } =head1 SEE ALSO L =cut 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/UserAgent/000755 000765 000024 00000000000 14107211622 022752 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Record/000755 000765 000024 00000000000 14107211622 022273 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Metadata.pm000644 000765 000024 00000000257 14107211622 023137 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Metadata; use Catmandu::Sane; use Moo; our $VERSION = "1.073"; has type => (is => 'ro',required => 1); has data => (is => 'ro',required => 1); 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/XPath/000755 000765 000024 00000000000 14107211622 022101 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/lib/Catmandu/AlephX/UserAgent.pm000644 000765 000024 00000000667 14107211622 023321 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::UserAgent; use Catmandu::Sane; use Catmandu::Util qw(:check); use Moo::Role; our $VERSION = "1.073"; has url => ( is => 'ro', isa => sub { $_[0] =~ /^https?:\/\//o or die("url must be a valid web url\n"); }, required => 1 ); has default_args => ( is => 'ro', isa => sub { check_hash_ref($_[0]); }, lazy => 1, default => sub { +{}; } ); #usage: request($params,$methods) requires qw(request); 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/000755 000765 000024 00000000000 14107211622 021433 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Response.pm000644 000765 000024 00000004276 14107211622 023222 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Response; use Catmandu::Sane; use Moo::Role; use Catmandu::Util qw(:is :check); use Catmandu::AlephX::XPath::Helper qw(:all); use Exporter qw(import); our @EXPORT_OK=qw(get_children xpath); our %EXPORT_TAGS = (all=>[@EXPORT_OK]); our $VERSION = "1.073"; =head1 NAME Catmandu::AlephX::Response - base class for xml-responses from the AlephX-server =head1 SYNOPSIS All responses from the AlephX-server share the same functionality and keys: - expressed in XML - name of the parent element is equal to the parameter 'op', except when the value in 'op' is not recognized. Then it is set to 'login'. - when an internal error occurred, the error is reported in the key 'error' - session-id is reported in the key 'session-id' - al the other subkeys are be treated as 'data' All public methods from Catmandu::AlephX return an object of a subclass of Catmandu::AlepX::Response. In case of connection errors, or xml parsing problems, exceptions are thrown. =head1 methods =head2 op type of 'op'. =head2 error internal error that was reported in the xml response. These errors only apply to values in your parameters. Other errors, like connection errors or problems while parsing the xml response are thrown as exceptions. =head2 session_id session-id of the current request =head2 is_success This method only checks if there was an internal error in the AlephX-response. So it simply tests if the key 'error' was undefined. As said before, other errors are thrown as exceptions =cut requires qw(op parse); has errors => ( is => 'rw', isa => sub { check_array_ref($_[0]); }, lazy => 1, default => sub { []; } ); #deprecated, use $self->errors sub error { warn "method 'error' is deprecated, and only return one error. Please use method 'errors' which gives you an array reference of all errors."; $_[0]->errors()->[-1]; } has session_id => (is => 'rw'); sub is_success { return !scalar(@{$_[0]->errors()}); } has content_ref => ( is => 'rw' ); sub parse_errors { my($self,$xpath)=@_; my $op = $self->op(); [map { $_->to_literal; } $xpath->find("/$op/error|/login/error|/$op/error-text-1|/$op/error-text-2")->get_nodelist()]; } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Record.pm000644 000765 000024 00000000611 14107211622 022627 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Record; use Catmandu::Sane; use Catmandu::Util qw(:is :check); use Moo; use Catmandu::AlephX::Metadata; our $VERSION = "1.073"; has metadata => ( is => 'ro', lazy => 1, isa => sub { defined($_[0]) && check_instance($_[0],"Catmandu::AlephX::Metadata"); }, coerce => sub { if(is_code_ref($_[0])){ return $_[0]->(); } $_[0]; } ); 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Metadata/000755 000765 000024 00000000000 14107211622 022575 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Metadata/MARC/000755 000765 000024 00000000000 14107211622 023317 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Metadata/MARC.pm000644 000765 000024 00000002675 14107211622 023667 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Metadata::MARC; use Catmandu::Sane; use Moo; extends qw(Catmandu::AlephX::Metadata); our $VERSION = "1.073"; #parse marcxml into Catmandu marc array sub parse { my($class,$xpath)=@_; my @marc = (); my $leader = $xpath->findvalue("./*[local-name() = 'leader']"); my $fmt = ""; my $_id; for my $controlfield($xpath->find("./*[local-name() = 'controlfield']")->get_nodelist()){ my $tag = $controlfield->findvalue('@tag'); my $value = $controlfield->findvalue('.'); if($tag eq "FMT"){ $fmt = $value; next; } if($tag eq "001"){ $_id = $value; } #leader can also be specified in a controlfield?? elsif($tag eq "LDR"){ $leader = $value; next; } push @marc,[$tag,'','','_',$value]; } unshift @marc,['FMT','','','_',$fmt],['LDR','','','_',$leader]; for my $datafield($xpath->find("./*[local-name() = 'datafield']")->get_nodelist()){ my $tag = $datafield->findvalue('@tag'); my $ind1 = $datafield->findvalue('@ind1'); my $ind2 = $datafield->findvalue('@ind2'); my @subf = (); foreach my $subfield($datafield->find("./*[local-name() = 'subfield']")->get_nodelist()) { my $code = $subfield->findvalue('@code'); my $value = $subfield->findvalue('.'); push @subf,$code,$value; } push @marc,[$tag,$ind1,$ind2,@subf]; } __PACKAGE__->new(type => 'oai_marc',data => { record => \@marc, _id => $_id }); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Metadata/MARC/Aleph.pm000644 000765 000024 00000003674 14107211622 024720 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Metadata::MARC::Aleph; use Catmandu::Sane; use Catmandu::Util qw(:array); use Moo; our $VERSION = "1.073"; extends qw(Catmandu::AlephX::Metadata); #parse aleph oai marc into catmandu marc array sub parse { my($class,$xpath)=@_; my @marc = (); my $_id; for my $fix_field($xpath->find('./fixfield')->get_nodelist()){ my $tag = $fix_field->findvalue('@id'); my $value = $fix_field->findvalue('.'); push @marc,[$tag,'','','_',$value]; if($tag eq "001"){ $_id = $value; } } for my $var_field($xpath->find('./varfield')->get_nodelist()){ my $tag = $var_field->findvalue('@id'); my $ind1 = $var_field->findvalue('@i1'); my $ind2 = $var_field->findvalue('@i2'); my @subf = (); foreach my $sub_field($var_field->find('.//subfield')->get_nodelist()) { my $code = $sub_field->findvalue('@label'); my $value = $sub_field->findvalue('.'); push @subf,$code,$value; } push @marc,[$tag,$ind1,$ind2,@subf]; } __PACKAGE__->new(type => 'oai_marc',data => { record => \@marc, _id => $_id }); } sub escape_value { my $data = $_[0]; $data =~ s/&/&/sg; $data =~ s//>/sg; $data =~ s/"/"/sg; $data; } sub to_xml { my($class,$record)=@_; my @xml = ""; for my $field(@{ $record->{record} }){ my($tag,$ind1,$ind2,@subfields)= @$field; if(array_includes([qw(FMT LDR)],$tag) || $tag =~ /^00/o){ push @xml,""; push @xml,escape_value($subfields[1]); push @xml,""; }else{ push @xml,""; for(my $i = 0;$i < scalar(@subfields);$i+=2){ my $label = $subfields[$i]; my $value = $subfields[$i+1]; push @xml,"".escape_value($value).""; } push @xml,""; } } push @xml,""; join('',@xml); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/CircStatM.pm000644 000765 000024 00000001620 14107211622 023621 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::CircStatM; use Catmandu::Sane; use Catmandu::Util qw(:check); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); #difference from CircStatus: former cannot fetch documents with than 1000 items has item_data => ( is => 'ro', isa => sub { check_array_ref($_[0]); } ); #only appears in the xml output when over 990 items are present has start_point => ( is => 'ro' ); sub op { 'circ-stat-m' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my @item_data; for my $i($xpath->find("/$op/item-data")->get_nodelist()){ push @item_data,get_children($i,1); } __PACKAGE__->new( start_point => $xpath->findvalue("/$op/start-point"), item_data => \@item_data, session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/HoldReq.pm000644 000765 000024 00000001262 14107211622 023330 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::HoldReq; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has reply => ( is => 'ro', required => 1, isa => sub{ check_maybe_string($_[0]); } ); sub op { 'hold-req' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my %args; for(qw(session-id reply)){ my $key = $_; $key =~ s/-/_/go; $args{$key} = $xpath->findvalue("/$op/$_"); $args{$key} = is_string($args{$key}) ? $args{$key} : undef; } $args{errors} = $class->parse_errors($xpath); $args{content_ref} = $str_ref; __PACKAGE__->new(%args); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/Renew.pm000644 000765 000024 00000001266 14107211622 023056 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::Renew; use Catmandu::Sane; use Catmandu::Util qw(:check); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has reply => ( is => 'ro' ); has due_date => ( is => 'ro' ); has due_hour => ( is => 'ro' ); sub op { 'renew' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); __PACKAGE__->new( session_id => $xpath->findvalue('/'.$op.'/session-id'), errors => $class->parse_errors($xpath), reply => $xpath->findvalue('/'.$op.'/reply'), due_date => $xpath->findvalue('/'.$op.'/due-date'), due_hour => $xpath->findvalue('/'.$op.'/due-hour'), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/FindDoc.pm000644 000765 000024 00000001742 14107211622 023303 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::FindDoc; use Catmandu::Sane; use Moo; use Catmandu::AlephX; use Catmandu::AlephX::Metadata::MARC::Aleph; use Catmandu::AlephX::Record; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has record => ( is => 'ro' ); sub op { 'find-doc' } sub parse { my($class,$str_ref,$args) = @_; my $doc_num = $args->{doc_num} || $args->{doc_number}; $doc_num = Catmandu::AlephX->format_doc_num($doc_num); my $xpath = xpath($str_ref); my $op = op(); my @metadata = (); __PACKAGE__->new( record => Catmandu::AlephX::Record->new(metadata => sub { my($oai_marc) = $xpath->find("/$op/record[1]/metadata/oai_marc")->get_nodelist(); if($oai_marc){ my $m = Catmandu::AlephX::Metadata::MARC::Aleph->parse($oai_marc); $m->data->{_id} = $doc_num; return $m; } }), session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/IllLoanInfo.pm000644 000765 000024 00000001525 14107211622 024142 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::IllLoanInfo; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has z36 => ( is => 'ro', lazy => 1, isa => sub { check_hash_ref($_[0]); }, default => sub { +{}; } ); sub op { 'ill-loan-info' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my $z36 = {}; my($z) = $xpath->find("/ill-LOAN-INFO/z36")->get_nodelist(); $z36 = get_children($z) if $z; __PACKAGE__->new( session_id => $xpath->findvalue('/ill-LOAN-INFO/session-id'), errors => $class->parse_errors($xpath), z36 => $z36, content_ref => $str_ref ); } sub parse_errors { my($self,$xpath)=@_; [map { $_->to_literal; } $xpath->find("/ill-LOAN-INFO/error|/ill-loan-info/error")->get_nodelist()]; } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/BorAuth.pm000644 000765 000024 00000001771 14107211622 023343 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::BorAuth; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has z303 => ( is => 'ro', lazy => 1, isa => sub{ check_hash_ref($_[0]); }, default => sub { {}; } ); has z304 => ( is => 'ro', lazy => 1, isa => sub{ check_hash_ref($_[0]); }, default => sub { {}; } ); has z305 => ( is => 'ro', lazy => 1, isa => sub{ check_hash_ref($_[0]); }, default => sub { {}; } ); sub op { 'bor-auth' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my @keys = qw(z303 z304 z305); my %args = (); for my $key(@keys){ my($l) = $xpath->find("/$op/$key")->get_nodelist(); my $data = $l ? get_children($l,1) : {}; $args{$key} = $data; } __PACKAGE__->new( %args, session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/UserAuth.pm000644 000765 000024 00000001273 14107211622 023534 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::UserAuth; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has z66 => ( is => 'ro', isa => sub{ check_hash_ref($_[0]); } ); has reply => ( is => 'ro' ); sub op { 'user-auth' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my($z66) = $xpath->find('/z66')->get_nodelist(); $z66 = get_children($z66,1); __PACKAGE__->new( session_id => $xpath->findvalue('/'.$op.'/session-id'), errors => $class->parse_errors($xpath), reply => $xpath->findvalue('/'.$op.'/reply'), z66 => $z66, content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/GetHolding.pm000644 000765 000024 00000001351 14107211622 024015 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::GetHolding; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has cdl_holdings => ( is => 'ro', lazy => 1, isa => sub{ check_array_ref($_[0]); }, default => sub { []; } ); sub op { 'get-holding' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my @cdl_holdings; for my $ch($xpath->find("/$op/cdl-holdings")->get_nodelist()){ push @cdl_holdings,get_children($ch,1); } __PACKAGE__->new( cdl_holdings => \@cdl_holdings, session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/Present.pm000644 000765 000024 00000002405 14107211622 023412 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::Present; use Catmandu::Sane; use Catmandu::Util qw(:is :check); use Moo; use Catmandu::AlephX::Metadata::MARC::Aleph; use Catmandu::AlephX::Record::Present; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has records => ( is => 'ro', lazy => 1, default => sub { [] }, coerce => sub { if(is_code_ref($_[0])){ return $_[0]->(); } $_[0]; } ); sub op { 'present' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); __PACKAGE__->new( records => sub{ my @records; for my $r($xpath->find("/$op/record")->get_nodelist()){ my($l) = $r->find('./record_header')->get_nodelist(); my $record_header = $l ? get_children($l,1) : {}; my $metadata = Catmandu::AlephX::Metadata::MARC::Aleph->parse( $r->find('./metadata/oai_marc')->get_nodelist() ); push @records,Catmandu::AlephX::Record::Present->new( metadata => $metadata, record_header => $record_header, doc_number => $r->findvalue('./doc_number') ); } \@records }, session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/IllGetDoc.pm000644 000765 000024 00000002040 14107211622 023573 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::IllGetDoc; use Catmandu::Sane; use Catmandu::Util qw(:check); use Catmandu::AlephX::Metadata::MARC; use Catmandu::AlephX::Record; use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); # has extra tag in marc array called 'AVA' has record => ( is => 'ro', isa => sub { check_instance($_[0],"Catmandu::AlephX::Record"); } ); sub op { 'ill-get-doc' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); __PACKAGE__->new( errors => $class->parse_errors($xpath), session_id => $xpath->findvalue("/$op/session-id"), record => Catmandu::AlephX::Record->new(metadata => sub { $xpath->registerNs("marc","http://www.loc.gov/MARC21/slim/"); my($marc) = $xpath->find("/$op/marc:record")->get_nodelist(); if($marc){ #remove controlfield with tag 'FMT' and 'LDR' because Catmandu::Importer::MARC cannot handle these return Catmandu::AlephX::Metadata::MARC->parse($marc); } }), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/PublishAvail.pm000644 000765 000024 00000003246 14107211622 024361 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::PublishAvail; use Catmandu::Sane; use Catmandu::Util qw(:check); use Catmandu::AlephX::Metadata::MARC; use Catmandu::AlephX::Record; use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); #format: [ { _id => , record => }, .. ] # has extra tag in marc array called 'AVA' has records => ( is => 'ro', isa => sub { check_array_ref($_[0]); } ); sub op { 'publish-avail' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); $xpath->registerNs(oai => "http://www.openarchives.org/OAI/2.0/"); $xpath->registerNs(marc => "http://www.loc.gov/MARC21/slim"); my $op = op(); my @records; for my $record($xpath->find("/$op/oai:OAI-PMH/oai:ListRecords/oai:record")->get_nodelist()){ my $identifier = $record->findvalue("./*[local-name() = 'header']/*[local-name()='identifier']"); $identifier =~ s/aleph-publish://o; my($record) = $record->find("./*[local-name()='metadata']/*[local-name() = 'record']")->get_nodelist(); if($record){ #remove controlfield with tag 'FMT' and 'LDR' because Catmandu::Importer::MARC cannot handle these my $m = Catmandu::AlephX::Metadata::MARC->parse($record); $m->{_id} = $identifier; push @records,Catmandu::AlephX::Record->new(metadata => $m); }else{ push @records,Catmandu::AlephX::Record->new( metadata => Catmandu::AlephX::Metadata::MARC->new( data => { _id => $identifier }, type => "oai_marc" ) ); } } __PACKAGE__->new( errors => $class->parse_errors($xpath), session_id => $xpath->findvalue("/$op/session-id"), records => \@records, content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/UpdateDoc.pm000644 000765 000024 00000000671 14107211622 023645 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::UpdateDoc; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); sub op { 'update-doc' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); __PACKAGE__->new( session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/CreateItem.pm000644 000765 000024 00000000673 14107211622 024021 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::CreateItem; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); sub op { 'create-item' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); __PACKAGE__->new( session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/BorInfo.pm000644 000765 000024 00000004034 14107211622 023330 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::BorInfo; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; extends('Catmandu::AlephX::Op::BorAuth'); with('Catmandu::AlephX::Response'); has item_l => ( is => 'ro', lazy => 1, isa => sub { check_array_ref($_[0]); }, default => sub { [] } ); has item_h => ( is => 'ro', lazy => 1, isa => sub { check_array_ref($_[0]); }, default => sub { [] } ); has balance => ( is => 'ro' ); has sign => ( is => 'ro' ); has fine => ( is => 'ro', lazy => 1, isa => sub { check_array_ref($_[0]); }, default => sub { [] } ); sub op { 'bor-info' } my $config = { fine => [qw(z31 z30 z13)], 'item-h' => [qw(z37 z30 z13)] }; sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my $args = {}; for my $zkey(qw(z303 z304 z305)){ my($l) = $xpath->find("/$op/$zkey")->get_nodelist(); $args->{$zkey} = $l ? get_children($l,1) : {}; } for my $child($xpath->find("/$op/item-l")->get_nodelist()){ $args->{'item_l'} //= []; my $item_l = {}; $item_l->{due_date} = $child->findvalue('./due-date'); $item_l->{due_hour} = $child->findvalue('./due-hour'); for my $key(qw(z36 z30 z13)){ for my $data($child->find("./$key")->get_nodelist()){ $item_l->{ $key } = get_children($data,1); } } push @{ $args->{'item_l'} },$item_l; } for my $key(keys %$config){ for my $child($xpath->find("/$op/$key")->get_nodelist()){ my $n = $key; $n =~ s/-/_/go; $args->{$n} //= []; my %result = map { my($l) = $child->find("./$_")->get_nodelist(); $l ? ($_ => get_children($l,1 )) : ($_ => {}); } @{ $config->{ $key } }; push @{ $args->{$n} },\%result; } } __PACKAGE__->new( %$args, balance => $xpath->findvalue("/$op/balance"), sign => $xpath->findvalue("/$op/sign"), session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/UpdateItem.pm000644 000765 000024 00000001276 14107211622 024040 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::UpdateItem; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has z30 => ( is => 'ro', lazy => 1, isa => sub{ check_hash_ref($_[0]); }, default => sub { +{}; } ); sub op { 'update-item' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my @z30; for my $z($xpath->find("/$op/z30")->get_nodelist()){ push @z30,get_children($z,1); } __PACKAGE__->new( session_id => $xpath->findvalue('/'.$op.'/session-id'), errors => $class->parse_errors($xpath), content_ref => $str_ref, z30 => $z30[0] // +{} ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/IllGetDocShort.pm000644 000765 000024 00000001262 14107211622 024620 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::IllGetDocShort; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has z13 => ( is => 'ro', lazy => 1, isa => sub{ check_hash_ref($_[0]); }, default => sub { {}; } ); sub op { 'ill-get-doc-short' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my $z13 = {}; my($z) = $xpath->find("/$op/z13")->get_nodelist(); $z13 = get_children($z) if $z; __PACKAGE__->new( session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), z13 => $z13, content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/Find.pm000644 000765 000024 00000001400 14107211622 022644 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::Find; use Catmandu::Sane; use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); #'set_number' == id waaronder zoekactie wordt opgeslagen door Aleph (kan je later hergebruiken) has set_number => ( is => 'ro' ); has no_records => ( is => 'ro' ); has no_entries => ( is => 'ro', ); sub op { 'find' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); __PACKAGE__->new( errors => $class->parse_errors($xpath), session_id => $xpath->findvalue("/$op/session-id"), set_number => $xpath->findvalue("/$op/set_number"), no_records => $xpath->findvalue("/$op/no_records"), no_entries => $xpath->findvalue("/$op/no_entries"), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/ItemData.pm000644 000765 000024 00000001362 14107211622 023463 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::ItemData; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has items => ( is => 'ro', lazy => 1, isa => sub{ check_array_ref($_[0]); for(@{ $_[0] }){ check_hash_ref($_); } }, default => sub { []; } ); sub op { 'item-data' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my @items; for my $item($xpath->find("/$op/item")->get_nodelist()){ push @items,get_children($item,1); } __PACKAGE__->new( session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), items => \@items, content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/ReadItem.pm000644 000765 000024 00000001265 14107211622 023467 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::ReadItem; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has z30 => ( is => 'ro', lazy => 1, isa => sub{ check_hash_ref($_[0]); }, default => sub { {}; } ); sub op { 'read-item' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my @z30; for my $z($xpath->find("/$op/z30")->get_nodelist()){ push @z30,get_children($z,1); } __PACKAGE__->new( session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), z30 => $z30[0] // +{}, content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/CircStatus.pm000644 000765 000024 00000001241 14107211622 024053 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::CircStatus; use Catmandu::Sane; use Catmandu::Util qw(:check); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has item_data => ( is => 'ro', isa => sub { check_array_ref($_[0]); } ); sub op { 'circ-status' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my @item_data; for my $i($xpath->find("/$op/item-data")->get_nodelist()){ push @item_data,get_children($i,1); } __PACKAGE__->new( item_data => \@item_data, session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/HoldReqCancel.pm000644 000765 000024 00000001277 14107211622 024444 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::HoldReqCancel; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has reply => ( is => 'ro', required => 1, isa => sub{ check_maybe_string($_[0]); } ); sub op { 'hold-req-cancel' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my %args; for(qw(session-id reply)){ my $key = $_; $key =~ s/-/_/go; $args{$key} = $xpath->findvalue("/$op/$_"); $args{$key} = is_string($args{$key}) ? $args{$key} : undef; } $args{errors} = $class->parse_errors($xpath); $args{content_ref} = $str_ref; __PACKAGE__->new(%args); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/ItemDataMulti.pm000644 000765 000024 00000001532 14107211622 024475 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::ItemDataMulti; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; our $VERSION = "1.073"; with('Catmandu::AlephX::Response'); has items => ( is => 'ro', lazy => 1, isa => sub{ check_array_ref($_[0]); for(@{ $_[0] }){ check_hash_ref($_); } }, default => sub { []; } ); has start_point => (is => 'ro'); sub op { 'item-data-multi' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my @items; for my $item($xpath->find("/$op/item")->get_nodelist()){ push @items,get_children($item,1); } __PACKAGE__->new( session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), items => \@items, start_point => $xpath->findvalue("/$op/start-point"), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Op/IllBorInfo.pm000644 000765 000024 00000001473 14107211622 023775 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Op::IllBorInfo; use Catmandu::Sane; use Catmandu::Util qw(:check); use Moo; our $VERSION = "1.073"; extends('Catmandu::AlephX::Op::BorAuth'); with('Catmandu::AlephX::Response'); has z308 => ( is => 'ro', lazy => 1, isa => sub { check_array_ref($_[0]); }, default => sub { []; } ); sub op { 'ill-bor-info' } sub parse { my($class,$str_ref) = @_; my $xpath = xpath($str_ref); my $op = op(); my @keys = qw(z303 z304 z305 z308); my %args = (); for my $key(@keys){ my($l) = $xpath->find("/$op/$key")->get_nodelist(); my $data = $l ? get_children($l,1) : {}; $args{$key} = $data; } __PACKAGE__->new( %args, session_id => $xpath->findvalue("/$op/session-id"), errors => $class->parse_errors($xpath), content_ref => $str_ref ); } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/XPath/Helper.pm000644 000765 000024 00000002165 14107211622 023662 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::XPath::Helper; use Catmandu::Sane; use XML::LibXML; use XML::LibXML::XPathContext; use Catmandu::Util qw(:is io); use Exporter qw(import); our @EXPORT_OK=qw(get_children xpath); our %EXPORT_TAGS = (all=>[@EXPORT_OK]); our $VERSION = "1.073"; sub get_children { my($xpath,$is_hash) = @_; my $hash = {}; if($xpath){ for my $child($xpath->find('child::*')->get_nodelist()){ my $name = $child->nodeName(); my $value = $child->textContent(); if($is_hash){ $hash->{ $name } = $value; }else{ $hash->{$name} //= []; push @{ $hash->{$name} },$value if is_string($value); } } } $hash; } sub xpath { my $str = $_[0]; my $xpath; if(is_scalar_ref($str)){ my $xml = XML::LibXML->load_xml(IO => io($str)); $xpath = XML::LibXML::XPathContext->new($xml); }elsif(-f $str){ my $xml = XML::LibXML->load_xml(location => $str); $xpath = XML::LibXML::XPathContext->new($xml); }elsif(is_glob_ref($str)){ my $xml = XML::LibXML->load_xml(IO => io($str)); $xpath = XML::LibXML::XPathContext->new($xml); } return $xpath; } 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/Record/Present.pm000644 000765 000024 00000000352 14107211622 024251 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::Record::Present; use Catmandu::Sane; use Moo; our $VERSION = "1.073"; extends 'Catmandu::AlephX::Record'; has record_header => (is => 'ro',required => 1); has doc_number => (is => 'ro',required => 1); 1; Catmandu-AlephX-1.073/lib/Catmandu/AlephX/UserAgent/LWP.pm000644 000765 000024 00000004036 14107211622 023755 0ustar00njfranckstaff000000 000000 package Catmandu::AlephX::UserAgent::LWP; use Catmandu::Sane; use Carp qw(confess); use Moo; use LWP::UserAgent; use URI::Escape; use Catmandu::Util qw(:check :is); our $VERSION = "1.073"; with qw(Catmandu::AlephX::UserAgent); has ua => ( is => 'ro', lazy => 1, default => sub { my $ua = LWP::UserAgent->new( cookie_jar => {} ); if(is_string($ENV{LWP_TRACE})){ $ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return }); } $ua; } ); sub request { my($self,$params,$method)=@_; #default_args $params = { %{ $self->default_args() }, %$params }; $method ||= "GET"; my $res; if(uc($method) eq "GET"){ $res = $self->_get($params); }elsif(uc($method) eq "POST"){ $res = $self->_post($params); }else{ confess "method $method not supported"; } _validate_web_response($res); $res; } sub _validate_web_response { my($res) = @_; ($res->is_error || $res->content_type !~ /xml/io) && confess($res->content); } sub _post { my($self,$data)=@_; $self->ua->post($self->url,_construct_params_as_array($data)); } sub _construct_query { my $data = shift; my @parts = (); for my $key(keys %$data){ if(is_array_ref($data->{$key})){ for my $val(@{ $data->{$key} }){ push @parts,URI::Escape::uri_escape($key)."=".URI::Escape::uri_escape($val // ""); } }else{ push @parts,URI::Escape::uri_escape($key)."=".URI::Escape::uri_escape($data->{$key} // ""); } } join("&",@parts); } sub _construct_params_as_array { my $params = shift; my @array = (); for my $key(keys %$params){ if(is_array_ref($params->{$key})){ #PHP only recognizes 'arrays' when their keys are appended by '[]' (yuk!) for my $val(@{ $params->{$key} }){ push @array,$key => $val; } }else{ push @array,$key => $params->{$key}; } } return \@array; } sub _get { my($self,$data)=@_; my $query = _construct_query($data) || ""; $self->ua->get($self->url."?$query"); } 1; Catmandu-AlephX-1.073/lib/Catmandu/Importer/AlephX.pm000644 000765 000024 00000013425 14107211622 023221 0ustar00njfranckstaff000000 000000 package Catmandu::Importer::AlephX; use Catmandu::Sane; use Catmandu::Util qw(:check :is); use Moo; use Catmandu::AlephX; use Data::Dumper; with 'Catmandu::Importer'; our $VERSION = "1.073"; has url => (is => 'ro', required => 1); has base => (is => 'ro', required => 1); has query => (is => 'ro' ); has skip_deleted => (is => 'ro', default => sub { 0 }); has include_items => (is => 'ro',required => 0,lazy => 1,default => sub { 1; }); has limit => ( is => 'ro', isa => sub { check_natural($_[0]); }, lazy => 1, default => sub { 20; } ); has alephx => (is => 'ro', init_arg => undef , lazy => 1 , builder => '_build_alephx'); sub _build_alephx { Catmandu::AlephX->new(url => $_[0]->url); } sub _fetch_items { my ($self, $doc_number) = @_; my $item_data = $self->alephx->item_data(base => $self->base, doc_number => $doc_number); return [] unless $item_data->is_success; return $item_data->items; } sub check_deleted { my $r = $_[0]; return 1 unless defined $r; for (@{$r->{record}}) { return 1 if ($_->[0] eq 'DEL'); } return 0; } sub generator { my $self = $_[0]; #generator, based on a query (limited) if(is_string($self->query)){ return sub { my $find = $self->alephx->find(request => $self->query , base => $self->base); return unless $find->is_success; state $buffer = []; state $set_number = $find->set_number; state $no_records = int($find->no_records); state $no_entries = int($find->no_entries); #warning: no_records is the number of records found, but only no_entries are stored in the set. # a call to 'present' with set_number higher than no_entries has no use. state $offset = 1; state $limit = $self->limit; return if $no_entries == 0 || $offset > $no_entries; unless(@$buffer){ my $set_entry; { my $start = Catmandu::AlephX->format_doc_num($offset); my $l = $offset + $limit - 1; my $end = Catmandu::AlephX->format_doc_num($l > $no_entries ? $no_entries : $l); $set_entry = "$start-$end"; } my $present = $self->alephx->present(set_number => $set_number , set_entry => $set_entry); return unless $present->is_success; for my $record(@{ $present->records() }){ my $items = []; if($self->include_items){ $items = $self->_fetch_items($record->{doc_number}); } #do NOT use $record->metadata->data->{_id}, for that uses the field '001' that can be empty push @$buffer,{ record => $record->metadata->data->{record} , items => $items, _id => $record->{doc_number} }; } $offset += $limit; } shift(@$buffer); }; } #generator that tries to fetch all records else{ return sub { state $count = 1; state $alephx = $self->alephx; my $doc; do { my $doc_num = Catmandu::AlephX->format_doc_num($count++); my $find_doc = $alephx->find_doc(base => $self->base,doc_num => $doc_num); return unless $find_doc->is_success; my $items = []; if($self->include_items){ $items = $self->_fetch_items($doc_num); } $doc = { record => $find_doc->record->metadata->data->{record}, items => $items, #do NOT use $record->metadata->data->{_id}, for that uses the field '001' that can be empty _id => $doc_num }; } while ($self->skip_deleted && check_deleted($doc) == 1); return $doc; }; } } =head1 NAME Catmandu::Importer::AlephX - Package that imports metadata records from the AlephX service =head1 SYNOPSIS use Catmandu::Importer::AlephX; my $importer = Catmandu::Importer::AlephX->new( url => 'http://ram19:8995/X' , query => 'WRD=(art)' , base => 'usm01' , ); my $n = $importer->each(sub { my $r = $_[0]; # ... say Dumper($r->{record}); say Dumper($r->{items}); }); =head1 METHODS =head2 new(url => '...' , base => '...' , query => '...') Create a new AlephX importer. Required parameters are the url baseUrl of the AlephX service, an Aleph 'base' catalog name and a 'query'. =head3 common parameters url base url of alephx service (e.g. "http://ram19:8995/X") include_items 0|1. When set to '1', the items of every bibliographical record are retrieved =head3 alephx parameters base name of catalog in Aleph where you want to search query the query of course =head3 output { record => [ [ 'FMT', '', '', '_', 'MX' ], [ 'LDR', '', '', '_', '01236npca^22001937|^4500' ] .. ], items => [ { 'sub-library' => 'WID', 'chronological-k' => '', 'chronological-i' => '', 'library' => 'USM50', 'collection' => 'HD', 'call-no-1' => '$$2ZHCL$$hH 810.80.20', 'chronological-j' => '', 'requested' => 'N', 'expected' => 'N', 'barcode' => 'HWM4M4', 'description' => '', 'note' => '', 'item-status' => '01', 'rec-key' => '000048762000010', 'enumeration-a' => '', 'call-no-2' => '', 'enumeration-b' => '', 'enumeration-c' => '', 'on-hold' => 'N' } ] } =head2 count =head2 each(&callback) =head2 ... Every Catmandu::Importer is a Catmandu::Iterable all its methods are inherited. The Catmandu::Importer::AlephX methods are not idempotent: Twitter feeds can only be read once. =head1 AUTHOR Patrick Hochstenbach C<< patrick dot hochstenbach at ugent dot be >> =head1 SEE ALSO L =cut 1; Catmandu-AlephX-1.073/examples/bor_info.pl000644 000765 000024 00000001010 14107211622 021332 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my %args = ( library => "rug50", bor_id => "demo", verification => "demo", user_name => "t", user_password => "t" ); my $info = $aleph->bor_info(%args); if($info->is_success){ print Dumper($info->item_l); print Dumper($info->item_h); }else{ say STDERR join('',@{$info->errors}); } Catmandu-AlephX-1.073/examples/circstatm.pl000644 000765 000024 00000000641 14107211622 021537 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $circstatus = $aleph->circ_stat_m(sys_no => '001484478',library => 'rug01'); if($circstatus->is_success){ print Dumper($circstatus); }else{ say STDERR join('',@{$circstatus->errors}); } Catmandu-AlephX-1.073/examples/import.pl000644 000765 000024 00000000620 14107211622 021055 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Importer::AlephX; use Data::Dumper; use open qw(:std :utf8); my $i = 1; Catmandu::Importer::AlephX->new( url => 'http://borges1.ugent.be/X', query => 'WRD=(all)', base => 'usm01', include_items => 0, limit => 5 )->each(sub{ my $record = shift; #print Dumper($record); say ($i++); }); Catmandu-AlephX-1.073/examples/delete.pl000644 000765 000024 00000000426 14107211622 021011 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Store::AlephX; use Data::Dumper; use open qw(:std :utf8); my $bag = Catmandu::Store::AlephX->new(url => "http://borges1.ugent.be/X")->bag(); my $id = shift; $bag->delete($id); Catmandu-AlephX-1.073/examples/bor_auth-sec.pl000644 000765 000024 00000002052 14107211622 022117 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); sub read_str { my $line = ; chomp $line; $line; } sub read_password { use Term::ReadKey; ReadMode 'noecho'; my $password = ReadLine 0; ReadMode 'normal'; chomp $password; print "\n"; return $password; } my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my($library,$bor_id,$verification); print "library: "; $library = read_str(); print "bor_id: "; $bor_id = read_str(); print "verification: "; $verification = read_password(); my %args = ( library => $library, bor_id => $bor_id, verification => $verification ); my $auth = $aleph->bor_auth(%args); if($auth->is_success){ for my $type(qw(z303 z304 z305)){ say "$type:"; my $data = $auth->$type(); for my $key(keys %$data){ next unless($data->{$key}); say "\t$key : '$data->{$key}'"; } } }else{ say STDERR "error: ".join('',@{$auth->errors}); exit 1; } Catmandu-AlephX-1.073/examples/update_doc.pl000644 000765 000024 00000001453 14107211622 021657 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Catmandu::Importer::AlephX; use Catmandu::AlephX::Metadata::MARC::Aleph; use Data::Dumper; use File::Slurp; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $importer = Catmandu::Importer::AlephX->new( url => 'http://borges1.ugent.be/X', query => 'WRD=(art)', base => 'usm01' ); my $marc = $importer->first(); print Dumper($marc); my %args = ( 'library' => 'usm01', 'doc_action' => 'UPDATE', 'doc_number' => $marc->{_id}, marc => $marc ); my $info = $aleph->update_doc(%args); if($info->is_success){ say "all ok"; }else{ say "test"; say "num errors:".scalar(@{ $info->errors() }); say STDERR join("\n",@{$info->errors}); } Catmandu-AlephX-1.073/examples/update_item.pl000644 000765 000024 00000002352 14107211622 022047 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Util qw(:is); use Catmandu::AlephX; use open qw(:std :utf8); use Data::Compare; use Test::Deep::NoTest; use Data::Dumper; use File::Slurp; use Catmandu::AlephX::XPath::Helper qw(:all); use Clone qw(clone); sub alephx { state $a = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); } my $file = shift; is_string($file) or die("usage: $0 \n"); my $xml = read_file($file); my $xpath = xpath(\$xml); my $item_barcode = $xpath->findvalue("/z30/z30-barcode"); say "item_barcode: $item_barcode"; my $z30 = get_children($xpath->find("/z30")->get_nodelist(),1); my %args = ( 'library' => 'usm50', 'xml_full_req' => $xml ); my $u = alephx->update_item(%args); if($u->is_success){ say "all ok"; }else{ say STDERR join("\n",@{$u->errors}); my $old_z30 = clone($z30); my $new_z30 = alephx->read_item("library" => "usm50","item_barcode" => $item_barcode)->z30(); delete $old_z30->{$_} for qw(z30-cataloger z30-update-date); delete $new_z30->{$_} for qw(z30-cataloger z30-update-date); say "old z30:"; say Dumper($old_z30); say "new z30"; say Dumper($new_z30); say "equal: ".(eq_deeply($old_z30,$new_z30) ? "yes":"no"); } Catmandu-AlephX-1.073/examples/update_doc_delete.pl000644 000765 000024 00000000741 14107211622 023200 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use open qw(:std :utf8); use Data::Dumper; sub alephx { state $a = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); } my $doc_number = shift; my %args = ( 'library' => 'usm01', 'doc_action' => 'DELETE', 'doc_number' => $doc_number ); my $u = alephx->update_doc(%args); if($u->is_success){ say "all ok"; }else{ say STDERR join("\n",@{$u->errors}); } Catmandu-AlephX-1.073/examples/illloaninfo.pl000644 000765 000024 00000000656 14107211622 022062 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $result = $aleph->ill_loan_info(doc_number => "000030527",library=>"rug01",item_seq => "000001"); if($result->is_success){ print Dumper($result->z36); }else{ say STDERR join('',@{$result->errors}); } Catmandu-AlephX-1.073/examples/finddoc.pl000644 000765 000024 00000000750 14107211622 021155 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X",default_args => { user_name => "test",user_password => "test" }); my $find = $aleph->find_doc(base=>'rug01',doc_num=>'000000444',user_name => ""); if($find->is_success){ say Dumper($find->record->metadata->data); }else{ say STDERR join('',@{$find->errors}); } Catmandu-AlephX-1.073/examples/patron-sec.pl000644 000765 000024 00000003113 14107211622 021616 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); sub read_str { my $line = ; chomp $line; $line; } sub read_password { use Term::ReadKey; ReadMode 'noecho'; my $password = ReadLine 0; ReadMode 'normal'; chomp $password; print "\n"; return $password; } my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $file; my($library,$bor_id,$verification); print "library: "; $library = read_str(); print "bor_id: "; $bor_id = read_str(); print "verification: "; $verification = read_password(); print "file: "; $file = read_str(); say "file is '$file'"; $file = "/dev/stdout" if $file eq "-"; open STDOUT,">:utf8",$file or die($!); my %args = ( library => $library, bor_id => $bor_id, verification => $verification ); my $info = $aleph->bor_info(%args); if($info->is_success){ my $z304 = $info->z304(); my @keys = qw(z304-address-0 z304-address-1 z304-address-2 z304-address-3 z304-address-4 z304-email-address z304-date-from z304-date-to z304-zip z304-telephone z304-telephone-1 z304-telephone-2 z304-telephone-3 z304-telephone-4); for my $key(@keys){ my $val = $z304->{$key} // ""; say sprintf("\t%20s : %s",$key,$val); } my $z305 = $info->z305(); @keys = qw(z305-no-cash z305-no-hold z305-no-loan z305-no-photo); for my $key(@keys){ my $val = $z305->{$key} // ""; say sprintf("\t%20s : %s",$key,$val); } }else{ say STDERR "error: ".join('',@{$info->errors}); exit 1; } Catmandu-AlephX-1.073/examples/illgetdoc.pl000644 000765 000024 00000001031 14107211622 021506 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use JSON qw(to_json); use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $illgetdoc = $aleph->ill_get_doc(doc_number => '001317121',library=>'rug01'); if($illgetdoc->is_success){ if($illgetdoc->record){ say "data: ".to_json($illgetdoc->record->metadata->data,{ pretty => 1 }); } else{ say "nothing found"; } }else{ say STDERR join('',@{$illgetdoc->errors}); } Catmandu-AlephX-1.073/examples/present.pl000644 000765 000024 00000001252 14107211622 021225 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $set_number = $aleph->find(request => "wrd=(BIB.AFF)",base => "rug01")->set_number; my $present = $aleph->present( set_number => $set_number, set_entry => "000000001" ); if($present->is_success){ for my $record(@{ $present->records }){ say "record_header: ".Dumper($record->{record_header}); say "\ttype: ".$record->metadata->type; say "\tdata: ".Dumper($record->metadata->data()); } }else{ say STDERR join('',@{$present->errors}); } Catmandu-AlephX-1.073/examples/bor_info-sec.pl000644 000765 000024 00000002420 14107211622 022110 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use open qw(:std :utf8); use Data::Dumper; sub read_str { my $line = ; chomp $line; $line; } sub read_password { use Term::ReadKey; ReadMode 'noecho'; my $password = ReadLine 0; ReadMode 'normal'; chomp $password; print "\n"; return $password; } my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $file = "-"; my($library,$bor_id,$verification); print "library: "; $library = read_str(); print "bor_id: "; $bor_id = read_str(); print "verification: "; $verification = read_password(); print "file: "; $file = read_str(); $file = "/dev/stdout" if $file eq "-"; open STDOUT,">:utf8",$file or die($!); my %args = ( library => $library, bor_id => $bor_id, verification => $verification, loans => 'P' ); my $info = $aleph->bor_info(%args); if($info->is_success){ for my $type(qw(z303 z304 z305)){ say "$type:"; my $data = $info->$type(); for my $key(keys %$data){ say "\tkey: $key"; say "\t$key : $data->{$key}" if $data->{$key}; } } say "fine:"; print Dumper($info->fine); print Dumper($info->item_l); }else{ say STDERR "error: ".join('',@{$info->errors}); exit 1; } Catmandu-AlephX-1.073/examples/patron.pl000644 000765 000024 00000002003 14107211622 021043 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my %args = ( library => 'rug50', bor_id => 'demo', verification => 'demo' ); my $info = $aleph->bor_info(%args); if($info->is_success){ my $z304 = $info->z304(); my @keys = qw(z304-address-0 z304-address-1 z304-address-2 z304-address-3 z304-address-4 z304-email-address z304-date-from z304-date-to z304-zip z304-telephone z304-telephone-1 z304-telephone-2 z304-telephone-3 z304-telephone-4); for my $key(@keys){ my $val = $z304->{$key} // ""; say sprintf("\t%20s : %s",$key,$val); } my $z305 = $info->z305(); @keys = qw(z305-no-cash z305-no-hold z305-no-loan z305-no-photo); for my $key(@keys){ my $val = $z305->{$key} // ""; say sprintf("\t%20s : %s",$key,$val); } }else{ say STDERR "error: ".join('',@{$info->errors}); exit 1; } Catmandu-AlephX-1.073/examples/user_auth.pl000644 000765 000024 00000000562 14107211622 021547 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my %args = ( library => "rug50", staff_user => "fvdpitte", staff_pass => "demo" ); my $info = $aleph->user_auth(%args); print Dumper($info); Catmandu-AlephX-1.073/examples/export_all.pl000644 000765 000024 00000000603 14107211622 021715 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Util qw(:is); use Catmandu::Store::AlephX; use Catmandu::Exporter::MARC; use open qw(:std :utf8); my $bag = Catmandu::Store::AlephX->new(url => "http://borges1.ugent.be/X"); my $exporter = Catmandu::Exporter::MARC->new(type => "ALEPHSEQ"); $bag->each(sub{ $exporter->add(shift); }); Catmandu-AlephX-1.073/examples/store_add.pl000644 000765 000024 00000001125 14107211622 021510 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Util qw(:is); use Catmandu::Store::AlephX; use Catmandu::Importer::MARC; use Data::Dumper; use open qw(:std :utf8); my $file = shift; if(is_string($file) && -f $file){ open STDIN,"<",$file or die($!); } my $importer = Catmandu::Importer::MARC->new(type => "ALEPHSEQ"); my $bag = Catmandu::Store::AlephX->new(url => "http://borges1.ugent.be/X",username => "t",password => "t")->bag(); $importer->each(sub{ my $r = shift; delete $r->{_id}; $r = $bag->add($r); say "added ".$r->{_id}; }); Catmandu-AlephX-1.073/examples/import_transform.pl000644 000765 000024 00000000674 14107211622 023161 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Importer::AlephX; use Catmandu::AlephX::Metadata::MARC::Aleph; use Data::Dumper; use open qw(:std :utf8); Catmandu::Importer::AlephX->new( url => 'http://borges1.ugent.be/X', query => 'WRD=(art)', base => 'usm01', include_items => 0 )->each(sub{ my $record = shift; say Catmandu::AlephX::Metadata::MARC::Aleph->to_xml($record); }); Catmandu-AlephX-1.073/examples/all.pl000644 000765 000024 00000001110 14107211622 020306 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Store::AlephX; use Data::Dumper; use open qw(:std :utf8); use Time::HiRes qw(gettimeofday tv_interval); sub verbose { state $count = 0; state $start = [gettimeofday]; ++$count; my $speed = $count / tv_interval($start); say STDERR sprintf " (doc %d %f)" ,$count,$speed if ($count % 10 == 0); } my $bag = Catmandu::Store::AlephX->new(url => "http://borges1.ugent.be/X",username=> "test",password => "test")->bag(); $bag->tap(\&verbose)->each(sub{ print Dumper(shift); }); Catmandu-AlephX-1.073/examples/import_all.pl000644 000765 000024 00000000520 14107211622 021704 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Importer::AlephX; use Data::Dumper; use open qw(:std :utf8); Catmandu::Importer::AlephX->new( url => 'http://borges1.ugent.be/X', base => 'usm01', include_items => 1 )->each(sub{ my $record = shift; print Dumper($record); }); Catmandu-AlephX-1.073/examples/update_doc_insert.pl000644 000765 000024 00000001457 14107211622 023247 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Catmandu::Importer::AlephX; use Catmandu::AlephX::Metadata::MARC::Aleph; use Data::Dumper; use File::Slurp; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $importer = Catmandu::Importer::AlephX->new( url => 'http://borges1.ugent.be/X', base => 'usm01' ); my $marc = $importer->first(); print Dumper($marc); my %args = ( 'library' => 'usm01', 'doc_action' => 'UPDATE', 'doc_number' => '000000000', marc => $marc ); my $info = $aleph->update_doc(%args); say ${ $info->content_ref }; if($info->is_success){ say "all ok"; }else{ say "test"; say "num errors:".scalar(@{ $info->errors() }); say STDERR join("\n",@{$info->errors}); } Catmandu-AlephX-1.073/examples/readitem.pl000644 000765 000024 00000000714 14107211622 021341 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my($library,$item_barcode)=("usm50","293"); my $readitem = $aleph->read_item(library=>$library,item_barcode=>$item_barcode); if($readitem->is_success){ print Dumper($readitem->z30); }else{ say STDERR join('',@{$readitem->errors}); } Catmandu-AlephX-1.073/examples/store_get.pl000644 000765 000024 00000000422 14107211622 021536 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Store::AlephX; use Data::Dumper; use open qw(:std :utf8); my $bag = Catmandu::Store::AlephX->new(url => "http://borges1.ugent.be/X")->bag(); print Dumper($bag->get(shift)); Catmandu-AlephX-1.073/examples/update_item2.pl000644 000765 000024 00000002376 14107211622 022137 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Util qw(:is); use Catmandu::AlephX; use open qw(:std :utf8); use Data::Compare; use Test::Deep::NoTest; use Data::Dumper; use File::Slurp; use Catmandu::AlephX::XPath::Helper qw(:all); use Clone qw(clone); use XML::Simple; sub alephx { state $a = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); } my $item_barcode = '32044044980076'; my %args = ( 'library' => 'usm50', 'item_barcode' => $item_barcode, ); my $z30 = alephx->read_item(%args)->z30(); $z30->{'z30-item-status'} = '01'; my $xml = XMLout($z30,,RootName=>"z30",NoAttr => 1); $xml = "\n".$xml; print $xml; $args{xml_full_req} = $xml; my $u = alephx->update_item(%args); if($u->is_success){ say "all ok"; }else{ say STDERR join("\n",@{$u->errors}); my $old_z30 = clone($z30); my $new_z30 = alephx->read_item("library" => "usm50","item_barcode" => $item_barcode)->z30(); delete $old_z30->{$_} for qw(z30-cataloger z30-update-date); delete $new_z30->{$_} for qw(z30-cataloger z30-update-date); say "old z30:"; say Dumper($old_z30); say "new z30"; say Dumper($new_z30); say "equal: ".(eq_deeply($old_z30,$new_z30) ? "yes":"no"); } Catmandu-AlephX-1.073/examples/find.pl000644 000765 000024 00000001006 14107211622 020462 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $find = $aleph->find(request => 'wrd=(art)',base=>'rug01'); if($find->is_success){ say "set_number: ".$find->set_number; say "no_records: ".$find->no_records; say "no_entries: ".$find->no_entries; say "session_id: ".$find->session_id; }else{ say STDERR join('',@{$find->errors}); } Catmandu-AlephX-1.073/examples/itemdata.pl000644 000765 000024 00000000742 14107211622 021340 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use JSON qw(to_json); use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my($base,$doc_number)=("rug01","000000444"); my $item_data = $aleph->item_data(base => $base,doc_number => $doc_number); if($item_data->is_success){ print to_json($item_data->items(),{pretty => 1}); }else{ say STDERR join('',@{$item_data->errors}); } Catmandu-AlephX-1.073/examples/user_info.pl000644 000765 000024 00000002427 14107211622 021543 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my %args = ( library => 'rug50', bor_id => 'demo', verification => 'demo' ); my $info = $aleph->bor_info(%args); if($info->is_success){ my $z304 = $info->z304(); my @keys = qw(z304-address-0 z304-address-1 z304-address-2 z304-address-3 z304-address-4 z304-email-address z304-date-from z304-date-to z304-zip z304-telephone z304-telephone-1 z304-telephone-2 z304-telephone-3 z304-telephone-4); for my $key(@keys){ my $val = $z304->{$key} // ""; say sprintf("\t%20s : %s",$key,$val); } my $z305 = $info->z305(); @keys = qw(z305-no-cash z305-no-hold z305-no-loan z305-no-photo); for my $key(@keys){ my $val = $z305->{$key} // ""; say sprintf("\t%20s : %s",$key,$val); } say sprintf("\t%20s : %s\b",'Loans (active)',scalar(@{$info->item_l})); say sprintf("\t%20s : %s\b",'Loans (history)',''); say sprintf("\t%20s : %s\b",'hold requests',scalar(@{$info->item_h()})); say sprintf("\t%20s : %s\b",'Cash',$info->balance); }else{ say STDERR "error: ".join('',@{$info->errors}); exit 1; } Catmandu-AlephX-1.073/examples/illgetdocshort.pl000644 000765 000024 00000000635 14107211622 022577 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $result = $aleph->ill_get_doc_short(doc_number => "000030527",library=>"rug01"); if($result->is_success){ print Dumper($result->z13); }else{ say STDERR join('',@{$result->errors}); } Catmandu-AlephX-1.073/examples/illgetdoc-sample.pl000644 000765 000024 00000006430 14107211622 022775 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use Catmandu::Sane; use open qw(:std :utf8); use XML::LibXML; use XML::LibXML::XPathContext; use Data::Dumper; local($/) = undef; my $str = ; my $xml = XML::LibXML->load_xml(string => $str); my $xpath = XML::LibXML::XPathContext->new($xml); my($node) = $xpath->find("/ill-get-doc/*[local-name() = 'record']")->get_nodelist(); say "node: $node"; __DATA__ 00000cam^^2200217u^^4500 001317121 20130221093138.0 831220q18211833gw^||||||||||^0^^^|^mul^^ 67071652 (DLC) 67071652 DLC CarP DLC latgrc R126.A1 K82 Galenus, Claudius, ca. 130-ca. 200 Claudii Galeni Opera omnia / Editionem curavit Carolus Gottlob. Kühn. Κλαυδίου Γαληνοῦ ἅπαντα [Klaudiou Galinou Apanta] Lipsiae : prostat in officina libraria Car. Cnoblochii, 1821-1833. 20 v. ; 8°. Medicorum graecorum opera quae exstant ; 1-20 Herkomst ACC.6673: Ex libris J. Roulez: Tekst in het Grieks en het Latijn Medicine Early works to 1800 Medicine, Greek and Roman Early works to 1800 Kühn, Karl Gottlob, 1754-1840 book V1CN2GYVR9KRY87PKQL1S1C123Q2R4S4KJS8SDH5TA23C8B3AD Catmandu-AlephX-1.073/examples/export_doc.pl000644 000765 000024 00000000556 14107211622 021721 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Store::AlephX; use Catmandu::Exporter::MARC; use open qw(:std :utf8); my $bag = Catmandu::Store::AlephX->new(url => "http://borges1.ugent.be/X"); my $exporter = Catmandu::Exporter::MARC->new(type => "ALEPHSEQ"); $exporter->add($bag->get(shift)); $exporter->commit; Catmandu-AlephX-1.073/examples/import_all_xml.pl000644 000765 000024 00000000704 14107211622 022570 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Importer::AlephX; use Data::Dumper; use Catmandu::Exporter::MARC; use open qw(:std :utf8); my $exporter = Catmandu::Exporter::MARC->new(type => "XML"); Catmandu::Importer::AlephX->new( url => 'http://borges1.ugent.be/X', base => 'usm01', include_items => 0 )->each(sub{ my $record = shift; $exporter->add($record); }); $exporter->commit(); Catmandu-AlephX-1.073/examples/import_all_aleph_seq.pl000644 000765 000024 00000000556 14107211622 023736 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Importer::AlephX; use Data::Dumper; use Catmandu::Exporter::MARC; use open qw(:std :utf8); Catmandu::Importer::AlephX->new( url => 'http://borges1.ugent.be/X', base => 'usm01', include_items => 1 )->each(sub{ my $record = shift; print Dumper($record); }); Catmandu-AlephX-1.073/examples/circstatus.pl000644 000765 000024 00000000641 14107211622 021732 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $circstatus = $aleph->circ_status(sys_no => '001484478',library => 'rug01'); if($circstatus->is_success){ print Dumper($circstatus); }else{ say STDERR join('',@{$circstatus->errors}); } Catmandu-AlephX-1.073/examples/store1.pl000644 000765 000024 00000001106 14107211622 020760 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Store::AlephX; use Data::Dumper; use open qw(:std :utf8); my $bag = Catmandu::Store::AlephX->new(url => "http://borges1.ugent.be/X")->bag(); #print Dumper($bag->get('000000444')); # #my $hits = $bag->search(query => "WRD=(art)"); #print Dumper($hits); my $record = $bag->get('000000444'); #$record->{record} = [grep { # $_->[0] ne "001"; #} @{ $record->{record} }]; #say Dumper($record); #$record->{_id} = "010000000"; delete $record->{_id}; print Dumper($bag->add($record)); Catmandu-AlephX-1.073/examples/bor_auth.pl000644 000765 000024 00000001020 14107211622 021341 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my %args = ( library => "rug50", sub_library => "HIL", bor_id => "demo", verification => "demo" ); my $auth = $aleph->bor_auth(%args); if($auth->is_success){ print Dumper($auth->z303); print Dumper($auth->z304); print Dumper($auth->z305); }else{ say STDERR join('',@{$auth->errors}); } Catmandu-AlephX-1.073/examples/create_item.xml000644 000765 000024 00000004336 14107211622 022221 0ustar00njfranckstaff000000 000000 32044103924339 CA20 BOOK 51 19980804 20020708 EXLIBRIS 20080607 1631 CONV 011 L DEPP 7 Heb 2106.385.5 7 selected v.1 00000000 00000000 000000 000000015 00000 00000 00000 1 No 000000000 007 20080408 Catmandu-AlephX-1.073/examples/publish_avail.pl000644 000765 000024 00000001513 14107211622 022367 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use JSON qw(to_json); use open qw(:std :utf8); use Catmandu::Exporter::MARC; use Data::Dumper; my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my $exporter = Catmandu::Exporter::MARC->new(type => 'ALEPHSEQ'); my $publish = $aleph->publish_avail(doc_num => '000196220,001313162,001484478,001484538,001317121,000000000',library=>'rug01'); #say ${ $publish->content_ref }; if($publish->is_success){ for my $record(@{ $publish->records }){ if($record->metadata->data->{record}){ $exporter->add($record->metadata->data); $exporter->commit; } else{ say "nothing for ".$record->metadata->data->{_id}; } say "\n---"; } }else{ say STDERR join('',@{$publish->errors}); } Catmandu-AlephX-1.073/examples/create_item.pl000644 000765 000024 00000001360 14107211622 022026 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::Util qw(:is); use Catmandu::AlephX; use open qw(:std :utf8); use Data::Compare; use Test::Deep::NoTest; use Data::Dumper; use File::Slurp; use Catmandu::AlephX::XPath::Helper qw(:all); use Clone qw(clone); sub alephx { state $a = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); } my $file = shift; is_string($file) or die("usage: $0 \n"); my $xml = read_file($file); my %args = ( 'adm_library' => 'rug50', 'bib_library' => 'rug01', 'bib_doc_number' => '000000444', 'xml_full_req' => $xml ); my $u = alephx->create_item(%args); if($u->is_success){ say "all ok"; } else{ say STDERR join("\n",@{$u->errors}); } Catmandu-AlephX-1.073/examples/update_doc2.pl000644 000765 000024 00000002462 14107211622 021742 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use open qw(:std :utf8); use Data::Compare; use Test::Deep::NoTest; use Data::Dumper; my $doc_number = '000000444'; sub alephx { state $a = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); } sub get_doc { alephx()->find_doc( doc_num => $doc_number, base => "usm01" ); } my $find_doc = get_doc(); my $marc = $find_doc->record->metadata->data; #warning: this removes all CAT fields in aleph! $marc->{record} = [grep { !( $_->[0] eq "CAT" && $_->[4] eq "WWW-X" ) } @{ $marc->{record} }]; my %args = ( 'library' => 'usm01', 'doc_action' => 'UPDATE', 'doc_number' => $doc_number, marc => $marc ); my $u = alephx->update_doc(%args); if($u->is_success){ say "all ok"; }else{ say STDERR join("\n",@{$u->errors}); } my $new_marc = get_doc()->record->metadata->data; #every updates creates 'CAT' fields, so first remove these, and also 005 (last modified) $marc->{record} = [grep { $_->[0] ne "CAT" && $_->[0] ne "005" } @{ $marc->{record} }]; $new_marc->{record} = [grep { $_->[0] ne "CAT" && $_->[0] ne "005" } @{ $new_marc->{record} }]; say "old marc:"; say Dumper($marc); say "new marc:"; say Dumper($new_marc); my $eq = eq_deeply($marc,$new_marc); say "equal: ".($eq ? "yes":"no"); Catmandu-AlephX-1.073/examples/itemdatamulti.pl000644 000765 000024 00000000770 14107211622 022414 0ustar00njfranckstaff000000 000000 #!/usr/bin/env perl use FindBin; use lib "$FindBin::Bin/../lib"; use Catmandu::Sane; use Catmandu::AlephX; use Data::Dumper; use open qw(:std :utf8); my $aleph = Catmandu::AlephX->new(url => "http://borges1.ugent.be/X"); my($base,$doc_number)=("rug01","001484477"); my $item_data = $aleph->item_data_multi(base => $base,doc_number => $doc_number); if($item_data->is_success){ for my $item(@{ $item_data->items() }){ print Dumper($item); }; }else{ say STDERR join('',@{$item_data->errors}); } Catmandu-AlephX-1.073/t/Catmandu/000755 000765 000024 00000000000 14107211622 017371 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/t/author-pod-syntax.t000644 000765 000024 00000000454 14107211622 021433 0ustar00njfranckstaff000000 000000 #!perl BEGIN { unless ($ENV{AUTHOR_TESTING}) { print qq{1..0 # SKIP these tests are for testing by the author\n}; exit } } # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use strict; use warnings; use Test::More; use Test::Pod 1.41; all_pod_files_ok(); Catmandu-AlephX-1.073/t/Catmandu/Importer/000755 000765 000024 00000000000 14107211622 021172 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/t/Catmandu/AlephX.t000644 000765 000024 00000000221 14107211622 020732 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/000755 000765 000024 00000000000 14107211622 020552 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/t/Catmandu/Store/000755 000765 000024 00000000000 14107211622 020465 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/t/Catmandu/Store/AlephX.t000644 000765 000024 00000000230 14107211622 022026 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::Store::AlephX'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/UserAgent/000755 000765 000024 00000000000 14107211622 022447 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/t/Catmandu/AlephX/Response.t000644 000765 000024 00000000233 14107211622 022533 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Response'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Record/000755 000765 000024 00000000000 14107211622 021770 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/t/Catmandu/AlephX/XPath/000755 000765 000024 00000000000 14107211622 021576 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/000755 000765 000024 00000000000 14107211622 021130 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/t/Catmandu/AlephX/Record.t000644 000765 000024 00000000231 14107211622 022151 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Record'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Metadata.t000644 000765 000024 00000000233 14107211622 022455 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Metadata'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/UserAgent.t000644 000765 000024 00000000234 14107211622 022633 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::UserAgent'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Metadata/000755 000765 000024 00000000000 14107211622 022272 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/t/Catmandu/AlephX/Metadata/MARC/000755 000765 000024 00000000000 14107211622 023014 5ustar00njfranckstaff000000 000000 Catmandu-AlephX-1.073/t/Catmandu/AlephX/Metadata/MARC.t000644 000765 000024 00000000241 14107211622 023176 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Metadata::MARC'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Metadata/MARC/Aleph.t000644 000765 000024 00000000250 14107211622 024227 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Metadata::MARC::Aleph'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/ItemDataMulti.t000644 000765 000024 00000000244 14107211622 024020 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::ItemDataMulti'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/IllGetDocShort.t000644 000765 000024 00000000245 14107211622 024144 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::IllGetDocShort'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/PublishAvail.t000644 000765 000024 00000000243 14107211622 023677 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::PublishAvail'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/CircStatus.t000644 000765 000024 00000000241 14107211622 023376 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::CircStatus'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/Find.t000644 000765 000024 00000000233 14107211622 022173 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::Find'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/HoldReq.t000644 000765 000024 00000000236 14107211622 022654 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::HoldReq'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/ItemData.t000644 000765 000024 00000000237 14107211622 023007 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::ItemData'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/UpdateDoc.t000644 000765 000024 00000000240 14107211622 023161 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::UpdateDoc'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/IllGetDoc.t000644 000765 000024 00000000240 14107211622 023117 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::IllGetDoc'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/Renew.t000644 000765 000024 00000000234 14107211622 022374 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::Renew'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/UpdateItem.t000644 000765 000024 00000000241 14107211622 023353 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::UpdateItem'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/BorAuth.t000644 000765 000024 00000000236 14107211622 022662 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::BorAuth'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/GetHolding.t000644 000765 000024 00000000241 14107211622 023336 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::GetHolding'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/ReadItem.t000644 000765 000024 00000000237 14107211622 023011 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::ReadItem'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/UserAuth.t000644 000765 000024 00000000237 14107211622 023057 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::UserAuth'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/CircStatM.t000644 000765 000024 00000000240 14107211622 023142 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::CircStatM'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/IllBorInfo.t000644 000765 000024 00000000241 14107211622 023311 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::IllBorInfo'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/Present.t000644 000765 000024 00000000236 14107211622 022736 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::Present'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/FindDoc.t000644 000765 000024 00000000236 14107211622 022624 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::FindDoc'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/HoldReqCancel.t000644 000765 000024 00000000244 14107211622 023761 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::HoldReqCancel'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/CreateItem.t000644 000765 000024 00000000241 14107211622 023334 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::CreateItem'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/BorInfo.t000644 000765 000024 00000000236 14107211622 022654 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::BorInfo'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Op/IllLoanInfo.t000644 000765 000024 00000000242 14107211622 023461 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Op::IllLoanInfo'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/XPath/Helper.t000644 000765 000024 00000000240 14107211622 023176 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::XPath::Helper'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/Record/Present.t000644 000765 000024 00000000242 14107211622 023573 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::Record::Present'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/AlephX/UserAgent/LWP.t000644 000765 000024 00000000241 14107211622 023273 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::AlephX::UserAgent::LWP'; use_ok $pkg; } require_ok $pkg; done_testing 2; Catmandu-AlephX-1.073/t/Catmandu/Importer/AlephX.t000644 000765 000024 00000000233 14107211622 022536 0ustar00njfranckstaff000000 000000 use strict; use warnings; use Test::More; my $pkg; BEGIN { $pkg = 'Catmandu::Importer::AlephX'; use_ok $pkg; } require_ok $pkg; done_testing 2;