Skip to content

Commit 5633b85

Browse files
committed
subjects: renamed bodc to nvs
1 parent 7a926b3 commit 5633b85

File tree

7 files changed

+30
-32
lines changed

7 files changed

+30
-32
lines changed

invenio_vocabularies/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ def is_edmo(val):
196196
)
197197
"""Subject GEMET file download link."""
198198

199-
VOCABULARIES_SUBJECTS_BODC_PUV_FILE_URL = "http://vocab.nerc.ac.uk/collection/P02/current/?_profile=nvs&_mediatype=application/rdf+xml"
200-
"""Subject BODC-PUV file download link."""
199+
VOCABULARIES_SUBJECTS_NVS_FILE_URL = "http://vocab.nerc.ac.uk/collection/P02/current/?_profile=nvs&_mediatype=application/rdf+xml"
200+
"""Subject NVS-P02 file download link."""
201201

202202
VOCABULARIES_AFFILIATIONS_EDMO_COUNTRY_MAPPING = {
203203
"Cape Verde": "Cabo Verde",

invenio_vocabularies/contrib/subjects/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
lambda: current_app.config["VOCABULARIES_SUBJECTS_EUROSCIVOC_FILE_URL"]
3737
)
3838

39-
bodc_puv_file_url = LocalProxy(
40-
lambda: current_app.config["VOCABULARIES_SUBJECTS_BODC_PUV_FILE_URL"]
39+
nvs_file_url = LocalProxy(
40+
lambda: current_app.config["VOCABULARIES_SUBJECTS_NVS_FILE_URL"]
4141
)
4242

4343

invenio_vocabularies/contrib/subjects/datastreams.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from invenio_i18n import lazy_gettext as _
1313

1414
from ...datastreams.writers import ServiceWriter
15-
from .bodc import datastreams as bodc_datastreams
1615
from .euroscivoc import datastreams as euroscivoc_datastreams
1716
from .gemet import datastreams as gemet_datastreams
1817
from .mesh import datastreams as mesh_datastreams
18+
from .nvs import datastreams as nvs_datastreams
1919

2020

2121
class SubjectsServiceWriter(ServiceWriter):
@@ -40,7 +40,7 @@ def _entry_id(self, entry):
4040
**mesh_datastreams.VOCABULARIES_DATASTREAM_TRANSFORMERS,
4141
**euroscivoc_datastreams.VOCABULARIES_DATASTREAM_TRANSFORMERS,
4242
**gemet_datastreams.VOCABULARIES_DATASTREAM_TRANSFORMERS,
43-
**bodc_datastreams.VOCABULARIES_DATASTREAM_TRANSFORMERS,
43+
**nvs_datastreams.VOCABULARIES_DATASTREAM_TRANSFORMERS,
4444
}
4545
"""Subjects Data Streams transformers."""
4646

invenio_vocabularies/contrib/subjects/bodc/__init__.py renamed to invenio_vocabularies/contrib/subjects/nvs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# modify it under the terms of the MIT License; see LICENSE file for more
77
# details.
88

9-
"""BODC Subjects module."""
9+
"""NVS Subjects module."""

invenio_vocabularies/contrib/subjects/bodc/datastreams.py renamed to invenio_vocabularies/contrib/subjects/nvs/datastreams.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
# modify it under the terms of the MIT License; see LICENSE file for more
77
# details.
88

9-
"""BODC subjects datastreams, readers, transformers, and writers."""
9+
"""NVS subjects datastreams, readers, transformers, and writers."""
1010

1111
from invenio_vocabularies.datastreams.errors import TransformerError
1212
from invenio_vocabularies.datastreams.readers import RDFReader
1313
from invenio_vocabularies.datastreams.transformers import RDFTransformer
1414

15-
from ..config import bodc_puv_file_url
15+
from ..config import nvs_file_url
1616

1717
# Available with the "rdf" extra
1818
try:
@@ -21,9 +21,9 @@
2121
rdflib = None
2222

2323

