Returns whether 'prepublish' transition can be perform or not. Returns
    True if the analysis request has at least one analysis in 'verified' or in
    'to_be_verified' status. Otherwise, return False
172519
def guard_prepublish(analysis_request):
    
    valid_states = ['verified', 'to_be_verified']
    for analysis in analysis_request.getAnalyses():
        analysis = api.get_object(analysis)
        if api.get_workflow_status_of(analysis) in valid_states:
            return True
    return False
645340
public boolean isFullyEstablished() {
        boolean result = true;
        for (ContentNegotiator contentNegotiator : contentNegotiators) {
            if (!contentNegotiator.isFullyEstablished())
                result = false;
        }
        return result;
    }
212313
public function canProcess()
    {
        if ($this->persisted()) {
            return false;
        }

        if (!$this->_subscriber) {
            return false;
        }

        if (!$this->validateEntity()) {
            return false;
        }

        if (!$this->_subscriber->persisted() && !$this->_subscriber->validateEntity()) {
            return false;
        }

        if (!isset($this->_package)) {
            return false;
        }

        if (!isset($this->_payment_method)) {
            return false;
        }

        return true;
    }
1326994
def isSelfVerificationEnabled(self):
        
        bsve = self.bika_setup.getSelfVerificationEnabled()
        vs = self.getSelfVerification()
        return bsve if vs == -1 else vs == 1
231399
def guard_assign(analysis):
    
    # Only if the request was done from worksheet context.
    if not is_worksheet_context():
        return False

    # Cannot assign if the Sample has not been received
    if not analysis.isSampleReceived():
        return False

    # Cannot assign if the analysis has a worksheet assigned already
    if analysis.getWorksheet():
        return False

    # Cannot assign if user does not have permissions to manage worksheets
    return user_can_manage_worksheets()
292995
def verify_preconditions
      super

      if not gitlib.status.clean?
        GitProc::ChangeFileHelper.new(gitlib).offer_to_help_uncommitted_changes
      end

      raise ParkedChangesError.new(self) if gitlib.is_parked?
    end
45476
def guard_deactivate(analysis_service):
    
    for dependant in analysis_service.getServiceDependants():
        status = api.get_workflow_status_of(dependant)
        if status == "active":
            return False

    return True
642058
def is_ready(instance, pending=False):
    

    last_reload = lookup(instance, 'lastOperatingSystemReload', 'id')
    active_transaction = lookup(instance, 'activeTransaction', 'id')

    reloading = all((
        active_transaction,
        last_reload,
        last_reload == active_transaction,
    ))
    outstanding = False
    if pending:
        outstanding = active_transaction
    if instance.get('provisionDate') and not reloading and not outstanding:
        return True
    return False
