Search in sources :

Example 36 with Property

use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.

the class ExecutionService method getProcessInstances.

@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessInstances() {
    // Populate query based on request
    ExecutionQueryRequest queryRequest = new ExecutionQueryRequest();
    Map<String, String> allRequestParams = new HashMap<>();
    for (String property : allPropertiesList) {
        String value = uriInfo.getQueryParameters().getFirst(property);
        if (value != null) {
            allRequestParams.put(property, value);
        }
    }
    String id = uriInfo.getQueryParameters().getFirst("id");
    if (id != null) {
        queryRequest.setId(id);
    }
    String processInstanceId = uriInfo.getQueryParameters().getFirst("processInstanceId");
    if (processInstanceId != null) {
        queryRequest.setProcessInstanceId(processInstanceId);
    }
    String processInstanceBusinessKey = uriInfo.getQueryParameters().getFirst("processInstanceBusinessKey");
    if (processInstanceBusinessKey != null) {
        queryRequest.setProcessBusinessKey(processInstanceBusinessKey);
    }
    String processDefinitionKey = uriInfo.getQueryParameters().getFirst("processDefinitionKey");
    if (processDefinitionKey != null) {
        queryRequest.setProcessDefinitionKey(processDefinitionKey);
    }
    String processDefinitionId = uriInfo.getQueryParameters().getFirst("processDefinitionId");
    if (processDefinitionId != null) {
        queryRequest.setProcessDefinitionId(processDefinitionId);
    }
    String messageEventSubscriptionName = uriInfo.getQueryParameters().getFirst("messageEventSubscriptionName");
    if (messageEventSubscriptionName != null) {
        queryRequest.setMessageEventSubscriptionName(messageEventSubscriptionName);
    }
    String signalEventSubscriptionName = uriInfo.getQueryParameters().getFirst("signalEventSubscriptionName");
    if (signalEventSubscriptionName != null) {
        queryRequest.setSignalEventSubscriptionName(signalEventSubscriptionName);
    }
    String activityId = uriInfo.getQueryParameters().getFirst("activityId");
    if (activityId != null) {
        queryRequest.setActivityId(activityId);
    }
    String parentId = uriInfo.getQueryParameters().getFirst("parentId");
    if (parentId != null) {
        queryRequest.setParentId(parentId);
    }
    String tenantId = uriInfo.getQueryParameters().getFirst("tenantId");
    if (tenantId != null) {
        queryRequest.setTenantId(tenantId);
    }
    String tenantIdLike = uriInfo.getQueryParameters().getFirst("tenantIdLike");
    if (tenantIdLike != null) {
        queryRequest.setTenantIdLike(tenantIdLike);
    }
    String withoutTenantId = uriInfo.getQueryParameters().getFirst("withoutTenantId");
    if (withoutTenantId != null) {
        if (Boolean.valueOf(withoutTenantId)) {
            queryRequest.setWithoutTenantId(Boolean.TRUE);
        }
    }
    // add common parameters such as sort,order,start etc.
    // allRequestParams = Utils.prepareCommonParameters(allRequestParams, uriInfo);
    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)

Example 37 with Property

use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.

the class WorkflowTaskService method getTasks.

