Search in sources :

Example 16 with Developer

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

the class AdventureService method removeDeveloperFromAdventure.

/**
 * Removes the developer from adventure
 * @param adventureId
 * @param developerId
 * @return adventure
 */
public Adventure removeDeveloperFromAdventure(long adventureId, long developerId) {
    Adventure adventure = adventureRepository.findOne(adventureId);
    final Developer developer = developerRepository.findOne(developerId);
    if (adventure != null && developer != null) {
        final List<Developer> developerList = adventure.getDevelopers();
        if (developerList.contains(developer)) {
            developerList.remove(developer);
        }
        adventure.setDevelopers(developerList);
        adventure = adventureRepository.save(adventure);
    }
    return adventure;
}
Also used : Adventure(com.viadee.sonarQuest.entities.Adventure) Developer(com.viadee.sonarQuest.entities.Developer)

Example 17 with Developer

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

the class DeveloperService method createDeveloper.

public Developer createDeveloper(DeveloperDto developerDto) {
    Developer developer;
    if (this.checkIfUsernameNotExists(developerDto)) {
        Level level1 = this.levelRepository.findById((long) 1);
        developer = this.developerRepository.save(new Developer(developerDto.getUsername(), (long) 0, (long) 0, level1, developerDto.getPicture(), developerDto.getAboutMe(), developerDto.getAvatarClass(), developerDto.getAvatarRace(), developerDto.getArtefacts(), developerDto.getAdventures(), developerDto.getParticipations()));
    } else {
        developer = null;
    }
    return developer;
}
Also used : Developer(com.viadee.sonarQuest.entities.Developer) Level(com.viadee.sonarQuest.entities.Level)

Example 18 with Developer

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

the class GratificationService method rewardDeveloperForSolvingTask.

@Override
public void rewardDeveloperForSolvingTask(final Task task) {
    final Participation participation = task.getParticipation();
    if (participation != null) {
        Developer developer = participation.getDeveloper();
        final Developer developer1 = developer;
        final Developer rewardedDeveloper = developer1;
        rewardedDeveloper.addXp(task.getXp());
        rewardedDeveloper.addGold(task.getGold());
        developer = rewardedDeveloper;
        developer = addSkillReward(developer, task);
        developer.setLevel(levelService.getLevelByDeveloperXp(developer.getXp()));
        developerRepository.save(developer);
    }
}
Also used : Participation(com.viadee.sonarQuest.entities.Participation) Developer(com.viadee.sonarQuest.entities.Developer)

Example 19 with Developer

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

the class ParticipationService method findParticipationByQuestIdAndDeveloperId.

public Participation findParticipationByQuestIdAndDeveloperId(Long questId, Long developerId) {
    Quest foundQuest = questRepository.findOne(questId);
    Developer foundDeveloper = developerRepository.findOne(developerId);
    Participation foundParticipation = null;
    if ((foundQuest != null) && (foundDeveloper != null)) {
        foundParticipation = participationRepository.findByQuestAndDeveloper(foundQuest, foundDeveloper);
    }
    return foundParticipation;
}
Also used : Participation(com.viadee.sonarQuest.entities.Participation) Developer(com.viadee.sonarQuest.entities.Developer) Quest(com.viadee.sonarQuest.entities.Quest)

Example 20 with Developer

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

the class UserManagementIT method testFilterOutDeletedDevelopers.

@Test
public void testFilterOutDeletedDevelopers() {
    // Given
    java.util.List<Developer> before = this.developerService.findActiveDevelopers();
    // When
    Developer dev = developerRepository.findAll().get(0);
    developerService.deleteDeveloper(dev);
    java.util.List<Developer> after = this.developerService.findActiveDevelopers();
    // Then
    assertTrue("active developers should not contain deleted ones", after.size() == before.size() - 1);
}
Also used : Developer(com.viadee.sonarQuest.entities.Developer) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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