1293708
boolean canBeSpeculated(long currentTime) {
    if (skipping || !isRunnable() || !isRunning() || 
        completes != 0 || isOnlyCommitPending() ||
        activeTasks.size() > MAX_TASK_EXECS) {
      if (isMapTask() ? job.shouldLogCannotspeculativeMaps() :
            job.shouldLogCannotspeculativeReduces()) {
           LOG.info("Task "+ getTIPId() + " cannot be speculated because of " 
               + "skipping = "+ skipping + " isRunnable() = "+ isRunnable() 
               + " isRunning() = "+ isRunning() + " completes = " + completes
               + " isOnlyCommitPending() = "+ isOnlyCommitPending()  
               + " activetask-size = "+ activeTasks.size() 
               + " MAX_TASK_EXECS = " + MAX_TASK_EXECS);
      }
      return false;
    }

    if (isSpeculativeForced()) {
      return true;
    }

    // no speculation for first few seconds
    if (currentTime - lastDispatchTime < speculativeLag) {
      if (isMapTask() ? job.shouldLogCannotspeculativeMaps() :
            job.shouldLogCannotspeculativeReduces()) {
           LOG.info("Task "+ getTIPId() + " cannot be speculated because of "
               + "no speculation for first few seconds");
      }
      return false;
    }

    // if the task is making progress fast enough to complete within
    // the acceptable duration allowed for each task - do not speculate
    if ((maxProgressRateForSpeculation > 0) &&
        (progressRate > maxProgressRateForSpeculation)) {
      if (isMapTask() ? job.shouldLogCannotspeculativeMaps() :
            job.shouldLogCannotspeculativeReduces()) {
           LOG.info("Task "+ getTIPId() +" cannot be speculated because "
               + "the task progress rate is fast enough to complete."
               + " maxProgressRateForSpeculation = " 
               + maxProgressRateForSpeculation
               + " and progressRate = " + progressRate);
      }
      return false;
    }

    if (isMapTask() ? job.shouldSpeculateAllRemainingMaps() :
                      job.shouldSpeculateAllRemainingReduces()) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Speculate " + getTIPId() +
            " because the job is almost finished");
      }
      return true;
    }
    if (useProcessingRateForSpeculation) {
      return canBeSpeculatedUsingProcessingRate(currentTime);
    } else {
      return canBeSpeculatedUsingProgressRate(currentTime);
    }
  }
984322
def guard_reinstate(analysis_request):
    
    parent = analysis_request.getParentAnalysisRequest()
    if not parent:
        return True
    if api.get_workflow_status_of(parent) != "cancelled":
        return True
    return isTransitionAllowed(parent, "reinstate")
985439
protected boolean involvedInTransaction() {

        final boolean isTracingEnabled = TraceComponent.isAnyTracingEnabled();

        if (state == STATE_TRAN_WRAPPER_INUSE) {

            if (isTracingEnabled && tc.isDebugEnabled()) {
                Tr.debug(this, tc, "involvedInTransaction: true");
            }

            return true;
        } else {

            if (isTracingEnabled && tc.isDebugEnabled()) {
                Tr.debug(this, tc, "involvedInTransaction: false");
            }

            return false;
        }

    }
573830
public function isSupported()
    {
        $mixer   = $this->getMixer();
        $request = $mixer->getRequest();

        if($request->getFormat() == 'html' && $request->isGet() && !$request->isAjax()) {
            return true;
        }

        return false;
    }
370043
protected static function hasNiceSupport()
    {
        exec("nice 2>&1", $niceOutput);

        if (is_array($niceOutput) && isset($niceOutput[0])) {
            if (preg_match('/usage/', $niceOutput[0]) || (preg_match('/^\d+$/', $niceOutput[0]))) {
                /*
                 * Nice is available - default niceness (+10)
                 * https://www.lifewire.com/uses-of-commands-nice-renice-2201087
                 * https://www.computerhope.com/unix/unice.htm
                 */

                return true;
            }
            return false;
        }
    }
151159
def isTransitionAllowed(instance, transition_id):
    
    wf_tool = getToolByName(instance, "portal_workflow")
    for wf_id in wf_tool.getChainFor(instance):
        wf = wf_tool.getWorkflowById(wf_id)
        if wf and wf.isActionSupported(instance, transition_id):
            return True

    return False
476482
def has_readonly(self, s):
        """"""
        for t in self.transitions:
            if list(t.lhs[s]) != list(t.rhs[s]):
                return False
        return True
530416
def can_be_(self, state):
    """"""
    translator = self._meta['translator']
    state = translator.translate(state)

    if self._meta['complete']:
        return True

    if self.actual_state is None:
        return True

    transitions = self._meta['transitions'][self.actual_state]
    return state in transitions
975026
public boolean isSubscriptionPreApprovalSupported() throws NotLoggedInException {
        final XMPPConnection connection = getAuthenticatedConnectionOrThrow();
        return connection.hasFeature(SubscriptionPreApproval.ELEMENT, SubscriptionPreApproval.NAMESPACE);
    }