Get the flow status for a specific execution.
@param flowName
@param flowGroup
@param flowExecutionId
@return the flow status, null is returned if the flow status does not exist
977799
public FlowStatus getFlowStatus(String flowName, String flowGroup, long flowExecutionId) {
    FlowStatus flowStatus = null;
    Iterator<JobStatus> jobStatusIterator =
        jobStatusRetriever.getJobStatusesForFlowExecution(flowName, flowGroup, flowExecutionId);

    if (jobStatusIterator.hasNext()) {
      flowStatus = new FlowStatus(flowName, flowGroup, flowExecutionId, jobStatusIterator);
    }

    return flowStatus;
  }
149889
public boolean containsFlowState(final Flow flow, final String stateId) {
        if (flow == null) {
            LOGGER.error("Flow is not configured correctly and cannot be null.");
            return false;
        }
        return flow.containsState(stateId);
    }
592912
public Boolean setExecutionState(
      ExecutionEnvironment.ExecutionState executionState, String topologyName) {
    return awaitResult(delegate.setExecutionState(executionState, topologyName));
  }
1121874
@Service
    public Workflow getExecutionStatus(String workflowId, boolean includeTasks) {
        Workflow workflow = executionService.getExecutionStatus(workflowId, includeTasks);
        if (workflow == null) {
            throw new ApplicationException(ApplicationException.Code.NOT_FOUND,
                    String.format("Workflow with Id: %s not found.", workflowId));
        }
        return workflow;
    }
1362505
@Override
    public boolean handleExecutionOutcome(
            FlowExecutionOutcome outcome, ActionRequest request, ActionResponse response) {
        if (this.redirectOnEnds != null && this.redirectOnEnds.containsKey(outcome.getId())) {
            final String redirectPath =
                    request.getContextPath() + this.redirectOnEnds.get(outcome.getId());
            try {
                response.sendRedirect(redirectPath);
                return true;
            } catch (IOException e) {
                this.logger.warn("Failed to send flow-end redirect to '" + redirectPath + "'");
            }
        }

        return false;
    }
129302
static String getFullyQualifiedJobName(DagNode<JobExecutionPlan> dagNode) {
    Config jobConfig = dagNode.getValue().getJobSpec().getConfig();

    String flowGroup = ConfigUtils.getString(jobConfig, ConfigurationKeys.FLOW_GROUP_KEY, "");
    String flowName = ConfigUtils.getString(jobConfig, ConfigurationKeys.FLOW_NAME_KEY, "");
    Long flowExecutionId = ConfigUtils.getLong(jobConfig, ConfigurationKeys.FLOW_EXECUTION_ID_KEY, 0L);
    String jobName = ConfigUtils.getString(jobConfig, ConfigurationKeys.JOB_NAME_KEY, "");

    return "(flowGroup: " + flowGroup + ", flowName: " + flowName + ", flowExecutionId: " + flowExecutionId + ", jobName: " + jobName + ")";
  }
790493
public static boolean isFinished(final ExecutableFlow flow) {
    switch (flow.getStatus()) {
      case SUCCEEDED:
      case FAILED:
      case KILLED:
        return true;
      default:
        return false;
    }
  }
463643
Map<Integer, Pair<ExecutionReference, ExecutableFlow>> fetchUnfinishedFlows()
      throws ExecutorManagerException {
    try {
      return this.dbOperator.query(FetchActiveExecutableFlows.FETCH_UNFINISHED_EXECUTABLE_FLOWS,
          new FetchActiveExecutableFlows());
    } catch (final SQLException e) {
      throw new ExecutorManagerException("Error fetching unfinished flows", e);
    }
  }
1368300
@Override
  public FlowConfig get(ComplexResourceKey<FlowId, EmptyRecord> key) {
    String flowGroup = key.getKey().getFlowGroup();
    String flowName = key.getKey().getFlowName();
    FlowId flowId = new FlowId().setFlowGroup(flowGroup).setFlowName(flowName);
    return this.flowConfigsResourceHandler.getFlowConfig(flowId);
  }
