2021-02-19 19:49:53 +00:00
|
|
|
generic_message = """Workflow validation failed. For more information about the error, see below."""
|
|
|
|
|
2021-02-12 19:18:42 +00:00
|
|
|
known_errors = {'Error is Non-default exclusive outgoing sequence flow without condition':
|
|
|
|
{'message': 'Missing condition', 'hint': 'Add a Condition Type to your gateway path.'}}
|
2021-02-19 19:49:53 +00:00
|
|
|
|
2021-02-04 16:23:05 +00:00
|
|
|
|
|
|
|
class ValidationErrorService(object):
|
|
|
|
|
|
|
|
"""Validation Error Service interprets messages return from api.workflow.validate_workflow_specification
|
|
|
|
Validation is run twice,
|
|
|
|
once where we try to fill in all form fields
|
|
|
|
and a second time where we only fill in the required fields.
|
|
|
|
|
|
|
|
We get a list that contains possible errors from the validation."""
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def interpret_validation_errors(errors):
|
|
|
|
if len(errors) == 0:
|
2021-02-10 17:28:59 +00:00
|
|
|
return ()
|
2021-02-19 19:49:53 +00:00
|
|
|
|
2021-02-12 19:18:42 +00:00
|
|
|
interpreted_errors = []
|
|
|
|
|
|
|
|
for error_type in ['all', 'required']:
|
|
|
|
if error_type in errors:
|
|
|
|
hint = generic_message
|
|
|
|
for known_key in known_errors:
|
|
|
|
if known_key in errors[error_type].message:
|
|
|
|
if 'hint' in known_errors[known_key]:
|
|
|
|
hint = known_errors[known_key]['hint']
|
2021-02-19 19:49:53 +00:00
|
|
|
|
2021-02-12 19:18:42 +00:00
|
|
|
errors[error_type].hint = hint
|
|
|
|
interpreted_errors.append(errors[error_type])
|
|
|
|
|
|
|
|
return interpreted_errors
|