All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.nflow.rest.v1.WorkflowExecutorResource Maven / Gradle / Ivy

There is a newer version: 4.2.0
Show newest version
package io.nflow.rest.v1;

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import org.springframework.stereotype.Component;

import io.nflow.engine.service.WorkflowExecutorService;
import io.nflow.engine.workflow.executor.WorkflowExecutor;
import io.nflow.rest.config.NflowCors;
import io.nflow.rest.v1.converter.ListWorkflowExecutorConverter;
import io.nflow.rest.v1.msg.ListWorkflowExecutorResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Path("/nflow/v1/workflow-executor")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Api("nFlow workflow executor management")
@Component
@NflowCors
public class WorkflowExecutorResource {

  private final WorkflowExecutorService workflowExecutors;
  private final ListWorkflowExecutorConverter converter;

  @Inject
  public WorkflowExecutorResource(WorkflowExecutorService workflowExecutors, ListWorkflowExecutorConverter converter) {
    this.workflowExecutors = workflowExecutors;
    this.converter = converter;
  }

  @GET
  @ApiOperation(value = "List workflow executors", response = ListWorkflowExecutorResponse.class, responseContainer = "List")
  public Collection listWorkflowExecutors() {
    List executors = workflowExecutors.getWorkflowExecutors();
    Collection response = new ArrayList<>();
    for (WorkflowExecutor executor : executors) {
      response.add(converter.convert(executor));
    }
    return response;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy