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

- refactoring, unpacked @_ to use modern perl

parent a58bfec0
Branches
No related tags found
No related merge requests found
...@@ -271,9 +271,8 @@ PAINLESS ...@@ -271,9 +271,8 @@ PAINLESS
return $aips_response; return $aips_response;
} }
sub get_ldp_projects { ## no critic (CognitiveComplexity::ProhibitExcessCognitiveComplexity) sub get_ldp_projects ($self, $opt, $args) { ## no critic (CognitiveComplexity::ProhibitExcessCognitiveComplexity)
my ($self, $opt, $args) = @_; my $query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_ldpprojects_query($self, $opt, $args);
my $query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_ldpprojects_query(@_);
my $response = SLUB::LZA::TA::Archivematica::Elasticsearch::query_elasticsearch( my $response = SLUB::LZA::TA::Archivematica::Elasticsearch::query_elasticsearch(
$SLUB::LZA::TA::config{elasticsearch_protocol}, $SLUB::LZA::TA::config{elasticsearch_protocol},
$SLUB::LZA::TA::config{elasticsearch_host}, $SLUB::LZA::TA::config{elasticsearch_host},
...@@ -303,8 +302,7 @@ sub get_ldp_projects { ## no critic (CognitiveComplexity::ProhibitExcessCognitiv ...@@ -303,8 +302,7 @@ sub get_ldp_projects { ## no critic (CognitiveComplexity::ProhibitExcessCognitiv
return @ret; return @ret;
} }
sub get_filestypes_by_aips { sub get_filestypes_by_aips($self, $opt, $args) {
my ($self, $opt, $args) = @_;
my $aips_query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_aip_query($opt); my $aips_query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_aip_query($opt);
$aips_query->{"_source"} = { $aips_query->{"_source"} = {
"includes" => 'uuid' "includes" => 'uuid'
...@@ -464,14 +462,13 @@ sub set_ldpflavour_results_for_filetype($self, $opt, $args, $results_ref, $newha ...@@ -464,14 +462,13 @@ sub set_ldpflavour_results_for_filetype($self, $opt, $args, $results_ref, $newha
return 1; return 1;
} }
sub execute { sub execute($self, $opt, $args) {
my ($self, $opt, $args) = @_;
my %results; my %results;
$results{date} = sprintf("%04u-%02u-%02u", Today()); $results{date} = sprintf("%04u-%02u-%02u", Today());
$results{package} = __PACKAGE__; $results{package} = __PACKAGE__;
$results{from} = $opt->{creationdate_epochs}->{from_string}; $results{from} = $opt->{creationdate_epochs}->{from_string};
$results{to} = $opt->{creationdate_epochs}->{to_string}; $results{to} = $opt->{creationdate_epochs}->{to_string};
my @ldp_projects = ($opt->{with_ldp}) ? get_ldp_projects(@_) : (); my @ldp_projects = ($opt->{with_ldp}) ? get_ldp_projects($self, $opt, $args) : ();
foreach my $aip_state (AIPSTATE) { foreach my $aip_state (AIPSTATE) {
my %newhash = %{$opt}; my %newhash = %{$opt};
filtered_set_for_aipstate($aip_state, \%newhash); filtered_set_for_aipstate($aip_state, \%newhash);
......
...@@ -174,11 +174,10 @@ sub validate_args($self, $opt, $args) { ## no critic qw(CognitiveComplexity::Pro ...@@ -174,11 +174,10 @@ sub validate_args($self, $opt, $args) { ## no critic qw(CognitiveComplexity::Pro
} }
sub find_aips_by_file_pronom_id { sub find_aips_by_file_pronom_id($self, $opt, $args) {
my ($self, $opt, $args) = @_;
# index aipfiles needed # index aipfiles needed
# find all AIPs where pronom-id like XXX # find all AIPs where pronom-id like XXX
my $files_query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_files_query(@_); my $files_query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_files_query($self, $opt, $args);
my $files_response = SLUB::LZA::TA::Archivematica::Elasticsearch::query_elasticsearch( my $files_response = SLUB::LZA::TA::Archivematica::Elasticsearch::query_elasticsearch(
$SLUB::LZA::TA::config{elasticsearch_protocol}, $SLUB::LZA::TA::config{elasticsearch_protocol},
$SLUB::LZA::TA::config{elasticsearch_host}, $SLUB::LZA::TA::config{elasticsearch_host},
...@@ -198,15 +197,14 @@ sub find_aips_by_file_pronom_id { ...@@ -198,15 +197,14 @@ sub find_aips_by_file_pronom_id {
return keys %aips; return keys %aips;
} }
sub execute { sub execute($self, $opt, $args) {
my ($self, $opt, $args) = @_;
my $aips_query; my $aips_query;
my $aips_response; my $aips_response;
#p($opt); #p($opt);
if (exists $opt->{format} and $opt->{format} eq 'pronom_id') { if (exists $opt->{format} and $opt->{format} eq 'pronom_id') {
$aips_query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_aip_query($opt); $aips_query = SLUB::LZA::TA::Archivematica::Elasticsearch::PrepareQuery::prepare_aip_query($opt);
# replace AIP query with all match # replace AIP query with all match
my @aips = find_aips_by_file_pronom_id(@_); my @aips = find_aips_by_file_pronom_id($self, $opt, $args);
$aips_query->{query}->{bool}->{must}->{terms}->{uuid} = \@aips; $aips_query->{query}->{bool}->{must}->{terms}->{uuid} = \@aips;
} else { } else {
# only index aips needed # only index aips needed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment