Search in sources :

Example 16 with DataResponse

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

the class HistoricTaskInstanceService method getHistoricProcessInstances.

@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getHistoricProcessInstances() {
    Map<String, String> allRequestParams = new HashMap<>();
    for (String property : allPropertiesList) {
        String value = uriInfo.getQueryParameters().getFirst(property);
        if (value != null) {
            allRequestParams.put(property, value);
        }
    }
    // Populate query based on request
    HistoricTaskInstanceQueryRequest queryRequest = new HistoricTaskInstanceQueryRequest();
    if (allRequestParams.get("taskId") != null) {
        queryRequest.setTaskId(allRequestParams.get("taskId"));
    }
    if (allRequestParams.get("processInstanceId") != null) {
        queryRequest.setProcessInstanceId(allRequestParams.get("processInstanceId"));
    }
    if (allRequestParams.get("processBusinessKey") != null) {
        queryRequest.setProcessBusinessKey(allRequestParams.get("processBusinessKey"));
    }
    if (allRequestParams.get("processDefinitionKey") != null) {
        queryRequest.setProcessDefinitionKey(allRequestParams.get("processDefinitionKey"));
    }
    if (allRequestParams.get("processDefinitionId") != null) {
        queryRequest.setProcessDefinitionId(allRequestParams.get("processDefinitionId"));
    }
    if (allRequestParams.get("processDefinitionName") != null) {
        queryRequest.setProcessDefinitionName(allRequestParams.get("processDefinitionName"));
    }
    if (allRequestParams.get("executionId") != null) {
        queryRequest.setExecutionId(allRequestParams.get("executionId"));
    }
    if (allRequestParams.get("taskName") != null) {
        queryRequest.setTaskName(allRequestParams.get("taskName"));
    }
    if (allRequestParams.get("taskNameLike") != null) {
        queryRequest.setTaskNameLike(allRequestParams.get("taskNameLike"));
    }
    if (allRequestParams.get("taskDescription") != null) {
        queryRequest.setTaskDescription(allRequestParams.get("taskDescription"));
    }
    if (allRequestParams.get("taskDescriptionLike") != null) {
        queryRequest.setTaskDescriptionLike(allRequestParams.get("taskDescriptionLike"));
    }
    if (allRequestParams.get("taskDefinitionKey") != null) {
        queryRequest.setTaskDefinitionKey(allRequestParams.get("taskDefinitionKey"));
    }
    if (allRequestParams.get("taskDeleteReason") != null) {
        queryRequest.setTaskDeleteReason(allRequestParams.get("taskDeleteReason"));
    }
    if (allRequestParams.get("taskDeleteReasonLike") != null) {
        queryRequest.setTaskDeleteReasonLike(allRequestParams.get("taskDeleteReasonLike"));
    }
    if (allRequestParams.get("taskAssignee") != null) {
        queryRequest.setTaskAssignee(allRequestParams.get("taskAssignee"));
    }
    if (allRequestParams.get("taskAssigneeLike") != null) {
        queryRequest.setTaskAssigneeLike(allRequestParams.get("taskAssigneeLike"));
    }
    if (allRequestParams.get("taskOwner") != null) {
        queryRequest.setTaskOwner(allRequestParams.get("taskOwner"));
    }
    if (allRequestParams.get("taskOwnerLike") != null) {
        queryRequest.setTaskOwnerLike(allRequestParams.get("taskOwnerLike"));
    }
    if (allRequestParams.get("taskInvolvedUser") != null) {
        queryRequest.setTaskInvolvedUser(allRequestParams.get("taskInvolvedUser"));
    }
    if (allRequestParams.get("taskPriority") != null) {
        queryRequest.setTaskPriority(Integer.valueOf(allRequestParams.get("taskPriority")));
    }
    if (allRequestParams.get("finished") != null) {
        queryRequest.setFinished(Boolean.valueOf(allRequestParams.get("finished")));
    }
    if (allRequestParams.get("processFinished") != null) {
        queryRequest.setProcessFinished(Boolean.valueOf(allRequestParams.get("processFinished")));
    }
    if (allRequestParams.get("parentTaskId") != null) {
        queryRequest.setParentTaskId(allRequestParams.get("parentTaskId"));
    }
    if (allRequestParams.get("dueDate") != null) {
        queryRequest.setDueDate(RequestUtil.getDate(allRequestParams, "dueDate"));
    }
    if (allRequestParams.get("dueDateAfter") != null) {
        queryRequest.setDueDateAfter(RequestUtil.getDate(allRequestParams, "dueDateAfter"));
    }
    if (allRequestParams.get("dueDateBefore") != null) {
        queryRequest.setDueDateBefore(RequestUtil.getDate(allRequestParams, "dueDateBefore"));
    }
    if (allRequestParams.get("taskCreatedOn") != null) {
        queryRequest.setTaskCreatedOn(RequestUtil.getDate(allRequestParams, "taskCreatedOn"));
    }
    if (allRequestParams.get("taskCreatedBefore") != null) {
        queryRequest.setTaskCreatedBefore(RequestUtil.getDate(allRequestParams, "taskCreatedBefore"));
    }
    if (allRequestParams.get("taskCreatedAfter") != null) {
        queryRequest.setTaskCreatedAfter(RequestUtil.getDate(allRequestParams, "taskCreatedAfter"));
    }
    if (allRequestParams.get("taskCompletedOn") != null) {
        queryRequest.setTaskCompletedOn(RequestUtil.getDate(allRequestParams, "taskCompletedOn"));
    }
    if (allRequestParams.get("taskCompletedBefore") != null) {
        queryRequest.setTaskCompletedBefore(RequestUtil.getDate(allRequestParams, "taskCompletedBefore"));
    }
    if (allRequestParams.get("taskCompletedAfter") != null) {
        queryRequest.setTaskCompletedAfter(RequestUtil.getDate(allRequestParams, "taskCompletedAfter"));
    }
    if (allRequestParams.get("includeTaskLocalVariables") != null) {
        queryRequest.setIncludeTaskLocalVariables(Boolean.valueOf(allRequestParams.get("includeTaskLocalVariables")));
    }
    if (allRequestParams.get("includeProcessVariables") != null) {
        queryRequest.setIncludeProcessVariables(Boolean.valueOf(allRequestParams.get("includeProcessVariables")));
    }
    if (allRequestParams.get("tenantId") != null) {
        queryRequest.setTenantId(allRequestParams.get("tenantId"));
    }
    if (allRequestParams.get("tenantIdLike") != null) {
        queryRequest.setTenantIdLike(allRequestParams.get("tenantIdLike"));
    }
    if (allRequestParams.get("withoutTenantId") != null) {
        queryRequest.setWithoutTenantId(Boolean.valueOf(allRequestParams.get("withoutTenantId")));
    }
    if (allRequestParams.get("taskCandidateGroup") != null) {
        queryRequest.setTaskCandidateGroup(allRequestParams.get("taskCandidateGroup"));
    }
    String serverRootUrl = uriInfo.getBaseUri().toString().replace("/history/historic-task-instances", "");
    DataResponse dataResponse = getQueryResponse(queryRequest, allRequestParams, serverRootUrl);
    return Response.ok().entity(dataResponse).build();
}
Also used : HistoricTaskInstanceQueryRequest(org.wso2.carbon.bpmn.rest.model.history.HistoricTaskInstanceQueryRequest) HashMap(java.util.HashMap) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse)

