Search in sources :

Example 6 with Ability

use of wooteco.prolog.report.domain.ablity.Ability in project prolog by woowacourse.

the class AbilityService method deleteAbility.

@Transactional
public void deleteAbility(Long memberId, Long abilityId) {
    Ability ability = findAbilityByIdAndMemberId(abilityId, memberId);
    abilityRepository.delete(ability);
}
Also used : DefaultAbility(wooteco.prolog.report.domain.ablity.DefaultAbility) Ability(wooteco.prolog.report.domain.ablity.Ability) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with Ability

use of wooteco.prolog.report.domain.ablity.Ability in project prolog by woowacourse.

the class AbilityService method extractChildAbility.

private Ability extractChildAbility(Member member, List<Ability> abilities, String name, String description, String color, Long parentId) {
    Ability parentAbility = findAbilityById(parentId);
    Ability childAbility = Ability.child(name, description, color, parentAbility, member);
    childAbility.validateDuplicateName(abilities);
    childAbility.validateColorWithParent(abilities, parentAbility);
    return childAbility;
}
Also used : DefaultAbility(wooteco.prolog.report.domain.ablity.DefaultAbility) Ability(wooteco.prolog.report.domain.ablity.Ability)

Example 8 with Ability

use of wooteco.prolog.report.domain.ablity.Ability in project prolog by woowacourse.

the class AbilityService method addDefaultAbilities.

@Transactional
public void addDefaultAbilities(Long memberId, String template) {
    Member member = memberService.findById(memberId);
    List<DefaultAbility> defaultAbilities = findDefaultAbilitiesByTemplate(template);
    Map<DefaultAbility, Ability> parentAbilities = new HashMap<>();
    for (DefaultAbility defaultAbility : defaultAbilities) {
        if (defaultAbility.isParent()) {
            Ability parentAbility = mapToParentAbility(member, defaultAbility);
            parentAbilities.put(defaultAbility, parentAbility);
        } else {
            Ability parentAbility = parentAbilities.get(defaultAbility.getParent());
            mapToChildAbility(member, defaultAbility, parentAbility);
        }
    }
}
Also used : DefaultAbility(wooteco.prolog.report.domain.ablity.DefaultAbility) Ability(wooteco.prolog.report.domain.ablity.Ability) DefaultAbility(wooteco.prolog.report.domain.ablity.DefaultAbility) HashMap(java.util.HashMap) Member(wooteco.prolog.member.domain.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Ability (wooteco.prolog.report.domain.ablity.Ability)8 DefaultAbility (wooteco.prolog.report.domain.ablity.DefaultAbility)6 Transactional (org.springframework.transaction.annotation.Transactional)4 Member (wooteco.prolog.member.domain.Member)2 HashMap (java.util.HashMap)1 AbilityGraph (wooteco.prolog.report.domain.report.abilitygraph.AbilityGraph)1 GraphAbilities (wooteco.prolog.report.domain.report.abilitygraph.GraphAbilities)1 GraphAbility (wooteco.prolog.report.domain.report.abilitygraph.GraphAbility)1 ReportedStudylog (wooteco.prolog.report.domain.report.studylog.ReportedStudylog)1 ReportedStudylogAbility (wooteco.prolog.report.domain.report.studylog.ReportedStudylogAbility)1 ReportedStudylogs (wooteco.prolog.report.domain.report.studylog.ReportedStudylogs)1 Level (wooteco.prolog.studylog.domain.Level)1 Mission (wooteco.prolog.studylog.domain.Mission)1 Studylog (wooteco.prolog.studylog.domain.Studylog)1