24-
class BODCPUVSubjectsTransformer(RDFTransformer):
24+
class NVSSubjectsTransformer(RDFTransformer):
2525
"""
26-
Transformer class to convert BODC-PUV RDF data to a dictionary format.
26+
Transformer class to convert NVS RDF data to a dictionary format.
2727
2828
Input:
2929
- Relevant fields:
@@ -36,8 +36,8 @@ class BODCPUVSubjectsTransformer(RDFTransformer):
3636
Output:
3737
- A dictionary with the following structure:
3838
{
39-
"id": "SDN:P01::SAGEMSFM", # BODC-specific parameter ID (skos:notation).
40-
"scheme": "BODC-PUV", # The scheme name indicating this is a BODC Parameter Usage Vocabulary concept.
39+
"id": "SDN:P01::SAGEMSFM", # NVS-specific parameter ID (skos:notation).
40+
"scheme": "NVS-P01", # The scheme name indicating this is a collection P01 from NERC Vocabulary Server (NVS).
4141
"subject": "AMSSedAge", # The alternative label (skos:altLabel), if available, or None.
4242
"title": {
4343
"en": "14C age of Foraminiferida" # English preferred label (skos:prefLabel).
@@ -87,7 +87,7 @@ def _transform_entry(self, subject, rdf_graph):
8787

8888
return {
8989
"id": id,
90-
"scheme": "BODC-PUV",
90+
"scheme": "NVS-P02",
9191
"subject": subject_text,
9292
"title": labels,
9393
"props": {"definition": definition} if definition else {},
@@ -97,18 +97,18 @@ def _transform_entry(self, subject, rdf_graph):
9797

9898
# Configuration for datastream
9999

100-
VOCABULARIES_DATASTREAM_TRANSFORMERS = {"bodc-transformer": BODCPUVSubjectsTransformer}
100+
VOCABULARIES_DATASTREAM_TRANSFORMERS = {"nvs-transformer": NVSSubjectsTransformer}
101101

102102
DATASTREAM_CONFIG = {
103103
"readers": [
104104
{
105105
"type": "http",
106106
"args": {
107-
"origin": bodc_puv_file_url,
107+
"origin": nvs_file_url,
108108
},
109109
},
110110
{"type": "rdf"},
111111
],
112-
"transformers": [{"type": "bodc-transformer"}],
112+
"transformers": [{"type": "nvs-transformer"}],
113113
"writers": [{"args": {"writer": {"type": "subjects-service"}}, "type": "async"}],
114114
}

invenio_vocabularies/factories.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
)
2929
from .contrib.funders.datastreams import DATASTREAM_CONFIG as funders_ds_config
3030
from .contrib.names.datastreams import DATASTREAM_CONFIG as names_ds_config
31-
from .contrib.subjects.bodc.datastreams import DATASTREAM_CONFIG as bodc_ds_config
3231
from .contrib.subjects.datastreams import DATASTREAM_CONFIG as subjects_ds_config
3332
from .contrib.subjects.euroscivoc.datastreams import (
3433
DATASTREAM_CONFIG as euroscivoc_ds_config,
3534
)
3635
from .contrib.subjects.gemet.datastreams import DATASTREAM_CONFIG as gemet_ds_config
36+
from .contrib.subjects.nvs.datastreams import DATASTREAM_CONFIG as nvs_ds_config
3737

3838

3939
class VocabularyConfig:
@@ -164,15 +164,15 @@ def get_service(self):
164164
raise NotImplementedError("Service not implemented for GEMET Subjects")
165165

166166

167-
class SubjectsBODCVocabularyConfig(VocabularyConfig):
168-
"""BODC Subjects Vocabulary Config."""
167+
class SubjectsNVSVocabularyConfig(VocabularyConfig):
168+
"""NVS Subjects Vocabulary Config."""
169169

170-
config = bodc_ds_config
171-
vocabulary_name = "subjects:bodc-puv"
170+
config = nvs_ds_config
171+
vocabulary_name = "subjects:nvs"
172172

173173
def get_service(self):
174174
"""Get the service for the vocabulary."""
175-
raise NotImplementedError("Service not implemented for BODC Subjects")
175+
raise NotImplementedError("Service not implemented for NVS Subjects")
176176

177177

178178
def get_vocabulary_config(vocabulary):
@@ -187,7 +187,7 @@ def get_vocabulary_config(vocabulary):
187187
"affiliations:edmo": AffiliationsEDMOVocabularyConfig,
188188
"subjects": SubjectsVocabularyConfig,
189189
"subjects:gemet": SubjectsGEMETVocabularyConfig,
190-
"subjects:bodc": SubjectsBODCVocabularyConfig,
190+
"subjects:nvs": SubjectsNVSVocabularyConfig,
191191
"subjects:euroscivoc": SubjectsEuroSciVocVocabularyConfig,
192192
}
193193
return vocab_config.get(vocabulary, VocabularyConfig)()

tests/contrib/subjects/bodc/test_subjects_bodc_datastream.py renamed to tests/contrib/subjects/nvs/test_subjects_nvs_datastream.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
import pytest
1212
from rdflib import Graph
1313

14-
from invenio_vocabularies.contrib.subjects.bodc.datastreams import (
15-
BODCPUVSubjectsTransformer,
16-
)
14+
from invenio_vocabularies.contrib.subjects.nvs.datastreams import NVSSubjectsTransformer
1715
from invenio_vocabularies.datastreams.datastreams import StreamEntry
1816
from invenio_vocabularies.datastreams.errors import TransformerError
1917
from invenio_vocabularies.datastreams.readers import RDFReader
@@ -68,7 +66,7 @@ def expected_from_rdf():
6866
return [
6967
{
7068
"id": "SDN:P02::QDMD",
71-
"scheme": "BODC-PUV",
69+
"scheme": "NVS-P02",
7270
"subject": "Quantity of material dumped",
7371
"title": {
7472
"en": "Quantity of material dumped",
@@ -94,21 +92,21 @@ def parse_rdf_data(rdf_data):
9492
return list(reader._iter(rdf_graph))[0]
9593

9694

97-
def test_bodc_puv_transformer_pref_label(expected_from_rdf):
95+
def test_nvs_transformer_pref_label(expected_from_rdf):
9896
stream_entry = parse_rdf_data(VALID_XML_DATA)
9997
assert len(stream_entry) > 0
100-
transformer = BODCPUVSubjectsTransformer()
98+
transformer = NVSSubjectsTransformer()
10199
result = []
102100
entry = transformer.apply(StreamEntry(stream_entry)).entry
103101
result.append(entry)
104102
assert expected_from_rdf == result
105103

106104

107-
def test_bodc_puv_transformer_missing_id():
105+
def test_nvs_transformer_missing_id():
108106
stream_entry = parse_rdf_data(INVALID_XML_DATA)
109107
assert len(stream_entry) > 0
110108

111-
transformer = BODCPUVSubjectsTransformer()
109+
transformer = NVSSubjectsTransformer()
112110

113111
with pytest.raises(TransformerError) as err:
114112
transformer.apply(StreamEntry(stream_entry))

0 commit comments

Comments
 (0)