From 584fd8c9ac1425552c9b9fe5b79a7c40f8ef427f Mon Sep 17 00:00:00 2001
From: Jens Steidl <Jens.Steidl@slub-dresden.de>
Date: Tue, 16 Mar 2021 12:19:24 +0100
Subject: [PATCH] - refactor: get marc21 and mods with new funtionality

---
 bin/slubsipbuilderbagit.pl | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/bin/slubsipbuilderbagit.pl b/bin/slubsipbuilderbagit.pl
index 2e57564..3b94d3c 100644
--- a/bin/slubsipbuilderbagit.pl
+++ b/bin/slubsipbuilderbagit.pl
@@ -552,6 +552,7 @@ PATCH
 
         my @addMetaFile = @{ $aRefAddMetaFile };
         my @addBagInfo = @{ $refAddBagInfo };
+        my ($mods, $marc21);
 
         # create bag dir
         SLUB::LZA::SIPBuilderBagIt::createDir($bagPath);
@@ -560,6 +561,11 @@ PATCH
         # copy payload files to data
         print_scalar_data("", "INFO: copying original data...", "", "white");
         dircopy($ieDirectory, $dataPath) || die ("Error coping $ieDirectory to $dataPath");
+        # get descriptive metadata from catalog
+        if ($ppn) {
+            $marc21 = get_marc21_from_catalogue($ppn);
+            $mods = get_mods_from_marc21($marc21);
+        }
         # create meta dir
         SLUB::LZA::SIPBuilderBagIt::createDir($metaPath);
         # copy not payload files to meta
@@ -582,12 +588,18 @@ PATCH
 
         my @addMetaFile = @{ $aRefAddMetaFile };
         my @addBagInfo = @{ $refAddBagInfo };
+        my ($mods, $marc21);
 
         # create bag dir
         SLUB::LZA::SIPBuilderBagIt::createDir($bagPath);
         # move payloads to data dir (which is automatically renamed from IE Directory)
         print_scalar_data("", "INFO: moving original data...", "", "white");
         dirmove($ieDirectory, $dataPath) || die ("Error moving $ieDirectory to $dataPath");
+        # get descriptive metadata from catalog
+        if ($ppn) {
+            $marc21 = get_marc21_from_catalogue($ppn);
+            $mods = get_mods_from_marc21($marc21);
+        }
         # create meta dir
         SLUB::LZA::SIPBuilderBagIt::createDir($metaPath);
         # copy not payload files to meta
@@ -610,12 +622,18 @@ PATCH
 
         my @addMetaFile = @{ $aRefAddMetaFile };
         my @addBagInfo = @{ $refAddBagInfo };
+        my ($mods, $marc21);
 
         # create bag dir
         SLUB::LZA::SIPBuilderBagIt::createDir($bagPath);
         # move payloads to data dir (which is automatically renamed from IE Directory)
         print_scalar_data("", "INFO: moving original data...", "", "white");
         dirmove($ieDirectory, $dataPath) || die ("Error moving $ieDirectory to $dataPath");
+        # get descriptive metadata from catalog
+        if ($ppn) {
+            $marc21 = get_marc21_from_catalogue($ppn);
+            $mods = get_mods_from_marc21($marc21);
+        }
         # create meta dir
         SLUB::LZA::SIPBuilderBagIt::createDir($metaPath);
         # copy not payload files to meta
-- 
GitLab