From e92ea9efce038b541f8b19df5542f6bdab23f47c Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Mon, 14 Apr 2025 19:05:53 +0200
Subject: [PATCH] - fixed bug, if multiple lzaids occurred

---
 lib/SLUB/LZA/TA/Command/sample_testing.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/SLUB/LZA/TA/Command/sample_testing.pm b/lib/SLUB/LZA/TA/Command/sample_testing.pm
index f62ec18..fe1ea1d 100644
--- a/lib/SLUB/LZA/TA/Command/sample_testing.pm
+++ b/lib/SLUB/LZA/TA/Command/sample_testing.pm
@@ -183,7 +183,8 @@ sub _check_aip ($sample, $opt) {
 
     $line->{aipid}=$sample->{uuid};
     $line->{filePath}=$sample->{filePath};
-    $line->{lzaid}=$sample->{transferMetadata}->[0]->{'bim:bag-info_dict'}->{'bim:SLUBArchiv-lzaId'};
+    my $dict = $sample->{transferMetadata}->[0]->{'bim:bag-info_dict'};
+    $line->{lzaid}= (ref $dict eq 'ARRAY') ? $dict->[0]->{'bim:SLUBArchiv-lzaId'} : $dict->{'bim:SLUBArchiv-lzaId'};
     $line->{isvalid}=$is_valid ;
     $line->{checkdate}=localtime;
     $line->{creationdate}=localtime $sample->{created};
-- 
GitLab