From dda850dfc45974b0ad51369573c5cc7299046c5e Mon Sep 17 00:00:00 2001 From: Juraj Trappl Date: Wed, 16 Oct 2024 21:35:39 +0200 Subject: [PATCH 1/6] Trappl/be 491 model builder oai section component (#274) * add new builtin component * add that component to setup * bump version * add oai section component test to doi --- oarepo_model_builder/builtin_models/oaipmh.json | 9 +++++++++ setup.cfg | 3 ++- .../{test_include_doi.py => test_include_components.py} | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 oarepo_model_builder/builtin_models/oaipmh.json rename tests/{test_include_doi.py => test_include_components.py} (85%) diff --git a/oarepo_model_builder/builtin_models/oaipmh.json b/oarepo_model_builder/builtin_models/oaipmh.json new file mode 100644 index 0000000..d2c389a --- /dev/null +++ b/oarepo_model_builder/builtin_models/oaipmh.json @@ -0,0 +1,9 @@ +{ + "service-config": { + "extend:components": [ + "{{oarepo_oaipmh_harvester.components.OaiSectionComponent}}" + ] + } + } + + \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index e1fc583..a227712 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = oarepo-model-builder -version = 4.0.92 +version = 4.0.93 description = A utility library that generates OARepo required data model files from a JSON specification file authors = Miroslav Bauer , Miroslav Simek readme = README.md @@ -94,6 +94,7 @@ oarepo_model_builder.datatypes.components = oarepo.models = invenio = oarepo_model_builder.builtin_models:invenio.json doi = oarepo_model_builder.builtin_models:doi.json + oaipmh = oarepo_model_builder.builtin_models:oaipmh.json # outputs are generic, profile independent oarepo_model_builder.outputs = diff --git a/tests/test_include_doi.py b/tests/test_include_components.py similarity index 85% rename from tests/test_include_doi.py rename to tests/test_include_components.py index 62e4e1e..e7b5a2b 100644 --- a/tests/test_include_doi.py +++ b/tests/test_include_components.py @@ -18,7 +18,7 @@ def test_include_invenio(): "record": { "module": {"qualified": "test"}, - OAREPO_USE: ["invenio", "doi"], + OAREPO_USE: ["invenio", "doi", "oaipmh"], "properties": {"a": {"type": "keyword", "required": True}}, }, }, @@ -36,4 +36,4 @@ def test_include_invenio(): os.path.join("test", "services", "records", "config.py") ).read() data = str(data) - assert "components=[*PermissionsPresetsConfigMixin.components,*InvenioRecordServiceConfig.components,DoiComponent]" in re.sub(r"\s", "", data) \ No newline at end of file + assert "components=[*PermissionsPresetsConfigMixin.components,*InvenioRecordServiceConfig.components,DoiComponent,OaiSectionComponent]" in re.sub(r"\s", "", data) \ No newline at end of file From de81c98ea5cf33b36ef542fdb39f32b90304c567 Mon Sep 17 00:00:00 2001 From: Juraj Trappl Date: Thu, 31 Oct 2024 11:29:47 +0100 Subject: [PATCH 2/6] added oai object required fields --- .../builtin_models/oaipmh.json | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/oarepo_model_builder/builtin_models/oaipmh.json b/oarepo_model_builder/builtin_models/oaipmh.json index d2c389a..3037af2 100644 --- a/oarepo_model_builder/builtin_models/oaipmh.json +++ b/oarepo_model_builder/builtin_models/oaipmh.json @@ -1,9 +1,31 @@ { - "service-config": { - "extend:components": [ - "{{oarepo_oaipmh_harvester.components.OaiSectionComponent}}" - ] + "properties": { + "oai": { + "properties": { + "harvest": { + "properties": { + "identifier": { + "type": "keyword", + "label": { + "cs": "OAI identifikátor", + "en": "OAI identifier" + } + }, + "datestamp": { + "type": "keyword", + "label": { + "cs": "Datum poslední změny", + "en": "Datestamp" + } + } + } + } + } } + }, + "service-config": { + "extend:components": [ + "{{oarepo_oaipmh_harvester.components.OaiSectionComponent}}" + ] } - - \ No newline at end of file +} \ No newline at end of file From d6c9bf7861a2b26fdbb067c33132e5e4d65cc54f Mon Sep 17 00:00:00 2001 From: Juraj Trappl Date: Thu, 31 Oct 2024 11:29:53 +0100 Subject: [PATCH 3/6] version bump --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index a227712..e353fcd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = oarepo-model-builder -version = 4.0.93 +version = 4.0.94 description = A utility library that generates OARepo required data model files from a JSON specification file authors = Miroslav Bauer , Miroslav Simek readme = README.md From 4d100541f46f0993ae30cbf7a717fab560994d09 Mon Sep 17 00:00:00 2001 From: Juraj Trappl Date: Thu, 31 Oct 2024 12:09:22 +0100 Subject: [PATCH 4/6] added harvest properties --- tests/test_include_components.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/test_include_components.py b/tests/test_include_components.py index e7b5a2b..27307db 100644 --- a/tests/test_include_components.py +++ b/tests/test_include_components.py @@ -9,17 +9,23 @@ OAREPO_USE = "use" - def test_include_invenio(): schema = load_model( "test.yaml", # NOSONAR model_content={ "version": "1.0.0", - "record": { "module": {"qualified": "test"}, OAREPO_USE: ["invenio", "doi", "oaipmh"], - "properties": {"a": {"type": "keyword", "required": True}}, + "properties": { + "a": {"type": "keyword", "required": True}, + "harvest": { + "properties": { + "identifier": "oai:invenio.nusl.cz:203122", + "datestamp": "2024-07-17T07:04:25Z" + } + }, + }, }, }, isort=False, @@ -36,4 +42,7 @@ def test_include_invenio(): os.path.join("test", "services", "records", "config.py") ).read() data = str(data) - assert "components=[*PermissionsPresetsConfigMixin.components,*InvenioRecordServiceConfig.components,DoiComponent,OaiSectionComponent]" in re.sub(r"\s", "", data) \ No newline at end of file + assert ( + "components=[*PermissionsPresetsConfigMixin.components,*InvenioRecordServiceConfig.components,DoiComponent,OaiSectionComponent]" + in re.sub(r"\s", "", data) + ) From 903315fdaefd718dc247931cc5405895fdf7ea03 Mon Sep 17 00:00:00 2001 From: Juraj Trappl Date: Thu, 31 Oct 2024 12:12:15 +0100 Subject: [PATCH 5/6] removed labels --- oarepo_model_builder/builtin_models/oaipmh.json | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/oarepo_model_builder/builtin_models/oaipmh.json b/oarepo_model_builder/builtin_models/oaipmh.json index 3037af2..b2d3f38 100644 --- a/oarepo_model_builder/builtin_models/oaipmh.json +++ b/oarepo_model_builder/builtin_models/oaipmh.json @@ -5,18 +5,10 @@ "harvest": { "properties": { "identifier": { - "type": "keyword", - "label": { - "cs": "OAI identifikátor", - "en": "OAI identifier" - } + "type": "keyword" }, "datestamp": { - "type": "keyword", - "label": { - "cs": "Datum poslední změny", - "en": "Datestamp" - } + "type": "keyword" } } } From 815719d6bb2793d8da40abd541b4dedf8b97e098 Mon Sep 17 00:00:00 2001 From: Juraj Trappl Date: Thu, 31 Oct 2024 14:57:46 +0100 Subject: [PATCH 6/6] removed labels for now --- oarepo_model_builder/builtin_models/oaipmh.json | 7 +++++-- tests/test_include_components.py | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/oarepo_model_builder/builtin_models/oaipmh.json b/oarepo_model_builder/builtin_models/oaipmh.json index b2d3f38..ff6ca79 100644 --- a/oarepo_model_builder/builtin_models/oaipmh.json +++ b/oarepo_model_builder/builtin_models/oaipmh.json @@ -5,10 +5,13 @@ "harvest": { "properties": { "identifier": { - "type": "keyword" + "type": "keyword", + "required": true }, "datestamp": { - "type": "keyword" + "type": "keyword", + "required": true + } } } diff --git a/tests/test_include_components.py b/tests/test_include_components.py index 27307db..b740165 100644 --- a/tests/test_include_components.py +++ b/tests/test_include_components.py @@ -21,8 +21,14 @@ def test_include_invenio(): "a": {"type": "keyword", "required": True}, "harvest": { "properties": { - "identifier": "oai:invenio.nusl.cz:203122", - "datestamp": "2024-07-17T07:04:25Z" + "identifier": { + "type": "keyword", + "required": True + }, + "datestamp": { + "type": "keyword", + "required": True + }, } }, },