コード例 #1
0
 def fallinWorkitem(self, instance_id, workitem_id, process_id, activity_id, REQUEST=None, coming_from=None):
     """ the exceptional specified workitem (of the specified instance) will be put back in the activity
     specified by process_id and activity_id; workitem will still be in exceptional state:
     use endFallinWorkitem API to specify the end of the exceptional state"""
     instance = getattr(self, instance_id)
     workitem_from = getattr(instance, workitem_id)
     if workitem_from.status=='fallout':
         push_roles = getattr(getattr(self,process_id),activity_id).getPushRoles()
         pull_roles = getattr(getattr(self,process_id),activity_id).getPullRoles()
         workitem_to = instance.addWorkitem(process_id, activity_id, 0, push_roles, pull_roles)
         self.linkWorkitems(instance_id, workitem_id, [workitem_to.id])
         event = 'fallin to activity ' + activity_id + ' in process ' + process_id + \
                 ' (workitem ' + str(workitem_to.id) + ')'
         workitem_from.addEvent(event)
         event = 'fallin from activity ' + workitem_from.activity_id + \
                 ' in process ' + workitem_from.process_id + \
                 ' (workitem ' + str(workitem_id) + ')'
         workitem_to.addEvent(event)
         self.manageWorkitemCreation(instance_id, workitem_to.id)
     else:
         raise "WorkitemActionError","Wrong workitem enviroment"
     if REQUEST:
         if coming_from is not None:
             REQUEST.RESPONSE.redirect(coming_from)
         else:
             REQUEST.RESPONSE.redirect(REQUEST.HTTP_REFERER)
コード例 #2
0
 def startSubflow(self, instance_id, workitem_id, REQUEST=None):
     instance, workitem, process, activity = self.getEnvironment(instance_id, workitem_id)
     self.activateWorkitem(instance_id, workitem_id)
     self.assignWorkitem(instance_id, workitem_id, 'Engine')
     subflow_id = activity.subflow
     begin_activity_id = getattr(self, subflow_id).begin
     push_roles = getattr(getattr(self,process.id),activity.id).getPushRoles()
     pull_roles = getattr(getattr(self,process.id),activity.id).getPullRoles()
     w = instance.addWorkitem(subflow_id, begin_activity_id, 0, push_roles, pull_roles)
     self.linkWorkitems(instance_id, workitem_id, [w.id])
     self.manageWorkitemCreation(instance_id, w.id)
コード例 #3
0
    def forwardWorkitem(self, instance_id, workitem_id, path=None, REQUEST=None):
        """ instructs openflow to forward the specified workitem """
        instance, workitem, process, activity = self.getEnvironment(instance_id, workitem_id)
        if REQUEST:
            if not REQUEST.AUTHENTICATED_USER.getUserName() == workitem.actor:
                raise "WorkitemActionError","Invalid Workflow Actor"
        destinations = self.getDestinations(instance_id, workitem_id, path)
        new_workitems = []
        if instance.isActiveOrRunning() and \
          (workitem.status == 'complete' and not workitem.forwarded) and \
          not self.isEnd(workitem.process_id, workitem.activity_id):
            activity_to_id_list = map(lambda x : x['activity_to_id'], destinations)
            workitem.addEvent('forwarded to '+ reduce(lambda x, y : x+', '+y, activity_to_id_list))
            workitem_to_id_list = []
            for d in destinations:
                w = instance.getJoiningWorkitem(workitem_id, self)
                if w:
                    w.unblock()
                    workitem_to_id_list.append(w.id)
                else:
                    process_id = d['process_to_id']
                    activity_id = d['activity_to_id']
                    push_roles = getattr(getattr(self,process_id),activity_id).getPushRoles()
                    pull_roles = getattr(getattr(self,process_id),activity_id).getPullRoles()
                    w = instance.addWorkitem(process_id,
                                             activity_id,
                                             d['blocked_init'],
                                             push_roles,
                                             pull_roles)
                    workitem_to_id_list.append(w.id)
                if w.blocked == 0:
                    new_workitems.append(w.id)
                    w.addEvent('arrival from ' + workitem.activity_id)
            # indented with for

            self.linkWorkitems(instance_id, workitem_id, workitem_to_id_list)
        elif (workitem.status == 'complete' and not workitem.forwarded) and \
             self.isEnd(workitem.process_id, workitem.activity_id):
            pass
        else:
            msg=" wid: "+workitem.id+" act_id: "+workitem.activity_id
            msg=msg+" status:"+workitem.status+" forwarded:"+str(workitem.forwarded)
            raise "WorkitemActionError","Wrong workitem enviroment"+msg
        for w in new_workitems:
            self.manageWorkitemCreation(instance_id, w)
        workitem.forwarded=1
        if REQUEST: REQUEST.RESPONSE.redirect(REQUEST.HTTP_REFERER)
コード例 #4
0
 def startInstance(self, instance_id, REQUEST=None):
     """ Starts the flowing of the process instance inside the process definition """
     instance = getattr(self, instance_id)
     if instance.status == 'initiated':
         if REQUEST:
             actor=REQUEST.AUTHENTICATED_USER.getUserName()
         else:
             actor='Engine'
         instance.setStatus(status='running', actor=actor)
         process_id = instance.begin_process_id
         activity_id = instance.begin_activity_id
         push_roles = getattr(getattr(self,process_id),activity_id).getPushRoles()
         pull_roles = getattr(getattr(self,process_id),activity_id).getPullRoles()
         w = instance.addWorkitem(process_id, activity_id, 0, push_roles, pull_roles)
         self.manageWorkitemCreation(instance_id, w.id)
         if REQUEST: REQUEST.RESPONSE.redirect(REQUEST.HTTP_REFERER)
     else:
         raise "InstanceActionError","Instance in wrong status"