Skip to content
Snippets Groups Projects
Commit c5f68350 authored by Andreas Romeyke's avatar Andreas Romeyke
Browse files

- simplified "--with-XXX" if transferMetadata match needed

- fixed output encoding in CSV mode
- added various "--with-XXX" variants
parent f3077728
Branches
Tags
No related merge requests found
......@@ -79,22 +79,31 @@ sub opt_spec {
#['without-format=s' => 'without pronom format id'],
] } ],
[],
[ 'with-LDP-collection' => 'also returns AIP LDP collection' ],
[ 'with-LDP-funder' => 'also returns AIP LDP funder' ],
[ 'with-LDP-lender' => 'also returns AIP LDP lender' ],
[ 'with-LDP-project' => 'also returns AIP LDP project' ],
[ 'with-archival-value-description' => 'also returns AIP archival value description' ],
[ 'with-creationdate' => 'also returns AIP creation date' ],
[ 'with-export2archive-date' => 'also returns AIP export to archive date' ],
[ 'with-external-description' => 'also returns AIP external-description'],
[ 'with-external-identifier' => 'also returns AIP external-identifier'],
[ 'with-filecount' => 'also returns AIPs file count' ],
[ 'with-ldp-collection' => 'also returns AIP ldp-collection'],
[ 'with-ldp-funder' => 'also returns AIP ldp-funder'],
[ 'with-ldp-lender' => 'also returns AIP ldp-lender'],
[ 'with-ldp-project' => 'also returns AIP ldp-project'],
[ 'with-location' => 'also returns AIP location' ],
[ 'with-lzaid' => 'also returns lzaid' ],
[ 'with-migrated-AIP' => 'also returns AIP migrated state' ],
[ 'with-origin-AIS' => 'also returns AIP origin AIS if migrated' ],
[ 'with-path' => 'also returns AIP path' ],
[ 'with-previous-AIP' => 'also returns AIP predecessor if updated' ],
[ 'with-score' => 'also returns score of Elastic Search match (higher => better)' ],
[ 'with-size' => 'also returns AIP size' ],
[ 'with-slubarchiv-archivalvaluedescription|with-archival-value-description' => 'also returns AIP slubarchiv-archivalvaluedescription'],
[ 'with-slubarchiv-exporttoarchivedate|with-export2archive-date' => 'also returns AIP slubarchiv-exporttoarchivedate'],
[ 'with-slubarchiv-externalid' => 'also returns AIP slubarchiv-externalid'],
[ 'with-slubarchiv-externalisilid' => 'also returns AIP slubarchiv-externalisilid'],
[ 'with-slubarchiv-externalworkflow' => 'also returns AIP slubarchiv-externalworkflow'],
[ 'with-slubarchiv-hasconservationreason' => 'also returns AIP slubarchiv-hasconservationreason'],
[ 'with-slubarchiv-lzaid' => 'also returns AIP slubarchiv-lzaid'],
[ 'with-slubarchiv-lzaid|with-lzaid' => 'also returns lzaid' ],
[ 'with-slubarchiv-migrated-aip|with-migrated-aip' => 'also returns AIP slubarchiv-migrated-aip'],
[ 'with-slubarchiv-origin-ais|with-origin-ais' => 'also returns AIP slubarchiv-origin-ais'],
[ 'with-slubarchiv-previous-aip|with-previous-aip' => 'also returns AIP slubarchiv-previous-aip'],
[ 'with-slubarchiv-rightsversion' => 'also returns AIP slubarchiv-rightsversion'],
[ 'with-slubarchiv-sipversion' => 'also returns AIP slubarchiv-sipversion'],
[ 'with-status' => 'also returns AIP state in AIS' ],
[ 'with-title' => 'also returns AIP title' ],
[],
......@@ -114,13 +123,41 @@ sub line_result_mapper {
my ($partial_result, $opt) = @_;
my %line;
$line{aipid}= $partial_result->{_source}->{uuid};
if (defined $opt->{with_lzaid}) { $line{lzaid} = $partial_result->{_source}->{transferMetadata}->[0]->{'SLUBArchiv-lzaId'} };
if (defined $opt->{with_path}) { $line{path}= $partial_result->{_source}->{filePath} };
if (defined $opt->{with_size}) { $line{size}= $partial_result->{_source}->{size} };
if (defined $opt->{with_filecount}) { $line{filecount} = $partial_result->{_source}->{file_count} };
if (defined $opt->{with_export2archive_date}) { $line{export2archive_date}=$partial_result->{_source}->{transferMetadata}->[0]->{'SLUBArchiv-exportToArchiveDate'} };
p($partial_result->{_source});
p($opt);
my @tmd = qw(
External-Description
External-Identifier
LDP-collection
LDP-funder
LDP-lender
LDP-project
SLUBArchiv-archivalValueDescription
SLUBArchiv-exportToArchiveDate
SLUBArchiv-externalId
SLUBArchiv-externalIsilId
SLUBArchiv-externalWorkflow
SLUBArchiv-hasConservationReason
SLUBArchiv-lzaId
SLUBArchiv-migrated-AIP
SLUBArchiv-origin-AIS
SLUBArchiv-previous-AIP
SLUBArchiv-rightsVersion
SLUBArchiv-sipVersion
Title
);
foreach my $t (@tmd) {
my $linekey = lc($t); $linekey=~s/-/_/g;
my $optionkey = lc("with_".$t); $optionkey=~s/-/_/g;
if (defined $opt->{$optionkey}) {
$line{$linekey} = $partial_result->{_source}->{transferMetadata}->[0]->{ $t };
}
}
if (defined $opt->{with_creation_date}) { $line{creation_date} = $partial_result->{_source}->{created} };
if (defined $opt->{with_filecount}) { $line{filecount} = $partial_result->{_source}->{file_count} };
if (defined $opt->{with_path}) { $line{path}= $partial_result->{_source}->{filePath} };
if (defined $opt->{with_score}) { $line{score} = $partial_result->{_score}}
if (defined $opt->{with_size}) { $line{size}= $partial_result->{_source}->{size} };
\%line;
}
......@@ -157,6 +194,7 @@ sub execute {
}
if ($opt->{output_format} eq 'output_as_csv') {
binmode(STDOUT, ':encoding(UTF-8)');
say join(",", @headers);
say join("\n", map {
my $line = $_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment