Search in sources :

Example 6 with Quest

use of com.viadee.sonarQuest.entities.Quest 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 7 with Quest

use of com.viadee.sonarQuest.entities.Quest 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 8 with Quest

use of com.viadee.sonarQuest.entities.Quest 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 9 with Quest

use of com.viadee.sonarQuest.entities.Quest 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 10 with Quest

use of com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.

the class QuestController method deleteWorld.

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

Aggregations

Quest (com.viadee.sonarQuest.entities.Quest)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 CrossOrigin (org.springframework.web.bind.annotation.CrossOrigin)6 Developer (com.viadee.sonarQuest.entities.Developer)4 Participation (com.viadee.sonarQuest.entities.Participation)4 Task (com.viadee.sonarQuest.entities.Task)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 Adventure (com.viadee.sonarQuest.entities.Adventure)2 World (com.viadee.sonarQuest.entities.World)2 Test (org.junit.Test)2 SpecialTask (com.viadee.sonarQuest.entities.SpecialTask)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1