use of com.viadee.sonarQuest.entities.SpecialTask in project sonarQuest by viadee.
the class TaskController method updateTask.
@CrossOrigin
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public TaskDto updateTask(@PathVariable(value = "id") final Long id, @RequestBody final TaskDto taskDto) {
TaskDto resultTaskDto = null;
final Task task = this.taskRepository.findById(id);
if (task != null) {
task.setTitle(taskDto.getTitle());
task.setGold(taskDto.getGold());
task.setXp(taskDto.getXp());
this.taskRepository.save(task);
resultTaskDto = toTaskDto(task);
}
if (task instanceof SpecialTask) {
((SpecialTask) task).setMessage(((SpecialTaskDto) taskDto).getMessage());
this.taskRepository.save(task);
resultTaskDto = toTaskDto(task);
}
return resultTaskDto;
}
use of com.viadee.sonarQuest.entities.SpecialTask in project sonarQuest by viadee.
the class TaskController method solveSpecialTask.
@CrossOrigin
@RequestMapping(value = "/{taskId}/solveSpecialTask/", method = RequestMethod.PUT)
public TaskDto solveSpecialTask(@PathVariable(value = "taskId") final Long taskId) {
Task task = this.taskRepository.findOne(taskId);
if (task != null && task instanceof SpecialTask) {
task.setStatus(TaskStates.SOLVED);
task = this.taskRepository.save(task);
gratificationService.rewardDeveloperForSolvingTask(task);
questService.updateQuest(task.getQuest());
adventureService.updateAdventure(task.getQuest().getAdventure());
}
return toTaskDto(task);
}
use of com.viadee.sonarQuest.entities.SpecialTask in project sonarQuest by viadee.
the class TaskController method closeSpecialTask.
@CrossOrigin
@RequestMapping(value = "/{taskId}/closeSpecialTask/", method = RequestMethod.PUT)
public TaskDto closeSpecialTask(@PathVariable(value = "taskId") final Long taskId) {
Task task = this.taskRepository.findOne(taskId);
if (task != null && task instanceof SpecialTask) {
task.setStatus(TaskStates.CLOSED);
task = this.taskRepository.save(task);
questService.updateQuest(task.getQuest());
adventureService.updateAdventure(task.getQuest().getAdventure());
}
return toTaskDto(task);
}
use of com.viadee.sonarQuest.entities.SpecialTask in project sonarQuest by viadee.
the class SpecialTaskService method saveDto.
public void saveDto(SpecialTaskDto specialTaskDto) {
World world = worldRepository.findByProject(specialTaskDto.getWorld().getProject());
SpecialTask sp = new SpecialTask(specialTaskDto.getTitle(), TaskStates.CREATED, specialTaskDto.getGold(), specialTaskDto.getXp(), specialTaskDto.getQuest(), specialTaskDto.getMessage(), world);
this.specialTaskRepository.save(sp);
}
Aggregations