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
0698c2ec
Commit
0698c2ec
authored
Nov 12, 2020
by
Maja-Olivia Lenz
Committed by
Markus Scheidgen
Jan 08, 2021
Browse files
Add license, language
parent
fa155909
Changes
2
Hide whitespace changes
Inline
Side-by-side
nomad/app/dcat/mapping.py
View file @
0698c2ec
...
...
@@ -35,7 +35,6 @@ class Mapping():
self
.
g
.
namespace_manager
.
bind
(
'foaf'
,
FOAF
)
self
.
persons
=
{}
self
.
vcards
=
{}
def
map_entry
(
self
,
entry
:
EntryMetadata
):
dataset
=
URIRef
(
url
(
'datasets'
,
entry
.
calc_id
))
...
...
@@ -48,10 +47,12 @@ class Mapping():
config
.
gui_url
(),
entry
.
upload_id
,
entry
.
calc_id
))))
self
.
g
.
add
((
dataset
,
DCT
.
title
,
Literal
(
'unavailable'
if
entry
.
formula
is
None
else
entry
.
formula
)))
self
.
g
.
add
((
dataset
,
DCT
.
description
,
Literal
(
'unavailable'
if
entry
.
comment
is
None
else
entry
.
comment
)))
self
.
g
.
add
((
dataset
,
DCT
.
license
,
URIRef
(
'https://creativecommons.org/licenses/by/4.0/legalcode'
)))
self
.
g
.
add
((
dataset
,
DCT
.
language
,
URIRef
(
'http://id.loc.gov/vocabulary/iso639-1/en'
)))
self
.
g
.
add
((
dataset
,
DCT
.
publisher
,
self
.
map_user
(
entry
.
uploader
)))
for
author
in
entry
.
authors
:
self
.
g
.
add
((
dataset
,
DCT
.
creator
,
self
.
map_user
(
author
)))
self
.
g
.
add
((
dataset
,
DCT
.
creator
,
self
.
map_user
(
author
)))
self
.
g
.
add
((
dataset
,
DCAT
.
contactPoint
,
self
.
map_contact
(
entry
.
uploader
)))
self
.
g
.
add
((
dataset
,
DCAT
.
distribution
,
self
.
map_distribution
(
entry
,
'api'
)))
...
...
@@ -77,7 +78,7 @@ class Mapping():
self
.
persons
[
user
.
user_id
]
=
person
return
person
def
map_contact
(
self
,
user
:
User
):
person
=
self
.
persons
.
get
(
user
.
user_id
)
if
person
is
None
:
...
...
@@ -90,15 +91,15 @@ class Mapping():
self
.
g
.
add
((
person
,
VCARD
.
nickName
,
Literal
(
user
.
username
)))
self
.
g
.
add
((
person
,
VCARD
.
hasEmail
,
Literal
(
user
.
email
)))
self
.
g
.
add
((
person
,
VCARD
.
organizationName
,
Literal
(
'unavailable'
if
user
.
affiliation
is
None
else
user
.
affiliation
)))
#
address = BNode()
#
self.g.add((address, RDF.type, VCARD.Address))
#
self.g.add((address, VCARD.street_address, )) # affiliation_address?
#
self.g.add((address, VCARD.postal_code, )) # affiliation_address?
#
self.g.add((address, VCARD.country_name, )) # affiliation_address?
#
self.g.add((address, VCARD.locality, )) # affiliation_address?
#
self.g.add((address, VCARD.region, )) # affiliation_address?
#
self.g.add((person, VCARD.hasAddress, address))
address
=
BNode
()
self
.
g
.
add
((
address
,
RDF
.
type
,
VCARD
.
Address
))
self
.
g
.
add
((
address
,
VCARD
.
street_address
,
))
# affiliation_address?
self
.
g
.
add
((
address
,
VCARD
.
postal_code
,
))
# affiliation_address?
self
.
g
.
add
((
address
,
VCARD
.
country_name
,
))
# affiliation_address?
self
.
g
.
add
((
address
,
VCARD
.
locality
,
))
# affiliation_address?
self
.
g
.
add
((
address
,
VCARD
.
region
,
))
# affiliation_address?
self
.
g
.
add
((
person
,
VCARD
.
hasAddress
,
address
))
return
person
def
map_distribution
(
self
,
entry
,
dist_kind
):
...
...
tests/app/test_dcat.py
View file @
0698c2ec
...
...
@@ -21,7 +21,6 @@ from nomad.app.dcat.mapping import Mapping
from
tests.conftest
import
clear_elastic
from
tests.app.test_app
import
BlueprintClient
@
pytest
.
fixture
(
scope
=
'session'
)
def
api
(
session_client
):
return
BlueprintClient
(
session_client
,
'/dcat'
)
...
...
@@ -51,7 +50,7 @@ def test_mapping(example_entry):
mapping
=
Mapping
()
mapping
.
map_entry
(
example_entry
)
assert
mapping
.
g
is
not
None
#
print(mapping.g.serialize(format='xml').decode('utf-8'))
print
(
mapping
.
g
.
serialize
(
format
=
'xml'
).
decode
(
'utf-8'
))
def
test_get_dataset
(
api
,
example_entry
):
...
...
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