Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
postprocessing
Media Metadata Indexer
Commits
7aaa2455
Unverified
Commit
7aaa2455
authored
Mar 15, 2021
by
Sebastian Schüpbach
Browse files
take all access flags in a document into account
parent
7c8310ed
Pipeline
#23232
passed with stages
in 1 minute and 50 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
mediametadatatodb_app/resources/MediametadataToDB.py
View file @
7aaa2455
...
...
@@ -103,7 +103,7 @@ def _extract_thumbnail_values(msg, _access_status) -> dict:
else
:
file_extension
=
''
logging
.
warning
(
'No valid mimetype found!'
)
return_values
[
'uri'
]
=
'file:///data/{}-poster.{}'
.
\
return_values
[
'uri'
]
=
'file:///data/{}-poster.{}'
.
\
format
(
msg
[
'@id'
].
split
(
'/'
)[
-
2
],
file_extension
)
return
return_values
...
...
@@ -207,24 +207,45 @@ def _get_access_status(graph, record_id) -> str:
Decide on access status. Possible values are `public`, `closed`, `unavailable`,
`faro`, `onsite`, or `noonsite`
"""
# Since several access flags in one document are possible, we have to apply a ranking
# which is `closed`, `public`, `faro`, `onsite`, `noonsite` and as fallback `unavailable`
access_flags
=
list
()
for
resource
in
graph
:
if
'type'
in
resource
and
resource
[
'type'
]
==
'access'
and
\
'regulates'
in
resource
and
\
resource
[
'regulates'
].
startswith
(
'https://memobase.ch/digital/'
)
and
\
'name'
in
resource
:
if
resource
[
'name'
]
==
'public'
:
logging
.
debug
(
f
'
{
record_id
}
: Setting access for digital object to `public`'
)
return
'public'
access_flags
.
append
(
'public'
)
elif
resource
[
'name'
]
==
'private'
:
logging
.
debug
(
f
'
{
record_id
}
: Setting access for digital object to `closed`'
)
return
'closed'
access_flags
.
append
(
'closed'
)
else
:
logging
.
info
(
f
'Digital object of record
{
record_id
}
has access type '
+
f
'`
{
resource
[
"name"
]
}
`. This makes the media resource unavailable.'
)
return
resource
[
'name'
]
logging
.
info
(
f
'Digital object of record
{
record_id
}
has no related access information!'
+
' Media resource is therefore unavailable'
)
return
'unavailable'
access_flags
.
append
(
resource
[
'name'
])
if
'closed'
in
access_flags
:
logging
.
debug
(
f
'
{
record_id
}
: Setting access for digital object to `closed`'
)
return
'closed'
elif
'public'
in
access_flags
:
logging
.
debug
(
f
'
{
record_id
}
: Setting access for digital object to `public`'
)
return
'public'
elif
'faro'
in
access_flags
:
logging
.
info
(
f
'Digital object of record
{
record_id
}
has access type `faro`.'
+
' This makes the media resource unavailable.'
)
return
'faro'
elif
'onsite'
in
access_flags
:
logging
.
info
(
f
'Digital object of record
{
record_id
}
has access type `onsite`.'
+
' This makes the media resource unavailable.'
)
return
'onsite'
elif
'noonsite'
in
access_flags
:
logging
.
info
(
f
'Digital object of record
{
record_id
}
has access type `noonsite`.'
+
' This makes the media resource unavailable.'
)
return
'noonsite'
else
:
logging
.
info
(
f
'Digital object of record
{
record_id
}
has no or invalid access information!'
+
' The media resource is therefore unavailable'
)
return
'unavailable'
def
_get_record_id
(
graph
)
->
str
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment