Simplify the format, it'll be easy enough to convert to and from the backend requirements

This commit is contained in:
Jon Herron 2023-04-12 18:12:33 -04:00
parent 54a0030ebd
commit 7ca888ff32
6 changed files with 148 additions and 174 deletions

View File

@ -13,16 +13,6 @@ PROCESS_MODELS_DIR = "tests/data/process-models"
def bpmn_test_case(suffix):
return f"{PROCESS_MODELS_DIR}/test-cases/{suffix}"
# TODO: as we add more do a convention where the folder, file and process id line up so
# this can be assumed for the majority of cases
PROCESS_IDS = {
bpmn_test_case("countries-and-cities/country_cities.bpmn"): "Process_sypm122",
bpmn_test_case("manual-tasks/manual_tasks.bpmn"): "Process_diu8ta2",
bpmn_test_case("no-tasks/no-tasks.bpmn"): "no_tasks",
bpmn_test_case("simple-call-activity/simple_call_activity.bpmn"): "Process_p4pfxhq",
bpmn_test_case("single-task/single_task.bpmn"): "SingleTask_Process",
}
SUPPORTING_FILES = {
bpmn_test_case("simple-call-activity/simple_call_activity.bpmn"): [
bpmn_test_case("single-task/single_task.bpmn"),
@ -36,20 +26,10 @@ def _required_files(bpmn_file):
def _to_dict(bpmn_file):
parser = SpiffBpmnParser()
bpmn_files = _required_files(bpmn_file)
process_id = PROCESS_IDS[bpmn_file]
parser.add_bpmn_files(bpmn_files)
# TODO: backend make two find calls, one for the spec and one for the subprocesses
specs = parser.find_all_specs()
# spiffworkflow-backend does it like this, so
bpmn_process_spec = parser.get_spec(process_id)
subspecs = parser.get_subprocess_specs(process_id)
#return {k: SPEC_CONVERTER.convert(v) for k, v in specs.items()}
return {
"spec": SPEC_CONVERTER.convert(bpmn_process_spec),
"sub_processes": {k: SPEC_CONVERTER.convert(v) for k, v in subspecs.items()}
}
return {k: SPEC_CONVERTER.convert(v) for k, v in specs.items()}
def _write_dict_as_json(bpmn_file, dct):
# correct, this is not very robust

View File

@ -1,5 +1,5 @@
{
"spec": {
"Process_sypm122": {
"correlation_keys": {},
"data_objects": {},
"description": "Process_sypm122",
@ -348,6 +348,5 @@
}
},
"typename": "BpmnProcessSpec"
},
"sub_processes": {}
}
}

View File

@ -1,5 +1,5 @@
{
"spec": {
"Process_diu8ta2": {
"correlation_keys": {},
"data_objects": {},
"description": "Process_diu8ta2",
@ -164,6 +164,5 @@
}
},
"typename": "BpmnProcessSpec"
},
"sub_processes": {}
}
}

View File

@ -1,5 +1,5 @@
{
"spec": {
"no_tasks": {
"correlation_keys": {},
"data_objects": {},
"description": "No Tasks",
@ -110,6 +110,5 @@
}
},
"typename": "BpmnProcessSpec"
},
"sub_processes": {}
}
}

View File

