diff --git a/lib/SLUB/LZA/Rosetta/TA/Command/count.pm b/lib/SLUB/LZA/Rosetta/TA/Command/count.pm index 6ff656e04a58bc3788a67cec05fc0578e6993e05..43f2475af6cbba559124f18dc730fc20f39ca1a0 100644 --- a/lib/SLUB/LZA/Rosetta/TA/Command/count.pm +++ b/lib/SLUB/LZA/Rosetta/TA/Command/count.pm @@ -16,6 +16,12 @@ Examples: $0 count -d SLUB:LZA:Kitodo:kitodo:422766 * How many IEs were modified in 2021-05-31? $0 count -m 2021-05-31 + * How many IEs have at least one invalid file? + $0 count --with-invalid-files + * How many IEs with mkv-files are in archive? + $0 count --with-format=fmt/569 + * How many IEs have at least one file without virus check? + $0 count --with-missed-viruscheck DESCR sub description { @@ -31,6 +37,20 @@ sub opt_spec { ["descriptive|d" => "count based on string search in descriptive metadata"], ["source|s" => "count based on string search in source metadata"], ["ie|i=s" => "search a specific IE"], + ["format" => hidden => {one_of => [ + ["with-format=s" => "with pronom format id"], + # unsupported by Rosetta <= 7.0 + #["without-format=s" => "without pronom format id"], + ] } ], + ["validation" => hidden => {one_of => [ + ["with-valid-files" => "with valid files"], + ["with-invalid-files" => "with at least one invalid file"], + ] } ], + ["viruscheck" => hidden => {one_of => [ + ["with-passed-viruschecks" => "with passed virus checks"], + ["with-missed-viruschecks" => "with missed virus checks"], + ["with-failed-viruschecks" => "with failed virus checks"], + ]}], ); } sub validate_args { @@ -59,7 +79,37 @@ sub execute { if (exists $opt->{modificationdate}) { push @queries, "FILE.objectCharacteristics.modificationDate==$opt->{modificationdate}"; } + if (exists $opt->{'with_format'}) { + push @queries, "FILE.generalFileCharacteristics.formatLibraryId=$opt->{'with_format'}"; + } + # unsupported by Rosetta <= 7.0 + #if (exists $opt->{'without_format'}) { + # push @queries, "FILE.generalFileCharacteristics.formatLibraryId!=$opt->{'without_format'}"; + #} + if (exists $opt->{'with_valid_files'}) { + push @queries, "FILE.fileValidation.isValid=true"; + } + if (exists $opt->{'with_invalid_files'}) { + push @queries, "FILE.fileValidation.isValid=false"; + } + if (exists $opt->{'with_passed_viruschecks'}) { + push @queries, "FILE.fileVirusCheck.status=true"; + } + if (exists $opt->{'with_failed_viruschecks'}) { + push @queries, "FILE.fileVirusCheck.status=false"; + } + if (exists $opt->{'with_missed_viruschecks'}) { + push @queries, "FILE.fileVirusCheck.status==%22%22"; + } + + my $query = join(" and ", @queries); + if (exists $opt->{debug}) { + use Data::Printer; + p( $opt); + p(@queries); + p( $query); + } my $response = SLUB::LZA::Rosetta::TA::sru_search('ie', $query, $startrecord, $maxrecords, $opt->{verbose}); $response=~s|.*?<numberOfRecords>(\d+)</numberOfRecords.*|$1|s; say $response; diff --git a/lib/SLUB/LZA/Rosetta/TA/Command/search.pm b/lib/SLUB/LZA/Rosetta/TA/Command/search.pm index cd7c55d01b299e0164abfeba874d63ab797e4ec3..1125748859a5c6607779b663e50404761c6a8420 100644 --- a/lib/SLUB/LZA/Rosetta/TA/Command/search.pm +++ b/lib/SLUB/LZA/Rosetta/TA/Command/search.pm @@ -23,6 +23,12 @@ Examples: $0 search -s copyrighted * Which IEs were modified in 2021-05-31? $0 search -m 2021-05-31 + Which IEs have at least one invalid file? + $0 search --with-invalid-files + * Which IEs with mkv-files are in archive? + $0 search --with-format=fmt/569 + * Which IEs have at least one file without virus check? + $0 search --with-missed-viruscheck DESCR sub description { @@ -41,6 +47,21 @@ sub opt_spec { ["ie|i=s" => "search a specific IE"], ["maxrecords=i", "set maxrecords, default is 10"], ["startrecord=i", "set startrecord, default is 1"], + ["format" => hidden => {one_of => [ + ["with-format=s" => "with pronom format id"], + # unsupported by Rosetta <= 7.0 + #["without-format=s" => "without pronom format id"], + ] } ], + ["validation" => hidden => {one_of => [ + ["with-valid-files" => "with valid files"], + ["with-invalid-files" => "with at least one invalid file"], + ] } ], + ["viruscheck" => hidden => {one_of => [ + ["with-passed-viruschecks" => "with passed virus checks"], + ["with-missed-viruschecks" => "with missed virus checks"], + ["with-failed-viruschecks" => "with failed virus checks"], + ]}], + ); } sub validate_args { @@ -59,8 +80,6 @@ sub execute { if (exists $opt->{startrecord}) { $startrecord = $opt->{startrecord}; } - - use Data::Printer; p($opt); my @queries; if (exists $opt->{source}) { push @queries, "IE.sourceMD.content=$opt->{source}"; @@ -77,9 +96,40 @@ sub execute { if (exists $opt->{modificationdate}) { push @queries, "FILE.objectCharacteristics.modificationDate==$opt->{modificationdate}"; } + if (exists $opt->{'with_format'}) { + push @queries, "FILE.generalFileCharacteristics.formatLibraryId=$opt->{'with_format'}"; + } + # unsupported by Rosetta <= 7.0 + #if (exists $opt->{'without_format'}) { + # push @queries, "FILE.generalFileCharacteristics.formatLibraryId!=$opt->{'without_format'}"; + #} + if (exists $opt->{'with_valid_files'}) { + push @queries, "FILE.fileValidation.isValid=true"; + } + if (exists $opt->{'with_invalid_files'}) { + push @queries, "FILE.fileValidation.isValid=false"; + } + if (exists $opt->{'with_passed_viruschecks'}) { + push @queries, "FILE.fileVirusCheck.status=true"; + } + if (exists $opt->{'with_failed_viruschecks'}) { + push @queries, "FILE.fileVirusCheck.status=false"; + } + if (exists $opt->{'with_missed_viruschecks'}) { + push @queries, "FILE.fileVirusCheck.status==%22%22"; + } + + my $query = join(" and ", @queries); + if (exists $opt->{debug}) { + use Data::Printer; + p( $opt); + p(@queries); + p( $query); + } + my $response = SLUB::LZA::Rosetta::TA::sru_search('ie', $query, $startrecord, $maxrecords, $opt->{verbose}); say $response; } -1; \ No newline at end of file +1;