WIP - not getting a keyerror with an escalation boundary event now w/ burnettk

This commit is contained in:
jasquat 2023-04-05 14:22:37 -04:00
parent e5ecb82557
commit c11e71dd02
No known key found for this signature in database
4 changed files with 68 additions and 34 deletions

View File

@ -354,6 +354,9 @@ class CustomBpmnScriptEngine(PythonScriptEngine): # type: ignore
external_methods: Optional[Dict[str, Any]] = None,
) -> Any:
"""_evaluate."""
# if task.task_spec.name == 'passing_script_task':
# import pdb; pdb.set_trace()
# print("HEY2")
methods = self.__get_augment_methods(task)
if external_methods:
methods.update(external_methods)
@ -375,6 +378,9 @@ class CustomBpmnScriptEngine(PythonScriptEngine): # type: ignore
def execute(self, task: SpiffTask, script: str, external_methods: Any = None) -> None:
"""Execute."""
# if task.task_spec.name == 'passing_script_task':
# import pdb; pdb.set_trace()
# print("HEY3")
try:
# reset failing task just in case
self.failing_spiff_task = None
@ -1644,6 +1650,7 @@ class ProcessInstanceProcessor:
and self._script_engine.failing_spiff_task is not None
):
self._script_engine.failing_spiff_task = None
with open("do_engine_steps.json", 'w') as f: f.write(json.dumps(self.serialize(), indent=2))
@classmethod
def get_tasks_with_data(cls, bpmn_process_instance: BpmnWorkflow) -> List[SpiffTask]:

View File

