invenio-vocabularies 2.3.1__py2.py3-none-any.whl → 6.3.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of invenio-vocabularies might be problematic. Click here for more details.
- invenio_vocabularies/__init__.py +2 -2
- invenio_vocabularies/administration/__init__.py +10 -0
- invenio_vocabularies/administration/views/__init__.py +10 -0
- invenio_vocabularies/administration/views/vocabularies.py +45 -0
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/package.json +1 -7
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/CustomAwardForm.js +80 -64
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FundingField.js +49 -41
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/FundingModal.js +5 -7
- invenio_vocabularies/assets/semantic-ui/js/invenio_vocabularies/src/contrib/forms/Funding/NoAwardResults.js +3 -3
- invenio_vocabularies/cli.py +31 -44
- invenio_vocabularies/config.py +68 -4
- invenio_vocabularies/contrib/affiliations/affiliations.py +11 -0
- invenio_vocabularies/contrib/affiliations/api.py +1 -2
- invenio_vocabularies/contrib/affiliations/config.py +13 -2
- invenio_vocabularies/contrib/affiliations/datastreams.py +186 -0
- invenio_vocabularies/contrib/affiliations/jsonschemas/affiliations/affiliation-v1.0.0.json +38 -1
- invenio_vocabularies/contrib/affiliations/mappings/os-v1/affiliations/affiliation-v1.0.0.json +22 -1
- invenio_vocabularies/contrib/affiliations/mappings/os-v1/affiliations/affiliation-v2.0.0.json +171 -0
- invenio_vocabularies/contrib/affiliations/mappings/os-v2/affiliations/affiliation-v1.0.0.json +22 -1
- invenio_vocabularies/contrib/affiliations/mappings/os-v2/affiliations/affiliation-v2.0.0.json +171 -0
- invenio_vocabularies/contrib/affiliations/mappings/v7/affiliations/affiliation-v1.0.0.json +22 -1
- invenio_vocabularies/contrib/affiliations/schema.py +17 -3
- invenio_vocabularies/contrib/affiliations/services.py +1 -2
- invenio_vocabularies/contrib/awards/awards.py +17 -5
- invenio_vocabularies/contrib/awards/datastreams.py +241 -7
- invenio_vocabularies/contrib/awards/jsonschemas/awards/award-v1.0.0.json +38 -0
- invenio_vocabularies/contrib/awards/mappings/os-v1/awards/award-v1.0.0.json +51 -2
- invenio_vocabularies/contrib/awards/mappings/os-v2/awards/award-v1.0.0.json +51 -2
- invenio_vocabularies/contrib/awards/mappings/v7/awards/award-v1.0.0.json +51 -2
- invenio_vocabularies/contrib/awards/schema.py +16 -1
- invenio_vocabularies/contrib/awards/serializer.py +8 -1
- invenio_vocabularies/contrib/awards/services.py +1 -2
- invenio_vocabularies/contrib/common/__init__.py +9 -0
- invenio_vocabularies/contrib/common/openaire/__init__.py +9 -0
- invenio_vocabularies/contrib/common/openaire/datastreams.py +84 -0
- invenio_vocabularies/contrib/common/ror/__init__.py +9 -0
- invenio_vocabularies/contrib/common/ror/datastreams.py +220 -0
- invenio_vocabularies/contrib/funders/config.py +11 -2
- invenio_vocabularies/contrib/funders/datastreams.py +40 -62
- invenio_vocabularies/contrib/funders/funders.py +3 -1
- invenio_vocabularies/contrib/funders/jsonschemas/funders/funder-v1.0.0.json +36 -1
- invenio_vocabularies/contrib/funders/mappings/os-v1/funders/funder-v1.0.0.json +22 -1
- invenio_vocabularies/contrib/funders/mappings/os-v1/funders/funder-v2.0.0.json +156 -0
- invenio_vocabularies/contrib/funders/mappings/os-v2/funders/funder-v1.0.0.json +22 -1
- invenio_vocabularies/contrib/funders/mappings/os-v2/funders/funder-v2.0.0.json +156 -0
- invenio_vocabularies/contrib/funders/mappings/v7/funders/funder-v1.0.0.json +22 -1
- invenio_vocabularies/contrib/funders/schema.py +8 -0
- invenio_vocabularies/contrib/funders/serializer.py +2 -1
- invenio_vocabularies/contrib/names/config.py +5 -3
- invenio_vocabularies/contrib/names/datastreams.py +172 -4
- invenio_vocabularies/contrib/names/jsonschemas/names/name-v1.0.0.json +3 -0
- invenio_vocabularies/contrib/names/mappings/os-v1/names/name-v1.0.0.json +3 -0
- invenio_vocabularies/contrib/names/mappings/os-v1/names/name-v2.0.0.json +150 -0
- invenio_vocabularies/contrib/names/mappings/os-v2/names/name-v1.0.0.json +3 -0
- invenio_vocabularies/contrib/names/mappings/os-v2/names/name-v2.0.0.json +150 -0
- invenio_vocabularies/contrib/names/mappings/v7/names/name-v1.0.0.json +3 -0
- invenio_vocabularies/contrib/names/names.py +15 -3
- invenio_vocabularies/contrib/names/permissions.py +20 -0
- invenio_vocabularies/contrib/names/s3client.py +44 -0
- invenio_vocabularies/contrib/names/schema.py +14 -0
- invenio_vocabularies/contrib/subjects/config.py +9 -3
- invenio_vocabularies/contrib/subjects/datastreams.py +61 -0
- invenio_vocabularies/contrib/subjects/euroscivoc/__init__.py +9 -0
- invenio_vocabularies/contrib/subjects/euroscivoc/datastreams.py +171 -0
- invenio_vocabularies/contrib/subjects/jsonschemas/subjects/subject-v1.0.0.json +31 -0
- invenio_vocabularies/contrib/subjects/mappings/os-v1/subjects/subject-v1.0.0.json +35 -0
- invenio_vocabularies/contrib/subjects/mappings/os-v2/subjects/subject-v1.0.0.json +35 -0
- invenio_vocabularies/contrib/subjects/mappings/v7/subjects/subject-v1.0.0.json +35 -0
- invenio_vocabularies/contrib/subjects/mesh/__init__.py +9 -0
- invenio_vocabularies/contrib/subjects/mesh/datastreams.py +43 -0
- invenio_vocabularies/contrib/subjects/schema.py +47 -5
- invenio_vocabularies/contrib/subjects/subjects.py +10 -0
- invenio_vocabularies/datastreams/datastreams.py +61 -13
- invenio_vocabularies/datastreams/factories.py +1 -2
- invenio_vocabularies/datastreams/readers.py +138 -29
- invenio_vocabularies/datastreams/tasks.py +37 -0
- invenio_vocabularies/datastreams/transformers.py +17 -27
- invenio_vocabularies/datastreams/writers.py +116 -14
- invenio_vocabularies/datastreams/xml.py +34 -0
- invenio_vocabularies/ext.py +59 -5
- invenio_vocabularies/factories.py +137 -0
- invenio_vocabularies/jobs.py +133 -0
- invenio_vocabularies/proxies.py +2 -2
- invenio_vocabularies/records/jsonschemas/vocabularies/definitions-v1.0.0.json +7 -0
- invenio_vocabularies/records/jsonschemas/vocabularies/vocabulary-v1.0.0.json +1 -4
- invenio_vocabularies/records/mappings/os-v1/vocabularies/vocabulary-v1.0.0.json +3 -3
- invenio_vocabularies/records/mappings/os-v2/vocabularies/vocabulary-v1.0.0.json +3 -3
- invenio_vocabularies/records/mappings/v7/vocabularies/vocabulary-v1.0.0.json +3 -3
- invenio_vocabularies/records/models.py +2 -4
- invenio_vocabularies/records/pidprovider.py +1 -2
- invenio_vocabularies/records/systemfields/relations.py +2 -2
- invenio_vocabularies/resources/__init__.py +9 -1
- invenio_vocabularies/resources/config.py +105 -0
- invenio_vocabularies/resources/resource.py +31 -41
- invenio_vocabularies/resources/schema.py +2 -1
- invenio_vocabularies/services/__init__.py +5 -2
- invenio_vocabularies/services/config.py +179 -0
- invenio_vocabularies/services/custom_fields/__init__.py +6 -2
- invenio_vocabularies/services/custom_fields/subject.py +82 -0
- invenio_vocabularies/services/custom_fields/vocabulary.py +5 -3
- invenio_vocabularies/services/permissions.py +3 -1
- invenio_vocabularies/services/results.py +110 -0
- invenio_vocabularies/services/schema.py +11 -2
- invenio_vocabularies/services/service.py +46 -94
- invenio_vocabularies/services/tasks.py +1 -1
- invenio_vocabularies/templates/semantic-ui/invenio_vocabularies/subjects.html +23 -0
- invenio_vocabularies/templates/semantic-ui/invenio_vocabularies/vocabularies-list.html +12 -0
- invenio_vocabularies/templates/semantic-ui/invenio_vocabularies/vocabulary-details.html +71 -0
- invenio_vocabularies/translations/af/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ar/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/bg/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ca/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/cs/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/da/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/de/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/de_AT/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/de_DE/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/el/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/en/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/en_AT/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/en_HU/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/es/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/es_CU/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/es_MX/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/et/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/et_EE/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/fa/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/fa_IR/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/fr/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/fr_CI/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/fr_FR/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/gl/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/hi_IN/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/hr/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/hu/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/hu_HU/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/it/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ja/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ka/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/lt/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/messages.pot +95 -48
- invenio_vocabularies/translations/ne/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/no/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/pl/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/pt/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ro/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/ru/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/rw/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/sk/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/sv/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/sv_SE/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/tr/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/uk/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/uk_UA/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/zh_CN/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/translations/zh_TW/LC_MESSAGES/messages.mo +0 -0
- invenio_vocabularies/views.py +12 -26
- invenio_vocabularies/webpack.py +3 -3
- {invenio_vocabularies-2.3.1.dist-info → invenio_vocabularies-6.3.1.dist-info}/METADATA +150 -6
- {invenio_vocabularies-2.3.1.dist-info → invenio_vocabularies-6.3.1.dist-info}/RECORD +165 -132
- {invenio_vocabularies-2.3.1.dist-info → invenio_vocabularies-6.3.1.dist-info}/WHEEL +1 -1
- {invenio_vocabularies-2.3.1.dist-info → invenio_vocabularies-6.3.1.dist-info}/entry_points.txt +17 -0
- {invenio_vocabularies-2.3.1.dist-info → invenio_vocabularies-6.3.1.dist-info}/AUTHORS.rst +0 -0
- {invenio_vocabularies-2.3.1.dist-info → invenio_vocabularies-6.3.1.dist-info}/LICENSE +0 -0
- {invenio_vocabularies-2.3.1.dist-info → invenio_vocabularies-6.3.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2021-2024 CERN.
|
|
4
|
+
#
|
|
5
|
+
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
6
|
+
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
7
|
+
# details.
|
|
8
|
+
|
|
9
|
+
"""XML utils."""
|
|
10
|
+
|
|
11
|
+
from collections import defaultdict
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def etree_to_dict(tree):
|
|
15
|
+
"""Convert an ElementTree to a dictionary."""
|
|
16
|
+
tag = tree.tag.split(":")[-1] # strip namespace
|
|
17
|
+
d = {tag: {} if tree.attrib else None}
|
|
18
|
+
children = list(tree)
|
|
19
|
+
if children:
|
|
20
|
+
dd = defaultdict(list)
|
|
21
|
+
for dc in map(etree_to_dict, children):
|
|
22
|
+
for k, v in dc.items():
|
|
23
|
+
dd[k].append(v)
|
|
24
|
+
d = {tag: {k: v[0] if len(v) == 1 else v for k, v in dd.items()}}
|
|
25
|
+
if tree.attrib:
|
|
26
|
+
d[tag].update(("@" + k, v) for k, v in tree.attrib.items())
|
|
27
|
+
if tree.text:
|
|
28
|
+
text = tree.text.strip()
|
|
29
|
+
if children or tree.attrib:
|
|
30
|
+
if text:
|
|
31
|
+
d[tag]["#text"] = text
|
|
32
|
+
else:
|
|
33
|
+
d[tag] = text
|
|
34
|
+
return d
|
invenio_vocabularies/ext.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
#
|
|
3
|
-
# Copyright (C) 2020-
|
|
3
|
+
# Copyright (C) 2020-2024 CERN.
|
|
4
|
+
# Copyright (C) 2023 Graz University of Technology.
|
|
4
5
|
#
|
|
5
6
|
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
6
7
|
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
@@ -39,8 +40,14 @@ from .contrib.subjects import (
|
|
|
39
40
|
SubjectsService,
|
|
40
41
|
SubjectsServiceConfig,
|
|
41
42
|
)
|
|
42
|
-
from .resources
|
|
43
|
-
|
|
43
|
+
from .resources import (
|
|
44
|
+
VocabulariesAdminResource,
|
|
45
|
+
VocabulariesResource,
|
|
46
|
+
VocabulariesResourceConfig,
|
|
47
|
+
VocabularyTypeResourceConfig,
|
|
48
|
+
)
|
|
49
|
+
from .services.config import VocabularyTypesServiceConfig
|
|
50
|
+
from .services.service import VocabulariesService, VocabularyTypeService
|
|
44
51
|
|
|
45
52
|
|
|
46
53
|
class InvenioVocabularies(object):
|
|
@@ -75,6 +82,7 @@ class InvenioVocabularies(object):
|
|
|
75
82
|
funders = FundersServiceConfig
|
|
76
83
|
names = NamesServiceConfig
|
|
77
84
|
subjects = SubjectsServiceConfig
|
|
85
|
+
vocabulary_types = VocabularyTypesServiceConfig
|
|
78
86
|
|
|
79
87
|
return ServiceConfigs
|
|
80
88
|
|
|
@@ -92,9 +100,12 @@ class InvenioVocabularies(object):
|
|
|
92
100
|
self.funders_service = FundersService(config=service_configs.funders)
|
|
93
101
|
self.names_service = NamesService(config=service_configs.names)
|
|
94
102
|
self.subjects_service = SubjectsService(config=service_configs.subjects)
|
|
95
|
-
self.
|
|
103
|
+
self.vocabularies_service = VocabulariesService(
|
|
96
104
|
config=app.config["VOCABULARIES_SERVICE_CONFIG"],
|
|
97
105
|
)
|
|
106
|
+
self.vocabulary_types_service = VocabularyTypeService(
|
|
107
|
+
config=service_configs.vocabulary_types
|
|
108
|
+
)
|
|
98
109
|
|
|
99
110
|
def init_resource(self, app):
|
|
100
111
|
"""Initialize vocabulary resources."""
|
|
@@ -120,6 +131,49 @@ class InvenioVocabularies(object):
|
|
|
120
131
|
config=SubjectsResourceConfig,
|
|
121
132
|
)
|
|
122
133
|
self.resource = VocabulariesResource(
|
|
123
|
-
service=self.
|
|
134
|
+
service=self.vocabularies_service,
|
|
124
135
|
config=app.config["VOCABULARIES_RESOURCE_CONFIG"],
|
|
125
136
|
)
|
|
137
|
+
self.vocabulary_admin_resource = VocabulariesAdminResource(
|
|
138
|
+
service=self.vocabulary_types_service,
|
|
139
|
+
config=VocabularyTypeResourceConfig,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def finalize_app(app):
|
|
144
|
+
"""Finalize app.
|
|
145
|
+
|
|
146
|
+
NOTE: replace former @record_once decorator
|
|
147
|
+
"""
|
|
148
|
+
init(app)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def api_finalize_app(app):
|
|
152
|
+
"""Api Finalize app.
|
|
153
|
+
|
|
154
|
+
NOTE: replace former @record_once decorator
|
|
155
|
+
"""
|
|
156
|
+
init(app)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def init(app):
|
|
160
|
+
"""Init app."""
|
|
161
|
+
# Register services - cannot be done in extension because
|
|
162
|
+
# Invenio-Records-Resources might not have been initialized.
|
|
163
|
+
sregistry = app.extensions["invenio-records-resources"].registry
|
|
164
|
+
ext = app.extensions["invenio-vocabularies"]
|
|
165
|
+
sregistry.register(ext.affiliations_service, service_id="affiliations")
|
|
166
|
+
sregistry.register(ext.awards_service, service_id="awards")
|
|
167
|
+
sregistry.register(ext.funders_service, service_id="funders")
|
|
168
|
+
sregistry.register(ext.names_service, service_id="names")
|
|
169
|
+
sregistry.register(ext.subjects_service, service_id="subjects")
|
|
170
|
+
sregistry.register(ext.vocabularies_service, service_id="vocabularies")
|
|
171
|
+
sregistry.register(ext.vocabulary_types_service, service_id="vocabulary-types")
|
|
172
|
+
# Register indexers
|
|
173
|
+
iregistry = app.extensions["invenio-indexer"].registry
|
|
174
|
+
iregistry.register(ext.affiliations_service.indexer, indexer_id="affiliations")
|
|
175
|
+
iregistry.register(ext.awards_service.indexer, indexer_id="awards")
|
|
176
|
+
iregistry.register(ext.funders_service.indexer, indexer_id="funders")
|
|
177
|
+
iregistry.register(ext.names_service.indexer, indexer_id="names")
|
|
178
|
+
iregistry.register(ext.subjects_service.indexer, indexer_id="subjects")
|
|
179
|
+
iregistry.register(ext.vocabularies_service.indexer, indexer_id="vocabularies")
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2024 CERN.
|
|
4
|
+
# Copyright (C) 2024 KTH Royal Institute of Technology.
|
|
5
|
+
#
|
|
6
|
+
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
7
|
+
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
8
|
+
# details.
|
|
9
|
+
"""Generate Vocabulary Config."""
|
|
10
|
+
|
|
11
|
+
from copy import deepcopy
|
|
12
|
+
|
|
13
|
+
import yaml
|
|
14
|
+
from invenio_records_resources.proxies import current_service_registry
|
|
15
|
+
|
|
16
|
+
from .contrib.affiliations.datastreams import (
|
|
17
|
+
DATASTREAM_CONFIG as affiliations_ds_config,
|
|
18
|
+
)
|
|
19
|
+
from .contrib.affiliations.datastreams import (
|
|
20
|
+
DATASTREAM_CONFIG_OPENAIRE as affiliations_openaire_ds_config,
|
|
21
|
+
)
|
|
22
|
+
from .contrib.awards.datastreams import DATASTREAM_CONFIG as awards_ds_config
|
|
23
|
+
from .contrib.awards.datastreams import (
|
|
24
|
+
DATASTREAM_CONFIG_CORDIS as awards_cordis_ds_config,
|
|
25
|
+
)
|
|
26
|
+
from .contrib.funders.datastreams import DATASTREAM_CONFIG as funders_ds_config
|
|
27
|
+
from .contrib.names.datastreams import DATASTREAM_CONFIG as names_ds_config
|
|
28
|
+
from .contrib.subjects.datastreams import DATASTREAM_CONFIG as subjects_ds_config
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class VocabularyConfig:
|
|
32
|
+
"""Vocabulary Config Factory."""
|
|
33
|
+
|
|
34
|
+
config = None
|
|
35
|
+
vocabulary_name = None
|
|
36
|
+
|
|
37
|
+
def get_config(self, filepath=None, origin=None):
|
|
38
|
+
"""Get the configuration for the vocabulary."""
|
|
39
|
+
config = deepcopy(self.config)
|
|
40
|
+
if filepath:
|
|
41
|
+
with open(filepath, encoding="utf-8") as f:
|
|
42
|
+
config = yaml.safe_load(f).get(self.vocabulary_name)
|
|
43
|
+
if origin:
|
|
44
|
+
config["readers"][0].setdefault("args", {})
|
|
45
|
+
config["readers"][0]["args"]["origin"] = origin
|
|
46
|
+
return config
|
|
47
|
+
|
|
48
|
+
def get_service(self):
|
|
49
|
+
"""Get the service for the vocabulary."""
|
|
50
|
+
return current_service_registry.get(self.vocabulary_name)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class NamesVocabularyConfig(VocabularyConfig):
|
|
54
|
+
"""Names Vocabulary Config."""
|
|
55
|
+
|
|
56
|
+
config = names_ds_config
|
|
57
|
+
vocabulary_name = "names"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class FundersVocabularyConfig(VocabularyConfig):
|
|
61
|
+
"""Funders Vocabulary Config."""
|
|
62
|
+
|
|
63
|
+
config = funders_ds_config
|
|
64
|
+
vocabulary_name = "funders"
|
|
65
|
+
|
|
66
|
+
def get_service(self):
|
|
67
|
+
"""Get the service for the vocabulary."""
|
|
68
|
+
raise NotImplementedError("Service not implemented for Funders")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class SubjectsVocabularyConfig(VocabularyConfig):
|
|
72
|
+
"""Subjects Vocabulary Config."""
|
|
73
|
+
|
|
74
|
+
config = subjects_ds_config
|
|
75
|
+
vocabulary_name = "subjects"
|
|
76
|
+
|
|
77
|
+
def get_service(self):
|
|
78
|
+
"""Get the service for the vocabulary."""
|
|
79
|
+
raise NotImplementedError("Service not implemented for Subjects")
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class AwardsVocabularyConfig(VocabularyConfig):
|
|
83
|
+
"""Awards Vocabulary Config."""
|
|
84
|
+
|
|
85
|
+
config = awards_ds_config
|
|
86
|
+
vocabulary_name = "awards"
|
|
87
|
+
|
|
88
|
+
def get_service(self):
|
|
89
|
+
"""Get the service for the vocabulary."""
|
|
90
|
+
raise NotImplementedError("Service not implemented for Awards")
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class AwardsCordisVocabularyConfig(VocabularyConfig):
|
|
94
|
+
"""Awards Vocabulary Config."""
|
|
95
|
+
|
|
96
|
+
config = awards_cordis_ds_config
|
|
97
|
+
vocabulary_name = "awards:cordis"
|
|
98
|
+
|
|
99
|
+
def get_service(self):
|
|
100
|
+
"""Get the service for the vocabulary."""
|
|
101
|
+
raise NotImplementedError("Service not implemented for CORDIS Awards")
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class AffiliationsVocabularyConfig(VocabularyConfig):
|
|
105
|
+
"""Affiliations Vocabulary Config."""
|
|
106
|
+
|
|
107
|
+
config = affiliations_ds_config
|
|
108
|
+
vocabulary_name = "affiliations"
|
|
109
|
+
|
|
110
|
+
def get_service(self):
|
|
111
|
+
"""Get the service for the vocabulary."""
|
|
112
|
+
raise NotImplementedError("Service not implemented for Affiliations")
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class AffiliationsOpenAIREVocabularyConfig(VocabularyConfig):
|
|
116
|
+
"""OpenAIRE Affiliations Vocabulary Config."""
|
|
117
|
+
|
|
118
|
+
config = affiliations_openaire_ds_config
|
|
119
|
+
vocabulary_name = "affiliations:openaire"
|
|
120
|
+
|
|
121
|
+
def get_service(self):
|
|
122
|
+
"""Get the service for the vocabulary."""
|
|
123
|
+
raise NotImplementedError("Service not implemented for OpenAIRE Affiliations")
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def get_vocabulary_config(vocabulary):
|
|
127
|
+
"""Factory function to get the appropriate Vocabulary Config."""
|
|
128
|
+
vocab_config = {
|
|
129
|
+
"names": NamesVocabularyConfig,
|
|
130
|
+
"funders": FundersVocabularyConfig,
|
|
131
|
+
"awards": AwardsVocabularyConfig,
|
|
132
|
+
"awards:cordis": AwardsCordisVocabularyConfig,
|
|
133
|
+
"affiliations": AffiliationsVocabularyConfig,
|
|
134
|
+
"affiliations:openaire": AffiliationsOpenAIREVocabularyConfig,
|
|
135
|
+
"subjects": SubjectsVocabularyConfig,
|
|
136
|
+
}
|
|
137
|
+
return vocab_config.get(vocabulary, VocabularyConfig)()
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2021-2024 CERN.
|
|
4
|
+
#
|
|
5
|
+
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
6
|
+
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
7
|
+
# details.
|
|
8
|
+
|
|
9
|
+
"""Jobs module."""
|
|
10
|
+
|
|
11
|
+
import datetime
|
|
12
|
+
from datetime import timezone
|
|
13
|
+
|
|
14
|
+
from invenio_i18n import gettext as _
|
|
15
|
+
from invenio_jobs.jobs import JobType
|
|
16
|
+
from marshmallow import Schema, fields
|
|
17
|
+
from marshmallow_utils.fields import TZDateTime
|
|
18
|
+
|
|
19
|
+
from invenio_vocabularies.services.tasks import process_datastream
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ArgsSchema(Schema):
|
|
23
|
+
"""Schema of task input arguments."""
|
|
24
|
+
|
|
25
|
+
since = TZDateTime(
|
|
26
|
+
timezone=timezone.utc,
|
|
27
|
+
format="iso",
|
|
28
|
+
metadata={
|
|
29
|
+
"description": _(
|
|
30
|
+
"YYYY-MM-DD HH:mm format. "
|
|
31
|
+
"Leave field empty if it should continue since last successful run."
|
|
32
|
+
)
|
|
33
|
+
},
|
|
34
|
+
)
|
|
35
|
+
job_arg_schema = fields.String(
|
|
36
|
+
metadata={"type": "hidden"},
|
|
37
|
+
dump_default="ArgsSchema",
|
|
38
|
+
load_default="ArgsSchema",
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ProcessDataStreamJob(JobType):
|
|
43
|
+
"""Generic process data stream job type."""
|
|
44
|
+
|
|
45
|
+
arguments_schema = ArgsSchema
|
|
46
|
+
task = process_datastream
|
|
47
|
+
id = None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class ProcessRORAffiliationsJob(ProcessDataStreamJob):
|
|
51
|
+
"""Process ROR affiliations datastream registered task."""
|
|
52
|
+
|
|
53
|
+
description = "Process ROR affiliations"
|
|
54
|
+
title = "Load ROR affiliations"
|
|
55
|
+
id = "process_ror_affiliations"
|
|
56
|
+
|
|
57
|
+
@classmethod
|
|
58
|
+
def default_args(cls, job_obj, since=None, **kwargs):
|
|
59
|
+
"""Generate default job arguments here."""
|
|
60
|
+
if since is None and job_obj.last_runs["success"]:
|
|
61
|
+
since = job_obj.last_runs["success"].started_at
|
|
62
|
+
else:
|
|
63
|
+
since = since or datetime.datetime.now()
|
|
64
|
+
|
|
65
|
+
# NOTE: Update is set to False for now given we don't have the logic to re-index dependent records yet.
|
|
66
|
+
# Since jobs support custom args, update true can be passed via that.
|
|
67
|
+
return {
|
|
68
|
+
"config": {
|
|
69
|
+
"readers": [
|
|
70
|
+
{
|
|
71
|
+
"args": {"since": str(since)},
|
|
72
|
+
"type": "ror-http",
|
|
73
|
+
},
|
|
74
|
+
{"args": {"regex": "_schema_v2\\.json$"}, "type": "zip"},
|
|
75
|
+
{"type": "json"},
|
|
76
|
+
],
|
|
77
|
+
"writers": [
|
|
78
|
+
{
|
|
79
|
+
"args": {
|
|
80
|
+
"writer": {
|
|
81
|
+
"type": "affiliations-service",
|
|
82
|
+
"args": {"update": False},
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"type": "async",
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"transformers": [{"type": "ror-affiliations"}],
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class ProcessRORFundersJob(ProcessDataStreamJob):
|
|
94
|
+
"""Process ROR funders datastream registered task."""
|
|
95
|
+
|
|
96
|
+
description = "Process ROR funders"
|
|
97
|
+
title = "Load ROR funders"
|
|
98
|
+
id = "process_ror_funders"
|
|
99
|
+
|
|
100
|
+
@classmethod
|
|
101
|
+
def default_args(cls, job_obj, since=None, **kwargs):
|
|
102
|
+
"""Generate default job arguments here."""
|
|
103
|
+
if since is None and job_obj.last_runs["success"]:
|
|
104
|
+
since = job_obj.last_runs["success"].started_at
|
|
105
|
+
else:
|
|
106
|
+
since = since or datetime.datetime.now()
|
|
107
|
+
|
|
108
|
+
# NOTE: Update is set to False for now given we don't have the logic to re-index dependent records yet.
|
|
109
|
+
# Since jobs support custom args, update true can be passed via that.
|
|
110
|
+
return {
|
|
111
|
+
"config": {
|
|
112
|
+
"readers": [
|
|
113
|
+
{
|
|
114
|
+
"args": {"since": str(since)},
|
|
115
|
+
"type": "ror-http",
|
|
116
|
+
},
|
|
117
|
+
{"args": {"regex": "_schema_v2\\.json$"}, "type": "zip"},
|
|
118
|
+
{"type": "json"},
|
|
119
|
+
],
|
|
120
|
+
"writers": [
|
|
121
|
+
{
|
|
122
|
+
"args": {
|
|
123
|
+
"writer": {
|
|
124
|
+
"type": "funders-service",
|
|
125
|
+
"args": {"update": False},
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"type": "async",
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"transformers": [{"type": "ror-funders"}],
|
|
132
|
+
}
|
|
133
|
+
}
|
invenio_vocabularies/proxies.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
#
|
|
3
|
-
# Copyright (C) 2021 CERN.
|
|
3
|
+
# Copyright (C) 2021-2024 CERN.
|
|
4
4
|
# Copyright (C) 2021 Northwestern University.
|
|
5
5
|
#
|
|
6
6
|
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
@@ -19,7 +19,7 @@ def _ext_proxy(attr):
|
|
|
19
19
|
)
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
current_service = _ext_proxy("
|
|
22
|
+
current_service = _ext_proxy("vocabularies_service")
|
|
23
23
|
"""Proxy to the instantiated vocabulary service."""
|
|
24
24
|
|
|
25
25
|
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
},
|
|
82
82
|
"title": {
|
|
83
83
|
"type": "object",
|
|
84
|
-
"dynamic": true,
|
|
84
|
+
"dynamic": "true",
|
|
85
85
|
"properties": {
|
|
86
86
|
"en": {
|
|
87
87
|
"type": "search_as_you_type",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
},
|
|
92
92
|
"description": {
|
|
93
93
|
"type": "object",
|
|
94
|
-
"dynamic": true
|
|
94
|
+
"dynamic": "true"
|
|
95
95
|
},
|
|
96
96
|
"icon": {
|
|
97
97
|
"type": "keyword",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
},
|
|
103
103
|
"props": {
|
|
104
104
|
"type": "object",
|
|
105
|
-
"dynamic": true
|
|
105
|
+
"dynamic": "true"
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
},
|
|
82
82
|
"title": {
|
|
83
83
|
"type": "object",
|
|
84
|
-
"dynamic": true,
|
|
84
|
+
"dynamic": "true",
|
|
85
85
|
"properties": {
|
|
86
86
|
"en": {
|
|
87
87
|
"type": "search_as_you_type",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
},
|
|
92
92
|
"description": {
|
|
93
93
|
"type": "object",
|
|
94
|
-
"dynamic": true
|
|
94
|
+
"dynamic": "true"
|
|
95
95
|
},
|
|
96
96
|
"icon": {
|
|
97
97
|
"type": "keyword",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
},
|
|
103
103
|
"props": {
|
|
104
104
|
"type": "object",
|
|
105
|
-
"dynamic": true
|
|
105
|
+
"dynamic": "true"
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
},
|
|
82
82
|
"title": {
|
|
83
83
|
"type": "object",
|
|
84
|
-
"dynamic": true,
|
|
84
|
+
"dynamic": "true",
|
|
85
85
|
"properties": {
|
|
86
86
|
"en": {
|
|
87
87
|
"type": "search_as_you_type",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
},
|
|
92
92
|
"description": {
|
|
93
93
|
"type": "object",
|
|
94
|
-
"dynamic": true
|
|
94
|
+
"dynamic": "true"
|
|
95
95
|
},
|
|
96
96
|
"icon": {
|
|
97
97
|
"type": "keyword",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
},
|
|
103
103
|
"props": {
|
|
104
104
|
"type": "object",
|
|
105
|
-
"dynamic": true
|
|
105
|
+
"dynamic": "true"
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
#
|
|
3
|
-
# Copyright (C) 2020-
|
|
3
|
+
# Copyright (C) 2020-2024 CERN.
|
|
4
4
|
#
|
|
5
5
|
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
6
6
|
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
@@ -79,9 +79,7 @@ class VocabularyScheme(db.Model):
|
|
|
79
79
|
"""Create a new vocabulary subtype."""
|
|
80
80
|
banned = [",", ":"]
|
|
81
81
|
for b in banned:
|
|
82
|
-
assert
|
|
83
|
-
b not in data["id"]
|
|
84
|
-
), f"No '{b}' allowed in VocabularyScheme.id" # noqa
|
|
82
|
+
assert b not in data["id"], f"No '{b}' allowed in VocabularyScheme.id"
|
|
85
83
|
|
|
86
84
|
with db.session.begin_nested():
|
|
87
85
|
obj = cls(**data)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
#
|
|
3
|
-
# Copyright (C) 2021 CERN.
|
|
3
|
+
# Copyright (C) 2021-2024 CERN.
|
|
4
4
|
#
|
|
5
5
|
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
6
6
|
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
|
|
9
9
|
"""Persistent identifier provider for vocabularies."""
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
from invenio_pidstore.models import PIDStatus
|
|
13
12
|
from invenio_pidstore.providers.base import BaseProvider
|
|
14
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
#
|
|
3
|
-
# Copyright (C) 2022 CERN.
|
|
3
|
+
# Copyright (C) 2022-2024 CERN.
|
|
4
4
|
#
|
|
5
5
|
# Invenio-Records-Resources is free software; you can redistribute it and/or
|
|
6
6
|
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
@@ -38,7 +38,7 @@ class CustomFieldsRelation(RelationsField):
|
|
|
38
38
|
relations[cf.name] = cf.relation_cls(
|
|
39
39
|
f"custom_fields.{cf.name}",
|
|
40
40
|
keys=cf.field_keys,
|
|
41
|
-
pid_field=
|
|
41
|
+
pid_field=cf.pid_field,
|
|
42
42
|
cache_key=cf.vocabulary_id,
|
|
43
43
|
)
|
|
44
44
|
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
#
|
|
3
|
-
# Copyright (C) 2020-
|
|
3
|
+
# Copyright (C) 2020-2024 CERN.
|
|
4
4
|
#
|
|
5
5
|
# Invenio-Vocabularies is free software; you can redistribute it and/or
|
|
6
6
|
# modify it under the terms of the MIT License; see LICENSE file for more
|
|
7
7
|
# details.
|
|
8
8
|
|
|
9
9
|
"""Resources module."""
|
|
10
|
+
|
|
10
11
|
from invenio_vocabularies.resources.schema import L10NString, VocabularyL10Schema
|
|
11
12
|
|
|
13
|
+
from .config import VocabulariesResourceConfig, VocabularyTypeResourceConfig
|
|
14
|
+
from .resource import VocabulariesAdminResource, VocabulariesResource
|
|
15
|
+
|
|
12
16
|
__all__ = (
|
|
13
17
|
"VocabularyL10Schema",
|
|
14
18
|
"L10NString",
|
|
19
|
+
"VocabulariesResourceConfig",
|
|
20
|
+
"VocabularyTypeResourceConfig",
|
|
21
|
+
"VocabulariesAdminResource",
|
|
22
|
+
"VocabulariesResource",
|
|
15
23
|
)
|