Retrieve a workflow by workflow id

@param workflowId   the id of the workflow
@param includeTasks specify if the tasks in the workflow need to be returned
@return the requested workflow
497420
public Workflow getWorkflow(String workflowId, boolean includeTasks) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        Workflow workflow = getForEntity("workflow/{workflowId}", new Object[]{"includeTasks", includeTasks}, Workflow.class, workflowId);
        populateWorkflowOutput(workflow);
        return workflow;
    }
697980
public List<Integer> getComponentTasks(String componentId) {
        List<Integer> ret = _componentToTasks.get(componentId);
        if (ret == null)
            return new ArrayList<>();
        else
            return new ArrayList<>(ret);
    }
415919
@Service
    public BulkResponse pauseWorkflow(List<String> workflowIds){

        BulkResponse bulkResponse = new BulkResponse();
        for (String workflowId : workflowIds) {
            try {
                workflowExecutor.pauseWorkflow(workflowId);
                bulkResponse.appendSuccessResponse(workflowId);
            } catch (Exception e) {
                LOGGER.error("bulk pauseWorkflow exception, workflowId {}, message: {} ",workflowId, e.getMessage(), e);
                bulkResponse.appendFailedResponse(workflowId, e.getMessage());
            }
        }

        return bulkResponse;
    }
1247448
public function getDefinitionByID($object, $workflowID)
    {
        // Make sure the correct extensions have been applied to the data object.

        $workflow = null;
        if ($object->hasExtension(WorkflowApplicable::class)
            || $object->hasExtension(FileWorkflowApplicable::class)
        ) {
            // Validate the workflow ID against the data object.

            if (($object->WorkflowDefinitionID == $workflowID)
                || ($workflow = $object->AdditionalWorkflowDefinitions()->byID($workflowID))
            ) {
                if (is_null($workflow)) {
                    $workflow = DataObject::get_by_id(WorkflowDefinition::class, $workflowID);
                }
            }
        }
        return $workflow ? $workflow : null;
    }
516683
public String createWorkflow(Workflow workflow) {
        executionDAO.createWorkflow(workflow);
        indexDAO.indexWorkflow(workflow);
        return workflow.getWorkflowId();
    }
1213773
public String updateWorkflow(Workflow workflow) {
        executionDAO.updateWorkflow(workflow);
        indexDAO.indexWorkflow(workflow);
        return workflow.getWorkflowId();
    }
947358
@Service
    public String rerunWorkflow(String workflowId, RerunWorkflowRequest request) {
        request.setReRunFromWorkflowId(workflowId);
        return workflowExecutor.rerun(request);
    }
460263
def load_workflow(self, workflow_id):
        
        with switch_db(WorkflowDefinitionModel, db_alias='hyperstream'):
            workflow_definition = WorkflowDefinitionModel.objects.get(workflow_id=workflow_id)
            if not workflow_definition:
                logging.warn("Attempted to load workflow with id {}, but not found".format(workflow_id))

            workflow = Workflow(
                workflow_id=workflow_id,
                name=workflow_definition.name,
                description=workflow_definition.description,
                owner=workflow_definition.owner,
                online=workflow_definition.online,
                monitor=workflow_definition.monitor
            )

            for n in workflow_definition.nodes:
                workflow.create_node(
                    stream_name=n.stream_name,
                    channel=self.channel_manager.get_channel(n.channel_id),
                    plates=[self.plate_manager.plates[p] for p in n.plate_ids])

            for f in workflow_definition.factors:
                source_nodes = [workflow.nodes[node_id] for node_id in f.sources] if f.sources else []
                sink_nodes = [workflow.nodes[node_id] for node_id in f.sinks] if f.sinks else []
                alignment_node = workflow.nodes[f.alignment_node] if f.alignment_node else None
                splitting_node = workflow.nodes[f.splitting_node] if f.splitting_node else None
                output_plate = f.output_plate

                parameters = Tool.parameters_from_model(f.tool.parameters)
                # tool = dict(name=f.tool.name, parameters=parameters)
                tool = self.channel_manager.get_tool(f.tool.name, parameters, version=None)

                if f.factor_type == "Factor":
                    if len(sink_nodes) != 1:
                        raise ValueError(
                            "Standard factors should have a single sink node, received {}"
                            .format(len(sink_nodes)))

                    if splitting_node is not None:
                        raise ValueError(
                            "Standard factors do not support splitting nodes")

                    if output_plate is not None:
                        raise ValueError(
                            "Standard factors do not support output plates")

                    workflow.create_factor(
                        tool=tool,
                        sources=source_nodes,
                        sink=sink_nodes[0],
                        alignment_node=alignment_node
                    )

                elif f.factor_type == "MultiOutputFactor":
                    if len(source_nodes) > 1:
                        raise ValueError(
                            "MultiOutputFactor factors should have at most one source node, received {}"
                            .format(len(source_nodes)))

                    if len(sink_nodes) != 1:
                        raise ValueError(
                            "MultiOutputFactor factors should have a single sink node, received {}"
                            .format(len(sink_nodes)))

                    if alignment_node is not None:
                        raise ValueError(
                            "MultiOutputFactor does not support alignment nodes")

                    if output_plate is not None:
                        raise ValueError(
                            "MultiOutputFactor does not support output plates")

                    workflow.create_multi_output_factor(
                        tool=tool,
                        source=source_nodes[0] if source_nodes else None,
                        splitting_node=splitting_node,
                        sink=sink_nodes[0]
                    )

                elif f.factor_type == "NodeCreationFactor":
                    if len(source_nodes) > 1:
                        raise ValueError(
                            "NodeCreationFactor factors should no more than one source node, received {}"
                            .format(len(source_nodes)))

                    if len(sink_nodes) != 0:
                        raise ValueError(
                            "NodeCreationFactor factors should not have sink nodes"
                            .format(len(sink_nodes)))

                    if output_plate is None:
                        raise ValueError(
                            "NodeCreationFactor requires an output plate definition")

                    workflow.create_node_creation_factor(
                        tool=tool,
                        source=source_nodes[0] if source_nodes else None,
                        output_plate=output_plate.to_mongo().to_dict(),
                        plate_manager=self.plate_manager
                    )

                else:
                    raise NotImplementedError("Unsupported factor type {}".format(f.factor_type))

            self.add_workflow(workflow, False)
            return workflow
635802
public void skipTaskFromWorkflow(String workflowId, String taskReferenceName) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        Preconditions.checkArgument(StringUtils.isNotBlank(taskReferenceName), "Task reference name cannot be blank");
        stub.skipTaskFromWorkflow(WorkflowServicePb.SkipTaskRequest.newBuilder()
                .setWorkflowId(workflowId)
                .setTaskReferenceName(taskReferenceName)
                .build()
        );
    }
84927
@VisibleForTesting
    void correlateTaskToWorkflowInDS(String taskId, String workflowInstanceId) {
        String workflowToTaskKey = nsKey(WORKFLOW_TO_TASKS, workflowInstanceId);
        dynoClient.sadd(workflowToTaskKey, taskId);
        logger.debug("Task mapped in WORKFLOW_TO_TASKS with workflowToTaskKey: {}, workflowId: {}, taskId: {}",
                workflowToTaskKey, workflowInstanceId, taskId);
    }
356184
public void retryLastFailedTask(String workflowId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        postForEntityWithUriVariablesOnly("workflow/{workflowId}/retry", workflowId);
    }
474113
@GET
    @Path("{ids}")
    public final Response findByIds(@NotNull @PathParam("ids") URI_ID id,
                                    @NotNull @PathParam("ids") final PathSegment ids,
                                    @QueryParam("include_deleted") boolean includeDeleted) throws Exception {
        return super.findByIds(id, ids, includeDeleted);
    }
785806
public function getTaskServiceId($workflow, $taskName)
    {
        if (!isset($this->workflows[$workflow])) {
            $this->loadWorkflow($workflow);
        }

        return $this->workflows[$workflow]->getTask($taskName);
    }
48814
public List<Integer> getComponentTasks(String componentId) {
    List<Integer> retVal = new LinkedList<>();
    for (Map.Entry<Integer, String> entry : taskToComponentMap.entrySet()) {
      if (entry.getValue().equals(componentId)) {
        retVal.add(entry.getKey());
      }
    }
    return retVal;
  }
161707
def _extract_from_subworkflow(vs, step):
    
    substep_ids = set([x.name for x in step.workflow])
    out = []
    for var in vs:
        internal = False
        parts = var["id"].split("/")
        if len(parts) > 1:
            if parts[0] in substep_ids:
                internal = True
        if not internal:
            var.pop("source", None)
            out.append(var)
    return out
998324
public String obtainAndReturnTicketPoolId(Workflow<?> wf) {
        TicketPool tp = findPool(wf.getClass().getName());
        tp.obtain();
        return tp.getId();
    }
1083150
public List<String> getRunningWorkflow(String workflowName, Integer version) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowName), "Workflow name cannot be blank");
        return getForEntity("workflow/running/{name}", new Object[]{"version", version}, new GenericType<List<String>>() {
        }, workflowName);
    }