From 0a560e318b408e7b7fd1c0900d4ad07c2a944f85 Mon Sep 17 00:00:00 2001 From: jrcastro2 Date: Fri, 6 Sep 2024 09:12:22 +0200 Subject: [PATCH] global: add deprecation mechanism * closes https://github.com/CERNDocumentServer/cds-rdm/issues/194 --- .../affiliations/affiliation-v1.0.0.json | 9 +++++++++ .../os-v1/affiliations/affiliation-v2.0.0.json | 9 +++++++++ .../os-v2/affiliations/affiliation-v2.0.0.json | 9 +++++++++ .../awards/jsonschemas/awards/award-v1.0.0.json | 9 +++++++++ .../awards/mappings/os-v1/awards/award-v1.0.0.json | 9 +++++++++ .../awards/mappings/os-v2/awards/award-v1.0.0.json | 9 +++++++++ .../funders/jsonschemas/funders/funder-v1.0.0.json | 9 +++++++++ .../mappings/os-v1/funders/funder-v2.0.0.json | 9 +++++++++ .../mappings/os-v2/funders/funder-v2.0.0.json | 9 +++++++++ .../names/jsonschemas/names/name-v1.0.0.json | 9 +++++++++ .../names/mappings/os-v1/names/name-v2.0.0.json | 9 +++++++++ .../names/mappings/os-v2/names/name-v2.0.0.json | 9 +++++++++ invenio_vocabularies/contrib/names/services.py | 13 +++++++++++++ .../jsonschemas/subjects/subject-v1.0.0.json | 9 +++++++++ .../mappings/os-v1/subjects/subject-v1.0.0.json | 9 +++++++++ .../mappings/os-v2/subjects/subject-v1.0.0.json | 9 +++++++++ .../jsonschemas/vocabularies/vocabulary-v1.0.0.json | 9 +++++++++ .../os-v1/vocabularies/vocabulary-v1.0.0.json | 9 +++++++++ .../os-v2/vocabularies/vocabulary-v1.0.0.json | 9 +++++++++ invenio_vocabularies/services/schema.py | 3 +++ 20 files changed, 178 insertions(+) diff --git a/invenio_vocabularies/contrib/affiliations/jsonschemas/affiliations/affiliation-v1.0.0.json b/invenio_vocabularies/contrib/affiliations/jsonschemas/affiliations/affiliation-v1.0.0.json index 81e24973..13fe2638 100644 --- a/invenio_vocabularies/contrib/affiliations/jsonschemas/affiliations/affiliation-v1.0.0.json +++ b/invenio_vocabularies/contrib/affiliations/jsonschemas/affiliations/affiliation-v1.0.0.json @@ -58,6 +58,15 @@ }, "title": { "$ref": "local://vocabularies/definitions-v1.0.0.json#/title" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "array" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/affiliations/mappings/os-v1/affiliations/affiliation-v2.0.0.json b/invenio_vocabularies/contrib/affiliations/mappings/os-v1/affiliations/affiliation-v2.0.0.json index dae943df..bdeaa0bd 100644 --- a/invenio_vocabularies/contrib/affiliations/mappings/os-v1/affiliations/affiliation-v2.0.0.json +++ b/invenio_vocabularies/contrib/affiliations/mappings/os-v1/affiliations/affiliation-v2.0.0.json @@ -165,6 +165,15 @@ }, "types": { "type": "keyword" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/affiliations/mappings/os-v2/affiliations/affiliation-v2.0.0.json b/invenio_vocabularies/contrib/affiliations/mappings/os-v2/affiliations/affiliation-v2.0.0.json index dae943df..bdeaa0bd 100644 --- a/invenio_vocabularies/contrib/affiliations/mappings/os-v2/affiliations/affiliation-v2.0.0.json +++ b/invenio_vocabularies/contrib/affiliations/mappings/os-v2/affiliations/affiliation-v2.0.0.json @@ -165,6 +165,15 @@ }, "types": { "type": "keyword" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/awards/jsonschemas/awards/award-v1.0.0.json b/invenio_vocabularies/contrib/awards/jsonschemas/awards/award-v1.0.0.json index bdc2cfa1..56365363 100644 --- a/invenio_vocabularies/contrib/awards/jsonschemas/awards/award-v1.0.0.json +++ b/invenio_vocabularies/contrib/awards/jsonschemas/awards/award-v1.0.0.json @@ -42,6 +42,15 @@ }, "program": { "type": "string" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "array" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/awards/mappings/os-v1/awards/award-v1.0.0.json b/invenio_vocabularies/contrib/awards/mappings/os-v1/awards/award-v1.0.0.json index 90ec8049..dbfb4ae6 100644 --- a/invenio_vocabularies/contrib/awards/mappings/os-v1/awards/award-v1.0.0.json +++ b/invenio_vocabularies/contrib/awards/mappings/os-v1/awards/award-v1.0.0.json @@ -77,6 +77,15 @@ "type": "text" } } + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/awards/mappings/os-v2/awards/award-v1.0.0.json b/invenio_vocabularies/contrib/awards/mappings/os-v2/awards/award-v1.0.0.json index 90ec8049..dbfb4ae6 100644 --- a/invenio_vocabularies/contrib/awards/mappings/os-v2/awards/award-v1.0.0.json +++ b/invenio_vocabularies/contrib/awards/mappings/os-v2/awards/award-v1.0.0.json @@ -77,6 +77,15 @@ "type": "text" } } + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/funders/jsonschemas/funders/funder-v1.0.0.json b/invenio_vocabularies/contrib/funders/jsonschemas/funders/funder-v1.0.0.json index 1863fbec..ff9e4803 100644 --- a/invenio_vocabularies/contrib/funders/jsonschemas/funders/funder-v1.0.0.json +++ b/invenio_vocabularies/contrib/funders/jsonschemas/funders/funder-v1.0.0.json @@ -60,6 +60,15 @@ }, "title": { "$ref": "local://vocabularies/definitions-v1.0.0.json#/title" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "array" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/funders/mappings/os-v1/funders/funder-v2.0.0.json b/invenio_vocabularies/contrib/funders/mappings/os-v1/funders/funder-v2.0.0.json index ed050066..abff565c 100644 --- a/invenio_vocabularies/contrib/funders/mappings/os-v1/funders/funder-v2.0.0.json +++ b/invenio_vocabularies/contrib/funders/mappings/os-v1/funders/funder-v2.0.0.json @@ -134,6 +134,15 @@ }, "tags": { "type": "keyword" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/funders/mappings/os-v2/funders/funder-v2.0.0.json b/invenio_vocabularies/contrib/funders/mappings/os-v2/funders/funder-v2.0.0.json index ed050066..abff565c 100644 --- a/invenio_vocabularies/contrib/funders/mappings/os-v2/funders/funder-v2.0.0.json +++ b/invenio_vocabularies/contrib/funders/mappings/os-v2/funders/funder-v2.0.0.json @@ -134,6 +134,15 @@ }, "tags": { "type": "keyword" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/names/jsonschemas/names/name-v1.0.0.json b/invenio_vocabularies/contrib/names/jsonschemas/names/name-v1.0.0.json index 752bfb75..c10184bc 100644 --- a/invenio_vocabularies/contrib/names/jsonschemas/names/name-v1.0.0.json +++ b/invenio_vocabularies/contrib/names/jsonschemas/names/name-v1.0.0.json @@ -48,6 +48,15 @@ } }, "uniqueItems": true + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "array" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/names/mappings/os-v1/names/name-v2.0.0.json b/invenio_vocabularies/contrib/names/mappings/os-v1/names/name-v2.0.0.json index bb43c31f..413a9d94 100644 --- a/invenio_vocabularies/contrib/names/mappings/os-v1/names/name-v2.0.0.json +++ b/invenio_vocabularies/contrib/names/mappings/os-v1/names/name-v2.0.0.json @@ -148,6 +148,15 @@ "props": { "type": "object", "dynamic": "true" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/names/mappings/os-v2/names/name-v2.0.0.json b/invenio_vocabularies/contrib/names/mappings/os-v2/names/name-v2.0.0.json index bb43c31f..413a9d94 100644 --- a/invenio_vocabularies/contrib/names/mappings/os-v2/names/name-v2.0.0.json +++ b/invenio_vocabularies/contrib/names/mappings/os-v2/names/name-v2.0.0.json @@ -148,6 +148,15 @@ "props": { "type": "object", "dynamic": "true" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/names/services.py b/invenio_vocabularies/contrib/names/services.py index b2ac2941..f5866c44 100644 --- a/invenio_vocabularies/contrib/names/services.py +++ b/invenio_vocabularies/contrib/names/services.py @@ -32,6 +32,7 @@ def resolve(self, identity, id_, id_type): dsl.Q("term", identifiers__identifier=id_), dsl.Q("term", identifiers__scheme=id_type), ], + must_not=[dsl.Q("term", deprecated=True)], ) # max_records = 1, we assume there cannot be duplicates @@ -53,3 +54,15 @@ def resolve(self, identity, id_, id_type): record, links_tpl=self.links_item_tpl, ) + + def search( + self, identity, params=None, search_preference=None, expand=False, **kwargs + ): + return super().search( + identity, + params, + search_preference, + expand, + extra_filter=dsl.Q("bool", must_not=dsl.Q("term", deprecated=True)), + **kwargs + ) diff --git a/invenio_vocabularies/contrib/subjects/jsonschemas/subjects/subject-v1.0.0.json b/invenio_vocabularies/contrib/subjects/jsonschemas/subjects/subject-v1.0.0.json index c4c52fcf..5ed856a8 100644 --- a/invenio_vocabularies/contrib/subjects/jsonschemas/subjects/subject-v1.0.0.json +++ b/invenio_vocabularies/contrib/subjects/jsonschemas/subjects/subject-v1.0.0.json @@ -26,6 +26,15 @@ "description": "Human readable label.", "type": "string" }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "array" + }, + "managed": { + "type": "boolean" + }, "title": { "description": "Human readable label in different languages.", "$ref": "local://vocabularies/definitions-v1.0.0.json#/title" diff --git a/invenio_vocabularies/contrib/subjects/mappings/os-v1/subjects/subject-v1.0.0.json b/invenio_vocabularies/contrib/subjects/mappings/os-v1/subjects/subject-v1.0.0.json index 349277df..ddc77844 100644 --- a/invenio_vocabularies/contrib/subjects/mappings/os-v1/subjects/subject-v1.0.0.json +++ b/invenio_vocabularies/contrib/subjects/mappings/os-v1/subjects/subject-v1.0.0.json @@ -76,6 +76,15 @@ }, "tags": { "type": "keyword" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/contrib/subjects/mappings/os-v2/subjects/subject-v1.0.0.json b/invenio_vocabularies/contrib/subjects/mappings/os-v2/subjects/subject-v1.0.0.json index 349277df..ddc77844 100644 --- a/invenio_vocabularies/contrib/subjects/mappings/os-v2/subjects/subject-v1.0.0.json +++ b/invenio_vocabularies/contrib/subjects/mappings/os-v2/subjects/subject-v1.0.0.json @@ -76,6 +76,15 @@ }, "tags": { "type": "keyword" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/records/jsonschemas/vocabularies/vocabulary-v1.0.0.json b/invenio_vocabularies/records/jsonschemas/vocabularies/vocabulary-v1.0.0.json index 3511a0c8..c0e4d96c 100644 --- a/invenio_vocabularies/records/jsonschemas/vocabularies/vocabulary-v1.0.0.json +++ b/invenio_vocabularies/records/jsonschemas/vocabularies/vocabulary-v1.0.0.json @@ -50,6 +50,15 @@ "type": "string" } } + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "array" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/records/mappings/os-v1/vocabularies/vocabulary-v1.0.0.json b/invenio_vocabularies/records/mappings/os-v1/vocabularies/vocabulary-v1.0.0.json index fdd6525b..70893b9b 100644 --- a/invenio_vocabularies/records/mappings/os-v1/vocabularies/vocabulary-v1.0.0.json +++ b/invenio_vocabularies/records/mappings/os-v1/vocabularies/vocabulary-v1.0.0.json @@ -103,6 +103,15 @@ "props": { "type": "object", "dynamic": "true" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/records/mappings/os-v2/vocabularies/vocabulary-v1.0.0.json b/invenio_vocabularies/records/mappings/os-v2/vocabularies/vocabulary-v1.0.0.json index fdd6525b..70893b9b 100644 --- a/invenio_vocabularies/records/mappings/os-v2/vocabularies/vocabulary-v1.0.0.json +++ b/invenio_vocabularies/records/mappings/os-v2/vocabularies/vocabulary-v1.0.0.json @@ -103,6 +103,15 @@ "props": { "type": "object", "dynamic": "true" + }, + "deprecated": { + "type": "boolean" + }, + "superseeded_by": { + "type": "text" + }, + "managed": { + "type": "boolean" } } } diff --git a/invenio_vocabularies/services/schema.py b/invenio_vocabularies/services/schema.py index 0f179b03..840a734c 100644 --- a/invenio_vocabularies/services/schema.py +++ b/invenio_vocabularies/services/schema.py @@ -97,6 +97,9 @@ class BaseVocabularySchema(BaseRecordSchema): description = i18n_strings icon = fields.Str(allow_none=False) tags = fields.List(SanitizedUnicode()) + managed = fields.Bool() + deprecated = fields.Bool() + superseeded_by = fields.List(fields.Str()) # Nested field type for administration UI form generation administration_schema_type = "vocabulary"