Skip to content
Snippets Groups Projects
Commit a6446f1f authored by bolkun's avatar bolkun
Browse files
parents 16aeacac 379b4db4
No related branches found
No related tags found
No related merge requests found
...@@ -84,21 +84,6 @@ package SLUB::LZA::SIPBuilderBagIt; ...@@ -84,21 +84,6 @@ package SLUB::LZA::SIPBuilderBagIt;
my $recordschema = 'marcxmlvbos'; my $recordschema = 'marcxmlvbos';
our $with_debug = 0; our $with_debug = 0;
sub prepare_mods_section_with_noppn($){
if(! defined $_[0]) { croak "noppn is not defined!"; }
if($_[0] eq "") { croak "noppn is empty string!"; }
my $noppn = shift;
my $mods =<<"MODS";
<mods version="3.6"
xmlns="http://www.loc.gov/mods/v3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-6.xsd">
<identifier>$noppn</identifier>
</mods>
MODS
return $mods;
}
sub prepare_mods_section_with_ppn($){ sub prepare_mods_section_with_ppn($){
if(! defined $_[0]){ croak "ppn not defined!"; } if(! defined $_[0]){ croak "ppn not defined!"; }
...@@ -411,8 +396,10 @@ PATCH ...@@ -411,8 +396,10 @@ PATCH
} }
# mods.xml # mods.xml
my $mods = (defined $ppn)? prepare_mods_section_with_ppn($ppn) : prepare_mods_section_with_noppn($noppn); # prepare mods-sec if (defined $ppn) {
my $mods = prepare_mods_section_with_ppn($ppn); # get mods from catalog
write_file("$metaPath/mods.xml", $mods); write_file("$metaPath/mods.xml", $mods);
}
# rights.xml # rights.xml
if(basename($rightsFilePath) ne "rights.xml"){ if(basename($rightsFilePath) ne "rights.xml"){
...@@ -683,6 +670,8 @@ if (defined $outputPath && $outputPath eq "" && ($save eq "copy" || $save eq "mo ...@@ -683,6 +670,8 @@ if (defined $outputPath && $outputPath eq "" && ($save eq "copy" || $save eq "mo
# ppn, noppn # ppn, noppn
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) || (!defined $ppn && $noppn eq "") || (!defined $noppn && $ppn eq "")) { confess("you need to specify a PPN with --ppn or use --noppn"); } if ((!defined $ppn && !defined $noppn) || (!defined $ppn && $noppn eq "") || (!defined $noppn && $ppn eq "")) { confess("you need to specify a PPN with --ppn or use --noppn"); }
if ($ppn) { push @addBagInfo, {'External-Identifier' => "PPN:$ppn"}; }
if ($noppn) { push @addBagInfo, {'External-Identifier' => "$noppn"}; }
#########################################################> bag-info.txt <############################################################################### #########################################################> bag-info.txt <###############################################################################
# sipversion # sipversion
......
...@@ -24,7 +24,7 @@ use strict; ...@@ -24,7 +24,7 @@ use strict;
use warnings; use warnings;
use diagnostics; use diagnostics;
use Test::More tests => 123; use Test::More tests => 120;
use Test::Output; use Test::Output;
use Test::Exception; use Test::Exception;
use Test::File; use Test::File;
...@@ -716,10 +716,6 @@ SKIP: { ...@@ -716,10 +716,6 @@ SKIP: {
throws_ok{ SLUB::LZA::SIPBuilderBagIt::prepare_mods_section_with_ppn(""); } qr/invalid parameters/, "prepare_mods_section_with_ppn(), invalid parameters"; throws_ok{ SLUB::LZA::SIPBuilderBagIt::prepare_mods_section_with_ppn(""); } qr/invalid parameters/, "prepare_mods_section_with_ppn(), invalid parameters";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::prepare_mods_section_with_ppn(undef); } qr/ppn not defined/, "prepare_mods_section_with_ppn(\$ppn), ppn undef"; throws_ok{ SLUB::LZA::SIPBuilderBagIt::prepare_mods_section_with_ppn(undef); } qr/ppn not defined/, "prepare_mods_section_with_ppn(\$ppn), ppn undef";
# #
is(SLUB::LZA::SIPBuilderBagIt::prepare_mods_section_with_noppn("string"), $noppn_mods_res, "prepare_mods_section_with_noppn()");
throws_ok{ SLUB::LZA::SIPBuilderBagIt::prepare_mods_section_with_noppn(""); } qr/noppn is empty string!/, "prepare_mods_section_with_noppn(), noppn is empty string!";
throws_ok{ SLUB::LZA::SIPBuilderBagIt::prepare_mods_section_with_noppn(undef); } qr/noppn is not defined/, "prepare_mods_section_with_noppn(\$noppn), noppn undef";
# *************************************************************************** test new functions ****************************************************************************************************************** # *************************************************************************** test new functions ******************************************************************************************************************
is(SLUB::LZA::SIPBuilderBagIt::generateBagName($exportToArchiveDate, $ppn, $noppn), "PPN-457035137_2020-08-05_10-26-11", "generateBagName()"); is(SLUB::LZA::SIPBuilderBagIt::generateBagName($exportToArchiveDate, $ppn, $noppn), "PPN-457035137_2020-08-05_10-26-11", "generateBagName()");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment