Merge branch 'rrt/dev' into feature/approvals_enhancements

This commit is contained in:
Aaron Louie 2020-06-01 00:41:51 -04:00
commit 7c8b7829ea
2 changed files with 20 additions and 13 deletions

View File

@ -299,21 +299,27 @@ class WorkflowProcessor(object):
return WorkflowStatus.waiting return WorkflowStatus.waiting
def hard_reset(self): def hard_reset(self):
"""Recreate this workflow, but keep the data from the last completed task and add it back into the first task. """Recreate this workflow, but keep the data from the last completed task and add
This may be useful when a workflow specification changes, and users need to review all the it back into the first task. This may be useful when a workflow specification changes,
prior steps, but don't need to reenter all the previous data. and users need to review all the prior steps, but they don't need to reenter all the previous data.
Returns the new version. Returns the new version.
""" """
# Create a new workflow based on the latest specs.
self.spec_data_files = FileService.get_spec_data_files(workflow_spec_id=self.workflow_spec_id) self.spec_data_files = FileService.get_spec_data_files(workflow_spec_id=self.workflow_spec_id)
spec = WorkflowProcessor.get_spec(self.spec_data_files, self.workflow_spec_id) new_spec = WorkflowProcessor.get_spec(self.spec_data_files, self.workflow_spec_id)
# spec = WorkflowProcessor.get_spec(self.workflow_spec_id, version) new_bpmn_workflow = BpmnWorkflow(new_spec, script_engine=self._script_engine)
bpmn_workflow = BpmnWorkflow(spec, script_engine=self._script_engine) new_bpmn_workflow.data = self.bpmn_workflow.data
bpmn_workflow.data = self.bpmn_workflow.data
for task in bpmn_workflow.get_tasks(SpiffTask.READY): # Reset the current workflow to the beginning - which we will consider to be the first task after the root
task.data = self.bpmn_workflow.last_task.data # element. This feels a little sketchy, but I think it is safe to assume root will have one child.
bpmn_workflow.do_engine_steps() first_task = self.bpmn_workflow.task_tree.children[0]
self.bpmn_workflow = bpmn_workflow first_task.reset_token(reset_data=False)
for task in new_bpmn_workflow.get_tasks(SpiffTask.READY):
task.data = first_task.data
new_bpmn_workflow.do_engine_steps()
self.bpmn_workflow = new_bpmn_workflow
def get_status(self): def get_status(self):
return self.status_of(self.bpmn_workflow) return self.status_of(self.bpmn_workflow)

View File

@ -294,10 +294,11 @@ class WorkflowService(object):
template = Template(raw_doc) template = Template(raw_doc)
return template.render(**spiff_task.data) return template.render(**spiff_task.data)
except jinja2.exceptions.TemplateError as ue: except jinja2.exceptions.TemplateError as ue:
# return "Error processing template. %s" % ue.message
raise ApiError(code="template_error", message="Error processing template for task %s: %s" % raise ApiError(code="template_error", message="Error processing template for task %s: %s" %
(spiff_task.task_spec.name, str(ue)), status_code=500) (spiff_task.task_spec.name, str(ue)), status_code=500)
except TypeError as te:
raise ApiError(code="template_error", message="Error processing template for task %s: %s" %
(spiff_task.task_spec.name, str(te)), status_code=500)
# TODO: Catch additional errors and report back. # TODO: Catch additional errors and report back.
@staticmethod @staticmethod