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

- adapted count command

parent 8880e2c9
No related branches found
No related tags found
No related merge requests found
...@@ -3,15 +3,14 @@ use SLUB::LZA::TA -command; ...@@ -3,15 +3,14 @@ use SLUB::LZA::TA -command;
use strict; use strict;
use warnings; use warnings;
use feature qw(say); use feature qw(say);
use SLUB::LZA::TA::Rosetta::common_sru; use SLUB::LZA::TA::Archivematica::Elasticsearch;
use SLUB::LZA::TA::Rosetta::SRU; use Data::Printer;
# VERSION # VERSION
# ABSTRACT: count IEs module for ta-tool # ABSTRACT: count IEs module for ta-tool
sub abstract {"count IEs in Rosetta based Archival Information System";} sub abstract {"count IEs in Rosetta based Archival Information System";}
my $description=<<"DESCR"; my $description=<<"DESCR";
...@@ -20,15 +19,15 @@ and return counts of matches. ...@@ -20,15 +19,15 @@ and return counts of matches.
Examples: Examples:
* Is this dc identifier in Archiv? * Is this dc identifier in archive?
$0 count -d SLUB:LZA:Kitodo:kitodo:422766 $0 count -d SLUB:LZA:Kitodo:kitodo:422766
* How many IEs were modified in 2021-05-31? * How many AIPs were modified in 2021-05-31?
$0 count -m 2021-05-31 $0 count -m 2021-05-31
* How many IEs have at least one invalid file? * How many AIPs have at least one invalid file?
$0 count --with-invalid-files $0 count --with-invalid-files
* How many IEs with mkv-files are in archive? * How many AIPs with mkv-files are in archive?
$0 count --with-format=fmt/569 $0 count --with-format=fmt/569
* How many IEs have at least one file without virus check? * How many AIPs have at least one file without virus check?
$0 count --with-missed-viruscheck $0 count --with-missed-viruscheck
DESCR DESCR
...@@ -37,15 +36,17 @@ sub description { ...@@ -37,15 +36,17 @@ sub description {
} }
sub opt_spec { sub opt_spec {
return( return(
["target-version|V" => "get current elasticsearch version"],
["verbose|v" => "enable verbose output"], ["verbose|v" => "enable verbose output"],
["debug" => "enable user agent debug output"], ["debug" => "enable user agent debug output"],
["datemode" => hidden => {one_of => [ ["datemode" => hidden => {one_of => [
["creationdate|c=s" => "search based on creationdate string"], ["creationdate|c=s" => "search based on creationdate string"],
["modificationdate|m=s" => "search based on modificationdate string"] ["modificationdate|m=s" => "search based on modificationdate string"]
] } ], ] } ],
[ "lzaid|l=s", "count AIPs by given LZA id"],
["descriptive|d=s" => "count based on string search in descriptive metadata"], ["descriptive|d=s" => "count based on string search in descriptive metadata"],
["source|s=s" => "count based on string search in source metadata"], ["source|s=s" => "count based on string search in source metadata"],
["ie|i=s" => "search a specific IE"], ["aip|a=s" => "count AIPs by given AIP id"],
["format" => hidden => {one_of => [ ["format" => hidden => {one_of => [
["with-format=s" => "with pronom format id"], ["with-format=s" => "with pronom format id"],
# unsupported by Rosetta <= 7.0 # unsupported by Rosetta <= 7.0
...@@ -71,12 +72,24 @@ sub validate_args { ...@@ -71,12 +72,24 @@ sub validate_args {
sub execute { sub execute {
my ($self, $opt, $args) = @_; my ($self, $opt, $args) = @_;
my $maxrecords="0"; if ($opt->{target_version}) {
my $startrecord=1; say SLUB::LZA::TA::Archivematica::Elasticsearch::version_elasticsearch(
my $query = SLUB::LZA::TA::Rosetta::common_sru::prepare_query($opt); $SLUB::LZA::TA::config{elasticsearchprotocol},
my $response = SLUB::LZA::TA::Rosetta::SRU::sru_search('ie', $query, $startrecord, $maxrecords, $opt->{verbose}, $opt->{debug}); $SLUB::LZA::TA::config{elasticsearchhost},
$response=~s|.*?<numberOfRecords>(\d+)</numberOfRecords.*|$1|s; $SLUB::LZA::TA::config{elasticsearchport}
say $response; );
exit (0);
}
my $query = SLUB::LZA::TA::Archivematica::Elasticsearch::prepare_query($opt);
my $response = SLUB::LZA::TA::Archivematica::Elasticsearch::query_elasticsearch_count(
$SLUB::LZA::TA::config{elasticsearchprotocol},
$SLUB::LZA::TA::config{elasticsearchhost},
$SLUB::LZA::TA::config{elasticsearchport},
'aips', # indexname
$query, # query_hash ref
);
say np($response);
return 1;
} }
1; 1;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment