Search in sources :

Example 16 with CrossOrigin

use of org.springframework.web.bind.annotation.CrossOrigin in project sonarQuest by viadee.

the class QuestController method deleteQuest.

@CrossOrigin
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void deleteQuest(@PathVariable(value = "id") final Long id) {
    final Quest quest = this.questRepository.findOne(id);
    if (quest != null) {
        final List<Task> tasks = quest.getTasks();
        tasks.forEach(task -> task.setStatus(TaskStates.CREATED));
        this.questRepository.delete(quest);
    }
}
Also used : Task(com.viadee.sonarQuest.entities.Task) Quest(com.viadee.sonarQuest.entities.Quest) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with CrossOrigin

use of org.springframework.web.bind.annotation.CrossOrigin in project sonarQuest by viadee.

the class QuestController method addAdventure.

@CrossOrigin
@RequestMapping(value = "/{questId}/addAdventure/{adventureId}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public QuestDto addAdventure(@PathVariable(value = "questId") final Long questId, @PathVariable(value = "adventureId") final Long adventureId) {
    Quest quest = this.questRepository.findOne(questId);
    if (quest != null) {
        final Adventure adventure = this.adventureRepository.findOne(adventureId);
        quest.setAdventure(adventure);
        quest = this.questRepository.save(quest);
    }
    return toQuestDto(quest);
}
Also used : Adventure(com.viadee.sonarQuest.entities.Adventure) Quest(com.viadee.sonarQuest.entities.Quest) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with CrossOrigin

use of org.springframework.web.bind.annotation.CrossOrigin in project sonarQuest by viadee.

the class QuestController method deleteAdventure.

@CrossOrigin
@RequestMapping(value = "/{questId}/removeAdventure", method = RequestMethod.DELETE)
public void deleteAdventure(@PathVariable(value = "questId") final Long questId) {
    final Quest quest = this.questRepository.findOne(questId);
    if (quest != null) {
        quest.setAdventure(null);
        this.questRepository.save(quest);
    }
}
Also used : Quest(com.viadee.sonarQuest.entities.Quest) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with CrossOrigin

use of org.springframework.web.bind.annotation.CrossOrigin in project sonarQuest by viadee.

the class QuestController method updateQuest.

@CrossOrigin
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public Quest updateQuest(@PathVariable(value = "id") final Long id, @RequestBody final QuestDto questDto) {
    Quest quest = this.questRepository.findOne(id);
    if (quest != null) {
        quest.setTitle(questDto.getTitle());
        quest.setGold(questDto.getGold());
        quest.setXp(questDto.getXp());
        quest.setStory(questDto.getStory());
        quest.setImage(questDto.getImage());
        quest = this.questRepository.save(quest);
    }
    return quest;
}
Also used : Quest(com.viadee.sonarQuest.entities.Quest) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with CrossOrigin

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

Aggregations

CrossOrigin (org.springframework.web.bind.annotation.CrossOrigin)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)24 Task (com.viadee.sonarQuest.entities.Task)8 SpecialTask (com.viadee.sonarQuest.entities.SpecialTask)7 Quest (com.viadee.sonarQuest.entities.Quest)6 ApiOperation (io.swagger.annotations.ApiOperation)5 IOException (java.io.IOException)5 NotFoundException (org.c4sg.exception.NotFoundException)4 UserOrganizationException (org.c4sg.exception.UserOrganizationException)4 SpecialTaskDto (com.viadee.sonarQuest.dtos.SpecialTaskDto)3 TaskDto (com.viadee.sonarQuest.dtos.TaskDto)3 TaskDto.toTaskDto (com.viadee.sonarQuest.dtos.TaskDto.toTaskDto)3 World (com.viadee.sonarQuest.entities.World)3 WikiParsing (infoeval.main.WikiData.WikiParsing)3 ApiResponses (io.swagger.annotations.ApiResponses)3 ArrayList (java.util.ArrayList)3 CreateOrganizationDTO (org.c4sg.dto.CreateOrganizationDTO)3 OrganizationDTO (org.c4sg.dto.OrganizationDTO)3 BadRequestException (org.c4sg.exception.BadRequestException)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3