For internal use only!!

@param id
workflow instance id
199073
public void removeWorkflow(String id) {
        final Workflow<?> wf = workflowMap.remove(id);
        if (wf != null) {
            WorkflowAccessor.setProcessingState(wf, ProcessingState.FINISHED);
            ticketPoolManager.release(wf);
            statisticsCollector.submit(getEngineId() + "." + wf.getClass().getSimpleName() + ".ExecutionTime", 1, System.currentTimeMillis() - wf.getCreationTS().getTime(), TimeUnit.MILLISECONDS);
        }
    }
237731
protected Event newEvent(final String id, final Throwable error) {
        return newEvent(id, new LocalAttributeMap(CasWebflowConstants.TRANSITION_ID_ERROR, error));
    }
1060934
def commit_workflow(self, workflow_id):
        
        # TODO: We should also be committing the Stream definitions if there are new ones

        workflow = self.workflows[workflow_id]

        with switch_db(WorkflowDefinitionModel, "hyperstream"):
            workflows = WorkflowDefinitionModel.objects(workflow_id=workflow_id)
            if len(workflows) > 0:
                logging.warn("Workflow with id {} already exists in database".format(workflow_id))
                return

            factors = []
            for f in workflow.factors:
                tool = f.tool.get_model()

                if isinstance(f, Factor):
                    sources = [s.node_id for s in f.sources] if f.sources else []
                    sinks = [f.sink.node_id]
                    alignment_node = f.alignment_node.node_id if f.alignment_node else None
                    splitting_node = None
                    output_plate = None

                elif isinstance(f, MultiOutputFactor):
                    sources = [f.source.node_id] if f.source else []
                    sinks = [f.sink.node_id]
                    alignment_node = None
                    splitting_node = f.splitting_node.node_id if f.splitting_node else None
                    output_plate = None

                elif isinstance(f, NodeCreationFactor):
                    sources = [f.source.node_id] if f.source else []
                    sinks = []
                    alignment_node = None
                    splitting_node = None
                    output_plate = f.output_plate

                else:
                    raise NotImplementedError("Unsupported factor type")

                if output_plate:
                    output_plate_copy = deepcopy(output_plate)
                    if 'parent_plate' in output_plate_copy:
                        del output_plate_copy['parent_plate']
                else:
                    output_plate_copy = None

                factor = FactorDefinitionModel(
                    tool=tool,
                    factor_type=f.__class__.__name__,
                    sources=sources,
                    sinks=sinks,
                    alignment_node=alignment_node,
                    splitting_node=splitting_node,
                    output_plate=output_plate_copy
                )

                factors.append(factor)

            nodes = []
            for n in workflow.nodes.values():
                nodes.append(NodeDefinitionModel(
                    stream_name=n.node_id,
                    plate_ids=n.plate_ids,
                    channel_id=n._channel.channel_id
                ))

            workflow_definition = WorkflowDefinitionModel(
                workflow_id=workflow.workflow_id,
                name=workflow.name,
                description=workflow.description,
                nodes=nodes,
                factors=factors,
                owner=workflow.owner,
                online=workflow.online,
                monitor=workflow.monitor
            )

            workflow_definition.save()

        with switch_db(WorkflowStatusModel, db_alias='hyperstream'):
            workflow_status = WorkflowStatusModel(
                workflow_id=workflow.workflow_id,
                last_updated=utcnow(),
                last_accessed=utcnow(),
                requested_intervals=[]
            )

            workflow_status.save()

        self.uncommitted_workflows.remove(workflow_id)
        logging.info("Committed workflow {} to database".format(workflow_id))
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);
    }
1352455
protected Task getTaskById(String id) {
    return engine.getTaskService().createTaskQuery().taskId(id).initializeFormKeys().singleResult();
  }
356184
public void retryLastFailedTask(String workflowId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        postForEntityWithUriVariablesOnly("workflow/{workflowId}/retry", workflowId);
    }
379474
def delete_workflow(self, workflow_id):
        
        deleted = False

        with switch_db(WorkflowDefinitionModel, "hyperstream"):
            workflows = WorkflowDefinitionModel.objects(workflow_id=workflow_id)
            if len(workflows) == 1:
                workflows[0].delete()
                deleted = True
            else:
                logging.debug("Workflow with id {} does not exist".format(workflow_id))

        with switch_db(WorkflowStatusModel, "hyperstream"):
            workflows = WorkflowStatusModel.objects(workflow_id=workflow_id)
            if len(workflows) == 1:
                workflows[0].delete()
                deleted = True
            else:
                logging.debug("Workflow status with id {} does not exist".format(workflow_id))

        if workflow_id in self.workflows:
            del self.workflows[workflow_id]
            deleted = True

        if deleted:
            logging.info("Deleted workflow with id {}".format(workflow_id))
547745
def send_event(workflow_name, custom_id, event)
      body = {
        ATTR_PROG => PROG,
        ATTR_NAME => workflow_name,
        ATTR_ID => custom_id,
        EVENT_NAME => event.class.name,
        EVENT_INPUT => @serializer.encode(@properties.from(event))
      }
      @http.post(send_event_url, body)
    end
908716
public void setId(String id)
	{
		if (id == null || id.length() == 0)
			throw new IllegalArgumentException(
			"id required in setId");

		this.setId(Integer.valueOf(id));
	}
17327
private void setId(String id) {
        requireArgument(id != null && !id.trim().isEmpty(), "ID cannot be null or empty.");
        _id = id;
    }
423203
public void setWorkflowState(java.util.Collection<StringFilter> workflowState) {
        if (workflowState == null) {
            this.workflowState = null;
            return;
        }

        this.workflowState = new java.util.ArrayList<StringFilter>(workflowState);
    }
872045
public void deleteById(String id) {
    if (idToVersion.containsKey(id)) {
      String version = idToVersion.remove(id);
      expirationVersion.remove(version);
      versionToItem.remove(version);
      if (collectionCachePath != null
          && !collectionCachePath.resolve(version).toFile().delete()) {
        log.debug("couldn't delete " + version);
      }
    }
  }
1068658
@Override
    public void setID(String id) {
        _ID = id;
        if (_store != null) {
            _store.setID(id);
        }
    }
813986
public void associateExecutionById(String executionId) {
    Execution execution = processEngine.getRuntimeService()
      .createExecutionQuery()
      .executionId(executionId)
      .singleResult();
    if(execution == null) {
      throw new ProcessEngineCdiException("Cannot associate execution by id: no execution with id '"+executionId+"' found.");
    }
    associationManager.setExecution(execution);
  }
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;
    }
370097
public function reopenIssue($id)
    {
        $this->connect();

        $action = $this->getReopenActionId($id);

        if (isset($action)) {
            $this->soapClient->progressWorkflowAction($this->token, $id, $action, array());
        }
    }
652483
public void resumeWorkflow(String workflowId) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        stub.resumeWorkflow(WorkflowServicePb.ResumeWorkflowRequest.newBuilder()
                .setWorkflowId(workflowId)
                .build()
        );
    }