Search in sources :

Example 11 with DataResponse

use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.

the class BaseHistoricActivitiInstanceService method getQueryResponse.

protected DataResponse getQueryResponse(HistoricActivityInstanceQueryRequest queryRequest, Map<String, String> allRequestParams, UriInfo uriInfo) {
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery();
    // Populate query based on request
    if (queryRequest.getActivityId() != null) {
        query.activityId(queryRequest.getActivityId());
    }
    if (queryRequest.getActivityInstanceId() != null) {
        query.activityInstanceId(queryRequest.getActivityInstanceId());
    }
    if (queryRequest.getActivityName() != null) {
        query.activityName(queryRequest.getActivityName());
    }
    if (queryRequest.getActivityType() != null) {
        query.activityType(queryRequest.getActivityType());
    }
    if (queryRequest.getExecutionId() != null) {
        query.executionId(queryRequest.getExecutionId());
    }
    if (queryRequest.getFinished() != null) {
        Boolean finished = queryRequest.getFinished();
        if (finished) {
            query.finished();
        } else {
            query.unfinished();
        }
    }
    if (queryRequest.getTaskAssignee() != null) {
        query.taskAssignee(queryRequest.getTaskAssignee());
    }
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getProcessDefinitionId() != null) {
        query.processDefinitionId(queryRequest.getProcessDefinitionId());
    }
    if (queryRequest.getTenantId() != null) {
        query.activityTenantId(queryRequest.getTenantId());
    }
    if (queryRequest.getTenantIdLike() != null) {
        query.activityTenantIdLike(queryRequest.getTenantIdLike());
    }
    if (Boolean.TRUE.equals(queryRequest.getWithoutTenantId())) {
        query.activityWithoutTenantId();
    }
    return new HistoricActivityInstancePaginateList(new RestResponseFactory(), uriInfo).paginateList(allRequestParams, queryRequest, query, "startTime", allowedSortProperties);
}
Also used : HistoricActivityInstancePaginateList(org.wso2.carbon.bpmn.rest.model.history.HistoricActivityInstancePaginateList) HistoricActivityInstanceQuery(org.activiti.engine.history.HistoricActivityInstanceQuery) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoryService(org.activiti.engine.HistoryService)

Example 12 with DataResponse

use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.

the class BaseHistoricTaskInstanceService method getQueryResponse.

protected DataResponse getQueryResponse(HistoricActivityInstanceQueryRequest queryRequest, Map<String, String> allRequestParams) {
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery();
    // Populate query based on request
    if (queryRequest.getActivityId() != null) {
        query.activityId(queryRequest.getActivityId());
    }
    if (queryRequest.getActivityInstanceId() != null) {
        query.activityInstanceId(queryRequest.getActivityInstanceId());
    }
    if (queryRequest.getActivityName() != null) {
        query.activityName(queryRequest.getActivityName());
    }
    if (queryRequest.getActivityType() != null) {
        query.activityType(queryRequest.getActivityType());
    }
    if (queryRequest.getExecutionId() != null) {
        query.executionId(queryRequest.getExecutionId());
    }
    if (queryRequest.getFinished() != null) {
        Boolean finished = queryRequest.getFinished();
        if (finished) {
            query.finished();
        } else {
            query.unfinished();
        }
    }
    if (queryRequest.getTaskAssignee() != null) {
        query.taskAssignee(queryRequest.getTaskAssignee());
    }
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getProcessDefinitionId() != null) {
        query.processDefinitionId(queryRequest.getProcessDefinitionId());
    }
    if (queryRequest.getTenantId() != null) {
        query.activityTenantId(queryRequest.getTenantId());
    }
    if (queryRequest.getTenantIdLike() != null) {
        query.activityTenantIdLike(queryRequest.getTenantIdLike());
    }
    if (Boolean.TRUE.equals(queryRequest.getWithoutTenantId())) {
        query.activityWithoutTenantId();
    }
    RestResponseFactory restResponseFactory = new RestResponseFactory();
    return new HistoricActivityInstancePaginateList(restResponseFactory, uriInfo).paginateList(allRequestParams, queryRequest, query, "startTime", allowedSortProperties);
}
Also used : HistoricActivityInstancePaginateList(org.wso2.carbon.bpmn.rest.model.history.HistoricActivityInstancePaginateList) HistoricActivityInstanceQuery(org.activiti.engine.history.HistoricActivityInstanceQuery) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoryService(org.activiti.engine.HistoryService)

Example 13 with DataResponse

use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.

the class BaseExecutionService method getQueryResponse.