@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTasks() {
    // Create a Task query request
    TaskQueryRequest request = new TaskQueryRequest();
    Map<String, String> requestParams = new HashMap<>();
    for (String property : allPropertiesList) {
        String value = uriInfo.getQueryParameters().getFirst(property);
        if (value != null) {
            requestParams.put(property, value);
        }
    }
    // Populate filter-parameters
    if (requestParams.containsKey("name")) {
        request.setName(requestParams.get("name"));
    }
    if (requestParams.containsKey("nameLike")) {
        request.setNameLike(requestParams.get("nameLike"));
    }
    if (requestParams.containsKey("description")) {
        request.setDescription(requestParams.get("description"));
    }
    if (requestParams.containsKey("descriptionLike")) {
        request.setDescriptionLike(requestParams.get("descriptionLike"));
    }
    if (requestParams.containsKey("priority")) {
        request.setPriority(Integer.valueOf(requestParams.get("priority")));
    }
    if (requestParams.containsKey("minimumPriority")) {
        request.setMinimumPriority(Integer.valueOf(requestParams.get("minimumPriority")));
    }
    if (requestParams.containsKey("maximumPriority")) {
        request.setMaximumPriority(Integer.valueOf(requestParams.get("maximumPriority")));
    }
    if (requestParams.containsKey("assignee")) {
        request.setAssignee(requestParams.get("assignee"));
    }
    if (requestParams.containsKey("owner")) {
        request.setOwner(requestParams.get("owner"));
    }
    if (requestParams.containsKey("unassigned")) {
        request.setUnassigned(Boolean.valueOf(requestParams.get("unassigned")));
    }
    if (requestParams.containsKey("delegationState")) {
        request.setDelegationState(requestParams.get("delegationState"));
    }
    if (requestParams.containsKey("candidateUser")) {
        request.setCandidateUser(requestParams.get("candidateUser"));
    }
    if (requestParams.containsKey("involvedUser")) {
        request.setInvolvedUser(requestParams.get("involvedUser"));
    }
    if (requestParams.containsKey("candidateGroup")) {
        request.setCandidateGroup(requestParams.get("candidateGroup"));
    }
    if (requestParams.containsKey("candidateGroups")) {
        String[] candidateGroups = requestParams.get("candidateGroups").split(",");
        List<String> groups = new ArrayList<String>(candidateGroups.length);
        for (String candidateGroup : candidateGroups) {
            groups.add(candidateGroup);
        }
        request.setCandidateGroupIn(groups);
    }
    if (requestParams.containsKey("processDefinitionKey")) {
        request.setProcessDefinitionKey(requestParams.get("processDefinitionKey"));
    }
    if (requestParams.containsKey("processDefinitionKeyLike")) {
        request.setProcessDefinitionKeyLike(requestParams.get("processDefinitionKeyLike"));
    }
    if (requestParams.containsKey("processDefinitionName")) {
        request.setProcessDefinitionName(requestParams.get("processDefinitionName"));
    }
    if (requestParams.containsKey("processDefinitionNameLike")) {
        request.setProcessDefinitionNameLike(requestParams.get("processDefinitionNameLike"));
    }
    if (requestParams.containsKey("processInstanceId")) {
        request.setProcessInstanceId(requestParams.get("processInstanceId"));
    }
    if (requestParams.containsKey("processInstanceBusinessKey")) {
        request.setProcessInstanceBusinessKey(requestParams.get("processInstanceBusinessKey"));
    }
    if (requestParams.containsKey("executionId")) {
        request.setExecutionId(requestParams.get("executionId"));
    }
    if (requestParams.containsKey("createdOn")) {
        request.setCreatedOn(RequestUtil.getDate(requestParams, "createdOn"));
    }
    if (requestParams.containsKey("createdBefore")) {
        request.setCreatedBefore(RequestUtil.getDate(requestParams, "createdBefore"));
    }
    if (requestParams.containsKey("createdAfter")) {
        request.setCreatedAfter(RequestUtil.getDate(requestParams, "createdAfter"));
    }
    if (requestParams.containsKey("excludeSubTasks")) {
        request.setExcludeSubTasks(Boolean.valueOf(requestParams.get("excludeSubTasks")));
    }
    if (requestParams.containsKey("taskDefinitionKey")) {
        request.setTaskDefinitionKey(requestParams.get("taskDefinitionKey"));
    }
    if (requestParams.containsKey("taskDefinitionKeyLike")) {
        request.setTaskDefinitionKeyLike(requestParams.get("taskDefinitionKeyLike"));
    }
    if (requestParams.containsKey("dueDate")) {
        request.setDueDate(RequestUtil.getDate(requestParams, "dueDate"));
    }
    if (requestParams.containsKey("dueBefore")) {
        request.setDueBefore(RequestUtil.getDate(requestParams, "dueBefore"));
    }
    if (requestParams.containsKey("dueAfter")) {
        request.setDueAfter(RequestUtil.getDate(requestParams, "dueAfter"));
    }
    if (requestParams.containsKey("active")) {
        request.setActive(Boolean.valueOf(requestParams.get("active")));
    }
    if (requestParams.containsKey("includeTaskLocalVariables")) {
        request.setIncludeTaskLocalVariables(Boolean.valueOf(requestParams.get("includeTaskLocalVariables")));
    }
    if (requestParams.containsKey("includeProcessVariables")) {
        request.setIncludeProcessVariables(Boolean.valueOf(requestParams.get("includeProcessVariables")));
    }
    if (requestParams.containsKey("tenantId")) {
        request.setTenantId(requestParams.get("tenantId"));
    }
    if (requestParams.containsKey("tenantIdLike")) {
        request.setTenantIdLike(requestParams.get("tenantIdLike"));
    }
    if (requestParams.containsKey("withoutTenantId") && Boolean.valueOf(requestParams.get("withoutTenantId"))) {
        request.setWithoutTenantId(Boolean.TRUE);
    }
    if (requestParams.containsKey("candidateOrAssigned")) {
        request.setCandidateOrAssigned(requestParams.get("candidateOrAssigned"));
    }
    DataResponse dataResponse = getTasksFromQueryRequest(request, uriInfo, requestParams);
    return Response.ok().entity(dataResponse).build();
// return getTasksFromQueryRequest(request, requestParams);
}
Also used : DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse)

