Skip to content

Commit

Permalink
global: add deprecation mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcastro2 committed Sep 6, 2024
1 parent cb88ac2 commit 0a560e3
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@
},
"title": {
"$ref": "local://vocabularies/definitions-v1.0.0.json#/title"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "array"
},
"managed": {
"type": "boolean"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@
},
"types": {
"type": "keyword"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@
},
"types": {
"type": "keyword"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@
},
"program": {
"type": "string"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "array"
},
"managed": {
"type": "boolean"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
"type": "text"
}
}
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
"type": "text"
}
}
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
},
"title": {
"$ref": "local://vocabularies/definitions-v1.0.0.json#/title"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "array"
},
"managed": {
"type": "boolean"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@
},
"tags": {
"type": "keyword"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@
},
"tags": {
"type": "keyword"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
}
},
"uniqueItems": true
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "array"
},
"managed": {
"type": "boolean"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@
"props": {
"type": "object",
"dynamic": "true"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@
"props": {
"type": "object",
"dynamic": "true"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions invenio_vocabularies/contrib/names/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@
},
"tags": {
"type": "keyword"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@
},
"tags": {
"type": "keyword"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@
"type": "string"
}
}
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "array"
},
"managed": {
"type": "boolean"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@
"props": {
"type": "object",
"dynamic": "true"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@
"props": {
"type": "object",
"dynamic": "true"
},
"deprecated": {
"type": "boolean"
},
"superseeded_by": {
"type": "text"
},
"managed": {
"type": "boolean"
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions invenio_vocabularies/services/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0a560e3

Please sign in to comment.