Search in sources :

Example 1 with Skill

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

Example 2 with 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;
}
Also used : Developer(com.viadee.sonarQuest.entities.Developer) SkillType(com.viadee.sonarQuest.constants.SkillType) Participation(com.viadee.sonarQuest.entities.Participation) Autowired(org.springframework.beans.factory.annotation.Autowired) DeveloperRepository(com.viadee.sonarQuest.repositories.DeveloperRepository) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Adventure(com.viadee.sonarQuest.entities.Adventure) Skill(com.viadee.sonarQuest.entities.Skill) List(java.util.List) Service(org.springframework.stereotype.Service) Quest(com.viadee.sonarQuest.entities.Quest) Task(com.viadee.sonarQuest.entities.Task) DeveloperGratification(com.viadee.sonarQuest.interfaces.DeveloperGratification) Skill(com.viadee.sonarQuest.entities.Skill) ArrayList(java.util.ArrayList) Developer(com.viadee.sonarQuest.entities.Developer)

Aggregations

Skill (com.viadee.sonarQuest.entities.Skill)2 SkillType (com.viadee.sonarQuest.constants.SkillType)1 Adventure (com.viadee.sonarQuest.entities.Adventure)1 Developer (com.viadee.sonarQuest.entities.Developer)1 Participation (com.viadee.sonarQuest.entities.Participation)1 Quest (com.viadee.sonarQuest.entities.Quest)1 Task (com.viadee.sonarQuest.entities.Task)1 DeveloperGratification (com.viadee.sonarQuest.interfaces.DeveloperGratification)1 DeveloperRepository (com.viadee.sonarQuest.repositories.DeveloperRepository)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1