Example 38 with Property

use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.

the class QueryExecutionService method queryProcessInstances.

@POST
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response queryProcessInstances(ExecutionQueryRequest 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 39 with Property

use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.

the class ProcessDefinitionService method getProcessDefinitions.

@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessDefinitions() {
    RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
    Map<String, String> allRequestParams = new HashMap<>();
    for (String property : allPropertiesList) {
        String value = uriInfo.getQueryParameters().getFirst(property);
        if (value != null) {
            allRequestParams.put(property, value);
        }
    }
    ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
    // Populate filter-parameters
    if (allRequestParams.containsKey("category")) {
        processDefinitionQuery.processDefinitionCategory(allRequestParams.get("category"));
    }
    if (allRequestParams.containsKey("categoryLike")) {
        processDefinitionQuery.processDefinitionCategoryLike(allRequestParams.get("categoryLike"));
    }
    if (allRequestParams.containsKey("categoryNotEquals")) {
        processDefinitionQuery.processDefinitionCategoryNotEquals(allRequestParams.get("categoryNotEquals"));
    }
    if (allRequestParams.containsKey("key")) {
        processDefinitionQuery.processDefinitionKey(allRequestParams.get("key"));
    }
    if (allRequestParams.containsKey("keyLike")) {
        processDefinitionQuery.processDefinitionKeyLike(allRequestParams.get("keyLike"));
    }
    if (allRequestParams.containsKey("name")) {
        processDefinitionQuery.processDefinitionName(allRequestParams.get("name"));
    }
    if (allRequestParams.containsKey("nameLike")) {
        processDefinitionQuery.processDefinitionNameLike(allRequestParams.get("nameLike"));
    }
    if (allRequestParams.containsKey("resourceName")) {
        processDefinitionQuery.processDefinitionResourceName(allRequestParams.get("resourceName"));
    }
    if (allRequestParams.containsKey("resourceNameLike")) {
        processDefinitionQuery.processDefinitionResourceNameLike(allRequestParams.get("resourceNameLike"));
    }
    if (allRequestParams.containsKey("version")) {
        processDefinitionQuery.processDefinitionVersion(Integer.valueOf(allRequestParams.get("version")));
    }
    if (allRequestParams.containsKey("suspended")) {
        Boolean suspended = Boolean.valueOf(allRequestParams.get("suspended"));
        if (suspended != null) {
            if (suspended) {
                processDefinitionQuery.suspended();
            } else {
                processDefinitionQuery.active();
            }
        }
    }
    if (allRequestParams.containsKey("latest")) {
        Boolean latest = Boolean.valueOf(allRequestParams.get("latest"));
        if (latest != null && latest) {
            processDefinitionQuery.latestVersion();
        }
    }
    if (allRequestParams.containsKey("deploymentId")) {
        processDefinitionQuery.deploymentId(allRequestParams.get("deploymentId"));
    }
    if (allRequestParams.containsKey("startableByUser")) {
        processDefinitionQuery.startableByUser(allRequestParams.get("startableByUser"));
    }
    if (allRequestParams.containsKey("tenantId")) {
        processDefinitionQuery.processDefinitionTenantId(allRequestParams.get("tenantId"));
    }
    if (allRequestParams.containsKey("tenantIdLike")) {
        processDefinitionQuery.processDefinitionTenantIdLike(allRequestParams.get("tenantIdLike"));
    }
    DataResponse response = new ProcessDefinitionsPaginateList(new RestResponseFactory(), uriInfo).paginateList(allRequestParams, processDefinitionQuery, "name", properties);
    return Response.ok().entity(response).build();
}
Also used : RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HashMap(java.util.HashMap) DataResponse(org.wso2.carbon.bpmn.rest.model.common.DataResponse) ProcessDefinitionQuery(org.activiti.engine.repository.ProcessDefinitionQuery) ProcessDefinitionsPaginateList(org.wso2.carbon.bpmn.rest.model.repository.ProcessDefinitionsPaginateList) RepositoryService(org.activiti.engine.RepositoryService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 40 with Property

use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.

the class UserSubstitutionUtils method getPaginatedModelFromRequest.

/**
 * Prepare the paginated data model for a substitution query
 * @param propertiesMap
 * @param tenantId
 * @return PaginatedSubstitutesDataModel
 */
private static PaginatedSubstitutesDataModel getPaginatedModelFromRequest(Map<String, String> propertiesMap, int tenantId) {
    PaginatedSubstitutesDataModel model = new PaginatedSubstitutesDataModel();
    if (propertiesMap.get(SubstitutionQueryProperties.SUBSTITUTE) != null) {
        model.setSubstitute(propertiesMap.get(SubstitutionQueryProperties.SUBSTITUTE));
    }
    if (propertiesMap.get(SubstitutionQueryProperties.USER) != null) {
        model.setUser(propertiesMap.get(SubstitutionQueryProperties.USER));
    }
    String enabled = propertiesMap.get(SubstitutionQueryProperties.ENABLED);
    if (enabled != null) {
        if (enabled.equalsIgnoreCase("true")) {
            model.setEnabled(true);
        } else if (enabled.equalsIgnoreCase("false")) {
            model.setEnabled(false);
        } else {
            throw new ActivitiIllegalArgumentException("Invalid parameter " + enabled + " for enabled property.");
        }
    }
    model.setTenantId(tenantId);
    int start = Integer.parseInt(propertiesMap.get(SubstitutionQueryProperties.START));
    int size = Integer.parseInt(propertiesMap.get(SubstitutionQueryProperties.SIZE));
    model.setStart(start);
    model.setSize(size);
    model.setOrder(propertiesMap.get(SubstitutionQueryProperties.ORDER));
    model.setSort(propertiesMap.get(SubstitutionQueryProperties.SORT));
    return model;
}
Also used : PaginatedSubstitutesDataModel(org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel)

Aggregations

HashMap (java.util.HashMap)17 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)17 Path (javax.ws.rs.Path)14 Produces (javax.ws.rs.Produces)14 ArrayList (java.util.ArrayList)7 GET (javax.ws.rs.GET)7 POST (javax.ws.rs.POST)7 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)7 Map (java.util.Map)6 QName (javax.xml.namespace.QName)6 File (java.io.File)5 List (java.util.List)5 IOException (java.io.IOException)4 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)4 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)3 RepositoryService (org.activiti.engine.RepositoryService)3 Iterator (java.util.Iterator)2 Set (java.util.Set)2 Consumes (javax.ws.rs.Consumes)2 FormService (org.activiti.engine.FormService)2