842008
public function getReportExecutionStatus($executionId)
    {
        $url = $this->makeUrl($executionId, true);
        $response = $this->service->prepAndSend($url, array(200), 'GET', null, true, "application/json", "application/status+json");

        return Status::createFromJSON(json_decode($response));
    }
815166
public static FlowElement getFlowElement(DelegateExecution execution) {
        BpmnModel bpmnModel = getBpmnModel(execution);
        FlowElement flowElement = bpmnModel.getFlowElement(execution.getCurrentActivityId());
        if (flowElement == null) {
            throw new ActivitiException("Could not find a FlowElement for activityId " + execution.getCurrentActivityId());
        }
        return flowElement;
    }
750349
@Override
  public void cancelFlow(final ExecutableFlow exFlow, final String userId)
      throws ExecutorManagerException {
    synchronized (exFlow) {
      if (this.runningExecutions.get().containsKey(exFlow.getExecutionId())) {
        final Pair<ExecutionReference, ExecutableFlow> pair =
            this.runningExecutions.get().get(exFlow.getExecutionId());
        this.apiGateway.callWithReferenceByUser(pair.getFirst(), ConnectorParams.CANCEL_ACTION,
            userId);
      } else if (this.queuedFlows.hasExecution(exFlow.getExecutionId())) {
        this.queuedFlows.dequeue(exFlow.getExecutionId());
        this.executionFinalizer
            .finalizeFlow(exFlow, "Cancelled before dispatching to executor", null);
      } else {
        throw new ExecutorManagerException("Execution "
            + exFlow.getExecutionId() + " of flow " + exFlow.getFlowId()
            + " isn't running.");
      }
    }
  }
164332
@Override
    public List<Workflow> getWorkflowsByType(String workflowName, Long startTime, Long endTime) {
        throw new UnsupportedOperationException("This method is not implemented in CassandraExecutionDAO. Please use ExecutionDAOFacade instead.");
    }