@ -1,5 +1,5 @@
{
"spec": {
"Process_p4pfxhq": {
"correlation_keys": {},
"data_objects": {},
"description": "Process_p4pfxhq",
@ -139,146 +139,144 @@
},
"typename": "BpmnProcessSpec"
},
"sub_processes": {
"SingleTask_Process": {
"correlation_keys": {},
"data_objects": {},
"description": "SingleTask_Process",
"file": "tests/data/process-models/test-cases/single-task/single_task.bpmn",
"io_specification": null,
"name": "SingleTask_Process",
"task_specs": {
"Activity_1mwbqi4": {
"data_input_associations": [],
"data_output_associations": [],
"description": "x=1",
"documentation": null,
"extensions": {},
"id": "SingleTask_Process_5",
"inputs": [
"StartEvent_1"
],
"internal": false,
"io_specification": null,
"lane": null,
"lookahead": 2,
"manual": false,
"name": "Activity_1mwbqi4",
"outputs": [
"Event_1gsb2u0"
],
"position": {
"x": 270.0,
"y": 137.0
},
"postscript": null,
"prescript": null,
"script": "x=1",
"typename": "ScriptTask"
"SingleTask_Process": {
"correlation_keys": {},
"data_objects": {},
"description": "SingleTask_Process",
"file": "tests/data/process-models/test-cases/single-task/single_task.bpmn",
"io_specification": null,
"name": "SingleTask_Process",
"task_specs": {
"Activity_1mwbqi4": {
"data_input_associations": [],
"data_output_associations": [],
"description": "x=1",
"documentation": null,
"extensions": {},
"id": "SingleTask_Process_5",
"inputs": [
"StartEvent_1"
],
"internal": false,
"io_specification": null,
"lane": null,
"lookahead": 2,
"manual": false,
"name": "Activity_1mwbqi4",
"outputs": [
"Event_1gsb2u0"
],
"position": {
"x": 270.0,
"y": 137.0
},
"End": {
"description": "",
"id": "SingleTask_Process_3",
"inputs": [
"SingleTask_Process.EndJoin"
],
"internal": false,
"lookahead": 2,
"manual": false,
"name": "End",
"outputs": [],
"typename": "Simple"
},
"Event_1gsb2u0": {
"data_input_associations": [],
"data_output_associations": [],
"description": null,
"documentation": null,
"event_definition": {
"external": false,
"internal": false,
"typename": "NoneEventDefinition"
},
"extensions": {},
"id": "SingleTask_Process_6",
"inputs": [
"Activity_1mwbqi4"
],
"internal": false,
"io_specification": null,
"lane": null,
"lookahead": 2,
"manual": false,
"name": "Event_1gsb2u0",
"outputs": [
"SingleTask_Process.EndJoin"
],
"position": {
"x": 432.0,
"y": 159.0
},
"typename": "EndEvent"
},
"SingleTask_Process.EndJoin": {
"description": "",
"id": "SingleTask_Process_2",
"inputs": [
"Event_1gsb2u0"
],
"internal": false,
"lookahead": 2,
"manual": false,
"name": "SingleTask_Process.EndJoin",
"outputs": [
"End"
],
"typename": "_EndJoin"
},
"Start": {
"description": "",
"id": "SingleTask_Process_1",
"inputs": [],
"internal": false,
"lookahead": 2,
"manual": false,
"name": "Start",
"outputs": [
"StartEvent_1"
],
"typename": "StartTask"
},
"StartEvent_1": {
"data_input_associations": [],
"data_output_associations": [],
"description": null,
"documentation": null,
"event_definition": {
"external": false,
"internal": false,
"typename": "NoneEventDefinition"
},
"extensions": {},
"id": "SingleTask_Process_4",
"inputs": [
"Start"
],
"internal": false,
"io_specification": null,
"lane": null,
"lookahead": 2,
"manual": false,
"name": "StartEvent_1",
"outputs": [
"Activity_1mwbqi4"
],
"position": {
"x": 179.0,
"y": 159.0
},
"typename": "StartEvent"
}
"postscript": null,
"prescript": null,
"script": "x=1",
"typename": "ScriptTask"
},
"typename": "BpmnProcessSpec"
}
"End": {
"description": "",
"id": "SingleTask_Process_3",
"inputs": [
"SingleTask_Process.EndJoin"
],
"internal": false,
"lookahead": 2,
"manual": false,
"name": "End",
"outputs": [],
"typename": "Simple"
},
"Event_1gsb2u0": {
"data_input_associations": [],
"data_output_associations": [],
"description": null,
"documentation": null,
"event_definition": {
"external": false,
"internal": false,
"typename": "NoneEventDefinition"
},
"extensions": {},
"id": "SingleTask_Process_6",
"inputs": [
"Activity_1mwbqi4"
],
"internal": false,
"io_specification": null,
"lane": null,
"lookahead": 2,
"manual": false,
"name": "Event_1gsb2u0",
"outputs": [
"SingleTask_Process.EndJoin"
],
"position": {
"x": 432.0,
"y": 159.0
},
"typename": "EndEvent"
},
"SingleTask_Process.EndJoin": {
"description": "",
"id": "SingleTask_Process_2",
"inputs": [
"Event_1gsb2u0"
],
"internal": false,
"lookahead": 2,
"manual": false,
"name": "SingleTask_Process.EndJoin",
"outputs": [
"End"
],
"typename": "_EndJoin"
},
"Start": {
"description": "",
"id": "SingleTask_Process_1",
"inputs": [],
"internal": false,
"lookahead": 2,
"manual": false,
"name": "Start",
"outputs": [
"StartEvent_1"
],
"typename": "StartTask"
},
"StartEvent_1": {
"data_input_associations": [],
"data_output_associations": [],
"description": null,
"documentation": null,
"event_definition": {
"external": false,
"internal": false,
"typename": "NoneEventDefinition"
},
"extensions": {},
"id": "SingleTask_Process_4",
"inputs": [
"Start"
],
"internal": false,
"io_specification": null,
"lane": null,
"lookahead": 2,
"manual": false,
"name": "StartEvent_1",
"outputs": [
"Activity_1mwbqi4"
],
"position": {
"x": 179.0,
"y": 159.0
},
"typename": "StartEvent"
}
},
"typename": "BpmnProcessSpec"
}
}

View File

@ -1,5 +1,5 @@
{
"spec": {
"SingleTask_Process": {
"correlation_keys": {},
"data_objects": {},
"description": "SingleTask_Process",
@ -138,6 +138,5 @@
}
},
"typename": "BpmnProcessSpec"
},
"sub_processes": {}
}
}