public void runDecider(String workflowId) { Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank"); stub.decideWorkflow(WorkflowServicePb.DecideWorkflowRequest.newBuilder() .setWorkflowId(workflowId) .build() ); }
public List<String> getRunningWorkflow(String workflowName, @Nullable Integer version) { Preconditions.checkArgument(StringUtils.isNotBlank(workflowName), "Workflow name cannot be blank"); WorkflowServicePb.GetRunningWorkflowsResponse workflows = stub.getRunningWorkflows( WorkflowServicePb.GetRunningWorkflowsRequest.newBuilder() .setName(workflowName) .setVersion(version == null ? 1 : version) .build() ); return workflows.getWorkflowIdsList(); }
/** * Retrieve all workflows for a given correlation id and name * * @param name the name of the workflow * @param correlationId the correlation id * @param includeClosed specify if all workflows are to be returned or only running workflows * @param includeTasks specify if the tasks in the workflow need to be returned * @return list of workflows for the given correlation id and name */ public List<Workflow> getWorkflows(String name, String correlationId, boolean includeClosed, boolean includeTasks) { Preconditions.checkArgument(StringUtils.isNotBlank(name), "name cannot be blank"); Preconditions.checkArgument(StringUtils.isNotBlank(correlationId), "correlationId cannot be blank"); WorkflowServicePb.GetWorkflowsResponse workflows = stub.getWorkflows( WorkflowServicePb.GetWorkflowsRequest.newBuilder() .setName(name) .addCorrelationId(correlationId) .setIncludeClosed(includeClosed) .setIncludeTasks(includeTasks) .build() ); if (!workflows.containsWorkflowsById(correlationId)) { return Collections.emptyList(); } return workflows.getWorkflowsByIdOrThrow(correlationId) .getWorkflowsList().stream() .map(protoMapper::fromProto) .collect(Collectors.toList()); }
/** * 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 */ public Workflow getWorkflow(String workflowId, boolean includeTasks) { Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank"); WorkflowPb.Workflow workflow = stub.getWorkflowStatus( WorkflowServicePb.GetWorkflowStatusRequest.newBuilder() .setWorkflowId(workflowId) .setIncludeTasks(includeTasks) .build() ); return protoMapper.fromProto(workflow); }
/** * Removes a workflow from the system * * @param workflowId the id of the workflow to be deleted * @param archiveWorkflow flag to indicate if the workflow should be archived before deletion */ public void deleteWorkflow(String workflowId, boolean archiveWorkflow) { Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "Workflow id cannot be blank"); stub.removeWorkflow( WorkflowServicePb.RemoveWorkflowRequest.newBuilder() .setWorkflodId(workflowId) .setArchiveWorkflow(archiveWorkflow) .build() ); }
/** * Restart a completed workflow * * @param workflowId the workflow id of the workflow to be restarted */ public void restart(String workflowId) { Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank"); stub.restartWorkflow(WorkflowServicePb.RestartWorkflowRequest.newBuilder() .setWorkflowId(workflowId) .build() ); }
/** * Pause a workflow by workflow id * * @param workflowId the workflow id of the workflow to be paused */ public void pauseWorkflow(String workflowId) { Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank"); stub.pauseWorkflow(WorkflowServicePb.PauseWorkflowRequest.newBuilder() .setWorkflowId(workflowId) .build() ); }
/** * Resets the callback times of all IN PROGRESS tasks to 0 for the given workflow * * @param workflowId the id of the workflow */ public void resetCallbacksForInProgressTasks(String workflowId) { Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank"); stub.resetWorkflowCallbacks(WorkflowServicePb.ResetWorkflowCallbacksRequest.newBuilder() .setWorkflowId(workflowId) .build() ); }
/** * Resume a paused workflow by workflow id * * @param workflowId the workflow id of the paused workflow */ public void resumeWorkflow(String workflowId) { Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank"); stub.resumeWorkflow(WorkflowServicePb.ResumeWorkflowRequest.newBuilder() .setWorkflowId(workflowId) .build() ); }
/** * Reruns the workflow from a specific task * * @param rerunWorkflowRequest the request containing the task to rerun from * @return the id of the workflow */ public String rerunWorkflow(RerunWorkflowRequest rerunWorkflowRequest) { Preconditions.checkNotNull(rerunWorkflowRequest, "RerunWorkflowRequest cannot be null"); return stub.rerunWorkflow( protoMapper.toProto(rerunWorkflowRequest) ).getWorkflowId(); }