Example 17 with DataResponse

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

the class HistoricVariableInstanceService method getHistoricActivityInstances.

@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getHistoricActivityInstances() {
    HistoricVariableInstanceQueryRequest query = new HistoricVariableInstanceQueryRequest();
    // Populate query based on request
    Map<String, String> allRequestParams = new HashMap<>();
    for (String property : allPropertiesList) {
        String value = uriInfo.getQueryParameters().getFirst(property);
        if (value != null) {
            allRequestParams.put(property, value);
        }
    }
    if (allRequestParams.get("excludeTaskVariables") != null) {
        query.setExcludeTaskVariables(Boolean.valueOf(allRequestParams.get("excludeTaskVariables")));
    }
    if (allRequestParams.get("taskId") != null) {
        query.setTaskId(allRequestParams.get("taskId"));
    }
    if (allRequestParams.get("executionId") != null) {
        query.setExecutionId(allRequestParams.get("executionId"));
    }
    if (allRequestParams.get("processInstanceId") != null) {
        query.setProcessInstanceId(allRequestParams.get("processInstanceId"));
    }
    if (allRequestParams.get("variableName") != null) {
        query.setVariableName(allRequestParams.get("variableName"));
    }
    if (allRequestParams.get("variableNameLike") != null) {
        query.setVariableNameLike(allRequestParams.get("variableNameLike"));
    }
    DataResponse dataResponse = getQueryResponse(query, allRequestParams);
    return Response.ok().entity(dataResponse).build();
}
Also used : HistoricVariableInstanceQueryRequest(org.wso2.carbon.bpmn.rest.model.history.HistoricVariableInstanceQueryRequest) HashMap(java.util.HashMap) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 18 with DataResponse

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

