Search in sources :

Example 11 with Developer

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

Example 12 with Developer

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

Example 13 with Developer

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

Example 14 with Developer

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;
}
Also used : Developer(com.viadee.sonarQuest.entities.Developer) List(java.util.List) World(com.viadee.sonarQuest.entities.World) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with Developer

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

Aggregations

Developer (com.viadee.sonarQuest.entities.Developer)21 World (com.viadee.sonarQuest.entities.World)7 Adventure (com.viadee.sonarQuest.entities.Adventure)6 Participation (com.viadee.sonarQuest.entities.Participation)5 Quest (com.viadee.sonarQuest.entities.Quest)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 DeveloperDto (com.viadee.sonarQuest.dtos.DeveloperDto)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 SkillType (com.viadee.sonarQuest.constants.SkillType)1 Level (com.viadee.sonarQuest.entities.Level)1 Skill (com.viadee.sonarQuest.entities.Skill)1 Task (com.viadee.sonarQuest.entities.Task)1 DeveloperGratification (com.viadee.sonarQuest.interfaces.DeveloperGratification)1 DeveloperRepository (com.viadee.sonarQuest.repositories.DeveloperRepository)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1