Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
use Modern::Perl; |
4 |
use Getopt::Long; |
5 |
use Pod::Usage; |
6 |
use C4::Context; |
7 |
use Koha::ArticleRequests; |
8 |
|
9 |
my $params = {}; |
10 |
GetOptions( |
11 |
'folder:s' => \$params->{folder}, |
12 |
'uploadcategory:s' => \$params->{uploadcategory}, |
13 |
'webservice:s' => \$params->{webservice}, |
14 |
'commit' => \$params->{commit}, |
15 |
'help' => \$params->{help}, |
16 |
'manual' => \$params->{manual}, |
17 |
); |
18 |
|
19 |
if( $params->{help} ) { |
20 |
pod2usage(); |
21 |
} elsif( $params->{manual} ) { |
22 |
pod2usage({ -verbose => 2 }); |
23 |
} elsif( !C4::Context->preference('ArticleRequests') || |
24 |
C4::Context->preference('ArticleRequestsSupportedFormats') !~ /SCAN/ ) { |
25 |
print "First enable ArticleRequests and add SCAN as supported format.\n"; |
26 |
} elsif( !$params->{folder} && !$params->{uploadcategory} || |
27 |
$params->{folder} && $params->{uploadcategory} ) { |
28 |
print "Specify a folder or an uploadcategory but not both.\n"; |
29 |
pod2usage(); |
30 |
} elsif( !$params->{commit} ) { |
31 |
print "You need to specify the commit parameter.\n"; |
32 |
pod2usage(); |
33 |
} else { |
34 |
Koha::ArticleRequests->complete_scans({ %$params{'folder', 'uploadcategory', 'webservice'} }); # perl 5.20 construct |
35 |
} |
36 |
|
37 |
=head1 NAME |
38 |
|
39 |
complete_article_requests.pl |
40 |
|
41 |
=head1 COPYRIGHT |
42 |
|
43 |
Copyright 2018 Rijksmuseum |
44 |
|
45 |
=head1 LICENSE |
46 |
|
47 |
This file is part of Koha. |
48 |
|
49 |
Koha is free software; you can redistribute it and/or modify it under the |
50 |
terms of the GNU General Public License as published by the Free Software |
51 |
Foundation; either version 3 of the License, or (at your option) any later |
52 |
version. |
53 |
|
54 |
Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
55 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
56 |
A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
57 |
|
58 |
You should have received a copy of the GNU General Public License along |
59 |
with Koha; if not, write to the Free Software Foundation, Inc., |
60 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
61 |
|
62 |
|
63 |
=head1 SYNOPSIS |
64 |
|
65 |
complete_article_requests.pl -help |
66 |
complete_article_requests.pl -manual |
67 |
complete_article_requests.pl -folder /my/scans -webservice My::Hdlr -commit |
68 |
complete_article_requests.pl -uploadcategory SCANS -commit |
69 |
|
70 |
=head1 DESCRIPTION |
71 |
|
72 |
This script serves to complete scanned article requests by offering a file path |
73 |
or an uploadcategory. If you specify a file path, you need to specify a handler |
74 |
class that returns a URL for each file. |
75 |
|
76 |
How does it work? The script is based on the following two assumptions: |
77 |
[1] If the file name contains the article request id, the script links it |
78 |
to that request. This is mandatory for multiple files per request. |
79 |
[2] The order of the remaining scanned files should match the list of |
80 |
requests in processing status sorted by timestamp. (The timestamp |
81 |
should tell here when the request status was set.) |
82 |
|
83 |
In the process of linking files to requests, the urls field is filled and the |
84 |
request is marked completed (triggering a mail to the requestor). |
85 |
|
86 |
=head1 OPTIONS |
87 |
|
88 |
=head2 help |
89 |
|
90 |
Print usage statement |
91 |
|
92 |
=head2 manual |
93 |
|
94 |
Print complete POD documentation |
95 |
|
96 |
=head2 folder |
97 |
|
98 |
File path to scanned materials for article requests |
99 |
|
100 |
=head2 webservice |
101 |
|
102 |
Name of the class you are using to generate a URL for each scanned file. This |
103 |
parameter is mandatory in combination with the folder option. In its simplest |
104 |
form the class can return a URL to access the scanned file on the local server. |
105 |
But other implementations may upload the file to some third party webservice |
106 |
and return the corresponding URL. |
107 |
|
108 |
=head2 uploadcategory |
109 |
|
110 |
Code of the Koha upload category that you are using for scanned article |
111 |
request materials. |
112 |
|
113 |
It may be combined with the webservice parameter in order to change the |
114 |
URL. But since the file can be made available via the local server, its use |
115 |
here may be limited. |
116 |
|
117 |
=head1 AUTHOR |
118 |
|
119 |
Marcel de Rooy, Rijksmuseum Amsterdam, The Netherlands |
120 |
|
121 |
=cut |