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;
}
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;
}
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);
}
}
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;
}
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);
}
Aggregations