Skip to content
Snippets Groups Projects
Commit aa4f9c73 authored by Jens Steidl's avatar Jens Steidl :baby_chick:
Browse files

- updated SWB SRU call

- removed --url argument (we only support SWB)
- updated help
parent 26b5e78b
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,6 @@ my $directory; ...@@ -46,7 +46,6 @@ my $directory;
my $ppn; my $ppn;
my $noppn; my $noppn;
my $output; my $output;
my $url;
my $as_zip; my $as_zip;
my $external_id; my $external_id;
my $external_workflow; my $external_workflow;
...@@ -64,7 +63,6 @@ GetOptions( ...@@ -64,7 +63,6 @@ GetOptions(
"noppn=s" => \$noppn, # semi-optional (choice 2 of 2) "noppn=s" => \$noppn, # semi-optional (choice 2 of 2)
"SIP_output_path=s" => \$output, # required "SIP_output_path=s" => \$output, # required
"as_zip" => \$as_zip, # optional, default: do not zip "as_zip" => \$as_zip, # optional, default: do not zip
"url=s" => \$url, # optional, default: SWB Online-Katalog
"external_id=s" => \$external_id, # required "external_id=s" => \$external_id, # required
"external_workflow=s" => \$external_workflow, # required "external_workflow=s" => \$external_workflow, # required
"external_ISIL=s" => \$external_isil, # optional, default: no ISIL "external_ISIL=s" => \$external_isil, # optional, default: no ISIL
...@@ -81,13 +79,14 @@ if (!defined $directory) { confess("you need to specify an IE ...@@ -81,13 +79,14 @@ if (!defined $directory) { confess("you need to specify an IE
if ((defined $ppn) && (defined $noppn)) { confess("you can only specify either -ppn or -noppn"); } if ((defined $ppn) && (defined $noppn)) { confess("you can only specify either -ppn or -noppn"); }
if ((!defined $ppn) && (!defined $noppn)) { confess("you need to specify a PPN with -ppn or use --noppn"); } if ((!defined $ppn) && (!defined $noppn)) { confess("you need to specify a PPN with -ppn or use --noppn"); }
if (!defined $output) { confess("you need to specify an output path, where the SIP will be stored"); } if (!defined $output) { confess("you need to specify an output path, where the SIP will be stored"); }
if (!defined $url) { $url = "http://swb.bsz-bw.de/sru/DB=2.1/username=/password=/";}
if (!defined $external_conservation_flag) { $external_conservation_flag="false"; } else { $external_conservation_flag="true"; } if (!defined $external_conservation_flag) { $external_conservation_flag="false"; } else { $external_conservation_flag="true"; }
if (! -d $directory) { confess("you need to specify an IE directory, which needs to be archived, $!"); } if (! -d $directory) { confess("you need to specify an IE directory, which needs to be archived, $!"); }
if ($directory !~ m#^/#) { $directory = abs_path($directory); } if ($directory !~ m#^/#) { $directory = abs_path($directory); }
if ($external_id !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external ID (^[a-z0-9]+\$)"); } if ($external_id !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external ID (^[a-z0-9]+\$)"); }
if ($external_workflow !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external workflow (^[a-z0-9]+\$)"); } if ($external_workflow !~ m#^[a-z0-9]+$#) { confess("you need to specify a valid external workflow (^[a-z0-9]+\$)"); }
if (!$external_value_descr) { confess("you need to specify an external value description (reason for archiving)"); } if (!$external_value_descr) { confess("you need to specify an external value description (reason for archiving)"); }
my ($url, $searchkey, $recordschema);
if (defined $ppn) { $url="https://sru.bsz-bw.de/swb"; $searchkey="pica.swn"; $recordschema="marcxmlvbos"; };
#=============================================================================== #===============================================================================
...@@ -168,9 +167,11 @@ PATCH2 ...@@ -168,9 +167,11 @@ PATCH2
return $result; return $result;
} }
sub get_mods_from ($$) { # $mods = ($url, $ppn) sub get_mods_from ($$$$) { # $mods = ($url, $ppn, $searchkey, $recordschema)
my $url = shift; my $url = shift;
my $ppn = shift; # example: "457035137" for "Der Fichtelberg" my $ppn = shift; # example: "457035137" for "Der Fichtelberg"
my $key = shift;
my $schema = shift;
# check xsl directory # check xsl directory
my $xsl_dir = dirname(__FILE__) . '/../xsl/'; my $xsl_dir = dirname(__FILE__) . '/../xsl/';
...@@ -220,11 +221,13 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn) ...@@ -220,11 +221,13 @@ sub get_mods_from ($$) { # $mods = ($url, $ppn)
} }
my $srubase=$url; # host my $srubase=$url; # host
my $srusearchkey="pica.ppn"; my $srusearchkey=$key; # SRU search key
my $sruvalue=$ppn; my $sruvalue=$ppn;
my $srumaxrecords=1; my $srumaxrecords=1;
my $sruschema="marc21"; my $srustartrecord=1;
my $sru = "${srubase}?query=${srusearchkey}+%3D+%22${sruvalue}%22&startRecord=1&maximumRecords=${srumaxrecords}&recordSchema=${sruschema}&recordPacking=xml&version=1.1&stylesheet=http%3A%2F%2Fswb2.bsz-bw.de%2Fsru%2FDB%3D2.1%2F%3Fxsl%3DsearchRetrieveResponse"; my $sruschema=$schema;
my $sru = "${srubase}?version=1.1&query=${srusearchkey}%3D${sruvalue}&operation=searchRetrieve&maximumRecords=${srumaxrecords}&startRecord=${srustartrecord}&recordSchema=${sruschema}";
if ($with_debug) { say "catalog-URL='$sru'"; };
my $record = $ua->get($sru); # ask SWB for given PPN my $record = $ua->get($sru); # ask SWB for given PPN
if ($record->is_success) { if ($record->is_success) {
# parse ZiNG repsonse, extract MARC-data # parse ZiNG repsonse, extract MARC-data
...@@ -286,7 +289,7 @@ sub main { ...@@ -286,7 +289,7 @@ sub main {
# prepare dmd-sec # prepare dmd-sec
my $mods; my $mods;
if (defined $ppn) { if (defined $ppn) {
$mods = get_mods_from($url, $ppn); $mods = get_mods_from($url, $ppn, $searchkey, $recordschema);
if ($with_debug) { if ($with_debug) {
write_file("DEBUG_${ppn}_mods.xml", $mods); write_file("DEBUG_${ppn}_mods.xml", $mods);
} }
...@@ -476,10 +479,9 @@ slubsipbuilder.pl [options] ...@@ -476,10 +479,9 @@ slubsipbuilder.pl [options]
-man full documentation -man full documentation
-IE_directory=<IE dir> existing IE directory (absolute path!) -IE_directory=<IE dir> existing IE directory (absolute path!)
-ppn=<ppn>|-noppn=<noppn> PPN (swb catalogue) or any identifier (uses minimalistic MODS) -ppn=<ppn>|-noppn=<noppn> SWB-PPN or any identifier (uses minimalistic MODS)
-SIP_output_path=<target dir> where to put the SIP dir (absolute path!) -SIP_output_path=<target dir> where to put the SIP dir (absolute path!)
-as_zip optional, if set a ZIP will be created -as_zip optional, if set a ZIP will be created
-url=<SRU url> optional, URL of the SRU for PICA catalogues
-external_id=<id> mandatory, should be uniqe ID -external_id=<id> mandatory, should be uniqe ID
-external_workflow=<workflow> mandatory, should be uniqe workflow name -external_workflow=<workflow> mandatory, should be uniqe workflow name
-external_ISIL=<isil> optional, ISIL number of library -external_ISIL=<isil> optional, ISIL number of library
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment