Search in sources :

Example 1 with KieServerEndpoint

use of org.kie.server.remote.rest.common.marker.KieServerEndpoint in project droolsjbpm-integration by kiegroup.

the class CaseQueryResource method queryCaseUserTasksByVariables.

@ApiOperation(value = "Queries cases tasks by variables", response = CaseUserTaskWithVariablesList.class)
@POST
@Path(RestURI.VARIABLES_TASKS_CASES_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@KieServerEndpoint(categories = { EndpointType.DEFAULT, EndpointType.HISTORY })
public Response queryCaseUserTasksByVariables(@Context HttpHeaders headers, String payload, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize) {
    Header conversationIdHeader = buildConversationIdHeader("", context, headers);
    Variant v = getVariant(headers);
    try {
        String type = getContentType(headers);
        CaseUserTaskWithVariablesList taskVariableSummaryList = caseManagementRuntimeDataServiceBase.queryUserTasksByVariables(payload, type, new QueryContext((page * pageSize), pageSize));
        logger.debug("Returning result of case instance user task search: {}", taskVariableSummaryList);
        return createCorrectVariant(taskVariableSummaryList, headers, Response.Status.OK, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", e.getMessage(), e);
        return internalServerError(errorMessage(e), v, conversationIdHeader);
    }
}
Also used : RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) Variant(javax.ws.rs.core.Variant) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) CaseUserTaskWithVariablesList(org.kie.server.api.model.cases.CaseUserTaskWithVariablesList) QueryContext(org.kie.api.runtime.query.QueryContext) Path(javax.ws.rs.Path) KieServerEndpoint(org.kie.server.remote.rest.common.marker.KieServerEndpoint) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with KieServerEndpoint

use of org.kie.server.remote.rest.common.marker.KieServerEndpoint in project droolsjbpm-integration by kiegroup.

the class RuntimeDataResource method queryUserTasksByVariables.

@ApiOperation(value = "Queries process tasks by variables", response = ProcessInstanceUserTaskWithVariablesList.class)
@POST
@Path(RestURI.VARIABLES_TASKS_PROCESSES_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@KieServerEndpoint(categories = { EndpointType.DEFAULT, EndpointType.HISTORY })
public Response queryUserTasksByVariables(@Context HttpHeaders headers, String payload, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize, @ApiParam(value = "optional sort column", required = false) @QueryParam("orderBy") String orderBy, @ApiParam(value = "optional sort direction - true ascending, false descending", required = false) @QueryParam("asc") @DefaultValue("true") boolean asc) {
    Header conversationIdHeader = buildConversationIdHeader("", context, headers);
    Variant v = getVariant(headers);
    try {
        String type = getContentType(headers);
        ProcessInstanceUserTaskWithVariablesList taskVariableSummaryList = runtimeDataServiceBase.queryUserTasksByVariables(payload, type, new QueryContext(page * pageSize, pageSize, orderBy, asc));
        logger.debug("Returning result of process tasks search: {}", taskVariableSummaryList);
        return createCorrectVariant(taskVariableSummaryList, headers, Response.Status.OK, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", e.getMessage(), e);
        return internalServerError(errorMessage(e), v, conversationIdHeader);
    }
}
Also used : RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) Variant(javax.ws.rs.core.Variant) ProcessInstanceUserTaskWithVariablesList(org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) QueryContext(org.kie.api.runtime.query.QueryContext) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) Path(javax.ws.rs.Path) KieServerEndpoint(org.kie.server.remote.rest.common.marker.KieServerEndpoint) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with KieServerEndpoint

use of org.kie.server.remote.rest.common.marker.KieServerEndpoint in project droolsjbpm-integration by kiegroup.

the class RuntimeDataResource method queryProcessesByVariables.

@ApiOperation(value = "Queries processes by variables and tasks", response = ProcessInstanceCustomVarsList.class)
@POST
@Path(RestURI.VARIABLES_PROCESSES_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@KieServerEndpoint(categories = { EndpointType.DEFAULT, EndpointType.HISTORY })
public Response queryProcessesByVariables(@Context HttpHeaders headers, String payload, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize, @ApiParam(value = "optional sort column", required = false) @QueryParam("orderBy") String orderBy, @ApiParam(value = "optional sort direction - true ascending, false descending", required = false) @QueryParam("asc") @DefaultValue("true") boolean asc) {
    Header conversationIdHeader = buildConversationIdHeader("", context, headers);
    Variant v = getVariant(headers);
    try {
        String type = getContentType(headers);
        ProcessInstanceCustomVarsList processVariableSummaryList = runtimeDataServiceBase.queryProcessesByVariables(payload, type, new QueryContext(page * pageSize, pageSize, orderBy, asc));
        logger.debug("Returning result of process instance search: {}", processVariableSummaryList);
        return createCorrectVariant(processVariableSummaryList, headers, Response.Status.OK, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", e.getMessage(), e);
        return internalServerError(errorMessage(e), v, conversationIdHeader);
    }
}
Also used : RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) Variant(javax.ws.rs.core.Variant) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) QueryContext(org.kie.api.runtime.query.QueryContext) ProcessInstanceCustomVarsList(org.kie.server.api.model.instance.ProcessInstanceCustomVarsList) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) Path(javax.ws.rs.Path) KieServerEndpoint(org.kie.server.remote.rest.common.marker.KieServerEndpoint) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with KieServerEndpoint

