use of com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.
the class QuestController method solveQuest.
@RequestMapping(value = "/{questId}/solveQuest/", method = RequestMethod.PUT)
public void solveQuest(@PathVariable(value = "questId") final Long questId) {
final Quest quest = this.questRepository.findOne(questId);
if (quest != null) {
quest.setStatus(QuestStates.SOLVED);
questRepository.save(quest);
gratificationService.rewardDevelopersForSolvingQuest(quest);
adventureService.updateAdventure(quest.getAdventure());
}
}
use of com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.
the class TaskController method addToQuest.
@CrossOrigin
@RequestMapping(value = "/{taskId}/addToQuest/{questId}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public TaskDto addToQuest(@PathVariable(value = "taskId") final Long taskId, @PathVariable(value = "questId") final Long questId) {
Task task = this.taskRepository.findOne(taskId);
if (task != null) {
final Quest quest = this.questRepository.findOne(questId);
task.setQuest(quest);
task.setStatus(TaskStates.OPEN);
task = this.taskRepository.save(task);
}
return toTaskDto(task);
}
use of com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.
the class GratificationService method rewardParticipation.
private void rewardParticipation(final Participation participation) {
final Developer developer = participation.getDeveloper();
final Quest quest = participation.getQuest();
developer.addGold(quest.getGold());
developer.addXp(quest.getXp());
developer.setLevel(levelService.getLevelByDeveloperXp(developer.getXp()));
developerRepository.save(developer);
}
use of com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.
the class ParticipationController method createParticipation.
@CrossOrigin
@RequestMapping(value = "/{questid}/{developerid}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public Participation createParticipation(@PathVariable(value = "questid") Long questid, @PathVariable(value = "developerid") Long developerid) {
Quest foundQuest = questRepository.findOne(questid);
Developer foundDeveloper = developerRepository.findOne(developerid);
Participation foundParticipation = participationRepository.findByQuestAndDeveloper(foundQuest, foundDeveloper);
Participation participation = null;
if ((foundQuest != null) && (foundDeveloper != null) && (foundParticipation == null)) {
participation = new Participation(foundQuest, foundDeveloper);
participation = participationRepository.save(participation);
}
return participation;
}
use of com.viadee.sonarQuest.entities.Quest in project sonarQuest by viadee.
the class QuestController method addWorld.
@CrossOrigin
@RequestMapping(value = "/{questId}/addWorld/{worldId}", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.CREATED)
public QuestDto addWorld(@PathVariable(value = "questId") final Long questId, @PathVariable(value = "worldId") final Long worldId) {
Quest quest = this.questRepository.findOne(questId);
if (quest != null) {
final World world = this.worldRepository.findOne(worldId);
quest.setWorld(world);
quest = this.questRepository.save(quest);
}
return toQuestDto(quest);
}
Aggregations