diff --git a/src/spiffworkflow_backend/api.yml b/src/spiffworkflow_backend/api.yml
index 9f66dd5c..c1905c32 100755
--- a/src/spiffworkflow_backend/api.yml
+++ b/src/spiffworkflow_backend/api.yml
@@ -39,33 +39,6 @@ paths:
schema:
$ref: "#/components/schemas/WorkflowSpecCategory"
/process-models:
- # get:
- # operationId: crc.api.workflow.all_specifications
- # summary: Provides a list of workflows specifications that can be added to a study manually. Please note that Protocol Builder will handle this most of the time.
- # tags:
- # - Workflow Specifications
- # parameters :
- # - name : libraries
- # in : query
- # required : false
- # description : True if we should return just library schemas
- # schema :
- # type : boolean
- # - name : standalone
- # in : query
- # required : false
- # description : True if we should return just standalone schemas
- # schema :
- # type : boolean
- # responses:
- # '200':
- # description: An array of workflow specifications
- # content:
- # application/json:
- # schema:
- # type: array
- # items:
- # $ref: "#/components/schemas/WorkflowSpec"
post:
operationId: spiffworkflow_backend.routes.process_api_blueprint.add_process_model
summary: Creates a new workflow specification with the given parameters.
@@ -147,7 +120,7 @@ paths:
schema:
$ref: "#/components/schemas/WorkflowSpec"
post:
- operationId: spiffworkflow_backend.routes.process_api_blueprint.create_process_instance
+ operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_create
summary: Creates a workflow from a workflow spec and returns the workflow
tags:
- Workflow Specifications
diff --git a/src/spiffworkflow_backend/routes/process_api_blueprint.py b/src/spiffworkflow_backend/routes/process_api_blueprint.py
index 9eb92a1a..413c103b 100644
--- a/src/spiffworkflow_backend/routes/process_api_blueprint.py
+++ b/src/spiffworkflow_backend/routes/process_api_blueprint.py
@@ -79,8 +79,9 @@ def add_file(process_model_id):
)
-def create_process_instance(process_model_id):
+def process_instance_create(process_model_id):
"""Create_process_instance."""
+ # import pdb; pdb.set_trace()
process_instance = ProcessInstanceService.create_process_instance(process_model_id, g.user)
processor = ProcessInstanceProcessor(process_instance)
@@ -88,11 +89,14 @@ def create_process_instance(process_model_id):
processor.save()
# ProcessInstanceService.update_task_assignments(processor)
- workflow_api_model = ProcessInstanceService.processor_to_process_instance_api(
+ process_instance_api = ProcessInstanceService.processor_to_process_instance_api(
processor
)
+ process_instance_data = processor.get_data()
+ process_instance_metadata = ProcessInstanceApiSchema().dump(process_instance_api)
+ process_instance_metadata["data"] = process_instance_data
return Response(
- json.dumps(ProcessInstanceApiSchema().dump(workflow_api_model)), status=201, mimetype="application/json"
+ json.dumps(process_instance_metadata), status=201, mimetype="application/json"
)
diff --git a/src/spiffworkflow_backend/services/process_instance_processor.py b/src/spiffworkflow_backend/services/process_instance_processor.py
index 8313eb27..8906c5c2 100644
--- a/src/spiffworkflow_backend/services/process_instance_processor.py
+++ b/src/spiffworkflow_backend/services/process_instance_processor.py
@@ -480,7 +480,7 @@ class ProcessInstanceProcessor:
# Assure that we find the end event for this process_instance, and not for any sub-process_instances.
if (
isinstance(task.task_spec, EndEvent)
- and task.process_instance == self.bpmn_process_instance
+ and task.workflow == self.bpmn_process_instance
):
endtasks.append(task)
return endtasks[-1]
diff --git a/tests/data/sample/sample.bpmn b/tests/data/sample/sample.bpmn
new file mode 100644
index 00000000..079f15a9
--- /dev/null
+++ b/tests/data/sample/sample.bpmn
@@ -0,0 +1,59 @@
+
+
+
+
+ Flow_10jwwqy
+
+
+
+ Flow_1hd6o66
+
+
+
+ Flow_10jwwqy
+ Flow_0htxke7
+ my_var = "Hello World"
+Mike = "Awesome"
+person = "Kevin"
+
+
+
+ Flow_0htxke7
+ Flow_1hd6o66
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/data/sample/wonderful.dmn b/tests/data/sample/wonderful.dmn
new file mode 100644
index 00000000..2d6e13df
--- /dev/null
+++ b/tests/data/sample/wonderful.dmn
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+ person
+
+
+
+
+
+ "Dan"
+
+
+ "pretty wonderful"
+
+
+
+
+ "Kevin"
+
+
+ "Very wonderful"
+
+
+
+
+ "Mike"
+
+
+ "Powerful wonderful"
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/spiffworkflow_backend/integration/test_process_api.py b/tests/spiffworkflow_backend/integration/test_process_api.py
index 8c5f5469..d7fd43bd 100644
--- a/tests/spiffworkflow_backend/integration/test_process_api.py
+++ b/tests/spiffworkflow_backend/integration/test_process_api.py
@@ -132,6 +132,22 @@ def test_get_process_model_when_not_found(app, client: FlaskClient, with_bpmn_fi
assert response.json["code"] == "process_mode_cannot_be_found"
+def test_process_instance_create(app, client: FlaskClient, with_bpmn_file_cleanup):
+ user = find_or_create_user()
+ test_process_group_id = "runs_without_input"
+ process_model_dir_name = "sample"
+ load_test_spec(app, process_model_dir_name, process_group_id=test_process_group_id)
+ response = client.post(
+ f"/v1.0/process-models/{process_model_dir_name}", headers=logged_in_headers(user)
+ )
+ assert response.status_code == 201
+ assert response.json["status"] == "complete"
+ assert response.json["process_model_identifier"] == "sample"
+ assert response.json["data"]["current_user"]["username"] == "test_user1"
+ assert response.json["data"]["Mike"] == "Awesome"
+ assert response.json["data"]["person"] == "Kevin"
+
+
def create_process_model(app, client: FlaskClient):
"""Create_process_model."""
process_model_service = ProcessModelService()