use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.
the class WorkflowTaskService method createTask.
/**
* Create a new task instance for a process instance.
* @param taskRequest
* @return
*/
@POST
@Path("/")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createTask(TaskRequest taskRequest) {
TaskService taskService = BPMNOSGIService.getTaskService();
Task task = taskService.newTask();
// Populate the task properties based on the request
populateTaskFromRequest(task, taskRequest);
if (taskRequest.isTenantIdSet()) {
((TaskEntity) task).setTenantId(taskRequest.getTenantId());
}
taskService.saveTask(task);
return Response.ok().entity(new RestResponseFactory().createTaskResponse(task, uriInfo.getBaseUri().toString())).build();
}
use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.
the class WorkflowTaskService method createComment.
@POST
@Path("/{taskId}/comments")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createComment(@PathParam("taskId") String taskId, CommentRequest comment) {
Task task = getTaskFromRequest(taskId);
if (comment.getMessage() == null) {
throw new ActivitiIllegalArgumentException("Comment text is required.");
}
String processInstanceId = null;
TaskService taskService = BPMNOSGIService.getTaskService();
if (comment.isSaveProcessInstanceId()) {
Task taskEntity = taskService.createTaskQuery().taskId(task.getId()).singleResult();
processInstanceId = taskEntity.getProcessInstanceId();
}
Comment createdComment = taskService.addComment(task.getId(), processInstanceId, 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.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.
the class WorkflowTaskService method setSimpleVariable.
protected RestVariable setSimpleVariable(RestVariable restVariable, Task task, boolean isNew) {
if (restVariable.getName() == null) {
throw new ActivitiIllegalArgumentException("Variable name is required");
}
// Figure out scope, revert to local is omitted
RestVariable.RestVariableScope scope = restVariable.getVariableScope();
if (scope == null) {
scope = RestVariable.RestVariableScope.LOCAL;
}
RestResponseFactory restResponseFactory = new RestResponseFactory();
Object actualVariableValue = restResponseFactory.getVariableValue(restVariable);
setVariable(task, restVariable.getName(), actualVariableValue, scope, isNew);
return restResponseFactory.createRestVariable(restVariable.getName(), actualVariableValue, scope, task.getId(), RestResponseFactory.VARIABLE_TASK, false, uriInfo.getBaseUri().toString());
}
use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.
the class WorkflowTaskService method executeTaskAction.
@POST
@Path("/{taskId}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response executeTaskAction(@PathParam("taskId") String taskId, TaskActionRequest actionRequest) {
if (actionRequest == null) {
throw new ActivitiException("A request body was expected when executing a task action.");
}
Task task = getTaskFromRequest(taskId);
TaskService taskService = BPMNOSGIService.getTaskService();
if (TaskActionRequest.ACTION_COMPLETE.equals(actionRequest.getAction())) {
completeTask(task, actionRequest, taskService);
} else if (TaskActionRequest.ACTION_CLAIM.equals(actionRequest.getAction())) {
claimTask(task, actionRequest, taskService);
} else if (TaskActionRequest.ACTION_DELEGATE.equals(actionRequest.getAction())) {
delegateTask(task, actionRequest, taskService);
} else if (TaskActionRequest.ACTION_RESOLVE.equals(actionRequest.getAction())) {
resolveTask(task, taskService);
} else {
throw new ActivitiIllegalArgumentException("Invalid action: '" + actionRequest.getAction() + "'.");
}
return Response.ok().status(Response.Status.OK).build();
}
use of org.wso2.carbon.humantask.core.dao.jpa.openjpa.model.Task in project carbon-business-process by wso2.
the class WorkflowTaskService method getIdentityLinks.
@GET
@Path("/{taskId}/identitylinks")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getIdentityLinks(@PathParam("taskId") String taskId) {
Task task = getTaskFromRequest(taskId);
TaskService taskService = BPMNOSGIService.getTaskService();
List<RestIdentityLink> restIdentityLinks = new RestResponseFactory().createRestIdentityLinks(taskService.getIdentityLinksForTask(task.getId()), uriInfo.getBaseUri().toString());
RestIdentityLinkCollection restIdentityLinkCollection = new RestIdentityLinkCollection();
restIdentityLinkCollection.setRestIdentityLinks(restIdentityLinks);
return Response.ok().entity(restIdentityLinkCollection).build();
}
Aggregations