def _rememberTrigger(self, triggering_workitem, route): mode = self.getActivity().mode all_routes = self._getAllRoutes() closed_routes = self.closed_routes if route in closed_routes: return controller = ILifeCycleController(self) if mode == MULTI_MERGE: closed_routes.append(route) self._doTrigger(triggering_workitem, route) if len(closed_routes) == len(all_routes): self.completing_work_item = triggering_workitem # XXX no test for this controller.complete("Gate '%s' found by route '%s'" % (self.activity_id, route)) elif mode == DISCRIMINATE: if len(closed_routes) == 0: self._doTrigger(triggering_workitem, route) self.completing_work_item = triggering_workitem controller.complete("Gate '%s' found by route '%s'" % (self.activity_id, route)) closed_routes.append(route) elif mode == DELAYED_DISCRIMINATE: self.delayed_discriminator = True elif mode == SYNCHRONIZING_MERGE: closed_routes.append(route) if len(closed_routes) == len(all_routes): self._doTrigger(triggering_workitem, route) self.completing_work_item = triggering_workitem controller.complete("Gate '%s' completed via route '%s'" % (self.activity_id, route)) else: # XXX no tests for this controller.fail("Unknown gate mode: '%s'" % mode) self.closed_routes = closed_routes
def _check_failed(self): """Perform a check whether this instance is failed. This method returns True in two cases: 1. The state of the process instance is `failed` 2. At least one of the work items is failed. """ items_failed = len(self.getWorkItemIds(state="failed")) controller = ILifeCycleController(self) if controller.state == 'failed': return True if items_failed > 0: controller.fail( "Automatically failed because %s work items failed." % items_failed) return True return False
def manage_action( self, action, REQUEST, comment="no comment", ): """Multiplexes the actions.""" controller = ILifeCycleController(self) if action == "start": controller.start(comment) elif action == "reset": controller.reset(comment) elif action == "terminate": controller.terminate(comment) elif action == "restart": controller.reset(comment) controller.start(comment) elif action == "recover": controller.recover(comment) elif action == "fail": controller.fail(comment) else: raise KeyError("Not a valid action.") REQUEST.RESPONSE.redirect(self.absolute_url() + "/manage_overview")