use of com.viadee.sonarQuest.entities.Developer in project sonarQuest by viadee.
the class AdventureController method getJoinedAdventures.
@RequestMapping(value = "/getJoined/{developer_id}/{world_id}", method = RequestMethod.GET)
public List<AdventureDto> getJoinedAdventures(@PathVariable(value = "developer_id") Long developer_id, @PathVariable(value = "world_id") Long world_id) {
World w = worldRepository.findOne(world_id);
Developer d = developerRepository.findOne(developer_id);
List<Adventure> adventures = this.adventureService.getJoinedAdventuresForDeveloperInWorld(w, d);
return AdventureDto.toAdventuresDto(adventures);
}
use of com.viadee.sonarQuest.entities.Developer in project sonarQuest by viadee.
the class DeveloperController method updateWorld.
/**
* @param world_id
* @param developer_id
* @return DeveloperDto
*/
@CrossOrigin
@RequestMapping(value = "/{id}/updateWorld/{world_id}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.CREATED)
public DeveloperDto updateWorld(@PathVariable(value = "id") Long developer_id, @PathVariable(value = "world_id") Long world_id) {
World w = this.worldRepository.findById(world_id);
Developer d = this.developerRepository.findById(developer_id);
d = this.developerService.setWorld(d, w);
return this.toDeveloperDto(d);
}
use of com.viadee.sonarQuest.entities.Developer 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.Developer in project sonarQuest by viadee.
the class QuestController method getAllQuestsForWorldAndUser.
@RequestMapping(value = "/getAllQuestsForWorldAndDeveloper/{worldId}/{developerId}", method = RequestMethod.GET)
public List<List<QuestDto>> getAllQuestsForWorldAndUser(@PathVariable(value = "worldId") final Long worldId, @PathVariable(value = "developerId") final Long developerId) {
final World world = worldRepository.findOne(worldId);
final Developer developer = developerRepository.findById(developerId);
List<List<QuestDto>> quests = null;
if (world != null && developer != null) {
final List<List<Quest>> allQuestsForWorldAndDeveloper = this.questService.getAllQuestsForWorldAndDeveloper(world, developer);
quests = allQuestsForWorldAndDeveloper.stream().map(questlist -> questlist.stream().map(quest -> toQuestDto(quest)).collect(Collectors.toList())).collect(Collectors.toList());
}
return quests;
}
use of com.viadee.sonarQuest.entities.Developer in project sonarQuest by viadee.
the class AdventureController method getFreeAdventures.
@RequestMapping(value = "/getFree/{developer_id}/{world_id}", method = RequestMethod.GET)
public List<AdventureDto> getFreeAdventures(@PathVariable(value = "developer_id") Long developer_id, @PathVariable(value = "world_id") Long world_id) {
World w = worldRepository.findOne(world_id);
Developer d = developerRepository.findOne(developer_id);
List<Adventure> adventures = this.adventureService.getFreeAdventuresForDeveloperInWorld(w, d);
return AdventureDto.toAdventuresDto(adventures);
}
Aggregations