the class IdentityService method getGroups.

/**
 * Get all the groups that match the filters given by query parameters of the request.
 * @return DataResponse
 */
@GET
@Path("/groups")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public DataResponse getGroups() {
    GroupQuery query = identityService.createGroupQuery();
    Map<String, String> allRequestParams = new HashMap<>();
    String id = uriInfo.getQueryParameters().getFirst("id");
    if (id != null) {
        query.groupId(id);
        allRequestParams.put("id", id);
    }
    String name = uriInfo.getQueryParameters().getFirst("name");
    if (name != null) {
        query.groupName(name);
        allRequestParams.put("name", name);
    }
    String nameLike = uriInfo.getQueryParameters().getFirst("nameLike");
    if (nameLike != null) {
        query.groupNameLike(nameLike);
        allRequestParams.put("nameLike", nameLike);
    }
    String type = uriInfo.getQueryParameters().getFirst("type");
    if (type != null) {
        query.groupType(type);
        allRequestParams.put("type", type);
    }
    String member = uriInfo.getQueryParameters().getFirst("name");
    if (member != null) {
        query.groupMember(member);
        allRequestParams.put("member", member);
    }
    String potentialStarter = uriInfo.getQueryParameters().getFirst("potentialStarter");
    if (potentialStarter != null) {
        query.potentialStarter(potentialStarter);
        allRequestParams.put("potentialStarter", potentialStarter);
    }
    allRequestParams = Utils.prepareCommonParameters(allRequestParams, uriInfo);
    GroupPaginateList groupPaginateList = new GroupPaginateList(new RestResponseFactory(), uriInfo);
    return groupPaginateList.paginateList(allRequestParams, query, "id", groupProperties);
}
Also used : RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HashMap(java.util.HashMap) GroupQuery(org.activiti.engine.identity.GroupQuery) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 19 with DataResponse

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

the class HistoricActivitiInstanceQueryService method queryActivityInstances.

@POST
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response queryActivityInstances(HistoricActivityInstanceQueryRequest queryRequest, @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);
        }
    }
    DataResponse dataResponse = getQueryResponse(queryRequest, allRequestParams, uriInfo);
    return Response.ok().entity(dataResponse).build();
}
Also used : HashMap(java.util.HashMap) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 20 with DataResponse

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

the class BaseRuntimeService method getQueryResponse.

protected DataResponse getQueryResponse(ExecutionQueryRequest queryRequest, Map<String, String> requestParams, String serverRootUrl) {
    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());
    }
    return new ExecutionPaginateList(new RestResponseFactory(), uriInfo).paginateList(requestParams, queryRequest, query, "processInstanceId", allowedSortProperties);
}
Also used : RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) ExecutionPaginateList(org.wso2.carbon.bpmn.rest.model.runtime.ExecutionPaginateList) ExecutionQuery(org.activiti.engine.runtime.ExecutionQuery)

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