@ -432,10 +432,11 @@ class TaskService:
spiff_task_guid = str(spiff_task.id)
if spiff_task_parent_guid in task_models:
parent_task_model = task_models[spiff_task_parent_guid]
new_parent_properties_json = copy.copy(parent_task_model.properties_json)
new_parent_properties_json["children"].remove(spiff_task_guid)
parent_task_model.properties_json = new_parent_properties_json
task_models[spiff_task_parent_guid] = parent_task_model
if spiff_task_guid in parent_task_model.properties_json['children']:
new_parent_properties_json = copy.copy(parent_task_model.properties_json)
new_parent_properties_json["children"].remove(spiff_task_guid)
parent_task_model.properties_json = new_parent_properties_json
task_models[spiff_task_parent_guid] = parent_task_model
@classmethod
def update_task_data_on_bpmn_process(

View File

@ -1,5 +1,6 @@
import time
from typing import Callable
import json
from typing import Optional
from SpiffWorkflow.bpmn.serializer.workflow import BpmnWorkflowSerializer # type: ignore
@ -71,6 +72,9 @@ class TaskModelSavingDelegate(EngineStepDelegate):
def will_complete_task(self, spiff_task: SpiffTask) -> None:
if self._should_update_task_model():
# if spiff_task.task_spec.name == 'passing_script_task':
# import pdb; pdb.set_trace()
# print("HEY1")
self.current_task_start_in_seconds = time.time()
spiff_task.task_spec._predict(spiff_task, mask=TaskState.NOT_FINISHED_MASK)
if self.secondary_engine_step_delegate:
@ -78,12 +82,17 @@ class TaskModelSavingDelegate(EngineStepDelegate):
def did_complete_task(self, spiff_task: SpiffTask) -> None:
if self._should_update_task_model():
# if spiff_task.task_spec.name == 'test_process_to_call_script.BoundaryEventParent':
# import pdb; pdb.set_trace()
# print("HEY")
task_model = self.task_service.update_task_model_with_spiff_task(spiff_task)
if self.current_task_start_in_seconds is None:
raise Exception("Could not find cached current_task_start_in_seconds. This should never have happend")
task_model.start_in_seconds = self.current_task_start_in_seconds
task_model.end_in_seconds = time.time()
self.last_completed_spiff_task = spiff_task
# self.task_service.process_spiff_task_parent_subprocess_tasks(spiff_task)
# self.task_service.process_spiff_task_children(spiff_task)
if self.secondary_engine_step_delegate:
self.secondary_engine_step_delegate.did_complete_task(spiff_task)
@ -103,9 +112,20 @@ class TaskModelSavingDelegate(EngineStepDelegate):
def after_engine_steps(self, bpmn_process_instance: BpmnWorkflow) -> None:
if self._should_update_task_model():
if self.last_completed_spiff_task is not None:
self.task_service.process_spiff_task_parent_subprocess_tasks(self.last_completed_spiff_task)
self.task_service.process_spiff_task_children(self.last_completed_spiff_task)
# excludes COMPLETED. the others were required to get PP1 to go to completion.
# process FUTURE tasks because Boundary events are not processed otherwise.
for waiting_spiff_task in bpmn_process_instance.get_tasks(
TaskState.WAITING | TaskState.CANCELLED | TaskState.READY | TaskState.MAYBE | TaskState.LIKELY | TaskState.FUTURE
):
# include PREDICTED_MASK tasks in list so we can remove them from the parent
if waiting_spiff_task._has_state(TaskState.PREDICTED_MASK):
TaskService.remove_spiff_task_from_parent(waiting_spiff_task, self.task_service.task_models)
continue
self.task_service.update_task_model_with_spiff_task(waiting_spiff_task)
# if self.last_completed_spiff_task is not None:
# self.task_service.process_spiff_task_parent_subprocess_tasks(self.last_completed_spiff_task)
# self.task_service.process_spiff_task_children(self.last_completed_spiff_task)
def _should_update_task_model(self) -> bool:
"""We need to figure out if we have previously save task info on this process intance.

View File

@ -1,9 +1,13 @@
const approveWithUser = (
username,
processInstanceId,
expectAdditionalApprovalInfoPage = false
expectAdditionalApprovalInfoPage = false,
password = null
) => {
cy.login(username, username);
if (!password) {
password = username;
}
cy.login(username, password);
cy.visit('/admin/process-instances/find-by-id');
cy.get('#process-instance-id-input').type(processInstanceId);
cy.get('button')
@ -33,22 +37,23 @@ const approveWithUser = (
describe('pp1', () => {
it('can run PP1', () => {
cy.login('core-a1.contributor', 'core-a1.contributor');
// cy.login('sasha', 'sasha');
cy.visit('/');
cy.contains('Start New +').click();
cy.contains('Raise New Demand Request');
cy.contains('New Demand Request - Procurement').click();
cy.runPrimaryBpmnFile(true);
cy.contains('Please select the type of request to start the process.');
// wait a second to ensure we can click the radio button
cy.wait(2000);
cy.get('input#root-procurement').click();
cy.wait(2000);
cy.get('button')
.contains(/^Submit$/)
.click();
cy.contains(
'Submit a new demand request for the procurement of needed items',
{ timeout: 60000 }
);
// cy.contains('Please select the type of request to start the process.');
// // wait a second to ensure we can click the radio button
// cy.wait(2000);
// cy.get('input#root-procurement').click();
// cy.wait(2000);
// cy.get('button')
// .contains(/^Submit$/)
// .click();
// cy.contains(
// 'Submit a new demand request for the procurement of needed items',
// { timeout: 60000 }
// );
cy.url().then((currentUrl) => {
// if url is "/tasks/8/d37c2f0f-016a-4066-b669-e0925b759560"
@ -64,17 +69,17 @@ describe('pp1', () => {
cy.get('#root_payment_method').select('Bank Transfer');
cy.get('#root_project').select('18564');
cy.get('#root_category').select('soft_and_lic');
cy.get('button')
.contains(/^Submit$/)
.click();
cy.contains('Task: Enter NDR-P Items', { timeout: 60000 });
cy.get('#root_0_sub_category').select('op_src');
cy.get('#root_0_item').clear().type('spiffworkflow');
cy.get('#root_0_qty').clear().type('1');
cy.get('#root_0_currency_type').select('Fiat');
cy.get('#root_0_currency').select('AUD');
cy.get('#root_0_unit_price').type('100');
// cy.get('button')
// .contains(/^Submit$/)
// .click();
//
// cy.contains('Task: Enter NDR-P Items', { timeout: 60000 });
cy.get('#root_item_0_sub_category').select('op_src');
cy.get('#root_item_0_item_name').clear().type('spiffworkflow');
cy.get('#root_item_0_qty').clear().type('1');
cy.get('#root_item_0_currency_type').select('Fiat');
cy.get('#root_item_0_currency').select('AUD');
cy.get('#root_item_0_unit_price').type('100');
cy.get('button')
.contains(/^Submit$/)
.click();
@ -94,7 +99,8 @@ describe('pp1', () => {
approveWithUser(
'infra.project-lead',
processInstanceId,
'Task: Reminder: Request Additional Budget'
'Task: Reminder: Request Additional Budget',
'infra.project-leadx'
);
approveWithUser('ppg.ba-a1.sme', processInstanceId);
approveWithUser('security-a1.sme', processInstanceId);