use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory 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();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class ProcessDefinitionService method getIdentityLink.
@GET
@Path("/{processDefinitionId}/identitylinks/{family}/{identityId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getIdentityLink(@PathParam("processDefinitionId") String processDefinitionId, @PathParam("family") String family, @PathParam("identityId") String identityId) {
ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
validateIdentityLinkArguments(family, identityId);
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
// Check if identitylink to get exists
IdentityLink link = getIdentityLink(family, identityId, processDefinition.getId(), repositoryService);
return Response.ok().entity(new RestResponseFactory().createRestIdentityLink(link, uriInfo.getBaseUri().toString())).build();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class ProcessInstanceService method createIdentityLink.
@POST
@Path("/{processInstanceId}/identitylinks")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createIdentityLink(@PathParam("processInstanceId") String processInstanceId, RestIdentityLink identityLink) {
ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);
if (identityLink.getGroup() != null) {
throw new ActivitiIllegalArgumentException("Only user identity links are supported on a process instance.");
}
if (identityLink.getUser() == null) {
throw new ActivitiIllegalArgumentException("The user is required.");
}
if (identityLink.getType() == null) {
throw new ActivitiIllegalArgumentException("The identity link type is required.");
}
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
runtimeService.addUserIdentityLink(processInstance.getId(), identityLink.getUser(), identityLink.getType());
RestIdentityLink restIdentityLink = new RestResponseFactory().createRestIdentityLink(identityLink.getType(), identityLink.getUser(), identityLink.getGroup(), null, null, processInstance.getId(), uriInfo.getBaseUri().toString());
return Response.ok().status(Response.Status.CREATED).entity(restIdentityLink).build();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class ProcessInstanceService method performCorrelation.
private Response performCorrelation(ProcessInstanceCreateRequest processInstanceCreateRequest) {
CorrelationActionRequest correlationActionRequest = new CorrelationActionRequest();
String requestValue = processInstanceCreateRequest.getProcessDefinitionId();
if (requestValue != null) {
correlationActionRequest.setProcessDefinitionId(processInstanceCreateRequest.getProcessDefinitionId());
}
requestValue = processInstanceCreateRequest.getProcessDefinitionKey();
if (requestValue != null) {
correlationActionRequest.setProcessDefinitionKey(requestValue);
}
if (processInstanceCreateRequest.isCustomTenantSet()) {
correlationActionRequest.setTenantId(processInstanceCreateRequest.getTenantId());
}
requestValue = processInstanceCreateRequest.getMessageName();
if (requestValue != null) {
correlationActionRequest.setMessageName(requestValue);
}
List<RestVariable> variables = processInstanceCreateRequest.getVariables();
if (variables != null) {
RestResponseFactory restResponseFactory = new RestResponseFactory();
List<QueryVariable> correlationVariableList = new ArrayList<>();
for (RestVariable variable : variables) {
QueryVariable correlationVariable = new QueryVariable();
correlationVariable.setName(variable.getName());
correlationVariable.setOperation("equals");
correlationVariable.setType(variable.getType());
correlationVariable.setValue(restResponseFactory.getVariableValue(variable));
correlationVariableList.add(correlationVariable);
}
correlationActionRequest.setCorrelationVariables(correlationVariableList);
}
variables = processInstanceCreateRequest.getAdditionalVariables();
if (variables != null) {
correlationActionRequest.setVariables(variables);
}
correlationActionRequest.setAction(CorrelationActionRequest.ACTION_MESSAGE_EVENT_RECEIVED);
return new CorrelationProcess().getQueryResponse(correlationActionRequest, uriInfo);
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class ProcessInstanceService method performProcessInstanceAction.
@PUT
@Path("/{processInstanceId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response performProcessInstanceAction(@PathParam("processInstanceId") String processInstanceId, ProcessInstanceActionRequest actionRequest) {
ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);
RestResponseFactory restResponseFactory = new RestResponseFactory();
if (ProcessInstanceActionRequest.ACTION_ACTIVATE.equals(actionRequest.getAction())) {
return Response.ok().entity(activateProcessInstance(processInstance, uriInfo)).build();
} else if (ProcessInstanceActionRequest.ACTION_SUSPEND.equals(actionRequest.getAction())) {
return Response.ok().entity(suspendProcessInstance(processInstance, restResponseFactory, uriInfo)).build();
}
throw new ActivitiIllegalArgumentException("Invalid action: '" + actionRequest.getAction() + "'.");
}
Aggregations