use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class HistoricProcessInstanceService method createComment.
@POST
@Path("/{processInstanceId}/comments")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createComment(@PathParam("processInstanceId") String processInstanceId, CommentResponse comment) {
HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId);
if (comment.getMessage() == null) {
throw new ActivitiIllegalArgumentException("Comment text is required.");
}
TaskService taskService = BPMNOSGIService.getTaskService();
Comment createdComment = taskService.addComment(null, instance.getId(), comment.getMessage());
CommentResponse commentResponse = new RestResponseFactory().createRestComment(createdComment, uriInfo.getBaseUri().toString());
return Response.ok().status(Response.Status.CREATED).entity(commentResponse).build();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class HistoricTaskInstanceService method getVariableFromRequest.
protected RestVariable getVariableFromRequest(boolean includeBinary, String taskId, String variableName, String scope) {
HistoryService historyService = BPMNOSGIService.getHistoryService();
RestVariable.RestVariableScope variableScope = RestVariable.getScopeFromString(scope);
HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery().taskId(taskId);
if (variableScope != null) {
if (variableScope == RestVariable.RestVariableScope.GLOBAL) {
taskQuery.includeProcessVariables();
} else {
taskQuery.includeTaskLocalVariables();
}
} else {
taskQuery.includeTaskLocalVariables().includeProcessVariables();
}
HistoricTaskInstance taskObject = taskQuery.singleResult();
if (taskObject == null) {
throw new ActivitiObjectNotFoundException("Historic task instance '" + taskId + "' couldn't be found.", HistoricTaskInstanceEntity.class);
}
Object value = null;
if (variableScope != null) {
if (variableScope == RestVariable.RestVariableScope.GLOBAL) {
value = taskObject.getProcessVariables().get(variableName);
} else {
value = taskObject.getTaskLocalVariables().get(variableName);
}
} else {
// look for local task restVariables first
if (taskObject.getTaskLocalVariables().containsKey(variableName)) {
value = taskObject.getTaskLocalVariables().get(variableName);
} else {
value = taskObject.getProcessVariables().get(variableName);
}
}
if (value == null) {
throw new ActivitiObjectNotFoundException("Historic task instance '" + taskId + "' variable value for " + variableName + " couldn't be found.", VariableInstanceEntity.class);
} else {
return new RestResponseFactory().createRestVariable(variableName, value, null, taskId, RestResponseFactory.VARIABLE_HISTORY_TASK, includeBinary, uriInfo.getBaseUri().toString());
}
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory 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);
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory 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);
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class BaseRuntimeService method addGlobalVariables.
protected void addGlobalVariables(Execution execution, int variableType, Map<String, RestVariable> variableMap) {
Map<String, Object> rawVariables = runtimeService.getVariables(execution.getId());
List<RestVariable> globalVariables = new RestResponseFactory().createRestVariables(rawVariables, execution.getId(), variableType, RestVariable.RestVariableScope.GLOBAL, uriInfo.getBaseUri().toString());
// since local variables get precedence over global ones at all times.
for (RestVariable var : globalVariables) {
if (!variableMap.containsKey(var.getName())) {
variableMap.put(var.getName(), var);
}
}
}
Aggregations