use of org.kie.server.remote.rest.common.marker.KieServerEndpoint in project droolsjbpm-integration by kiegroup.

the class ReadOnlySwaggerDecoration method decorateOperation.

@Override
public void decorateOperation(Operation operation, Method method, Iterator<SwaggerExtension> chain) {
    if (method.isAnnotationPresent(GET.class)) {
        operation.setVendorExtension(SWAGGER_EXTENSION_READ_ONLY, Boolean.TRUE);
        if (chain.hasNext()) {
            chain.next().decorateOperation(operation, method, chain);
        }
        return;
    }
    KieServerEndpoint api = method.getAnnotation(KieServerEndpoint.class);
    if (api == null) {
        api = method.getDeclaringClass().getAnnotation(KieServerEndpoint.class);
    }
    if (api != null) {
        List<EndpointType> current = new ArrayList<>(asList(api.categories()));
        current.retainAll(valid);
        if (!current.isEmpty()) {
            operation.setVendorExtension(SWAGGER_EXTENSION_READ_ONLY, Boolean.TRUE);
        }
    }
    if (chain.hasNext()) {
        chain.next().decorateOperation(operation, method, chain);
    }
}
Also used : KieServerEndpoint(org.kie.server.remote.rest.common.marker.KieServerEndpoint) EndpointType(org.kie.server.remote.rest.common.marker.KieServerEndpoint.EndpointType) ArrayList(java.util.ArrayList)

Example 5 with KieServerEndpoint

use of org.kie.server.remote.rest.common.marker.KieServerEndpoint in project droolsjbpm-integration by kiegroup.

the class CaseQueryResource method queryCaseByVariables.

@ApiOperation(value = "Queries cases by variables and tasks", response = CaseInstanceCustomVarsList.class)
@POST
@Path(RestURI.VARIABLES_CASES_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@KieServerEndpoint(categories = { EndpointType.DEFAULT, EndpointType.HISTORY })
public Response queryCaseByVariables(@Context HttpHeaders headers, String payload, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize) {
    Header conversationIdHeader = buildConversationIdHeader("", context, headers);
    Variant v = getVariant(headers);
    try {
        String type = getContentType(headers);
        CaseInstanceCustomVarsList processVariableSummaryList = caseManagementRuntimeDataServiceBase.queryCasesByVariables(payload, type, new QueryContext(page * pageSize, pageSize));
        logger.debug("Returning result of case instance search: {}", processVariableSummaryList);
        return createCorrectVariant(processVariableSummaryList, headers, Response.Status.OK, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", e.getMessage(), e);
        return internalServerError(errorMessage(e), v, conversationIdHeader);
    }
}
Also used : RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) Variant(javax.ws.rs.core.Variant) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) QueryContext(org.kie.api.runtime.query.QueryContext) CaseInstanceCustomVarsList(org.kie.server.api.model.cases.CaseInstanceCustomVarsList) Path(javax.ws.rs.Path) KieServerEndpoint(org.kie.server.remote.rest.common.marker.KieServerEndpoint) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

KieServerEndpoint (org.kie.server.remote.rest.common.marker.KieServerEndpoint)5 ApiOperation (io.swagger.annotations.ApiOperation)4 Consumes (javax.ws.rs.Consumes)4 POST (javax.ws.rs.POST)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 Variant (javax.ws.rs.core.Variant)4 QueryContext (org.kie.api.runtime.query.QueryContext)4 Header (org.kie.server.remote.rest.common.Header)4 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)4 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)4 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)4 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)2 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)2 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)2 ArrayList (java.util.ArrayList)1 CaseInstanceCustomVarsList (org.kie.server.api.model.cases.CaseInstanceCustomVarsList)1 CaseUserTaskWithVariablesList (org.kie.server.api.model.cases.CaseUserTaskWithVariablesList)1 ProcessInstanceCustomVarsList (org.kie.server.api.model.instance.ProcessInstanceCustomVarsList)1 ProcessInstanceUserTaskWithVariablesList (org.kie.server.api.model.instance.ProcessInstanceUserTaskWithVariablesList)1