예제 #1
0
 def completeWorkitem(self, instance_id, workitem_id, REQUEST=None):
     """ declares the completion of the specified workitem of the given instance """
     instance, workitem, process, activity = self.getEnvironment(instance_id, workitem_id)
     if REQUEST:
         actor = REQUEST.AUTHENTICATED_USER.getUserName()
     else:
         actor = 'Engine'
     if REQUEST:
         if not actor == workitem.actor:
             raise "WorkitemActionError","Invalid Workflow Actor"
     if instance.isActiveOrRunning():
         workitem_return_id = None
         if workitem.status in ('active', 'fallout'):
             workitem.setStatus('complete', actor=actor)
             if instance.getActiveWorkitems() == 0 and instance.status!='running':
                 instance.setStatus(status='running', actor=actor)
             if self.isEnd(workitem.process_id, workitem.activity_id):
                 subflow_workitem_id = self.getSubflowWorkitem(instance_id, workitem_id, workitem.process_id)
                 if subflow_workitem_id:
                     self.completeSubflow(instance_id, subflow_workitem_id)
                 else:
                     instance.setStatus(status='complete', actor=actor)
         if activity.isAutoFinish() and not process.end == activity.id and \
            not (activity.kind=='dummy' or activity.kind=='subflow'):
             self.forwardWorkitem(instance_id, workitem_id)
         if REQUEST is not None: REQUEST.RESPONSE.redirect(REQUEST.HTTP_REFERER)
     else:
         raise "WorkitemActionError","Wrong workitem enviroment"
예제 #2
0
 def suspendWorkitem(self, instance_id, workitem_id, REQUEST=None):
     """ declares the suspension of the specified workitem of the given instance """
     instance = getattr(self, instance_id)
     workitem = getattr(instance, str(workitem_id))
     if REQUEST:
         actor = REQUEST.AUTHENTICATED_USER.getUserName()
     else:
         actor = 'Engine'
     if REQUEST:
         if  workitem.actor and workitem.actor != actor:
             raise "Invalid Workflow Actor: %s"%actor
     if instance.isActiveOrRunning() and workitem.status == 'inactive' and not workitem.blocked:
         workitem.setStatus('suspended', actor=actor)
         if instance.getActiveWorkitems() == 0 and not instance.status=='running':
             instance.setStatus(status='running', actor=actor)
     else:
         raise "WorkitemActionError","Wrong workitem enviroment"
     if REQUEST: REQUEST.RESPONSE.redirect(REQUEST.HTTP_REFERER)
예제 #3
0
 def inactivateWorkitem(self, instance_id, workitem_id, REQUEST=None):
     """ declares the inactivation of the specified workitem of the given instance """
     instance = getattr(self, instance_id)
     workitem = getattr(instance, str(workitem_id))
     if REQUEST:
         actor=REQUEST.AUTHENTICATED_USER.getUserName()
     else:
         actor='Engine'
     if REQUEST:
         if not (actor == workitem.actor or \
            REQUEST.AUTHENTICATED_USER.has_permission('Manage OpenFlow', self)):
             raise "WorkitemActionError","Invalid actor"
     if instance.isActiveOrRunning() and workitem.status == 'active' and not workitem.blocked:
         workitem.setStatus('inactive', actor=actor)
         if instance.getActiveWorkitems() == 0 and instance.status!='running':
             instance.setStatus(status='running', actor=actor)
     else:
         raise "WorkitemActionError","Wrong workitem enviroment"
     if REQUEST: REQUEST.RESPONSE.redirect(REQUEST.HTTP_REFERER)