Search in sources :

Example 1 with QueryDefinitionList

use of org.kie.server.api.model.definition.QueryDefinitionList in project droolsjbpm-integration by kiegroup.

the class QueryServicesClientImpl method getQueries.

@Override
public List<QueryDefinition> getQueries(Integer page, Integer pageSize) {
    QueryDefinitionList result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        String queryString = getPagingQueryString("", page, pageSize);
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI, valuesMap) + queryString, QueryDefinitionList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "getQueries", new Object[] { page, pageSize })));
        ServiceResponse<QueryDefinitionList> response = (ServiceResponse<QueryDefinitionList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null && result.getQueries() != null) {
        return Arrays.asList(result.getQueries());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) QueryDefinitionList(org.kie.server.api.model.definition.QueryDefinitionList)

Example 2 with QueryDefinitionList

use of org.kie.server.api.model.definition.QueryDefinitionList in project droolsjbpm-integration by kiegroup.

the class QueryDataResource method getQueries.

@ApiOperation(value = "Returns all custom query definitions.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = QueryDefinitionList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = QUERY_DEF_LIST_RESPONSE_JSON) })) })
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getQueries(@Context HttpHeaders headers, @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) {
    // no container id available so only used to transfer conversation id if
    // given by client
    Header conversationIdHeader = buildConversationIdHeader("", context, headers);
    QueryDefinitionList result = queryDataServiceBase.getQueries(page, pageSize);
    logger.debug("Returning result of get queries definition: {}", result);
    return createCorrectVariant(result, headers, Response.Status.OK, conversationIdHeader);
}
Also used : Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) QueryDefinitionList(org.kie.server.api.model.definition.QueryDefinitionList) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

QueryDefinitionList (org.kie.server.api.model.definition.QueryDefinitionList)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 HashMap (java.util.HashMap)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 CommandScript (org.kie.server.api.commands.CommandScript)1 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)1 KieServerCommand (org.kie.server.api.model.KieServerCommand)1 ServiceResponse (org.kie.server.api.model.ServiceResponse)1 Header (org.kie.server.remote.rest.common.Header)1 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)1