From f24768c20c0ef1582b9f56cd8ea125ae934550fe Mon Sep 17 00:00:00 2001 From: gNahcab Date: Mon, 2 May 2022 15:07:31 +0200 Subject: [PATCH 1/6] -delete old lists.json and old lists-only.json - and add new lists.json --- knora/dsplib/schemas/lists-only.json | 130 -------------------------- knora/dsplib/schemas/lists.json | 132 --------------------------- 2 files changed, 262 deletions(-) delete mode 100644 knora/dsplib/schemas/lists-only.json delete mode 100644 knora/dsplib/schemas/lists.json diff --git a/knora/dsplib/schemas/lists-only.json b/knora/dsplib/schemas/lists-only.json deleted file mode 100644 index 8ed6bc9c6..000000000 --- a/knora/dsplib/schemas/lists-only.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft-07/schema", - "$id": "https://dasch.swiss/schema/list-only.json", - "title": "JSON schema for DSP lists", - "description": "JSON schema for the lists section used in DSP ontologies", - "definitions": { - "label": { - "type": "object", - "patternProperties": { - "^(en|de|fr|it)": { - "type": "string" - } - }, - "additionalProperties": false - }, - "comment": { - "type": "object", - "patternProperties": { - "^(en|de|fr|it)": { - "type": "string" - } - }, - "additionalProperties": false - }, - "node": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "labels": { - "$ref": "#/definitions/label" - }, - "comments": { - "$ref": "#/definitions/comment" - }, - "nodes": { - "oneOf": [ - { - "type": "array", - "items": { - "$ref": "#/definitions/node" - } - }, - { - "type": "object", - "$ref": "#/definitions/excelfileref" - }, - { - "type": "object", - "$ref": "#/definitions/excelfolderref" - } - ] - } - }, - "required": [ - "name", - "labels" - ], - "additionalProperties": false - }, - "excelfileref": { - "type": "object", - "properties": { - "file": { - "type": "string" - }, - "worksheet": { - "type": "string" - }, - "startrow": { - "type": "integer" - }, - "startcol": { - "type": "integer" - } - }, - "required": [ - "file", - "worksheet" - ] - }, - "excelfolderref": { - "type": "object", - "properties": { - "folder": { - "type": "string" - } - }, - "required": [ - "folder" - ] - } - }, - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "labels": { - "$ref": "#/definitions/label" - }, - "comments": { - "$ref": "#/definitions/comment" - }, - "nodes": { - "oneOf": [ - { - "type": "array", - "items": { - "$ref": "#/definitions/node" - } - }, - { - "type": "object", - "$ref": "#/definitions/excelfileref" - }, - { - "type": "object", - "$ref": "#/definitions/excelfolderref" - } - ] - } - }, - "required": [ - "name", - "nodes" - ], - "additionalProperties": false -} diff --git a/knora/dsplib/schemas/lists.json b/knora/dsplib/schemas/lists.json deleted file mode 100644 index 47ade9f21..000000000 --- a/knora/dsplib/schemas/lists.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft-07/schema", - "$id": "https://dasch.swiss/schema/lists.json", - "title": "JSON schema for DSP lists", - "description": "JSON schema for lists used in DSP ontologies", - "definitions": { - "langstring": { - "type": "object", - "patternProperties": { - "^(en|de|fr|it)": { - "type": "string" - } - }, - "additionalProperties": false - }, - "label": { - "$ref": "#/definitions/langstring" - }, - "description": { - "$ref": "#/definitions/langstring" - }, - "comment": { - "$ref": "#/definitions/langstring" - }, - "excelfileref": { - "type": "object", - "properties": { - "file": { - "type": "string" - }, - "worksheet": { - "type": "string" - }, - "startrow": { - "type": "integer" - }, - "startcol": { - "type": "integer" - } - }, - "required": [ - "file", - "worksheet" - ] - }, - "excelfolderref": { - "type": "object", - "properties": { - "folder": { - "type": "string" - } - }, - "required": [ - "folder" - ] - }, - "node": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "labels": { - "$ref": "#/definitions/label" - }, - "comments": { - "$ref": "#/definitions/comment" - }, - "nodes": { - "oneOf": [ - { - "type": "array", - "items": { - "$ref": "#/definitions/node" - } - }, - { - "type": "object", - "$ref": "#/definitions/excelfileref" - }, - { - "type": "object", - "$ref": "#/definitions/excelfolderref" - } - ] - } - }, - "required": [ - "name", - "labels" - ], - "additionalProperties": false - } - }, - "type": "object", - "properties": { - "project": { - "type": "object", - "properties": { - "shortcode": { - "type": "string", - "pattern": "^[0-9A-F]{4}$" - }, - "lists": { - "type": "array", - "items": { - "$ref": "#/definitions/node" - } - } - }, - "required": [ - "shortcode", - "lists" - ], - "additionalProperties": false - }, - "prefixes": { - "type": "object", - "patternProperties": { - "^[-\\w]+$": { - "format": "uri" - } - }, - "additionalProperties": false - } - }, - "required": [ - "prefixes", - "project" - ], - "additionalProperties": false -} From e5c6319eee37b9b4b52889b313a6792fcdc8001b Mon Sep 17 00:00:00 2001 From: gNahcab Date: Mon, 2 May 2022 15:27:22 +0200 Subject: [PATCH 2/6] -delete lists-only.json -update lists.json --- knora/dsplib/schemas/lists.json | 133 ++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 knora/dsplib/schemas/lists.json diff --git a/knora/dsplib/schemas/lists.json b/knora/dsplib/schemas/lists.json new file mode 100644 index 000000000..e1fac7528 --- /dev/null +++ b/knora/dsplib/schemas/lists.json @@ -0,0 +1,133 @@ +{ + "$schema": "https://json-schema.org/draft-07/schema", + "$id": "https://dasch.swiss/schema/list-only.json", + "title": "JSON schema for DSP lists", + "description": "JSON schema for the lists section used in DSP ontologies", + "definitions": { + "langstring": { + "type": "object", + "patternProperties": { + "^(en|de|fr|it)": { + "type": "string" + } + }, + "additionalProperties": false + }, + "label": { + "$ref": "#/definitions/langstring" + }, + "comment": { + "type": "object", + "patternProperties": { + "^(en|de|fr|it)": { + "type": "string" + } + }, + "additionalProperties": false + }, + "node": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "labels": { + "$ref": "#/definitions/label" + }, + "comments": { + "$ref": "#/definitions/comment" + }, + "nodes": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/definitions/node" + } + }, + { + "type": "object", + "$ref": "#/definitions/excelfileref" + }, + { + "type": "object", + "$ref": "#/definitions/excelfolderref" + } + ] + } + }, + "required": [ + "name", + "labels" + ], + "additionalProperties": false + }, + "excelfileref": { + "type": "object", + "properties": { + "file": { + "type": "string" + }, + "worksheet": { + "type": "string" + }, + "startrow": { + "type": "integer" + }, + "startcol": { + "type": "integer" + } + }, + "required": [ + "file", + "worksheet" + ] + }, + "excelfolderref": { + "type": "object", + "properties": { + "folder": { + "type": "string" + } + }, + "required": [ + "folder" + ] + } + }, + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "labels": { + "$ref": "#/definitions/label" + }, + "comments": { + "$ref": "#/definitions/comment" + }, + "nodes": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/definitions/node" + } + }, + { + "type": "object", + "$ref": "#/definitions/excelfileref" + }, + { + "type": "object", + "$ref": "#/definitions/excelfolderref" + } + ] + } + }, + "required": [ + "name", + "labels" + ], + "additionalProperties": false +} From de257c29eb100d37e71f77f230a2e13982f44645 Mon Sep 17 00:00:00 2001 From: gNahcab Date: Mon, 2 May 2022 15:31:35 +0200 Subject: [PATCH 3/6] update lists.json --- knora/dsplib/schemas/lists.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knora/dsplib/schemas/lists.json b/knora/dsplib/schemas/lists.json index e1fac7528..c8ccade73 100644 --- a/knora/dsplib/schemas/lists.json +++ b/knora/dsplib/schemas/lists.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/draft-07/schema", - "$id": "https://dasch.swiss/schema/list-only.json", + "$id": "https://dasch.swiss/schema/lists.json", "title": "JSON schema for DSP lists", "description": "JSON schema for the lists section used in DSP ontologies", "definitions": { From 8ad42563f231c1a2bf60bc248b2fb0d09fbc5b60 Mon Sep 17 00:00:00 2001 From: gNahcab Date: Mon, 2 May 2022 15:42:43 +0200 Subject: [PATCH 4/6] replace "lists-only.json" by "lists.json" --- MANIFEST.in | 1 - knora/dsplib/utils/excel_to_json_lists.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 0b584a039..e4ce8ac66 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,6 @@ include README.md include knora/dsplib/schemas/ontology.json include knora/dsplib/schemas/lists.json -include knora/dsplib/schemas/lists-only.json include knora/dsplib/schemas/resources-only.json include knora/dsplib/schemas/properties-only.json include knora/dsplib/schemas/data.xsd diff --git a/knora/dsplib/utils/excel_to_json_lists.py b/knora/dsplib/utils/excel_to_json_lists.py index 7c23c3aeb..55190072b 100644 --- a/knora/dsplib/utils/excel_to_json_lists.py +++ b/knora/dsplib/utils/excel_to_json_lists.py @@ -298,7 +298,7 @@ def validate_list_with_schema(json_list: str) -> bool: True if the list passed validation, False otherwise """ current_dir = os.path.dirname(os.path.realpath(__file__)) - with open(os.path.join(current_dir, '../schemas/lists-only.json')) as schema: + with open(os.path.join(current_dir, '../schemas/lists.json')) as schema: list_schema = json.load(schema) try: From ca06dd1cc72cf38c0eaf8782587e0efd75977aba Mon Sep 17 00:00:00 2001 From: gNahcab Date: Tue, 3 May 2022 09:47:07 +0200 Subject: [PATCH 5/6] change name "lists.json" to "lists-only.json" --- MANIFEST.in | 2 +- knora/dsp_tools.py | 2 +- knora/dsplib/schemas/{lists.json => lists-only.json} | 0 knora/dsplib/utils/excel_to_json_lists.py | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename knora/dsplib/schemas/{lists.json => lists-only.json} (100%) diff --git a/MANIFEST.in b/MANIFEST.in index e4ce8ac66..ceded8fc5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,6 @@ include README.md include knora/dsplib/schemas/ontology.json -include knora/dsplib/schemas/lists.json +include knora/dsplib/schemas/lists-only.json include knora/dsplib/schemas/resources-only.json include knora/dsplib/schemas/properties-only.json include knora/dsplib/schemas/data.xsd diff --git a/knora/dsp_tools.py b/knora/dsp_tools.py index ee4dd407d..a24ed3f0e 100644 --- a/knora/dsp_tools.py +++ b/knora/dsp_tools.py @@ -58,7 +58,7 @@ def program(user_args: list[str]) -> None: parser_create.add_argument('-V', '--validate', action='store_true', help='Do only validation of JSON, no upload of the ' 'ontology') - parser_create.add_argument('-L', '--listfile', type=str, default='lists.json', + parser_create.add_argument('-L', '--listfile', type=str, default='lists-only.json', help='Name of list node informationfile') parser_create.add_argument('-l', '--lists', action='store_true', help='Upload only the list(s)') parser_create.add_argument('-v', '--verbose', action='store_true', help=verbose_text) diff --git a/knora/dsplib/schemas/lists.json b/knora/dsplib/schemas/lists-only.json similarity index 100% rename from knora/dsplib/schemas/lists.json rename to knora/dsplib/schemas/lists-only.json diff --git a/knora/dsplib/utils/excel_to_json_lists.py b/knora/dsplib/utils/excel_to_json_lists.py index 55190072b..7c23c3aeb 100644 --- a/knora/dsplib/utils/excel_to_json_lists.py +++ b/knora/dsplib/utils/excel_to_json_lists.py @@ -298,7 +298,7 @@ def validate_list_with_schema(json_list: str) -> bool: True if the list passed validation, False otherwise """ current_dir = os.path.dirname(os.path.realpath(__file__)) - with open(os.path.join(current_dir, '../schemas/lists.json')) as schema: + with open(os.path.join(current_dir, '../schemas/lists-only.json')) as schema: list_schema = json.load(schema) try: From fe0ec29f9ea0a08afbaf94faacc2806b9e6ca558 Mon Sep 17 00:00:00 2001 From: gNahcab Date: Tue, 3 May 2022 11:19:40 +0200 Subject: [PATCH 6/6] make mandatory: lists must contain "nodes" and at least one node --- knora/dsplib/schemas/lists-only.json | 2 ++ knora/dsplib/schemas/ontology.json | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/knora/dsplib/schemas/lists-only.json b/knora/dsplib/schemas/lists-only.json index c8ccade73..c6904d351 100644 --- a/knora/dsplib/schemas/lists-only.json +++ b/knora/dsplib/schemas/lists-only.json @@ -38,6 +38,7 @@ "$ref": "#/definitions/comment" }, "nodes": { + "minItems": 1, "oneOf": [ { "type": "array", @@ -127,6 +128,7 @@ }, "required": [ "name", + "nodes", "labels" ], "additionalProperties": false diff --git a/knora/dsplib/schemas/ontology.json b/knora/dsplib/schemas/ontology.json index ad91e4d5a..f05ce54fa 100644 --- a/knora/dsplib/schemas/ontology.json +++ b/knora/dsplib/schemas/ontology.json @@ -183,6 +183,7 @@ "$ref": "#/definitions/comment" }, "nodes": { + "minItems": 1, "oneOf": [ { "type": "array", @@ -1207,7 +1208,8 @@ "$ref": "#/definitions/comment" }, "required": [ - "comments" + "comments", + "nodes" ] } },