use of com.viadee.sonarQuest.entities.Skill in project sonarQuest by viadee.
the class SkillController method updateSkill.
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public Skill updateSkill(@PathVariable(value = "id") Long id, @RequestBody SkillDto skillDto) {
Skill skill = this.skillRepository.findOne(id);
if (skill != null) {
skill.setName(skillDto.getName());
skill = this.skillRepository.save(skill);
}
return skill;
}
use of com.viadee.sonarQuest.entities.Skill in project sonarQuest by viadee.
the class GratificationService method addSkillReward.
private Developer addSkillReward(final Developer developer, final Task task) {
final Developer rewardedDeveloper = developer;
final List<Skill> avatarClassSkills = rewardedDeveloper.getAvatarClass().getSkills();
final List<Skill> artefactSkills = rewardedDeveloper.getArtefacts().stream().map(artefact -> artefact.getSkills()).flatMap(skills -> skills.stream()).collect(Collectors.toList());
final List<Skill> totalSkills = new ArrayList<>();
totalSkills.addAll(avatarClassSkills);
totalSkills.addAll(artefactSkills);
final Long extraGold = totalSkills.stream().filter(skill -> skill.getType().equals(SkillType.GOLD)).mapToLong(skill -> skill.getValue()).sum();
final Long extraXP = totalSkills.stream().filter(skill -> skill.getType().equals(SkillType.XP)).mapToLong(skill -> skill.getValue()).sum();
rewardedDeveloper.addGold(extraGold);
rewardedDeveloper.addXp(extraXP);
return rewardedDeveloper;
}
Aggregations