diff --git a/models/nr-documents/harvest.yaml b/models/nr-documents/harvest.yaml new file mode 100644 index 00000000..79faf9c8 --- /dev/null +++ b/models/nr-documents/harvest.yaml @@ -0,0 +1,16 @@ +properties: + oai: + properties: + harvest: + properties: + identifier: + type: keyword + label.cs: OAI identifikátor + label.en: OAI identifier + datestamp: + type: keyword + label.cs: Datum poslední změny + label.en: Datestamp +service-config: + components: + - "{{invenio_records_resources.services.records.components.DataComponent}}" \ No newline at end of file diff --git a/models/nr-documents/model.yaml b/models/nr-documents/model.yaml index a50afdb5..ebac190d 100644 --- a/models/nr-documents/model.yaml +++ b/models/nr-documents/model.yaml @@ -41,6 +41,7 @@ record: - invenio - ./custom_fields.yaml - ./requests.yaml + - ./harvest.yaml plugins: builder: disable: diff --git a/models/nr-documents/nr_documents/models/records.json b/models/nr-documents/nr_documents/models/records.json index 07b1fd17..c5d4d69c 100644 --- a/models/nr-documents/nr_documents/models/records.json +++ b/models/nr-documents/nr_documents/models/records.json @@ -5730,6 +5730,46 @@ } } }, + "oai": { + "type": "object", + "marshmallow": { + "generate": true, + "class": "nr_documents.services.records.schema.OaiSchema" + }, + "ui": { + "marshmallow": { + "generate": true, + "class": "nr_documents.services.records.ui_schema.OaiUISchema" + } + }, + "properties": { + "harvest": { + "type": "object", + "marshmallow": { + "generate": true, + "class": "nr_documents.services.records.schema.HarvestSchema" + }, + "ui": { + "marshmallow": { + "generate": true, + "class": "nr_documents.services.records.ui_schema.HarvestUISchema" + } + }, + "properties": { + "datestamp": { + "type": "keyword", + "label.cs": "Datum poslední změny", + "label.en": "Datestamp" + }, + "identifier": { + "type": "keyword", + "label.cs": "OAI identifikátor", + "label.en": "OAI identifier" + } + } + } + } + }, "syntheticFields": { "type": "object", "marshmallow": { diff --git a/models/nr-documents/nr_documents/models/ui.json b/models/nr-documents/nr_documents/models/ui.json index 86b76567..e17bd3bf 100644 --- a/models/nr-documents/nr_documents/models/ui.json +++ b/models/nr-documents/nr_documents/models/ui.json @@ -1952,6 +1952,40 @@ } } }, + "oai": { + "detail": false, + "input": false, + "help": "oai.help", + "label": "oai.label", + "hint": "oai.hint", + "children": { + "harvest": { + "detail": false, + "input": false, + "help": "oai/harvest.help", + "label": "oai/harvest.label", + "hint": "oai/harvest.hint", + "children": { + "datestamp": { + "detail": "keyword", + "input": "keyword", + "help": "oai/harvest/datestamp.help", + "label": "oai/harvest/datestamp.label", + "hint": "oai/harvest/datestamp.hint", + "facet": "oai_harvest_datestamp" + }, + "identifier": { + "detail": "keyword", + "input": "keyword", + "help": "oai/harvest/identifier.help", + "label": "oai/harvest/identifier.label", + "hint": "oai/harvest/identifier.hint", + "facet": "oai_harvest_identifier" + } + } + } + } + }, "syntheticFields": { "detail": "syntheticfield", "input": "syntheticfield", diff --git a/models/nr-documents/nr_documents/records/jsonschemas/nr_documents-1.0.0.json b/models/nr-documents/nr_documents/records/jsonschemas/nr_documents-1.0.0.json index f142a6e1..d2009ae0 100644 --- a/models/nr-documents/nr_documents/records/jsonschemas/nr_documents-1.0.0.json +++ b/models/nr-documents/nr_documents/records/jsonschemas/nr_documents-1.0.0.json @@ -847,6 +847,22 @@ } } }, + "oai": { + "type": "object", + "properties": { + "harvest": { + "type": "object", + "properties": { + "datestamp": { + "type": "string" + }, + "identifier": { + "type": "string" + } + } + } + } + }, "syntheticFields": { "type": "object", "properties": { diff --git a/models/nr-documents/nr_documents/records/mappings/os-v2/nr_documents/nr_documents-1.0.0.json b/models/nr-documents/nr_documents/records/mappings/os-v2/nr_documents/nr_documents-1.0.0.json index 98e9918e..da3888ff 100644 --- a/models/nr-documents/nr_documents/records/mappings/os-v2/nr_documents/nr_documents-1.0.0.json +++ b/models/nr-documents/nr_documents/records/mappings/os-v2/nr_documents/nr_documents-1.0.0.json @@ -1148,6 +1148,24 @@ } } }, + "oai": { + "type": "object", + "properties": { + "harvest": { + "type": "object", + "properties": { + "datestamp": { + "type": "keyword", + "ignore_above": 1024 + }, + "identifier": { + "type": "keyword", + "ignore_above": 1024 + } + } + } + } + }, "syntheticFields": { "type": "object", "properties": { diff --git a/models/nr-documents/nr_documents/records/mappings/os-v2/nr_documents/nr_documents_draft-1.0.0.json b/models/nr-documents/nr_documents/records/mappings/os-v2/nr_documents/nr_documents_draft-1.0.0.json index d829814d..4e492ad5 100644 --- a/models/nr-documents/nr_documents/records/mappings/os-v2/nr_documents/nr_documents_draft-1.0.0.json +++ b/models/nr-documents/nr_documents/records/mappings/os-v2/nr_documents/nr_documents_draft-1.0.0.json @@ -1148,6 +1148,24 @@ } } }, + "oai": { + "type": "object", + "properties": { + "harvest": { + "type": "object", + "properties": { + "datestamp": { + "type": "keyword", + "ignore_above": 1024 + }, + "identifier": { + "type": "keyword", + "ignore_above": 1024 + } + } + } + } + }, "syntheticFields": { "type": "object", "properties": { diff --git a/models/nr-documents/nr_documents/records/requests/delete_record/types.py b/models/nr-documents/nr_documents/records/requests/delete_record/types.py index 30138eb4..55a020ad 100644 --- a/models/nr-documents/nr_documents/records/requests/delete_record/types.py +++ b/models/nr-documents/nr_documents/records/requests/delete_record/types.py @@ -18,4 +18,3 @@ class DeleteRecordRequestType(DeleteRecordRequestType): # {"record": {pid}} as reference value. This reference is then by # setattr set on the Request record topic ReferencedEntityField, and the set # operation checks, whether this key is in allowed_topic_ref_types - # TODO would it make sense to customize the topic ref types? diff --git a/models/nr-documents/nr_documents/records/requests/publish_draft/types.py b/models/nr-documents/nr_documents/records/requests/publish_draft/types.py index 3fc7206d..6cae8689 100644 --- a/models/nr-documents/nr_documents/records/requests/publish_draft/types.py +++ b/models/nr-documents/nr_documents/records/requests/publish_draft/types.py @@ -18,4 +18,3 @@ class PublishDraftRequestType(PublishDraftRequestType): # {"record": {pid}} as reference value. This reference is then by # setattr set on the Request record topic ReferencedEntityField, and the set # operation checks, whether this key is in allowed_topic_ref_types - # TODO would it make sense to customize the topic ref types? diff --git a/models/nr-documents/nr_documents/services/records/facets.py b/models/nr-documents/nr_documents/services/records/facets.py index 44e64dd5..ae82ccfd 100644 --- a/models/nr-documents/nr_documents/services/records/facets.py +++ b/models/nr-documents/nr_documents/services/records/facets.py @@ -492,6 +492,14 @@ field="metadata.version", label=_("metadata/version.label") ) +oai_harvest_datestamp = TermsFacet( + field="oai.harvest.datestamp", label=_("oai/harvest/datestamp.label") +) + +oai_harvest_identifier = TermsFacet( + field="oai.harvest.identifier", label=_("oai/harvest/identifier.label") +) + syntheticFields_institutions = TermsFacet( field="syntheticFields.institutions", label=_("syntheticFields/institutions.label") ) diff --git a/models/nr-documents/nr_documents/services/records/schema.py b/models/nr-documents/nr_documents/services/records/schema.py index 311a7010..553adcee 100644 --- a/models/nr-documents/nr_documents/services/records/schema.py +++ b/models/nr-documents/nr_documents/services/records/schema.py @@ -102,6 +102,16 @@ def pop_publish_draft_if_none(self, data, many, **kwargs): return data +class NrDocumentsSchema(NRDocumentRecordSchema): + class Meta: + unknown = ma.RAISE + + oai = ma_fields.Nested(lambda: OaiSchema()) + + syntheticFields = ma_fields.Nested(lambda: SyntheticFieldsSchema()) + parent = ma.fields.Nested(GeneratedParentSchema) + + class GeoLocationsItemSchema(NRGeoLocationSchema): class Meta: unknown = ma.RAISE @@ -128,12 +138,11 @@ class Meta: thesis = ma_fields.Nested(lambda: ThesisSchema()) -class NrDocumentsSchema(NRDocumentRecordSchema): +class OaiSchema(Schema): class Meta: unknown = ma.RAISE - syntheticFields = ma_fields.Nested(lambda: SyntheticFieldsSchema()) - parent = ma.fields.Nested(GeneratedParentSchema) + harvest = ma_fields.Nested(lambda: HarvestSchema()) class RelatedItemsItemSchema(NRRelatedItemSchema): @@ -251,6 +260,15 @@ class Meta: unknown = ma.RAISE +class HarvestSchema(Schema): + class Meta: + unknown = ma.RAISE + + datestamp = ma_fields.String() + + identifier = ma_fields.String() + + class ItemContributorsItemSchema(NRRelatedItemContributorSchema): class Meta: unknown = ma.RAISE diff --git a/models/nr-documents/nr_documents/services/records/search.py b/models/nr-documents/nr_documents/services/records/search.py index 4878e033..40cf6278 100644 --- a/models/nr-documents/nr_documents/services/records/search.py +++ b/models/nr-documents/nr_documents/services/records/search.py @@ -170,6 +170,8 @@ class NrDocumentsSearchOptions(I18nSearchOptions): "metadata_thesis_studyFields": facets.metadata_thesis_studyFields, "metadata_title": facets.metadata_title, "metadata_version": facets.metadata_version, + "oai_harvest_datestamp": facets.oai_harvest_datestamp, + "oai_harvest_identifier": facets.oai_harvest_identifier, "syntheticFields_institutions": facets.syntheticFields_institutions, "syntheticFields_keywords_cs": facets.syntheticFields_keywords_cs, "syntheticFields_keywords_en": facets.syntheticFields_keywords_en, diff --git a/models/nr-documents/nr_documents/services/records/ui_schema.py b/models/nr-documents/nr_documents/services/records/ui_schema.py index c624f1ab..59329388 100644 --- a/models/nr-documents/nr_documents/services/records/ui_schema.py +++ b/models/nr-documents/nr_documents/services/records/ui_schema.py @@ -106,6 +106,16 @@ def pop_publish_draft_if_none(self, data, many, **kwargs): return data +class NrDocumentsUISchema(NRDocumentRecordUISchema): + class Meta: + unknown = ma.RAISE + + oai = ma_fields.Nested(lambda: OaiUISchema()) + + syntheticFields = ma_fields.Nested(lambda: SyntheticFieldsUISchema()) + parent = ma.fields.Nested(GeneratedParentSchema) + + class GeoLocationsItemUISchema(NRGeoLocationUISchema): class Meta: unknown = ma.RAISE @@ -130,12 +140,11 @@ class Meta: thesis = ma_fields.Nested(lambda: ThesisUISchema()) -class NrDocumentsUISchema(NRDocumentRecordUISchema): +class OaiUISchema(Schema): class Meta: unknown = ma.RAISE - syntheticFields = ma_fields.Nested(lambda: SyntheticFieldsUISchema()) - parent = ma.fields.Nested(GeneratedParentSchema) + harvest = ma_fields.Nested(lambda: HarvestUISchema()) class RelatedItemsItemUISchema(NRRelatedItemUISchema): @@ -253,6 +262,15 @@ class Meta: unknown = ma.RAISE +class HarvestUISchema(Schema): + class Meta: + unknown = ma.RAISE + + datestamp = ma_fields.String() + + identifier = ma_fields.String() + + class ItemContributorsItemUISchema(NRRelatedItemContributorUISchema): class Meta: unknown = ma.RAISE diff --git a/models/nr-documents/nr_documents/translations/cs/LC_MESSAGES/messages.mo b/models/nr-documents/nr_documents/translations/cs/LC_MESSAGES/messages.mo index b4baed15..b242e145 100644 Binary files a/models/nr-documents/nr_documents/translations/cs/LC_MESSAGES/messages.mo and b/models/nr-documents/nr_documents/translations/cs/LC_MESSAGES/messages.mo differ diff --git a/models/nr-documents/nr_documents/translations/cs/LC_MESSAGES/messages.po b/models/nr-documents/nr_documents/translations/cs/LC_MESSAGES/messages.po index 92a7d0c9..43b4e0a0 100644 --- a/models/nr-documents/nr_documents/translations/cs/LC_MESSAGES/messages.po +++ b/models/nr-documents/nr_documents/translations/cs/LC_MESSAGES/messages.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: 1.0\n" -"POT-Creation-Date: 2023-11-02T09:17:40.420744\n" -"PO-Revision-Date: 2023-11-02T09:17:40.420755\n" +"POT-Creation-Date: 2023-11-13T08:42:04.454823\n" +"PO-Revision-Date: 2023-11-13T08:42:04.454834\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -1869,6 +1869,42 @@ msgstr "" msgid "metadata/version.hint" msgstr "" +msgid "oai.help" +msgstr "" + +msgid "oai.label" +msgstr "" + +msgid "oai.hint" +msgstr "" + +msgid "oai/harvest.help" +msgstr "" + +msgid "oai/harvest.label" +msgstr "" + +msgid "oai/harvest.hint" +msgstr "" + +msgid "oai/harvest/datestamp.label" +msgstr "Datum poslední změny" + +msgid "oai/harvest/datestamp.help" +msgstr "" + +msgid "oai/harvest/datestamp.hint" +msgstr "" + +msgid "oai/harvest/identifier.label" +msgstr "OAI identifikátor" + +msgid "oai/harvest/identifier.help" +msgstr "" + +msgid "oai/harvest/identifier.hint" +msgstr "" + msgid "syntheticFields.help" msgstr "" diff --git a/models/nr-documents/nr_documents/translations/en/LC_MESSAGES/messages.mo b/models/nr-documents/nr_documents/translations/en/LC_MESSAGES/messages.mo index 7b3cdfe6..980c42d2 100644 Binary files a/models/nr-documents/nr_documents/translations/en/LC_MESSAGES/messages.mo and b/models/nr-documents/nr_documents/translations/en/LC_MESSAGES/messages.mo differ diff --git a/models/nr-documents/nr_documents/translations/en/LC_MESSAGES/messages.po b/models/nr-documents/nr_documents/translations/en/LC_MESSAGES/messages.po index 14c85d7f..e51ddd98 100644 --- a/models/nr-documents/nr_documents/translations/en/LC_MESSAGES/messages.po +++ b/models/nr-documents/nr_documents/translations/en/LC_MESSAGES/messages.po @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: 1.0\n" -"POT-Creation-Date: 2023-11-02T09:17:40.420776\n" -"PO-Revision-Date: 2023-11-02T09:17:40.420778\n" +"POT-Creation-Date: 2023-11-13T08:42:04.454856\n" +"PO-Revision-Date: 2023-11-13T08:42:04.454857\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -1869,6 +1869,42 @@ msgstr "" msgid "metadata/version.hint" msgstr "" +msgid "oai.help" +msgstr "" + +msgid "oai.label" +msgstr "" + +msgid "oai.hint" +msgstr "" + +msgid "oai/harvest.help" +msgstr "" + +msgid "oai/harvest.label" +msgstr "" + +msgid "oai/harvest.hint" +msgstr "" + +msgid "oai/harvest/datestamp.label" +msgstr "Datestamp" + +msgid "oai/harvest/datestamp.help" +msgstr "" + +msgid "oai/harvest/datestamp.hint" +msgstr "" + +msgid "oai/harvest/identifier.label" +msgstr "OAI identifier" + +msgid "oai/harvest/identifier.help" +msgstr "" + +msgid "oai/harvest/identifier.hint" +msgstr "" + msgid "syntheticFields.help" msgstr "" diff --git a/models/nr-documents/nr_documents/translations/messages.pot b/models/nr-documents/nr_documents/translations/messages.pot index 5290ff7f..c8d27641 100644 --- a/models/nr-documents/nr_documents/translations/messages.pot +++ b/models/nr-documents/nr_documents/translations/messages.pot @@ -2,8 +2,8 @@ msgid "" msgstr "" "Project-Id-Version: 1.0\n" -"POT-Creation-Date: 2023-11-02T09:17:40.420793\n" -"PO-Revision-Date: 2023-11-02T09:17:40.420794\n" +"POT-Creation-Date: 2023-11-13T08:42:04.454874\n" +"PO-Revision-Date: 2023-11-13T08:42:04.454875\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -1859,6 +1859,42 @@ msgstr "" msgid "metadata/version.hint" msgstr "" +msgid "oai.help" +msgstr "" + +msgid "oai.label" +msgstr "" + +msgid "oai.hint" +msgstr "" + +msgid "oai/harvest.help" +msgstr "" + +msgid "oai/harvest.label" +msgstr "" + +msgid "oai/harvest.hint" +msgstr "" + +msgid "oai/harvest/datestamp.label" +msgstr "" + +msgid "oai/harvest/datestamp.help" +msgstr "" + +msgid "oai/harvest/datestamp.hint" +msgstr "" + +msgid "oai/harvest/identifier.label" +msgstr "" + +msgid "oai/harvest/identifier.help" +msgstr "" + +msgid "oai/harvest/identifier.hint" +msgstr "" + msgid "syntheticFields.help" msgstr "" diff --git a/models/nr-documents/tests/test_resource.py b/models/nr-documents/tests/test_resource.py index 5937890b..461a0319 100644 --- a/models/nr-documents/tests/test_resource.py +++ b/models/nr-documents/tests/test_resource.py @@ -98,12 +98,10 @@ def test_create( f"{base_urls['base_url']}", json=sample_metadata_point ) assert response_code_ok("create", False, unauth_response, 201) - assert all( - [ - response_code_ok("create", True, new_response, 201) - for new_response in created_responses - ] - ) + assert all([ + response_code_ok("create", True, new_response, 201) + for new_response in created_responses + ]) if is_action_allowed("create", True): for sample_metadata_point, created_response in zip(