protected DataResponse getQueryResponse(ExecutionQueryRequest queryRequest, Map<String, String> requestParams, UriInfo uriInfo) {
    RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
    ExecutionQuery query = runtimeService.createExecutionQuery();
    // Populate query based on request
    if (queryRequest.getId() != null) {
        query.executionId(queryRequest.getId());
        requestParams.put("id", queryRequest.getId());
    }
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
        requestParams.put("processInstanceId", queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getProcessDefinitionKey() != null) {
        query.processDefinitionKey(queryRequest.getProcessDefinitionKey());
        requestParams.put("processDefinitionKey", queryRequest.getProcessDefinitionKey());
    }
    if (queryRequest.getProcessDefinitionId() != null) {
        query.processDefinitionId(queryRequest.getProcessDefinitionId());
        requestParams.put("processDefinitionId", queryRequest.getProcessDefinitionId());
    }
    if (queryRequest.getProcessBusinessKey() != null) {
        query.processInstanceBusinessKey(queryRequest.getProcessBusinessKey());
        requestParams.put("processInstanceBusinessKey", queryRequest.getProcessBusinessKey());
    }
    if (queryRequest.getActivityId() != null) {
        query.activityId(queryRequest.getActivityId());
        requestParams.put("activityId", queryRequest.getActivityId());
    }
    if (queryRequest.getParentId() != null) {
        query.parentId(queryRequest.getParentId());
        requestParams.put("parentId", queryRequest.getParentId());
    }
    if (queryRequest.getMessageEventSubscriptionName() != null) {
        query.messageEventSubscriptionName(queryRequest.getMessageEventSubscriptionName());
        requestParams.put("messageEventSubscriptionName", queryRequest.getMessageEventSubscriptionName());
    }
    if (queryRequest.getSignalEventSubscriptionName() != null) {
        query.signalEventSubscriptionName(queryRequest.getSignalEventSubscriptionName());
        requestParams.put("signalEventSubscriptionName", queryRequest.getSignalEventSubscriptionName());
    }
    if (queryRequest.getVariables() != null) {
        addVariables(query, queryRequest.getVariables(), false);
    }
    if (queryRequest.getProcessInstanceVariables() != null) {
        addVariables(query, queryRequest.getProcessInstanceVariables(), true);
    }
    if (queryRequest.getTenantId() != null) {
        query.executionTenantId(queryRequest.getTenantId());
        requestParams.put("tenantId", queryRequest.getTenantId());
    }
    if (queryRequest.getTenantIdLike() != null) {
        query.executionTenantIdLike(queryRequest.getTenantIdLike());
        requestParams.put("tenantIdLike", queryRequest.getTenantIdLike());
    }
    if (Boolean.TRUE.equals(queryRequest.getWithoutTenantId())) {
        query.executionWithoutTenantId();
        requestParams.put("withoutTenantId", queryRequest.getWithoutTenantId().toString());
    }
    DataResponse dataResponse = new ExecutionPaginateList(new RestResponseFactory(), uriInfo).paginateList(requestParams, queryRequest, query, "processInstanceId", allowedSortProperties);
    return dataResponse;
}
Also used : RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) RuntimeService(org.activiti.engine.RuntimeService) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) ExecutionQuery(org.activiti.engine.runtime.ExecutionQuery)

Example 14 with DataResponse

use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.

the class BaseHistoricDetailService method getQueryResponse.

protected DataResponse getQueryResponse(HistoricDetailQueryRequest queryRequest, Map<String, String> allRequestParams, UriInfo uriInfo) {
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    HistoricDetailQuery query = historyService.createHistoricDetailQuery();
    // Populate query based on request
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getExecutionId() != null) {
        query.executionId(queryRequest.getExecutionId());
    }
    if (queryRequest.getActivityInstanceId() != null) {
        query.activityInstanceId(queryRequest.getActivityInstanceId());
    }
    if (queryRequest.getTaskId() != null) {
        query.taskId(queryRequest.getTaskId());
    }
    if (queryRequest.getSelectOnlyFormProperties() != null) {
        if (queryRequest.getSelectOnlyFormProperties()) {
            query.formProperties();
        }
    }
    if (queryRequest.getSelectOnlyVariableUpdates() != null) {
        if (queryRequest.getSelectOnlyVariableUpdates()) {
            query.variableUpdates();
        }
    }
    return new HistoricDetailPaginateList(new RestResponseFactory(), uriInfo).paginateList(allRequestParams, queryRequest, query, "processInstanceId", allowedSortProperties);
}
Also used : HistoricDetailPaginateList(org.wso2.carbon.bpmn.rest.model.history.HistoricDetailPaginateList) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoryService(org.activiti.engine.HistoryService) HistoricDetailQuery(org.activiti.engine.history.HistoricDetailQuery)

Example 15 with DataResponse

use of org.wso2.carbon.bpmn.rest.model.common.DataResponse in project carbon-business-process by wso2.

the class HistoricActivitiInstanceService method getHistoricActivityInstances.

@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getHistoricActivityInstances(@Context UriInfo uriInfo) {
    Map<String, String> allRequestParams = new HashMap<>();
    for (String property : allPropertiesList) {
        String value = uriInfo.getQueryParameters().getFirst(property);
        if (value != null) {
            allRequestParams.put(property, value);
        }
    }
    HistoricActivityInstanceQueryRequest query = getHistoricActivityInstanceQueryRequest(uriInfo, allRequestParams);
    DataResponse dataResponse = getQueryResponse(query, allRequestParams, uriInfo);
    return Response.ok().entity(dataResponse).build();
}
Also used : HashMap(java.util.HashMap) HistoricActivityInstanceQueryRequest(org.wso2.carbon.bpmn.rest.model.history.HistoricActivityInstanceQueryRequest) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)20 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)17 HashMap (java.util.HashMap)15 Path (javax.ws.rs.Path)14 Produces (javax.ws.rs.Produces)14 GET (javax.ws.rs.GET)8 HistoryService (org.activiti.engine.HistoryService)7 POST (javax.ws.rs.POST)6 RepositoryService (org.activiti.engine.RepositoryService)3 RuntimeService (org.activiti.engine.RuntimeService)3 List (java.util.List)2 Consumes (javax.ws.rs.Consumes)2 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)2 HistoricActivityInstanceQuery (org.activiti.engine.history.HistoricActivityInstanceQuery)2 ExecutionQuery (org.activiti.engine.runtime.ExecutionQuery)2 HistoricActivityInstancePaginateList (org.wso2.carbon.bpmn.rest.model.history.HistoricActivityInstancePaginateList)2 HistoricProcessInstancePaginateList (org.wso2.carbon.bpmn.rest.model.history.HistoricProcessInstancePaginateList)2 ArrayList (java.util.ArrayList)1 NotFoundException (javax.ws.rs.NotFoundException)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1