Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
5310f3da
Commit
5310f3da
authored
Nov 02, 2020
by
Maja-Olivia Lenz
Committed by
Markus Scheidgen
Jan 08, 2021
Browse files
Add distributions
parent
ed6a3802
Changes
1
Hide whitespace changes
Inline
Side-by-side
nomad/app/dcat/mapping.py
View file @
5310f3da
...
...
@@ -51,9 +51,14 @@ class Mapping():
for
author
in
entry
.
authors
:
self
.
g
.
add
((
dataset
,
DCT
.
creator
,
self
.
map_user
(
author
)))
self
.
g
.
add
((
dataset
,
DCAT
.
distribution
,
self
.
map_distribution
(
entry
,
'api'
)))
self
.
g
.
add
((
dataset
,
DCAT
.
distribution
,
self
.
map_distribution
(
entry
,
'json'
)))
self
.
g
.
add
((
dataset
,
DCAT
.
distribution
,
self
.
map_distribution
(
entry
,
'raw'
)))
return
dataset
def
map_user
(
self
,
user
:
User
):
# TODO: creator and publisher are FOAF agents, contactPoint is vCard
vcard
=
self
.
vcards
.
get
(
user
.
user_id
)
if
vcard
is
not
None
:
return
vcard
...
...
@@ -69,3 +74,41 @@ class Mapping():
self
.
vcards
[
user
.
user_id
]
=
vcard
return
vcard
def
map_distribution
(
self
,
entry
,
dist_kind
):
if
dist_kind
==
'api'
:
# DataService: API
service
=
BNode
()
self
.
g
.
add
((
service
,
RDF
.
type
,
DCAT
.
DataService
))
self
.
g
.
add
((
service
,
DCT
.
title
,
Literal
(
'NOMAD API'
)))
# How to include terms from swagger document here?
self
.
g
.
add
((
service
,
DCT
.
description
,
Literal
(
'Official NOMAD API'
)))
# same question
self
.
g
.
add
((
service
,
DCAT
.
endpointURL
,
URIRef
(
'https://nomad-lab.eu/prod/rae/api/'
)))
# config.api_url() ?
# not sure if the following needs to be dataset specific:
self
.
g
.
add
((
service
,
DCAT
.
endpointDescription
,
URIRef
(
'https://nomad-lab.eu/prod/rae/api/swagger.json'
)))
# Distribution over API
dist
=
BNode
()
self
.
g
.
add
((
dist
,
DCT
.
title
,
Literal
(
'unavailable'
if
entry
.
formula
is
None
else
entry
.
formula
+
'api'
)))
self
.
g
.
add
((
dist
,
RDF
.
type
,
DCAT
.
Distribution
))
self
.
g
.
add
((
dist
,
DCAT
.
accessService
,
service
))
elif
dist_kind
==
'json'
:
# Distribution as JSON
dist
=
BNode
()
self
.
g
.
add
((
dist
,
RDF
.
type
,
DCAT
.
Distribution
))
self
.
g
.
add
((
dist
,
DCT
.
title
,
Literal
(
'unavailable'
if
entry
.
formula
is
None
else
entry
.
formula
+
'json'
)))
self
.
g
.
add
((
dist
,
DCAT
.
mediaType
,
URIRef
(
'https://www.iana.org/assignments/media-types/application/json'
)))
self
.
g
.
add
((
dist
,
DCAT
.
packageFormat
,
URIRef
(
'https://www.iana.org/assignments/media-types/application/zip'
)))
self
.
g
.
add
((
dist
,
DCAT
.
downloadURL
,
URIRef
(
'http://nomad-lab.eu/prod/rae/api/archive/download?upload_id=%s&calc_id=%s'
%
(
entry
.
upload_id
,
entry
.
calc_id
))))
self
.
g
.
add
((
dist
,
DCAT
.
accessURL
,
URIRef
(
'%s/entry/id/%s/%s'
%
(
config
.
gui_url
(),
entry
.
upload_id
,
entry
.
calc_id
))))
elif
dist_kind
==
'raw'
:
# Distribution of the raw data
dist
=
BNode
()
self
.
g
.
add
((
dist
,
RDF
.
type
,
DCAT
.
Distribution
))
self
.
g
.
add
((
dist
,
DCT
.
title
,
Literal
(
'unavailable'
if
entry
.
formula
is
None
else
entry
.
formula
+
'raw'
)))
self
.
g
.
add
((
dist
,
DCAT
.
accessURL
,
URIRef
(
'https://nomad-lab.eu/prod/rae/api/raw/calc/%s/%s'
%
(
entry
.
upload_id
,
entry
.
calc_id
))))
self
.
g
.
add
((
dist
,
DCAT
.
packageFormat
,
URIRef
(
'https://www.iana.org/assignments/media-types/application/zip'
)))
return
dist
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment