Search in sources :

Example 1 with SpecialTask

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;
}
Also used : SpecialTask(com.viadee.sonarQuest.entities.SpecialTask) Task(com.viadee.sonarQuest.entities.Task) SpecialTask(com.viadee.sonarQuest.entities.SpecialTask) SpecialTaskDto(com.viadee.sonarQuest.dtos.SpecialTaskDto) TaskDto(com.viadee.sonarQuest.dtos.TaskDto) TaskDto.toTaskDto(com.viadee.sonarQuest.dtos.TaskDto.toTaskDto) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SpecialTask

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);
}
Also used : SpecialTask(com.viadee.sonarQuest.entities.SpecialTask) Task(com.viadee.sonarQuest.entities.Task) SpecialTask(com.viadee.sonarQuest.entities.SpecialTask) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with SpecialTask

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);
}
Also used : SpecialTask(com.viadee.sonarQuest.entities.SpecialTask) Task(com.viadee.sonarQuest.entities.Task) SpecialTask(com.viadee.sonarQuest.entities.SpecialTask) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with SpecialTask

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);
}
Also used : SpecialTask(com.viadee.sonarQuest.entities.SpecialTask) World(com.viadee.sonarQuest.entities.World)

Aggregations

SpecialTask (com.viadee.sonarQuest.entities.SpecialTask)4 Task (com.viadee.sonarQuest.entities.Task)3 CrossOrigin (org.springframework.web.bind.annotation.CrossOrigin)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 SpecialTaskDto (com.viadee.sonarQuest.dtos.SpecialTaskDto)1 TaskDto (com.viadee.sonarQuest.dtos.TaskDto)1 TaskDto.toTaskDto (com.viadee.sonarQuest.dtos.TaskDto.toTaskDto)1 World (com.viadee.sonarQuest.entities.World)1