397502
@ReadOperation
    public Map<?, ?> getReport(@Nullable final String flowId) {
        val jsonMap = new LinkedHashMap<String, Object>();
        val map = this.applicationContext.getBeansOfType(FlowDefinitionRegistry.class, false, true);

        map.forEach((k, v) -> Arrays.stream(v.getFlowDefinitionIds())
            .filter(currentId -> {
                if (StringUtils.isNotBlank(flowId)) {
                    return flowId.equalsIgnoreCase(currentId);
                }
                return true;
            })
            .forEach(id -> {
                val flowDetails = new LinkedHashMap<String, Object>();
                val def = Flow.class.cast(v.getFlowDefinition(id));
                flowDetails.put("startState", def.getStartState().getId());

                val states = new LinkedHashMap<String, Map>();
                Arrays.stream(def.getStateIds()).forEach(st -> {

                    val state = (State) def.getState(st);
                    val stateMap = new LinkedHashMap<String, Object>();

                    if (!state.getAttributes().asMap().isEmpty()) {
                        stateMap.put("attributes", CollectionUtils.wrap(state.getAttributes()));
                    }
                    if (StringUtils.isNotBlank(state.getCaption())) {
                        stateMap.put("caption", state.getCaption());
                    }

                    var acts = StreamSupport.stream(state.getEntryActionList().spliterator(), false)
                        .map(Object::toString)
                        .collect(Collectors.toList());

                    if (!acts.isEmpty()) {
                        stateMap.put("entryActions", acts);
                    }

                    if (state instanceof ActionState) {
                        acts = StreamSupport.stream(ActionState.class.cast(state).getActionList().spliterator(), false)
                            .map(Object::toString)
                            .collect(Collectors.toList());
                        if (!acts.isEmpty()) {
                            stateMap.put("actionList", acts);
                        }
                    }

                    if (state instanceof EndState) {
                        stateMap.put("isEndState", Boolean.TRUE);
                    }
                    if (state.isViewState()) {
                        stateMap.put("isViewState", state.isViewState());
                        stateMap.put("isRedirect", ((ViewState) state).getRedirect());

                        acts = StreamSupport.stream(state.getEntryActionList().spliterator(), false)
                            .map(Object::toString)
                            .collect(Collectors.toList());

                        if (!acts.isEmpty()) {
                            stateMap.put("renderActions", ((ViewState) state).getRenderActionList());
                        }

                        acts = Arrays.stream(((ViewState) state).getVariables())
                            .map(value -> value.getName() + " -> " + value.getValueFactory().toString())
                            .collect(Collectors.toList());

                        if (!acts.isEmpty()) {
                            stateMap.put("viewVariables", acts);
                        }

                        val field = ReflectionUtils.findField(((ViewState) state).getViewFactory().getClass(), "viewId");
                        if (field != null) {
                            ReflectionUtils.makeAccessible(field);
                            val exp = (Expression) ReflectionUtils.getField(field, ((ViewState) state).getViewFactory());
                            stateMap.put("viewId", StringUtils.defaultIfBlank(exp.getExpressionString(), exp.getValue(null).toString()));
                        } else {
                            LOGGER.warn("Field viewId cannot be located on view state [{}]", state);
                        }
                    }

                    if (state instanceof TransitionableState) {
                        val stDef = TransitionableState.class.cast(state);

                        acts = StreamSupport.stream(stDef.getExitActionList().spliterator(), false)
                            .map(Object::toString)
                            .collect(Collectors.toList());

                        if (!acts.isEmpty()) {
                            stateMap.put("exitActions", acts);
                        }

                        acts = Arrays.stream(stDef.getTransitions())
                            .map(tr -> tr.getId() + " -> " + tr.getTargetStateId())
                            .collect(Collectors.toList());

                        if (!acts.isEmpty()) {
                            stateMap.put("transitions", acts);
                        }
                    }
                    states.put(st, stateMap);
                });
                flowDetails.put("states", states);
                flowDetails.put("possibleOutcomes", def.getPossibleOutcomes());
                flowDetails.put("stateCount", def.getStateCount());

                var acts = StreamSupport.stream(def.getEndActionList().spliterator(), false)
                    .map(Object::toString)
                    .collect(Collectors.toList());
                if (!acts.isEmpty()) {
                    flowDetails.put("endActions", acts);
                }

                acts = StreamSupport.stream(def.getGlobalTransitionSet().spliterator(), false)
                    .map(tr -> tr.getId() + " -> " + tr.getTargetStateId() + " @ " + tr.getExecutionCriteria().toString())
                    .collect(Collectors.toList());
                if (!acts.isEmpty()) {
                    flowDetails.put("globalTransitions", acts);
                }

                acts = Arrays.stream(def.getExceptionHandlerSet().toArray())
                    .map(Object::toString)
                    .collect(Collectors.toList());
                if (!acts.isEmpty()) {
                    flowDetails.put("exceptionHandlers", acts);
                }

                val vars = Arrays.stream(def.getVariables())
                    .map(FlowVariable::getName)
                    .collect(Collectors.joining(","));

                if (StringUtils.isNotBlank(vars)) {
                    flowDetails.put("variables", vars);
                }

                jsonMap.put(id, flowDetails);
            }));

        return jsonMap;
    }
571630
Map<Integer, Pair<ExecutionReference, ExecutableFlow>> fetchActiveFlows()
      throws ExecutorManagerException {
    try {
      return this.dbOperator.query(FetchActiveExecutableFlows.FETCH_ACTIVE_EXECUTABLE_FLOWS,
          new FetchActiveExecutableFlows());
    } catch (final SQLException e) {
      throw new ExecutorManagerException("Error fetching active flows", e);
    }
  }
947006
@Service
    public Task getPendingTaskForWorkflow(String workflowId, String taskReferenceName) {
        return executionService.getPendingTaskForWorkflow(taskReferenceName, workflowId);
    }
882624
public static QueueName getQueueName(String appName, String flowName, KeyValue keyValue) {
    return getQueueName(appName, flowName, keyValue.getBuffer(), keyValue.getRowOffset(), keyValue.getRowLength());
  }