Search in sources :

Example 1 with ProcessDTO

use of io.automatiko.engine.addons.process.management.model.ProcessDTO in project automatiko-engine by automatiko-io.

the class ProcessInstanceManagementResource method get.

@APIResponses(value = { @APIResponse(responseCode = "200", description = "List of available processes", content = @Content(mediaType = "application/json")) })
@Operation(summary = "Lists available public processes in the service")
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public List<ProcessDTO> get(@Context UriInfo uriInfo, @Parameter(description = "Pagination - page to start on", required = false) @QueryParam(value = "page") @DefaultValue("1") int page, @Parameter(description = "Pagination - number of items to return", required = false) @QueryParam(value = "size") @DefaultValue("10") int size, @Parameter(description = "User identifier as alternative autroization info", required = false, hidden = true) @QueryParam("user") final String user, @Parameter(description = "Groups as alternative autroization info", required = false, hidden = true) @QueryParam("group") final List<String> groups) {
    List<ProcessDTO> collected = new ArrayList<ProcessDTO>();
    try {
        identitySupplier.buildIdentityProvider(user, groups);
        for (String id : processData.keySet()) {
            Process<?> process = processData.get(id);
            if (!WorkflowProcess.PUBLIC_VISIBILITY.equals(((WorkflowProcess) ((AbstractProcess<?>) process).process()).getVisibility())) {
                continue;
            }
            String pathprefix = "";
            if (process.version() != null) {
                pathprefix = "v" + process.version().replaceAll("\\.", "_") + "/";
            }
            collected.add(new ProcessDTO(id, process.version(), process.name(), (String) ((AbstractProcess<?>) process).process().getMetaData().get("Documentation"), uriInfo.getBaseUri().toString() + pathprefix + ((AbstractProcess<?>) process).process().getId() + "/image", process.instances().size()));
        }
        return collected;
    } finally {
        IdentityProvider.set(null);
    }
}
Also used : ArrayList(java.util.ArrayList) ProcessDTO(io.automatiko.engine.addons.process.management.model.ProcessDTO) WorkflowProcess(io.automatiko.engine.workflow.process.core.WorkflowProcess) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) APIResponses(org.eclipse.microprofile.openapi.annotations.responses.APIResponses) Operation(org.eclipse.microprofile.openapi.annotations.Operation)

Aggregations

ProcessDTO (io.automatiko.engine.addons.process.management.model.ProcessDTO)1 WorkflowProcess (io.automatiko.engine.workflow.process.core.WorkflowProcess)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Operation (org.eclipse.microprofile.openapi.annotations.Operation)1 APIResponses (org.eclipse.microprofile.openapi.annotations.responses.APIResponses)1