Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tools for technical analysts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Digital Preservation
tools for technical analysts
Commits
58ed2670
Commit
58ed2670
authored
1 year ago
by
Andreas Romeyke
Browse files
Options
Downloads
Patches
Plain Diff
- add rsv support
parent
a2f7c6a7
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/SLUB/LZA/TA/Command/search.pm
+77
-28
77 additions, 28 deletions
lib/SLUB/LZA/TA/Command/search.pm
with
77 additions
and
28 deletions
lib/SLUB/LZA/TA/Command/search.pm
+
77
−
28
View file @
58ed2670
...
...
@@ -5,6 +5,13 @@ use warnings;
use
feature
qw(say)
;
use
SLUB::LZA::TA::Archivematica::
Elasticsearch
;
use
Data::
Printer
;
use
constant
VALUE_TERMINATOR
=>
0xff
;
use
constant
NULL
=>
0xfe
;
use
constant
ROW_TERMINATOR
=>
0xfd
;
use
constant
CHR_VALUE_TERMINATOR
=>
chr
(
VALUE_TERMINATOR
);
use
constant
CHR_NULL
=>
chr
(
NULL
);
use
constant
CHR_ROW_TERMINATOR
=>
chr
(
ROW_TERMINATOR
);
use
List::
Util
qw(any none)
;
# VERSION
...
...
@@ -43,40 +50,42 @@ sub description {
"
$description
"
}
sub
opt_spec
{
return
(
["
target-version|V
"
=>
"
get current elasticsearch version
",
{
shortcircuit
=>
1
}
],
["
debug
"
=>
"
enable user agent debug output
"],
["
output-format
"
=>
hidden
=>
{
return
(
[
"
target-version|V
"
=>
"
get current elasticsearch version
",
{
shortcircuit
=>
1
}
],
[
"
debug
"
=>
"
enable user agent debug output
"
],
[
"
output-format
"
=>
hidden
=>
{
one_of
=>
[
[
"
output-as-rsv|r
"
=>
"
prints output as Raw Strings Values (RSV) [default]
"],
[
"
output-as-csv|C
"
=>
"
prints output as Comma Separated Values (CSV)
"],
[
"
verbose|v
"
=>
"
enable verbose output, returns full elasticsearch response
"],
]
}
[
"
output-as-rsv|r
"
=>
"
prints output as Raw Strings Values (RSV) [default]
"
],
[
"
output-as-csv|C
"
=>
"
prints output as Comma Separated Values (CSV)
"
],
[
"
verbose|v
"
=>
"
enable verbose output, returns full elasticsearch response
"
],
]
,
}
],
["
with-lzaid
"
=>
"
also returns lzaid
"],
["
with-path
"
=>
"
also returns AIP path
"],
["
with-size
"
=>
"
also returns AIP size
"],
["
with-filecount
"
=>
"
also returns AIPs file count
"],
["
with-export2archive-date
"
=>
"
also returns AIP export to archive date
"],
["
with-creationdate
"
=>
"
also returns AIP creation date
"],
["
datemode
"
=>
hidden
=>
{
[
"
with-lzaid
"
=>
"
also returns lzaid
"
],
[
"
with-path
"
=>
"
also returns AIP path
"
],
[
"
with-size
"
=>
"
also returns AIP size
"
],
[
"
with-filecount
"
=>
"
also returns AIPs file count
"
],
[
"
with-export2archive-date
"
=>
"
also returns AIP export to archive date
"
],
[
"
with-creationdate
"
=>
"
also returns AIP creation date
"
],
[
"
datemode
"
=>
hidden
=>
{
one_of
=>
[
[
"
creationdate|c=s
"
=>
"
search based on creationdate string
"],
[
"
modificationdate|m=s
"
=>
"
search based on modificationdate string
"]
[
"
creationdate|c=s
"
=>
"
search based on creationdate string
"
],
[
"
modificationdate|m=s
"
=>
"
search based on modificationdate string
"
]
]
}
}
],
["
lzaid|l=s
",
"
search a specific AIP by given LZA id
"],
["
descriptive|d=s
",
"
search descriptive metadata (dc identifier)
"],
["
source|s=s
",
"
search source metadata
"],
["
aip|a=s
"
=>
"
search a specific AIP by given AIP id
"],
["
maxrecords=i
",
"
set maxrecords, default is 10
"],
["
startrecord=i
",
"
set startrecord, default is 1
"],
["
format
"
=>
hidden
=>
{
one_of
=>
[
["
pronom-id=s
"
=>
"
with pronom format id
"],
[
"
lzaid|l=s
",
"
search a specific AIP by given LZA id
"
],
[
"
descriptive|d=s
",
"
search descriptive metadata (dc identifier)
"
],
[
"
source|s=s
",
"
search source metadata
"
],
[
"
aip|a=s
"
=>
"
search a specific AIP by given AIP id
"
],
[
"
maxrecords=i
",
"
set maxrecords, default is 10
"
,
{
default
=>
10
}
],
[
"
startrecord=i
",
"
set startrecord, default is 1
"
],
[
"
format
"
=>
hidden
=>
{
one_of
=>
[
[
"
pronom-id=s
"
=>
"
with pronom format id
"
],
#["without-format=s" => "without pronom format id"],
]
}
],
[
'
help|h
',
"
print usage message and exit
",
{
shortcircuit
=>
1
}
],
[
'
version|i
',
"
print version information
",
{
shortcircuit
=>
1
}
],
);
}
sub
validate_args
{
...
...
@@ -86,6 +95,19 @@ sub validate_args {
1
;
}
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
'}
};
if
(
defined
$opt
->
{
with_creation_date
})
{
$line
{
creation_date
}
=
$partial_result
->
{
_source
}
->
{
created
}
};
\
%line
;
}
sub
execute
{
my
(
$self
,
$opt
,
$args
)
=
@_
;
if
(
$opt
->
{
target_version
})
{
...
...
@@ -104,7 +126,34 @@ sub execute {
'
aips
',
# indexname
$query
,
# query_hash ref
);
say
np
(
$response
);
my
@result
=
map
{
line_result_mapper
(
$_
,
$opt
);
}
@
{
$response
->
{
hits
}
->
{
hits
}
};
my
@headers
=
sort
keys
%
{
$result
[
0
]};
my
$aip_only
=
List::Util::
none
{
$_
=~
m/^with/
}
keys
%
{
$opt
};
p
(
$opt
);
if
(
$opt
->
{
output_format
}
eq
'
verbose
')
{
say
np
(
$response
);
}
elsif
(
$aip_only
or
(
$opt
->
{
output_format
}
eq
'
output_as_csv
')
)
{
say
join
("
,
",
@headers
);
say
join
("
\n
",
map
{
my
$line
=
$_
;
my
$res_line
=
join
(
"
,
",
map
{
$line
->
{
$_
}
}
@headers
);
$res_line
;
}
@result
);
}
elsif
(
$opt
->
{
output_format
}
eq
'
output_as_rsv
')
{
binmode
(
STDOUT
,
'
:bytes
');
print
join
(
CHR_VALUE_TERMINATOR
,
@headers
);
print
CHR_ROW_TERMINATOR
;
print
join
(
CHR_ROW_TERMINATOR
,
map
{
join
(
CHR_VALUE_TERMINATOR
,
values
%
{
$_
});
}
@result
);
print
CHR_ROW_TERMINATOR
;
binmode
(
STDOUT
,
'
:encoding(UTF-8)
');
}
return
1
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment