See if we've been saved in context of managing the workflow directly
548923
public function onBeforeWrite()
    {
        parent::onBeforeWrite();

        $vars = $this->record;

        if (isset($vars['DirectUpdate'])) {
            // Unset now so that we don't end up in an infinite loop!
            unset($this->record['DirectUpdate']);
            $this->updateWorkflow($vars);
        }
    }
242945
def shot_save_callback(self, *args, **kwargs):
        
        tasksel = self.browser.shotbrws.selected_indexes(2)
        if not tasksel or not tasksel[0].isValid():
            self.statusbar.showMessage('No task selected! Cannot save!')
            return

        taskitem = tasksel[0].internalPointer()
        task = taskitem.internal_data()
        rtype = djadapter.RELEASETYPES['work']
        descriptor = self.shot_descriptor_le.text()
        if not self.check_selection_for_save(task, rtype, descriptor):
            return

        tfi = TaskFileInfo.get_next(task=task, releasetype=rtype,
                                    typ=self._filetype, descriptor=descriptor)
        self._save_tfi(tfi)
483899
function () {
      var i;
      for (i = 0; i < arguments.length; i++) {
         if ( ! (this.has_activity_completed(arguments[i]) || this.has_lambda_completed(arguments[i]) || this.childworkflow_completed(arguments[i])  || this.timer_fired(arguments[i]) ) ) {
            return false;
         }
      }
      return true;
   }
299379
def valid_workflow(self):
        
        for ix, handler in enumerate(self.handlers[:-1]):
            next_input_type = self.handlers[ix + 1].input_type

            if (handler.output_type is not None and
                    next_input_type is not None):
                if handler.output_type != next_input_type:
                    return False

        return True
179878
def _show_status_for_work(self, work):
    
    work_count = len(work.work)
    work_completed = {}
    work_completed_count = 0
    for v in itervalues(work.work):
      if v['is_completed']:
        work_completed_count += 1
        worker_id = v['claimed_worker_id']
        if worker_id not in work_completed:
          work_completed[worker_id] = {
              'completed_count': 0,
              'last_update': 0.0,
          }
        work_completed[worker_id]['completed_count'] += 1
        work_completed[worker_id]['last_update'] = max(
            work_completed[worker_id]['last_update'],
            v['claimed_worker_start_time'])
    print('Completed {0}/{1} work'.format(work_completed_count,
                                          work_count))
    for k in sorted(iterkeys(work_completed)):
      last_update_time = time.strftime(
          '%Y-%m-%d %H:%M:%S',
          time.localtime(work_completed[k]['last_update']))
      print('Worker {0}: completed {1}   last claimed work at {2}'.format(
          k, work_completed[k]['completed_count'], last_update_time))
1096375
private void populateWorkflowOutput(Workflow workflow) {
        if (StringUtils.isNotBlank(workflow.getExternalOutputPayloadStoragePath())) {
            WorkflowTaskMetrics.incrementExternalPayloadUsedCount(workflow.getWorkflowName(), ExternalPayloadStorage.Operation.READ.name(), ExternalPayloadStorage.PayloadType.WORKFLOW_OUTPUT.name());
            workflow.setOutput(downloadFromExternalStorage(ExternalPayloadStorage.PayloadType.WORKFLOW_OUTPUT, workflow.getExternalOutputPayloadStoragePath()));
        }
    }
272188
def save_date(self):
        
        task_invitation = TaskInvitation.objects.get(self.task_invitation_key)
        wfi = task_invitation.instance
        if wfi.current_actor.exist and wfi.current_actor == self.current.role:

            dt_start = datetime.strptime(self.input['form']['start_date'], "%d.%m.%Y")
            dt_finish = datetime.strptime(self.input['form']['finish_date'], "%d.%m.%Y")

            task_invitation.start_date = dt_start
            task_invitation.finish_date = dt_finish
            task_invitation.save()

            wfi.start_date = dt_start
            wfi.finish_date = dt_finish
            wfi.save()

            title = _(u"Successful")
            msg = _(u"You've extended the workflow time.")
        else:
            title = _(u"Unsuccessful")
            msg = _(u"This workflow does not belong to you.")

        self.current.msg_box(title=title, msg=msg)
741542
def get_current_task_info(self):
        """"""
        name = self.model.workflow.name
        if not name:
            return

        current_task = workflows[name].workflow
        for step in self.callback_pos:
            current_task = current_task[step]
            if callable(current_task):
                return get_func_info(current_task)
518677
def load_or_create_workflow(self):
        
        self.workflow_spec = self.get_worfklow_spec()
        return self._load_workflow() or self.create_workflow()
525795
def add_workflow(self, workflow, commit=False):
        
        if workflow.workflow_id in self.workflows:
            raise KeyError("Workflow with id {} already exists".format(workflow.workflow_id))

        self.workflows[workflow.workflow_id] = workflow
        logging.info("Added workflow {} to workflow manager".format(workflow.workflow_id))

        # Optionally also save the workflow to database
        if commit:
            self.commit_workflow(workflow.workflow_id)
        else:
            self.uncommitted_workflows.add(workflow.workflow_id)
97290
def check_for_permission(self):
        # TODO: Works but not beautiful, needs review!
        
        if self.current.task:
            lane = self.current.lane_id
            permission = "%s.%s.%s" % (self.current.workflow_name, lane, self.current.task_name)
        else:
            permission = self.current.workflow_name
        log.debug("CHECK PERM: %s" % permission)

        if (self.current.task_type not in PERM_REQ_TASK_TYPES or
                permission.startswith(tuple(settings.ANONYMOUS_WORKFLOWS)) or
                (self.current.is_auth and permission.startswith(tuple(settings.COMMON_WORKFLOWS)))):
            return
        # FIXME:needs hardening

        log.debug("REQUIRE PERM: %s" % permission)
        if not self.current.has_permission(permission):
            raise HTTPError(403, "You don't have required permission: %s" % permission)
903782
def on_finished(self):
        """"""
        self.controller.is_running = False

        error = self.controller.current_error
        if error is not None:
            self.info(self.tr("Stopped due to error(s), see Terminal."))
        else:
            self.info(self.tr("Finished successfully!"))
1007089
def before_processing(eng, objects):
        """"""
        super(InvenioProcessingFactory, InvenioProcessingFactory)\
            .before_processing(eng, objects)
        eng.save(WorkflowStatus.RUNNING)
        db.session.commit()
487836
def complete(self):
        
        if callable(self.task.workflow_complete):
            return self.task.workflow_complete()
        else:
            return super(BaseWorkflowProxy, self).complete()
869313
def manager_post_save_handler(sender, instance, created, **kwargs):
    """"""
    if instance.status == Data.STATUS_DONE or instance.status == Data.STATUS_ERROR or created:
        # Run manager at the end of the potential transaction. Otherwise
        # tasks are send to workers before transaction ends and therefore
        # workers cannot access objects created inside transaction.
        transaction.on_commit(lambda: commit_signal(instance.id))
272542
def save(self):
        """"""
        if ( self._new or
            (self._validID() and self._changed) or
            (self._updated and self._changed > self._updated) ):
            # Don't save if we have not loaded existing data!
            self._saveDB()
            return True
        return False
2279
def checkForSave( self ):
        
        # if the file is not modified, then save is not needed
        if ( not self.isModified() ):
            return True
        
        options     = QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel
        question    = 'Would you like to save your changes to %s?' % \
                                            self.windowTitle()
                                            
        answer      = QMessageBox.question( None, 
                                            'Save Changes', 
                                            question, 
                                            options )
        
        if ( answer == QMessageBox.Yes ):
            return self.save()
        elif ( answer == QMessageBox.Cancel ):
            return False
        return True