From 9a5a50b18f362f731c44bd31e8a056337be5a7df Mon Sep 17 00:00:00 2001 From: Gregor Bachmann <91829513+gNahcab@users.noreply.github.com> Date: Thu, 28 Apr 2022 13:02:22 +0200 Subject: [PATCH] chore: update schema-files (DEV-449) (#187) * update schema-files * adapt test-onto.json * update properties-only.json and resources-only.json * delete longname as required and knora-schema-properties-only.json --- knora/dsplib/schemas/ontology.json | 224 +++++- knora/dsplib/schemas/properties-only.json | 653 +++++++++++++++++- knora/dsplib/schemas/resources-only.json | 3 +- .../utils/knora-schema-properties-only.json | 179 ----- testdata/test-onto.json | 2 +- 5 files changed, 874 insertions(+), 187 deletions(-) delete mode 100644 knora/dsplib/utils/knora-schema-properties-only.json diff --git a/knora/dsplib/schemas/ontology.json b/knora/dsplib/schemas/ontology.json index 6fa08000b..053105e4b 100644 --- a/knora/dsplib/schemas/ontology.json +++ b/knora/dsplib/schemas/ontology.json @@ -386,6 +386,68 @@ ], "additionalProperties": false, "allOf": [ + { + "if": { + "properties": { + "super": { + "const": "hasLinkTo" + } + } + }, + "then": { + "properties": { + "gui_element": { + "const": "Searchbox" + } + } + } + }, + { + "if": { + "properties": { + "super": { + "const": "isPartOf" + } + } + }, + "then": { + "properties": { + "gui_element": { + "const": "Searchbox" + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "Representation" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasRepresentation"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "const": "Searchbox" + } + } + } + }, { "if": { "properties": { @@ -396,6 +458,20 @@ }, "then": { "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasComment","hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, "gui_element": { "enum": [ "SimpleText", "Textarea", "Richtext" ] } @@ -412,6 +488,20 @@ }, "then": { "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasColor"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, "gui_element": { "const": "Colorpicker" } @@ -428,6 +518,20 @@ }, "then": { "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, "gui_element": { "const": "Date" } @@ -444,6 +548,20 @@ }, "then": { "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, "gui_element": { "const": "TimeStamp" } @@ -460,6 +578,20 @@ }, "then": { "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, "gui_element": { "enum": ["Slider","SimpleText"] } @@ -482,9 +614,7 @@ "type": "string", "oneOf": [ { - "enum": [ - "hasGeometry" - ] + "enum": ["hasGeometry"] }, { "$ref": "#/definitions/prefixedname" @@ -511,6 +641,20 @@ }, "then": { "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, "gui_element": { "const": "Geonames" @@ -528,6 +672,20 @@ }, "then": { "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue", "seqnum"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, "gui_element": { "enum": [ "Spinbox", @@ -547,6 +705,20 @@ }, "then": { "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, "gui_element": { "const": "Checkbox" } @@ -563,6 +735,20 @@ }, "then": { "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, "gui_element": { "const": "SimpleText" } @@ -579,6 +765,20 @@ }, "then": { "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, "gui_element": { "enum": [ "Interval", @@ -599,6 +799,20 @@ "then": { "properties": { "gui_element": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, "enum": [ "Radio", "List" @@ -879,7 +1093,8 @@ "type": "array", "items": { "$ref": "#/definitions/cardinality" - } + }, + "minItems": 1 } }, "required": [ @@ -963,7 +1178,6 @@ "required": [ "shortcode", "shortname", - "longname", "descriptions", "ontologies", "keywords" diff --git a/knora/dsplib/schemas/properties-only.json b/knora/dsplib/schemas/properties-only.json index 29d075531..9a1a42654 100644 --- a/knora/dsplib/schemas/properties-only.json +++ b/knora/dsplib/schemas/properties-only.json @@ -166,11 +166,662 @@ }, "required": [ "name", + "super", "object", "labels", "gui_element" ], - "additionalProperties": false + "additionalProperties": false, + "allOf": [ + { + "if": { + "properties": { + "super": { + "const": "hasLinkTo" + } + } + }, + "then": { + "properties": { + "gui_element": { + "const": "Searchbox" + } + } + } + }, + { + "if": { + "properties": { + "super": { + "const": "isPartOf" + } + } + }, + "then": { + "properties": { + "gui_element": { + "const": "Searchbox" + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "Representation" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasRepresentation"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "const": "Searchbox" + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "TextValue" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + {"enum": ["hasComment","hasValue"] }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "enum": [ "SimpleText", "Textarea", "Richtext" ] + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "ColorValue" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasColor"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "const": "Colorpicker" + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "DateValue" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "const": "Date" + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "TimeValue" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "const": "TimeStamp" + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "DecimalValue" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "enum": ["Slider","SimpleText"] + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "GeomValue" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasGeometry"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "enum": [ + "Geometry", + "SimpleText" + ] + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "GeonameValue" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "const": + "Geonames" + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "IntValue" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue", "seqnum"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "enum": [ + "Spinbox", + "SimpleText" + ] + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "BooleanValue" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "const": "Checkbox" + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "UriValue" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "const": "SimpleText" + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "IntervalValue" + } + } + }, + "then": { + "properties": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "gui_element": { + "enum": [ + "Interval", + "SimpleText" + ] + } + } + } + }, + { + "if": { + "properties": { + "object": { + "const": "ListValue" + } + } + }, + "then": { + "properties": { + "gui_element": { + "super": { + "type": "array", + "items": { + "type": "string", + "oneOf": [ + { + "enum": ["hasValue"] + }, + { + "$ref": "#/definitions/prefixedname" + } + ] + } + }, + "enum": [ + "Radio", + "List" + ] + } + } + } + }, + { + "if": { + "properties": { + "object": { + "$ref": "#/definitions/prefixedname" + } + } + }, + "then": { + "properties": { + "gui_element": { + "const": "Searchbox" + } + } + } + }, + { + "if": { + "properties": { + "gui_element": { + "const": "SimpleText" + } + } + }, + "then": { + "properties": { + "gui_attributes": { + "type": "object", + "properties": { + "maxlength": { + "type": "integer" + }, + "size": { + "type": "integer" + } + }, + "additionalProperties": false + } + } + } + }, + { + "if": { + "properties": { + "gui_element": { + "const": "Textarea" + } + } + }, + "then": { + "properties": { + "gui_attributes": { + "type": "object", + "properties": { + "cols": { + "type": "integer" + }, + "rows": { + "type": "integer" + }, + "width": { + "type": "string", + "pattern": "^[0-9]*%?$" + }, + "wrap": { + "enum": [ + "soft", + "hard" + ] + } + }, + "additionalProperties": false + } + } + } + }, + { + "if": { + "properties": { + "gui_element": { + "const": "Colorpicker" + } + } + }, + "then": { + "properties": { + "gui_attributes": { + "type": "object", + "properties": { + "ncolors": { + "type": "integer" + } + }, + "additionalProperties": false + } + } + } + }, + { + "if": { + "properties": { + "gui_element": { + "const": "Slider" + } + } + }, + "then": { + "properties": { + "gui_attributes": { + "type": "object", + "properties": { + "max": { + "type": "number" + }, + "min": { + "type": "number" + } + }, + "additionalProperties": false + } + }, + "required": [ + "gui_attributes" + ] + } + }, + { + "if": { + "properties": { + "gui_element": { + "const": "Spinbox" + } + } + }, + "then": { + "properties": { + "gui_attributes": { + "type": "object", + "properties": { + "max": { + "type": "number" + }, + "min": { + "type": "number" + } + }, + "additionalProperties": false + } + } + } + }, + { + "if": { + "properties": { + "gui_element": { + "enum": ["Radio", "List"] + } + } + }, + "then": { + "properties": { + "gui_attributes": { + "type": "object", + "properties": { + "hlist": { + "type": "string" + } + }, + "additionalProperties": false + + } + }, + "required": [ + "gui_attributes" + ] + } + }, + { + "if": { + "properties": { + "gui_element": { + "const": "Searchbox" + } + } + }, + "then": { + "properties": { + "gui_attributes": { + "type": "object", + "properties": { + "numprops": { + "type": "integer" + } + }, + "additionalProperties": false + } + } + } + }, + { + "if": { + "properties": { + "gui_element": { + "enum": ["Richtext", "Date", "TimeStamp", "Geometry", "Geonames", "Checkbox", "Interval"] + } + } + }, + "then": { + "not": { + "required": [ + "gui_attributes" + ] + } + } + } + ] } }, "type": "array", diff --git a/knora/dsplib/schemas/resources-only.json b/knora/dsplib/schemas/resources-only.json index c0840a77e..20a0b265a 100644 --- a/knora/dsplib/schemas/resources-only.json +++ b/knora/dsplib/schemas/resources-only.json @@ -80,7 +80,8 @@ "type": "array", "items": { "$ref": "#/definitions/cardinality" - } + }, + "minItems": 1 } }, "required": [ diff --git a/knora/dsplib/utils/knora-schema-properties-only.json b/knora/dsplib/utils/knora-schema-properties-only.json deleted file mode 100644 index 30489cc19..000000000 --- a/knora/dsplib/utils/knora-schema-properties-only.json +++ /dev/null @@ -1,179 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema-properties-only#", - "$id": "http://knora.org/pyknora/ontology/properties-only.json", - "title": "Knora JSON schema for properties only", - "description": "JSON schema for properties used in Knora ontologies", - "definitions": { - "langstring": { - "anyOf": [ - { - "type": "object", - "patternProperties": { - "^(en|de|fr|it)": { - "type": "string" - } - }, - "additionalProperties": false - }, - { - "type": "string" - } - ] - }, - "label": { - "$ref": "#/definitions/langstring" - }, - "comment": { - "$ref": "#/definitions/langstring" - }, - "property": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "super": { - "type": "array", - "items": { - "type": "string", - "oneOf": [ - { - "enum": [ - "hasValue", - "hasLinkTo", - "hasColor", - "hasComment", - "hasGeometry", - "isPartOf", - "isRegionOf", - "isAnnotationOf", - "hasRepresentation", - "seqnum" - ] - }, - { - "pattern": "^([\\w-]+)?:(\\w+)$" - }, - { - "pattern": "^(http)(s)?://.*" - } - ] - } - }, - "object": { - "type": "string", - "oneOf": [ - { - "enum": [ - "TextValue", - "ColorValue", - "DateValue", - "DecimalValue", - "GeomValue", - "GeonameValue", - "IntValue", - "BooleanValue", - "TimeValue", - "UriValue", - "IntervalValue", - "ListValue", - "Region", - "Resource", - "Annotation" - ] - }, - { - "pattern": "^([\\w-]+)?:(\\w+)$" - } - ] - }, - "subject": { - "type": "string", - "pattern": "^([\\w-]+)?:(\\w+)$" - }, - "labels": { - "$ref": "#/definitions/label" - }, - "gui_element": { - "type": "string", - "enum": [ - "Colorpicker", - "Date", - "Geometry", - "Geonames", - "Interval", - "TimeStamp", - "List", - "Pulldown", - "Radio", - "Richtext", - "Searchbox", - "SimpleText", - "Slider", - "Spinbox", - "Textarea", - "Checkbox", - "Fileupload" - ] - }, - "gui_attributes": { - "type": "object", - "properties": { - "size": { - "type": "integer" - }, - "maxsize": { - "type": "integer" - }, - "hlist": { - "type": "string" - }, - "numprops": { - "type": "integer" - }, - "ncolors": { - "type": "integer" - }, - "cols": { - "type": "integer" - }, - "rows": { - "type": "integer" - }, - "width": { - "type": "string", - "pattern": "^[0-9]*%?$" - }, - "wrap": { - "type": "string", - "enum": [ - "soft", - "hard" - ] - }, - "max": { - "type": "number" - }, - "min": { - "type": "number" - } - } - }, - "comments": { - "$ref": "#/definitions/comment" - } - }, - "required": [ - "name", - "object", - "labels", - "gui_element" - ], - "additionalProperties": false - } - }, - "type": "array", - "items": { - "$ref": "#/definitions/property" - } -} diff --git a/testdata/test-onto.json b/testdata/test-onto.json index b197a159e..c865d1cb1 100644 --- a/testdata/test-onto.json +++ b/testdata/test-onto.json @@ -326,7 +326,7 @@ { "name": "hasColor", "super": [ - "hasValue" + "hasColor" ], "object": "ColorValue", "labels": {