Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. @Autowired
  2. private UserTaskService userTaskService;
  3.  
  4.  
  5. @ApiOperation(value = "Complete a task in Ready or Reserved state")
  6. @ApiResponses(value = {
  7. @ApiResponse(code = 200, message = "Task completed")
  8. })
  9. @POST
  10. @Path(value = "/tasks/{taskId}/{actor}")
  11. @Produces(MediaType.APPLICATION_JSON)
  12. public Response autoCompleteTask(
  13. @ApiParam(value = "task id", required = true) @PathParam("taskId") Long taskId,
  14. @ApiParam(value = "name of the actor", required = true) @PathParam("actor") String actor) {
  15. Task task = userTaskService.getTask(taskId);
  16. if(task != null) {
  17. LOGGER.info("Task {} status {}", task.getId(), task.getTaskData().getStatus());
  18. if(task.getTaskData().getStatus() == Status.Reserved) {
  19. userTaskService.start(task.getId(), actor);
  20. userTaskService.complete(task.getId(), actor, null);
  21. }
  22. else if(task.getTaskData().getStatus() == Status.Ready) {
  23. userTaskService.claim(task.getId(), actor);
  24. userTaskService.start(task.getId(), actor);
  25. userTaskService.complete(task.getId(), actor, null);
  26. }
  27. }
  28.  
  29. return Response.ok().build();
  30. }
  31.  
  32.  
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement