use of com.viadee.sonarQuest.dtos.TaskDto 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.dtos.TaskDto in project sonarQuest by viadee.
the class TaskController method getAllTasksForWorld.
@CrossOrigin
@RequestMapping(value = "/world/{id}", method = RequestMethod.GET)
public List<List<TaskDto>> getAllTasksForWorld(@PathVariable(value = "id") final Long world_id) {
World w = worldRepository.findOne(world_id);
final List<List<TaskDto>> taskDtos = new ArrayList<>();
List<TaskDto> specialTaskDtos = new ArrayList<>();
List<TaskDto> standardTaskDtos = new ArrayList<>();
specialTaskDtos = this.specialTaskRepository.findByWorld(w).stream().map(task -> toTaskDto(task)).collect(Collectors.toList());
standardTaskDtos = this.standardTaskRepository.findByWorld(w).stream().map(task -> toTaskDto(task)).collect(Collectors.toList());
taskDtos.add(specialTaskDtos);
taskDtos.add(standardTaskDtos);
return taskDtos;
}
use of com.viadee.sonarQuest.dtos.TaskDto in project sonarQuest by viadee.
the class TaskController method getFreeTasksForWorld.
@RequestMapping(value = "/getFreeForWorld/{worldId}", method = RequestMethod.GET)
public List<TaskDto> getFreeTasksForWorld(@PathVariable(value = "worldId") final Long worldId) {
final World world = worldRepository.findOne(worldId);
List<TaskDto> freeTasks = null;
if (world != null) {
// List<TaskDto> freeSpecialTasks = null;
freeTasks = this.taskRepository.findByWorldAndStatus(world, TaskStates.CREATED).stream().map(task -> toTaskDto(task)).collect(Collectors.toList());
/*
* @Florian - For what?
freeSpecialTasks = this.specialTaskRepository.findByStatus(TaskStates.CREATED).stream().map(specialTask -> toTaskDto(specialTask)).collect(Collectors.toList());
freeTasks.addAll(freeSpecialTasks);
*/
}
return freeTasks;
}
use of com.viadee.sonarQuest.dtos.TaskDto in project sonarQuest by viadee.
the class TaskController method updateStandardTasksForWorld.
@CrossOrigin
@RequestMapping(value = "/updateStandardTasks/{worldId}", method = RequestMethod.GET)
public List<TaskDto> updateStandardTasksForWorld(@PathVariable(value = "worldId") final Long worldId) {
final World world = worldRepository.findOne(worldId);
List<TaskDto> taskDtos = null;
if (world != null) {
standardTaskService.updateStandardTasks(world);
final List<Task> savedTasks = taskRepository.findAll();
taskDtos = savedTasks.stream().map(task -> toTaskDto(task)).collect(Collectors.toList());
}
return taskDtos;
}
Aggregations