From c3f58370f69e7f7f098a5412751737328e3c673a Mon Sep 17 00:00:00 2001 From: Daniel <139119540+DeltaDaniel@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:47:46 +0100 Subject: [PATCH] Time Conditions for Bedingungsbaum (#520) * WIP * added test * update twine --- dev_requirements/requirements-docs.txt | 4 +- .../AhbExpressionEvaluationResultSchema.json | 158 +++--- json_schemas/CategorizedKeyExtractSchema.json | 536 ++++++++++-------- ...onditionKeyConditionTextMappingSchema.json | 236 ++++---- .../ContentEvaluationResultSchema.json | 413 ++++++++------ .../EvaluatedFormatConstraintSchema.json | 126 ++-- ...ormatConstraintEvaluationResultSchema.json | 91 +-- ...geKeyConditionExpressionMappingSchema.json | 314 +++++----- ...ementConstraintEvaluationResultSchema.json | 64 ++- json_schemas/TokenSchema.json | 446 ++++++++------- pyproject.toml | 2 +- .../condition_expression_parser.py | 10 +- .../expressions/expression_resolver.py | 57 +- unittests/test_time_condition_resolver.py | 58 +- 14 files changed, 1412 insertions(+), 1103 deletions(-) diff --git a/dev_requirements/requirements-docs.txt b/dev_requirements/requirements-docs.txt index 09d0f0e0..0139507f 100644 --- a/dev_requirements/requirements-docs.txt +++ b/dev_requirements/requirements-docs.txt @@ -20,7 +20,7 @@ docutils==0.20.1 # via # sphinx # sphinx-rtd-theme -efoli==1.2.0 +efoli==1.3.0 # via # ahbicht (pyproject.toml) # maus @@ -36,7 +36,7 @@ lark==1.2.2 # via ahbicht (pyproject.toml) markupsafe==2.1.5 # via jinja2 -marshmallow==3.22.0 +marshmallow==3.23.0 # via # ahbicht (pyproject.toml) # marshmallow-enum diff --git a/json_schemas/AhbExpressionEvaluationResultSchema.json b/json_schemas/AhbExpressionEvaluationResultSchema.json index 4f4d265b..ac9d47d9 100644 --- a/json_schemas/AhbExpressionEvaluationResultSchema.json +++ b/json_schemas/AhbExpressionEvaluationResultSchema.json @@ -1,80 +1,94 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "AhbExpressionEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraint_evaluation_result": { - "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", - "type": "object" + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "AhbExpressionEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraint_evaluation_result": { + "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_constraint_evaluation_result": { + "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_indicator": { + "title": "", + "type": "string" + } + }, + "type": "object" }, - "requirement_constraint_evaluation_result": { - "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", - "type": "object" + "EvaluatedFormatConstraintSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "default": true, + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraint_fulfilled": { + "title": "format_constraint_fulfilled", + "type": "boolean" + } + }, + "required": [ + "format_constraint_fulfilled" + ], + "type": "object" }, - "requirement_indicator": { - "title": "", - "type": "string" - } - }, - "type": "object" - }, - "EvaluatedFormatConstraintSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "default": true, - "title": "error_message", - "type": ["string", "null"] + "FormatConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraints_fulfilled": { + "title": "format_constraints_fulfilled", + "type": "boolean" + } + }, + "type": "object" }, - "format_constraint_fulfilled": { - "title": "format_constraint_fulfilled", - "type": "boolean" + "RequirementConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints_expression": { + "title": "format_constraints_expression", + "type": [ + "string", + "null" + ] + }, + "hints": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "requirement_constraints_fulfilled": { + "title": "requirement_constraints_fulfilled", + "type": "boolean" + }, + "requirement_is_conditional": { + "title": "requirement_is_conditional", + "type": "boolean" + } + }, + "type": "object" } - }, - "required": ["format_constraint_fulfilled"], - "type": "object" }, - "FormatConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "title": "error_message", - "type": ["string", "null"] - }, - "format_constraints_fulfilled": { - "title": "format_constraints_fulfilled", - "type": "boolean" - } - }, - "type": "object" + "properties": { + "$ref": "#/definitions/AhbExpressionEvaluationResultSchema/properties" }, - "RequirementConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints_expression": { - "title": "format_constraints_expression", - "type": ["string", "null"] - }, - "hints": { - "title": "hints", - "type": ["string", "null"] - }, - "requirement_constraints_fulfilled": { - "title": "requirement_constraints_fulfilled", - "type": "boolean" - }, - "requirement_is_conditional": { - "title": "requirement_is_conditional", - "type": "boolean" - } - }, - "type": "object" - } - }, - "properties": { - "$ref": "#/definitions/AhbExpressionEvaluationResultSchema/properties" - }, - "title": "AhbExpressionEvaluationResultSchema", - "type": "object" + "title": "AhbExpressionEvaluationResultSchema", + "type": "object" } diff --git a/json_schemas/CategorizedKeyExtractSchema.json b/json_schemas/CategorizedKeyExtractSchema.json index 02089540..48482ad5 100644 --- a/json_schemas/CategorizedKeyExtractSchema.json +++ b/json_schemas/CategorizedKeyExtractSchema.json @@ -1,261 +1,303 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "AhbExpressionEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraint_evaluation_result": { - "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", - "type": "object" - }, - "requirement_constraint_evaluation_result": { - "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", - "type": "object" - }, - "requirement_indicator": { - "title": "", - "type": "string" - } - }, - "type": "object" - }, - "CategorizedKeyExtractSchema": { - "additionalProperties": false, - "properties": { - "format_constraint_keys": { - "items": { - "title": "format_constraint_keys", - "type": "string" - }, - "title": "format_constraint_keys", - "type": "array" - }, - "hint_keys": { - "items": { - "title": "hint_keys", - "type": "string" - }, - "title": "hint_keys", - "type": "array" - }, - "package_keys": { - "items": { - "title": "package_keys", - "type": "string" - }, - "title": "package_keys", - "type": "array" - }, - "requirement_constraint_keys": { - "items": { - "title": "requirement_constraint_keys", - "type": "string" - }, - "title": "requirement_constraint_keys", - "type": "array" - }, - "time_condition_keys": { - "items": { - "title": "time_condition_keys", - "type": "string" - }, - "title": "time_condition_keys", - "type": "array" - } - }, - "type": "object" - }, - "ConditionKeyConditionTextMappingSchema": { - "additionalProperties": false, - "properties": { - "condition_key": { - "title": "condition_key", - "type": "string" - }, - "condition_text": { - "title": "condition_text", - "type": ["string", "null"] - }, - "edifact_format": { - "enum": [ - "APERAK", - "COMDIS", - "CONTRL", - "IFTSTA", - "INSRPT", - "INVOIC", - "MSCONS", - "ORDCHG", - "ORDERS", - "ORDRSP", - "PRICAT", - "QUOTES", - "REMADV", - "REQOTE", - "PARTIN", - "UTILMD", - "UTILTS" - ], - "title": "edifact_format", - "type": "string" - } - }, - "type": "object" - }, - "ContentEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints": { - "additionalProperties": { - "$ref": "#/definitions/EvaluatedFormatConstraintSchema", + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "AhbExpressionEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraint_evaluation_result": { + "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_constraint_evaluation_result": { + "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_indicator": { + "title": "", + "type": "string" + } + }, "type": "object" - }, - "title": "format_constraints", - "type": "object" }, - "hints": { - "additionalProperties": { - "title": "hints", - "type": ["string", "null"] - }, - "title": "hints", - "type": "object" + "CategorizedKeyExtractSchema": { + "additionalProperties": false, + "properties": { + "format_constraint_keys": { + "items": { + "title": "format_constraint_keys", + "type": "string" + }, + "title": "format_constraint_keys", + "type": "array" + }, + "hint_keys": { + "items": { + "title": "hint_keys", + "type": "string" + }, + "title": "hint_keys", + "type": "array" + }, + "package_keys": { + "items": { + "title": "package_keys", + "type": "string" + }, + "title": "package_keys", + "type": "array" + }, + "requirement_constraint_keys": { + "items": { + "title": "requirement_constraint_keys", + "type": "string" + }, + "title": "requirement_constraint_keys", + "type": "array" + }, + "time_condition_keys": { + "items": { + "title": "time_condition_keys", + "type": "string" + }, + "title": "time_condition_keys", + "type": "array" + } + }, + "type": "object" }, - "id": { - "default": false, - "format": "uuid", - "title": "id", - "type": ["string", "null"] + "ConditionKeyConditionTextMappingSchema": { + "additionalProperties": false, + "properties": { + "condition_key": { + "title": "condition_key", + "type": "string" + }, + "condition_text": { + "title": "condition_text", + "type": [ + "string", + "null" + ] + }, + "edifact_format": { + "enum": [ + "APERAK", + "COMDIS", + "CONTRL", + "IFTSTA", + "INSRPT", + "INVOIC", + "MSCONS", + "ORDCHG", + "ORDERS", + "ORDRSP", + "PRICAT", + "QUOTES", + "REMADV", + "REQOTE", + "PARTIN", + "UTILMD", + "UTILMDG", + "UTILMDS", + "UTILMDW", + "UTILTS" + ], + "title": "edifact_format", + "type": "string" + } + }, + "type": "object" }, - "packages": { - "additionalProperties": { - "title": "packages", - "type": "string" - }, - "title": "packages", - "type": ["object", "null"] + "ContentEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints": { + "additionalProperties": { + "$ref": "#/definitions/EvaluatedFormatConstraintSchema", + "type": "object" + }, + "title": "format_constraints", + "type": "object" + }, + "hints": { + "additionalProperties": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "title": "hints", + "type": "object" + }, + "id": { + "default": false, + "format": "uuid", + "title": "id", + "type": [ + "string", + "null" + ] + }, + "packages": { + "additionalProperties": { + "title": "packages", + "type": "string" + }, + "title": "packages", + "type": [ + "object", + "null" + ] + }, + "requirement_constraints": { + "additionalProperties": { + "title": "requirement_constraints", + "type": "string" + }, + "title": "requirement_constraints", + "type": "object" + } + }, + "required": [ + "format_constraints", + "hints", + "requirement_constraints" + ], + "type": "object" }, - "requirement_constraints": { - "additionalProperties": { - "title": "requirement_constraints", - "type": "string" - }, - "title": "requirement_constraints", - "type": "object" - } - }, - "required": ["format_constraints", "hints", "requirement_constraints"], - "type": "object" - }, - "EvaluatedFormatConstraintSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "default": true, - "title": "error_message", - "type": ["string", "null"] + "EvaluatedFormatConstraintSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "default": true, + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraint_fulfilled": { + "title": "format_constraint_fulfilled", + "type": "boolean" + } + }, + "required": [ + "format_constraint_fulfilled" + ], + "type": "object" }, - "format_constraint_fulfilled": { - "title": "format_constraint_fulfilled", - "type": "boolean" - } - }, - "required": ["format_constraint_fulfilled"], - "type": "object" - }, - "FormatConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "title": "error_message", - "type": ["string", "null"] + "FormatConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraints_fulfilled": { + "title": "format_constraints_fulfilled", + "type": "boolean" + } + }, + "type": "object" }, - "format_constraints_fulfilled": { - "title": "format_constraints_fulfilled", - "type": "boolean" - } - }, - "type": "object" - }, - "PackageKeyConditionExpressionMappingSchema": { - "additionalProperties": false, - "properties": { - "edifact_format": { - "enum": [ - "APERAK", - "COMDIS", - "CONTRL", - "IFTSTA", - "INSRPT", - "INVOIC", - "MSCONS", - "ORDCHG", - "ORDERS", - "ORDRSP", - "PRICAT", - "QUOTES", - "REMADV", - "REQOTE", - "PARTIN", - "UTILMD", - "UTILTS" - ], - "title": "edifact_format", - "type": "string" + "PackageKeyConditionExpressionMappingSchema": { + "additionalProperties": false, + "properties": { + "edifact_format": { + "enum": [ + "APERAK", + "COMDIS", + "CONTRL", + "IFTSTA", + "INSRPT", + "INVOIC", + "MSCONS", + "ORDCHG", + "ORDERS", + "ORDRSP", + "PRICAT", + "QUOTES", + "REMADV", + "REQOTE", + "PARTIN", + "UTILMD", + "UTILMDG", + "UTILMDS", + "UTILMDW", + "UTILTS" + ], + "title": "edifact_format", + "type": "string" + }, + "package_expression": { + "title": "package_expression", + "type": [ + "string", + "null" + ] + }, + "package_key": { + "title": "package_key", + "type": "string" + } + }, + "type": "object" }, - "package_expression": { - "title": "package_expression", - "type": ["string", "null"] + "RequirementConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints_expression": { + "title": "format_constraints_expression", + "type": [ + "string", + "null" + ] + }, + "hints": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "requirement_constraints_fulfilled": { + "title": "requirement_constraints_fulfilled", + "type": "boolean" + }, + "requirement_is_conditional": { + "title": "requirement_is_conditional", + "type": "boolean" + } + }, + "type": "object" }, - "package_key": { - "title": "package_key", - "type": "string" + "TokenSchema": { + "additionalProperties": false, + "properties": { + "type": { + "default": false, + "title": "type", + "type": "string" + }, + "value": { + "default": false, + "title": "value", + "type": [ + "string", + "null" + ] + } + }, + "type": "object" } - }, - "type": "object" }, - "RequirementConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints_expression": { - "title": "format_constraints_expression", - "type": ["string", "null"] - }, - "hints": { - "title": "hints", - "type": ["string", "null"] - }, - "requirement_constraints_fulfilled": { - "title": "requirement_constraints_fulfilled", - "type": "boolean" - }, - "requirement_is_conditional": { - "title": "requirement_is_conditional", - "type": "boolean" - } - }, - "type": "object" + "properties": { + "$ref": "#/definitions/CategorizedKeyExtractSchema/properties" }, - "TokenSchema": { - "additionalProperties": false, - "properties": { - "type": { - "default": false, - "title": "type", - "type": "string" - }, - "value": { - "default": false, - "title": "value", - "type": ["string", "null"] - } - }, - "type": "object" - } - }, - "properties": { - "$ref": "#/definitions/CategorizedKeyExtractSchema/properties" - }, - "title": "CategorizedKeyExtractSchema", - "type": "object" + "title": "CategorizedKeyExtractSchema", + "type": "object" } diff --git a/json_schemas/ConditionKeyConditionTextMappingSchema.json b/json_schemas/ConditionKeyConditionTextMappingSchema.json index 126e31ab..2da0bc6e 100644 --- a/json_schemas/ConditionKeyConditionTextMappingSchema.json +++ b/json_schemas/ConditionKeyConditionTextMappingSchema.json @@ -1,117 +1,137 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "AhbExpressionEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraint_evaluation_result": { - "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", - "type": "object" + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "AhbExpressionEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraint_evaluation_result": { + "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_constraint_evaluation_result": { + "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_indicator": { + "title": "", + "type": "string" + } + }, + "type": "object" }, - "requirement_constraint_evaluation_result": { - "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", - "type": "object" + "ConditionKeyConditionTextMappingSchema": { + "additionalProperties": false, + "properties": { + "condition_key": { + "title": "condition_key", + "type": "string" + }, + "condition_text": { + "title": "condition_text", + "type": [ + "string", + "null" + ] + }, + "edifact_format": { + "enum": [ + "APERAK", + "COMDIS", + "CONTRL", + "IFTSTA", + "INSRPT", + "INVOIC", + "MSCONS", + "ORDCHG", + "ORDERS", + "ORDRSP", + "PRICAT", + "QUOTES", + "REMADV", + "REQOTE", + "PARTIN", + "UTILMD", + "UTILMDG", + "UTILMDS", + "UTILMDW", + "UTILTS" + ], + "title": "edifact_format", + "type": "string" + } + }, + "type": "object" }, - "requirement_indicator": { - "title": "", - "type": "string" - } - }, - "type": "object" - }, - "ConditionKeyConditionTextMappingSchema": { - "additionalProperties": false, - "properties": { - "condition_key": { - "title": "condition_key", - "type": "string" + "EvaluatedFormatConstraintSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "default": true, + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraint_fulfilled": { + "title": "format_constraint_fulfilled", + "type": "boolean" + } + }, + "required": [ + "format_constraint_fulfilled" + ], + "type": "object" }, - "condition_text": { - "title": "condition_text", - "type": ["string", "null"] + "FormatConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraints_fulfilled": { + "title": "format_constraints_fulfilled", + "type": "boolean" + } + }, + "type": "object" }, - "edifact_format": { - "enum": [ - "APERAK", - "COMDIS", - "CONTRL", - "IFTSTA", - "INSRPT", - "INVOIC", - "MSCONS", - "ORDCHG", - "ORDERS", - "ORDRSP", - "PRICAT", - "QUOTES", - "REMADV", - "REQOTE", - "PARTIN", - "UTILMD", - "UTILTS" - ], - "title": "edifact_format", - "type": "string" + "RequirementConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints_expression": { + "title": "format_constraints_expression", + "type": [ + "string", + "null" + ] + }, + "hints": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "requirement_constraints_fulfilled": { + "title": "requirement_constraints_fulfilled", + "type": "boolean" + }, + "requirement_is_conditional": { + "title": "requirement_is_conditional", + "type": "boolean" + } + }, + "type": "object" } - }, - "type": "object" }, - "EvaluatedFormatConstraintSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "default": true, - "title": "error_message", - "type": ["string", "null"] - }, - "format_constraint_fulfilled": { - "title": "format_constraint_fulfilled", - "type": "boolean" - } - }, - "required": ["format_constraint_fulfilled"], - "type": "object" + "properties": { + "$ref": "#/definitions/ConditionKeyConditionTextMappingSchema/properties" }, - "FormatConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "title": "error_message", - "type": ["string", "null"] - }, - "format_constraints_fulfilled": { - "title": "format_constraints_fulfilled", - "type": "boolean" - } - }, - "type": "object" - }, - "RequirementConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints_expression": { - "title": "format_constraints_expression", - "type": ["string", "null"] - }, - "hints": { - "title": "hints", - "type": ["string", "null"] - }, - "requirement_constraints_fulfilled": { - "title": "requirement_constraints_fulfilled", - "type": "boolean" - }, - "requirement_is_conditional": { - "title": "requirement_is_conditional", - "type": "boolean" - } - }, - "type": "object" - } - }, - "properties": { - "$ref": "#/definitions/ConditionKeyConditionTextMappingSchema/properties" - }, - "title": "ConditionKeyConditionTextMappingSchema", - "type": "object" + "title": "ConditionKeyConditionTextMappingSchema", + "type": "object" } diff --git a/json_schemas/ContentEvaluationResultSchema.json b/json_schemas/ContentEvaluationResultSchema.json index 0782cd29..f901f266 100644 --- a/json_schemas/ContentEvaluationResultSchema.json +++ b/json_schemas/ContentEvaluationResultSchema.json @@ -1,199 +1,238 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "AhbExpressionEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraint_evaluation_result": { - "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", - "type": "object" - }, - "requirement_constraint_evaluation_result": { - "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", - "type": "object" - }, - "requirement_indicator": { - "title": "", - "type": "string" - } - }, - "type": "object" - }, - "ConditionKeyConditionTextMappingSchema": { - "additionalProperties": false, - "properties": { - "condition_key": { - "title": "condition_key", - "type": "string" - }, - "condition_text": { - "title": "condition_text", - "type": ["string", "null"] - }, - "edifact_format": { - "enum": [ - "APERAK", - "COMDIS", - "CONTRL", - "IFTSTA", - "INSRPT", - "INVOIC", - "MSCONS", - "ORDCHG", - "ORDERS", - "ORDRSP", - "PRICAT", - "QUOTES", - "REMADV", - "REQOTE", - "PARTIN", - "UTILMD", - "UTILTS" - ], - "title": "edifact_format", - "type": "string" - } - }, - "type": "object" - }, - "ContentEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints": { - "additionalProperties": { - "$ref": "#/definitions/EvaluatedFormatConstraintSchema", + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "AhbExpressionEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraint_evaluation_result": { + "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_constraint_evaluation_result": { + "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_indicator": { + "title": "", + "type": "string" + } + }, "type": "object" - }, - "title": "format_constraints", - "type": "object" }, - "hints": { - "additionalProperties": { - "title": "hints", - "type": ["string", "null"] - }, - "title": "hints", - "type": "object" + "ConditionKeyConditionTextMappingSchema": { + "additionalProperties": false, + "properties": { + "condition_key": { + "title": "condition_key", + "type": "string" + }, + "condition_text": { + "title": "condition_text", + "type": [ + "string", + "null" + ] + }, + "edifact_format": { + "enum": [ + "APERAK", + "COMDIS", + "CONTRL", + "IFTSTA", + "INSRPT", + "INVOIC", + "MSCONS", + "ORDCHG", + "ORDERS", + "ORDRSP", + "PRICAT", + "QUOTES", + "REMADV", + "REQOTE", + "PARTIN", + "UTILMD", + "UTILMDG", + "UTILMDS", + "UTILMDW", + "UTILTS" + ], + "title": "edifact_format", + "type": "string" + } + }, + "type": "object" }, - "id": { - "default": false, - "format": "uuid", - "title": "id", - "type": ["string", "null"] + "ContentEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints": { + "additionalProperties": { + "$ref": "#/definitions/EvaluatedFormatConstraintSchema", + "type": "object" + }, + "title": "format_constraints", + "type": "object" + }, + "hints": { + "additionalProperties": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "title": "hints", + "type": "object" + }, + "id": { + "default": false, + "format": "uuid", + "title": "id", + "type": [ + "string", + "null" + ] + }, + "packages": { + "additionalProperties": { + "title": "packages", + "type": "string" + }, + "title": "packages", + "type": [ + "object", + "null" + ] + }, + "requirement_constraints": { + "additionalProperties": { + "title": "requirement_constraints", + "type": "string" + }, + "title": "requirement_constraints", + "type": "object" + } + }, + "required": [ + "format_constraints", + "hints", + "requirement_constraints" + ], + "type": "object" }, - "packages": { - "additionalProperties": { - "title": "packages", - "type": "string" - }, - "title": "packages", - "type": ["object", "null"] + "EvaluatedFormatConstraintSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "default": true, + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraint_fulfilled": { + "title": "format_constraint_fulfilled", + "type": "boolean" + } + }, + "required": [ + "format_constraint_fulfilled" + ], + "type": "object" }, - "requirement_constraints": { - "additionalProperties": { - "title": "requirement_constraints", - "type": "string" - }, - "title": "requirement_constraints", - "type": "object" - } - }, - "required": ["format_constraints", "hints", "requirement_constraints"], - "type": "object" - }, - "EvaluatedFormatConstraintSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "default": true, - "title": "error_message", - "type": ["string", "null"] + "FormatConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraints_fulfilled": { + "title": "format_constraints_fulfilled", + "type": "boolean" + } + }, + "type": "object" }, - "format_constraint_fulfilled": { - "title": "format_constraint_fulfilled", - "type": "boolean" - } - }, - "required": ["format_constraint_fulfilled"], - "type": "object" - }, - "FormatConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "title": "error_message", - "type": ["string", "null"] + "PackageKeyConditionExpressionMappingSchema": { + "additionalProperties": false, + "properties": { + "edifact_format": { + "enum": [ + "APERAK", + "COMDIS", + "CONTRL", + "IFTSTA", + "INSRPT", + "INVOIC", + "MSCONS", + "ORDCHG", + "ORDERS", + "ORDRSP", + "PRICAT", + "QUOTES", + "REMADV", + "REQOTE", + "PARTIN", + "UTILMD", + "UTILMDG", + "UTILMDS", + "UTILMDW", + "UTILTS" + ], + "title": "edifact_format", + "type": "string" + }, + "package_expression": { + "title": "package_expression", + "type": [ + "string", + "null" + ] + }, + "package_key": { + "title": "package_key", + "type": "string" + } + }, + "type": "object" }, - "format_constraints_fulfilled": { - "title": "format_constraints_fulfilled", - "type": "boolean" + "RequirementConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints_expression": { + "title": "format_constraints_expression", + "type": [ + "string", + "null" + ] + }, + "hints": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "requirement_constraints_fulfilled": { + "title": "requirement_constraints_fulfilled", + "type": "boolean" + }, + "requirement_is_conditional": { + "title": "requirement_is_conditional", + "type": "boolean" + } + }, + "type": "object" } - }, - "type": "object" }, - "PackageKeyConditionExpressionMappingSchema": { - "additionalProperties": false, - "properties": { - "edifact_format": { - "enum": [ - "APERAK", - "COMDIS", - "CONTRL", - "IFTSTA", - "INSRPT", - "INVOIC", - "MSCONS", - "ORDCHG", - "ORDERS", - "ORDRSP", - "PRICAT", - "QUOTES", - "REMADV", - "REQOTE", - "PARTIN", - "UTILMD", - "UTILTS" - ], - "title": "edifact_format", - "type": "string" - }, - "package_expression": { - "title": "package_expression", - "type": ["string", "null"] - }, - "package_key": { - "title": "package_key", - "type": "string" - } - }, - "type": "object" + "properties": { + "$ref": "#/definitions/ContentEvaluationResultSchema/properties" }, - "RequirementConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints_expression": { - "title": "format_constraints_expression", - "type": ["string", "null"] - }, - "hints": { - "title": "hints", - "type": ["string", "null"] - }, - "requirement_constraints_fulfilled": { - "title": "requirement_constraints_fulfilled", - "type": "boolean" - }, - "requirement_is_conditional": { - "title": "requirement_is_conditional", - "type": "boolean" - } - }, - "type": "object" - } - }, - "properties": { - "$ref": "#/definitions/ContentEvaluationResultSchema/properties" - }, - "title": "ContentEvaluationResultSchema", - "type": "object" + "title": "ContentEvaluationResultSchema", + "type": "object" } diff --git a/json_schemas/EvaluatedFormatConstraintSchema.json b/json_schemas/EvaluatedFormatConstraintSchema.json index 3a2a6481..a9abd0ae 100644 --- a/json_schemas/EvaluatedFormatConstraintSchema.json +++ b/json_schemas/EvaluatedFormatConstraintSchema.json @@ -1,62 +1,76 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "EvaluatedFormatConstraintSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "default": true, - "title": "error_message", - "type": ["string", "null"] + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "EvaluatedFormatConstraintSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "default": true, + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraint_fulfilled": { + "title": "format_constraint_fulfilled", + "type": "boolean" + } + }, + "required": [ + "format_constraint_fulfilled" + ], + "type": "object" }, - "format_constraint_fulfilled": { - "title": "format_constraint_fulfilled", - "type": "boolean" - } - }, - "required": ["format_constraint_fulfilled"], - "type": "object" - }, - "FormatConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "title": "error_message", - "type": ["string", "null"] + "FormatConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraints_fulfilled": { + "title": "format_constraints_fulfilled", + "type": "boolean" + } + }, + "type": "object" }, - "format_constraints_fulfilled": { - "title": "format_constraints_fulfilled", - "type": "boolean" + "RequirementConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints_expression": { + "title": "format_constraints_expression", + "type": [ + "string", + "null" + ] + }, + "hints": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "requirement_constraints_fulfilled": { + "title": "requirement_constraints_fulfilled", + "type": "boolean" + }, + "requirement_is_conditional": { + "title": "requirement_is_conditional", + "type": "boolean" + } + }, + "type": "object" } - }, - "type": "object" }, - "RequirementConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints_expression": { - "title": "format_constraints_expression", - "type": ["string", "null"] - }, - "hints": { - "title": "hints", - "type": ["string", "null"] - }, - "requirement_constraints_fulfilled": { - "title": "requirement_constraints_fulfilled", - "type": "boolean" - }, - "requirement_is_conditional": { - "title": "requirement_is_conditional", - "type": "boolean" - } - }, - "type": "object" - } - }, - "properties": { - "$ref": "#/definitions/EvaluatedFormatConstraintSchema/properties" - }, - "title": "EvaluatedFormatConstraintSchema", - "type": "object" + "properties": { + "$ref": "#/definitions/EvaluatedFormatConstraintSchema/properties" + }, + "title": "EvaluatedFormatConstraintSchema", + "type": "object" } diff --git a/json_schemas/FormatConstraintEvaluationResultSchema.json b/json_schemas/FormatConstraintEvaluationResultSchema.json index 5700a8ba..aa8f2c64 100644 --- a/json_schemas/FormatConstraintEvaluationResultSchema.json +++ b/json_schemas/FormatConstraintEvaluationResultSchema.json @@ -1,46 +1,55 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "FormatConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "title": "error_message", - "type": ["string", "null"] + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "FormatConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraints_fulfilled": { + "title": "format_constraints_fulfilled", + "type": "boolean" + } + }, + "type": "object" }, - "format_constraints_fulfilled": { - "title": "format_constraints_fulfilled", - "type": "boolean" + "RequirementConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints_expression": { + "title": "format_constraints_expression", + "type": [ + "string", + "null" + ] + }, + "hints": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "requirement_constraints_fulfilled": { + "title": "requirement_constraints_fulfilled", + "type": "boolean" + }, + "requirement_is_conditional": { + "title": "requirement_is_conditional", + "type": "boolean" + } + }, + "type": "object" } - }, - "type": "object" }, - "RequirementConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints_expression": { - "title": "format_constraints_expression", - "type": ["string", "null"] - }, - "hints": { - "title": "hints", - "type": ["string", "null"] - }, - "requirement_constraints_fulfilled": { - "title": "requirement_constraints_fulfilled", - "type": "boolean" - }, - "requirement_is_conditional": { - "title": "requirement_is_conditional", - "type": "boolean" - } - }, - "type": "object" - } - }, - "properties": { - "$ref": "#/definitions/FormatConstraintEvaluationResultSchema/properties" - }, - "title": "FormatConstraintEvaluationResultSchema", - "type": "object" + "properties": { + "$ref": "#/definitions/FormatConstraintEvaluationResultSchema/properties" + }, + "title": "FormatConstraintEvaluationResultSchema", + "type": "object" } diff --git a/json_schemas/PackageKeyConditionExpressionMappingSchema.json b/json_schemas/PackageKeyConditionExpressionMappingSchema.json index bf5ed54b..d463649c 100644 --- a/json_schemas/PackageKeyConditionExpressionMappingSchema.json +++ b/json_schemas/PackageKeyConditionExpressionMappingSchema.json @@ -1,154 +1,180 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "AhbExpressionEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraint_evaluation_result": { - "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", - "type": "object" + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "AhbExpressionEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraint_evaluation_result": { + "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_constraint_evaluation_result": { + "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_indicator": { + "title": "", + "type": "string" + } + }, + "type": "object" }, - "requirement_constraint_evaluation_result": { - "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", - "type": "object" + "ConditionKeyConditionTextMappingSchema": { + "additionalProperties": false, + "properties": { + "condition_key": { + "title": "condition_key", + "type": "string" + }, + "condition_text": { + "title": "condition_text", + "type": [ + "string", + "null" + ] + }, + "edifact_format": { + "enum": [ + "APERAK", + "COMDIS", + "CONTRL", + "IFTSTA", + "INSRPT", + "INVOIC", + "MSCONS", + "ORDCHG", + "ORDERS", + "ORDRSP", + "PRICAT", + "QUOTES", + "REMADV", + "REQOTE", + "PARTIN", + "UTILMD", + "UTILMDG", + "UTILMDS", + "UTILMDW", + "UTILTS" + ], + "title": "edifact_format", + "type": "string" + } + }, + "type": "object" }, - "requirement_indicator": { - "title": "", - "type": "string" - } - }, - "type": "object" - }, - "ConditionKeyConditionTextMappingSchema": { - "additionalProperties": false, - "properties": { - "condition_key": { - "title": "condition_key", - "type": "string" + "EvaluatedFormatConstraintSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "default": true, + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraint_fulfilled": { + "title": "format_constraint_fulfilled", + "type": "boolean" + } + }, + "required": [ + "format_constraint_fulfilled" + ], + "type": "object" }, - "condition_text": { - "title": "condition_text", - "type": ["string", "null"] + "FormatConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraints_fulfilled": { + "title": "format_constraints_fulfilled", + "type": "boolean" + } + }, + "type": "object" }, - "edifact_format": { - "enum": [ - "APERAK", - "COMDIS", - "CONTRL", - "IFTSTA", - "INSRPT", - "INVOIC", - "MSCONS", - "ORDCHG", - "ORDERS", - "ORDRSP", - "PRICAT", - "QUOTES", - "REMADV", - "REQOTE", - "PARTIN", - "UTILMD", - "UTILTS" - ], - "title": "edifact_format", - "type": "string" - } - }, - "type": "object" - }, - "EvaluatedFormatConstraintSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "default": true, - "title": "error_message", - "type": ["string", "null"] - }, - "format_constraint_fulfilled": { - "title": "format_constraint_fulfilled", - "type": "boolean" - } - }, - "required": ["format_constraint_fulfilled"], - "type": "object" - }, - "FormatConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "title": "error_message", - "type": ["string", "null"] + "PackageKeyConditionExpressionMappingSchema": { + "additionalProperties": false, + "properties": { + "edifact_format": { + "enum": [ + "APERAK", + "COMDIS", + "CONTRL", + "IFTSTA", + "INSRPT", + "INVOIC", + "MSCONS", + "ORDCHG", + "ORDERS", + "ORDRSP", + "PRICAT", + "QUOTES", + "REMADV", + "REQOTE", + "PARTIN", + "UTILMD", + "UTILMDG", + "UTILMDS", + "UTILMDW", + "UTILTS" + ], + "title": "edifact_format", + "type": "string" + }, + "package_expression": { + "title": "package_expression", + "type": [ + "string", + "null" + ] + }, + "package_key": { + "title": "package_key", + "type": "string" + } + }, + "type": "object" }, - "format_constraints_fulfilled": { - "title": "format_constraints_fulfilled", - "type": "boolean" + "RequirementConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints_expression": { + "title": "format_constraints_expression", + "type": [ + "string", + "null" + ] + }, + "hints": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "requirement_constraints_fulfilled": { + "title": "requirement_constraints_fulfilled", + "type": "boolean" + }, + "requirement_is_conditional": { + "title": "requirement_is_conditional", + "type": "boolean" + } + }, + "type": "object" } - }, - "type": "object" }, - "PackageKeyConditionExpressionMappingSchema": { - "additionalProperties": false, - "properties": { - "edifact_format": { - "enum": [ - "APERAK", - "COMDIS", - "CONTRL", - "IFTSTA", - "INSRPT", - "INVOIC", - "MSCONS", - "ORDCHG", - "ORDERS", - "ORDRSP", - "PRICAT", - "QUOTES", - "REMADV", - "REQOTE", - "PARTIN", - "UTILMD", - "UTILTS" - ], - "title": "edifact_format", - "type": "string" - }, - "package_expression": { - "title": "package_expression", - "type": ["string", "null"] - }, - "package_key": { - "title": "package_key", - "type": "string" - } - }, - "type": "object" + "properties": { + "$ref": "#/definitions/PackageKeyConditionExpressionMappingSchema/properties" }, - "RequirementConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints_expression": { - "title": "format_constraints_expression", - "type": ["string", "null"] - }, - "hints": { - "title": "hints", - "type": ["string", "null"] - }, - "requirement_constraints_fulfilled": { - "title": "requirement_constraints_fulfilled", - "type": "boolean" - }, - "requirement_is_conditional": { - "title": "requirement_is_conditional", - "type": "boolean" - } - }, - "type": "object" - } - }, - "properties": { - "$ref": "#/definitions/PackageKeyConditionExpressionMappingSchema/properties" - }, - "title": "PackageKeyConditionExpressionMappingSchema", - "type": "object" + "title": "PackageKeyConditionExpressionMappingSchema", + "type": "object" } diff --git a/json_schemas/RequirementConstraintEvaluationResultSchema.json b/json_schemas/RequirementConstraintEvaluationResultSchema.json index ad074f10..f919ad2b 100644 --- a/json_schemas/RequirementConstraintEvaluationResultSchema.json +++ b/json_schemas/RequirementConstraintEvaluationResultSchema.json @@ -1,32 +1,38 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "RequirementConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints_expression": { - "title": "format_constraints_expression", - "type": ["string", "null"] - }, - "hints": { - "title": "hints", - "type": ["string", "null"] - }, - "requirement_constraints_fulfilled": { - "title": "requirement_constraints_fulfilled", - "type": "boolean" - }, - "requirement_is_conditional": { - "title": "requirement_is_conditional", - "type": "boolean" + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "RequirementConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints_expression": { + "title": "format_constraints_expression", + "type": [ + "string", + "null" + ] + }, + "hints": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "requirement_constraints_fulfilled": { + "title": "requirement_constraints_fulfilled", + "type": "boolean" + }, + "requirement_is_conditional": { + "title": "requirement_is_conditional", + "type": "boolean" + } + }, + "type": "object" } - }, - "type": "object" - } - }, - "properties": { - "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema/properties" - }, - "title": "RequirementConstraintEvaluationResultSchema", - "type": "object" + }, + "properties": { + "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema/properties" + }, + "title": "RequirementConstraintEvaluationResultSchema", + "type": "object" } diff --git a/json_schemas/TokenSchema.json b/json_schemas/TokenSchema.json index b5997bad..a8fac68c 100644 --- a/json_schemas/TokenSchema.json +++ b/json_schemas/TokenSchema.json @@ -1,215 +1,257 @@ { - "$schema": "http://json-schema.org/draft-07/schema#", - "definitions": { - "AhbExpressionEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraint_evaluation_result": { - "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", - "type": "object" - }, - "requirement_constraint_evaluation_result": { - "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", - "type": "object" - }, - "requirement_indicator": { - "title": "", - "type": "string" - } - }, - "type": "object" - }, - "ConditionKeyConditionTextMappingSchema": { - "additionalProperties": false, - "properties": { - "condition_key": { - "title": "condition_key", - "type": "string" - }, - "condition_text": { - "title": "condition_text", - "type": ["string", "null"] - }, - "edifact_format": { - "enum": [ - "APERAK", - "COMDIS", - "CONTRL", - "IFTSTA", - "INSRPT", - "INVOIC", - "MSCONS", - "ORDCHG", - "ORDERS", - "ORDRSP", - "PRICAT", - "QUOTES", - "REMADV", - "REQOTE", - "PARTIN", - "UTILMD", - "UTILTS" - ], - "title": "edifact_format", - "type": "string" - } - }, - "type": "object" - }, - "ContentEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints": { - "additionalProperties": { - "$ref": "#/definitions/EvaluatedFormatConstraintSchema", + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "AhbExpressionEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraint_evaluation_result": { + "$ref": "#/definitions/FormatConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_constraint_evaluation_result": { + "$ref": "#/definitions/RequirementConstraintEvaluationResultSchema", + "type": "object" + }, + "requirement_indicator": { + "title": "", + "type": "string" + } + }, "type": "object" - }, - "title": "format_constraints", - "type": "object" - }, - "hints": { - "additionalProperties": { - "title": "hints", - "type": ["string", "null"] - }, - "title": "hints", - "type": "object" }, - "id": { - "default": false, - "format": "uuid", - "title": "id", - "type": ["string", "null"] + "ConditionKeyConditionTextMappingSchema": { + "additionalProperties": false, + "properties": { + "condition_key": { + "title": "condition_key", + "type": "string" + }, + "condition_text": { + "title": "condition_text", + "type": [ + "string", + "null" + ] + }, + "edifact_format": { + "enum": [ + "APERAK", + "COMDIS", + "CONTRL", + "IFTSTA", + "INSRPT", + "INVOIC", + "MSCONS", + "ORDCHG", + "ORDERS", + "ORDRSP", + "PRICAT", + "QUOTES", + "REMADV", + "REQOTE", + "PARTIN", + "UTILMD", + "UTILMDG", + "UTILMDS", + "UTILMDW", + "UTILTS" + ], + "title": "edifact_format", + "type": "string" + } + }, + "type": "object" }, - "packages": { - "additionalProperties": { - "title": "packages", - "type": "string" - }, - "title": "packages", - "type": ["object", "null"] + "ContentEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints": { + "additionalProperties": { + "$ref": "#/definitions/EvaluatedFormatConstraintSchema", + "type": "object" + }, + "title": "format_constraints", + "type": "object" + }, + "hints": { + "additionalProperties": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "title": "hints", + "type": "object" + }, + "id": { + "default": false, + "format": "uuid", + "title": "id", + "type": [ + "string", + "null" + ] + }, + "packages": { + "additionalProperties": { + "title": "packages", + "type": "string" + }, + "title": "packages", + "type": [ + "object", + "null" + ] + }, + "requirement_constraints": { + "additionalProperties": { + "title": "requirement_constraints", + "type": "string" + }, + "title": "requirement_constraints", + "type": "object" + } + }, + "required": [ + "format_constraints", + "hints", + "requirement_constraints" + ], + "type": "object" }, - "requirement_constraints": { - "additionalProperties": { - "title": "requirement_constraints", - "type": "string" - }, - "title": "requirement_constraints", - "type": "object" - } - }, - "required": ["format_constraints", "hints", "requirement_constraints"], - "type": "object" - }, - "EvaluatedFormatConstraintSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "default": true, - "title": "error_message", - "type": ["string", "null"] + "EvaluatedFormatConstraintSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "default": true, + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraint_fulfilled": { + "title": "format_constraint_fulfilled", + "type": "boolean" + } + }, + "required": [ + "format_constraint_fulfilled" + ], + "type": "object" }, - "format_constraint_fulfilled": { - "title": "format_constraint_fulfilled", - "type": "boolean" - } - }, - "required": ["format_constraint_fulfilled"], - "type": "object" - }, - "FormatConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "error_message": { - "title": "error_message", - "type": ["string", "null"] + "FormatConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "error_message": { + "title": "error_message", + "type": [ + "string", + "null" + ] + }, + "format_constraints_fulfilled": { + "title": "format_constraints_fulfilled", + "type": "boolean" + } + }, + "type": "object" }, - "format_constraints_fulfilled": { - "title": "format_constraints_fulfilled", - "type": "boolean" - } - }, - "type": "object" - }, - "PackageKeyConditionExpressionMappingSchema": { - "additionalProperties": false, - "properties": { - "edifact_format": { - "enum": [ - "APERAK", - "COMDIS", - "CONTRL", - "IFTSTA", - "INSRPT", - "INVOIC", - "MSCONS", - "ORDCHG", - "ORDERS", - "ORDRSP", - "PRICAT", - "QUOTES", - "REMADV", - "REQOTE", - "PARTIN", - "UTILMD", - "UTILTS" - ], - "title": "edifact_format", - "type": "string" + "PackageKeyConditionExpressionMappingSchema": { + "additionalProperties": false, + "properties": { + "edifact_format": { + "enum": [ + "APERAK", + "COMDIS", + "CONTRL", + "IFTSTA", + "INSRPT", + "INVOIC", + "MSCONS", + "ORDCHG", + "ORDERS", + "ORDRSP", + "PRICAT", + "QUOTES", + "REMADV", + "REQOTE", + "PARTIN", + "UTILMD", + "UTILMDG", + "UTILMDS", + "UTILMDW", + "UTILTS" + ], + "title": "edifact_format", + "type": "string" + }, + "package_expression": { + "title": "package_expression", + "type": [ + "string", + "null" + ] + }, + "package_key": { + "title": "package_key", + "type": "string" + } + }, + "type": "object" }, - "package_expression": { - "title": "package_expression", - "type": ["string", "null"] + "RequirementConstraintEvaluationResultSchema": { + "additionalProperties": false, + "properties": { + "format_constraints_expression": { + "title": "format_constraints_expression", + "type": [ + "string", + "null" + ] + }, + "hints": { + "title": "hints", + "type": [ + "string", + "null" + ] + }, + "requirement_constraints_fulfilled": { + "title": "requirement_constraints_fulfilled", + "type": "boolean" + }, + "requirement_is_conditional": { + "title": "requirement_is_conditional", + "type": "boolean" + } + }, + "type": "object" }, - "package_key": { - "title": "package_key", - "type": "string" + "TokenSchema": { + "additionalProperties": false, + "properties": { + "type": { + "default": false, + "title": "type", + "type": "string" + }, + "value": { + "default": false, + "title": "value", + "type": [ + "string", + "null" + ] + } + }, + "type": "object" } - }, - "type": "object" }, - "RequirementConstraintEvaluationResultSchema": { - "additionalProperties": false, - "properties": { - "format_constraints_expression": { - "title": "format_constraints_expression", - "type": ["string", "null"] - }, - "hints": { - "title": "hints", - "type": ["string", "null"] - }, - "requirement_constraints_fulfilled": { - "title": "requirement_constraints_fulfilled", - "type": "boolean" - }, - "requirement_is_conditional": { - "title": "requirement_is_conditional", - "type": "boolean" - } - }, - "type": "object" + "properties": { + "$ref": "#/definitions/TokenSchema/properties" }, - "TokenSchema": { - "additionalProperties": false, - "properties": { - "type": { - "default": false, - "title": "type", - "type": "string" - }, - "value": { - "default": false, - "title": "value", - "type": ["string", "null"] - } - }, - "type": "object" - } - }, - "properties": { - "$ref": "#/definitions/TokenSchema/properties" - }, - "title": "TokenSchema", - "type": "object" + "title": "TokenSchema", + "type": "object" } diff --git a/pyproject.toml b/pyproject.toml index 4a393ef0..80b964be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ test_packaging = [ "build==1.2.2.post1", "setuptools==75.2.0", "setuptools-scm==8.1.0", - "twine==5.1.1", + "twine==6.0.1", ] tests = [ "pytest==8.3.3", diff --git a/src/ahbicht/expressions/condition_expression_parser.py b/src/ahbicht/expressions/condition_expression_parser.py index 154e73be..bd9fbf82 100644 --- a/src/ahbicht/expressions/condition_expression_parser.py +++ b/src/ahbicht/expressions/condition_expression_parser.py @@ -135,7 +135,10 @@ def extract_categorized_keys_from_tree( async def extract_categorized_keys( - condition_expression: str, resolve_packages: bool = False, replace_time_conditions: bool = False + condition_expression: str, + resolve_packages: bool = False, + resolve_time_conditions: bool = False, + replace_time_conditions: bool = False, ) -> CategorizedKeyExtract: """ Parses the given condition expression and returns CategorizedKeyExtract as a template for content @@ -148,6 +151,9 @@ async def extract_categorized_keys( from ahbicht.expressions.expression_resolver import parse_expression_including_unresolved_subexpressions tree = await parse_expression_including_unresolved_subexpressions( - condition_expression, resolve_packages=resolve_packages, replace_time_conditions=replace_time_conditions + condition_expression, + resolve_packages=resolve_packages, + resolve_time_conditions=resolve_time_conditions, + replace_time_conditions=replace_time_conditions, ) return extract_categorized_keys_from_tree(tree, sanitize=True) diff --git a/src/ahbicht/expressions/expression_resolver.py b/src/ahbicht/expressions/expression_resolver.py index 5f33bae9..72e43a3f 100644 --- a/src/ahbicht/expressions/expression_resolver.py +++ b/src/ahbicht/expressions/expression_resolver.py @@ -22,13 +22,17 @@ async def parse_expression_including_unresolved_subexpressions( - expression: str, resolve_packages: bool = False, replace_time_conditions: bool = True + expression: str, + resolve_packages: bool = False, + resolve_time_conditions: bool = True, + replace_time_conditions: bool = True, ) -> Tree[Token]: """ Parses expressions and resolves its subexpressions, for example condition_expressions in ahb_expressions or packages in condition_expressions. :param expression: a syntactically valid ahb_expression or condition_expression :param resolve_packages: if true resolves also the packages in the condition_expressions + :param resolve_time_conditions: if true resolves also the time conditions in the condition_expressions :param replace_time_conditions: if true the time conditions "UBx" are replaced with format constraints """ try: @@ -43,8 +47,8 @@ async def parse_expression_including_unresolved_subexpressions( if resolve_packages: # the condition expression inside the ahb expression has to be resolved before trying to resolve packages expression_tree = await expand_packages(expression_tree) - if replace_time_conditions: - expression_tree = expand_time_conditions(expression_tree) + if resolve_time_conditions: + expression_tree = expand_time_conditions(expression_tree, replace_time_conditions) return expression_tree @@ -60,11 +64,12 @@ async def expand_packages(parsed_tree: Tree) -> Tree[Token]: return result -def expand_time_conditions(parsed_tree: Tree) -> Tree[Token]: +def expand_time_conditions(parsed_tree: Tree, replace_time_conditions: bool = True) -> Tree[Token]: """ - Replaces all the time conditions "UBx" with format constraints (and requirements constraints for UB3) + Replaces either all the "short" time conditions in parser_tree with the respective "long" condition expressions + or replaces all the time conditions "UBx" with format constraints (and requirements constraints for UB3) """ - result = TimeConditionTransformer().transform(parsed_tree) + result = TimeConditionTransformer(replace_time_conditions).transform(parsed_tree) return result @@ -149,6 +154,10 @@ async def _package_async(self, package_key_token: Token, evaluatable_data: Evalu # pylint: disable=invalid-name class TimeConditionTransformer(Transformer): """ + There are two options which are chosen by the boolean `replace_time_conditions`: + i: + The time conditions are resolved as provided in the "Allgemeine Festlegungen". + ii: The TimeConditionEvaluator replaces "time conditions" (aka "UB1", "UB2", "UB3") with evaluatable format constraints. This is not what BDEW suggests us to do in the "Allgemeine Festlegungen". BDEW says that "UBx" conditions have to be expanded just like packages: For example "UB1" shall be expanded to "([931] ∧ [932] [490]) ⊻ ([931] ∧ [933] [491])". @@ -190,9 +199,21 @@ class TimeConditionTransformer(Transformer): constraint for the respective division. """ + def __init__(self, replace_time_conditions: bool = True): + super().__init__() + self.replace_time_conditions = replace_time_conditions + def time_condition(self, tokens: List[Token]) -> Tree: """ - try to resolve the package using the injected PackageResolver + Replace or resolve time conditions. + """ + if self.replace_time_conditions: + return self._replace_time_condition(tokens) + return self._expand_time_condition(tokens) + + def _replace_time_condition(self, tokens: List[Token]) -> Tree: + """ + Replace and resolve time conditions. """ time_condition_key = tokens[0].value if time_condition_key == "UB1": @@ -206,3 +227,25 @@ def time_condition(self, tokens: List[Token]) -> Tree: # RC 493 = receiver is from division gas return parse_condition_expression_to_tree("[932][492]X[934][493]") raise NotImplementedError(f"The time_condition '{time_condition_key}' is not implemented") + + def _expand_time_condition(self, tokens: List[Token]) -> Tree: + """ + try to resolve the time conditions using the injected PackageResolver + """ + time_condition_key = tokens[0].value + if time_condition_key == "UB1": + # a format constraint for "Stromtag" + return parse_condition_expression_to_tree("([931]∧[932][490])⊻([931]∧[933][491])") + if time_condition_key == "UB2": + # a format constraint for "Gastage" + return parse_condition_expression_to_tree("([931]∧[934][490])⊻([931]∧[935][491])") + if time_condition_key == "UB3": + # RC 492 = receiver is from division electricity/strom + # RC 493 = receiver is from division gas + return parse_condition_expression_to_tree( + "([931]∧[932][492]∧[490])⊻" + "([931]∧[933][492]∧[491])⊻" + "([931]∧[934][493]∧[490])⊻" + "([931]∧[935][493]∧[491])" + ) + raise NotImplementedError(f"The time_condition '{time_condition_key}' is not implemented") diff --git a/unittests/test_time_condition_resolver.py b/unittests/test_time_condition_resolver.py index 857007a6..6ec8814e 100644 --- a/unittests/test_time_condition_resolver.py +++ b/unittests/test_time_condition_resolver.py @@ -14,11 +14,12 @@ class TestTimeConditionReplacement: """ @pytest.mark.parametrize( - "expression, replace_time_conditions, expected_tree", + "expression, replace_time_conditions, resolve_time_conditions, expected_tree", [ pytest.param( "[UB1] U [42]", False, + False, Tree( # type:ignore[misc] "and_composition", [ @@ -30,6 +31,7 @@ class TestTimeConditionReplacement: pytest.param( "[UB1] U [42]", True, + True, Tree( # type:ignore[misc] "and_composition", [ @@ -41,6 +43,7 @@ class TestTimeConditionReplacement: pytest.param( "[UB2] U [42]", False, + False, Tree( # type:ignore[misc] "and_composition", [ @@ -51,11 +54,54 @@ class TestTimeConditionReplacement: ), pytest.param( "[UB2] U [42]", - True, + False, + False, Tree( # type:ignore[misc] "and_composition", [ - Tree(Token("RULE", "condition"), [Token("CONDITION_KEY", "934")]), + Tree(Token("RULE", "time_condition"), [Token("TIME_CONDITION_KEY", "UB2")]), + Tree(Token("RULE", "condition"), [Token("CONDITION_KEY", "42")]), + ], + ), + ), + pytest.param( + "[UB2] U [42]", + False, + True, + Tree( + "and_composition", + [ + Tree( + "xor_composition", + [ + Tree( + "and_composition", + [ + Tree(Token("RULE", "condition"), [Token("CONDITION_KEY", "931")]), + Tree( + "then_also_composition", + [ + Tree(Token("RULE", "condition"), [Token("CONDITION_KEY", "934")]), + Tree(Token("RULE", "condition"), [Token("CONDITION_KEY", "490")]), + ], + ), + ], + ), + Tree( + "and_composition", + [ + Tree(Token("RULE", "condition"), [Token("CONDITION_KEY", "931")]), + Tree( + "then_also_composition", + [ + Tree(Token("RULE", "condition"), [Token("CONDITION_KEY", "935")]), + Tree(Token("RULE", "condition"), [Token("CONDITION_KEY", "491")]), + ], + ), + ], + ), + ], + ), Tree(Token("RULE", "condition"), [Token("CONDITION_KEY", "42")]), ], ), @@ -63,6 +109,7 @@ class TestTimeConditionReplacement: pytest.param( "[UB3] U [42]", False, + False, Tree( # type:ignore[misc] "and_composition", [ @@ -74,6 +121,7 @@ class TestTimeConditionReplacement: pytest.param( "[UB3] U [42]", True, + True, Tree( # type:ignore[misc] "and_composition", [ @@ -103,9 +151,9 @@ class TestTimeConditionReplacement: ], ) async def test_time_condition_expansion( - self, expression: str, replace_time_conditions: bool, expected_tree: Tree[Token] + self, expression: str, replace_time_conditions: bool, resolve_time_conditions: bool, expected_tree: Tree[Token] ): parsed_tree = await parse_expression_including_unresolved_subexpressions( - expression, replace_time_conditions=replace_time_conditions + expression, replace_time_conditions=replace_time_conditions, resolve_time_conditions=resolve_time_conditions ) assert parsed_tree == expected_tree