Search in sources :

Example 1 with Ability

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

the class ReportRepositoryTest method createReport.

private Report createReport(Member member) {
    Ability ability1 = abilityRepository.save(AbilityFixture.parentAbility1(member));
    Ability ability2 = abilityRepository.save(AbilityFixture.parentAbility2(member));
    Ability ability3 = abilityRepository.save(AbilityFixture.parentAbility3(member));
    GraphAbilities graphAbilities = new GraphAbilities(Arrays.asList(new GraphAbility(ability1, 1L, true), new GraphAbility(ability2, 2L, true), new GraphAbility(ability3, 3L, true)));
    Level level1 = levelRepository.save(LevelFixture.level1());
    Mission mission = missionRepository.save(MissionFixture.mission1(level1));
    Ability ability4 = abilityRepository.save(AbilityFixture.childAbility1(member, ability1));
    Ability ability5 = abilityRepository.save(AbilityFixture.childAbility2(member, ability2));
    Studylog studylog = studylogRepository.save(createStudylog(member, mission));
    ReportedStudylogs reportedStudylogs = new ReportedStudylogs(Arrays.asList(new ReportedStudylog(studylog.getId(), Arrays.asList(new ReportedStudylogAbility(ability4), new ReportedStudylogAbility(ability5))), new ReportedStudylog(studylog.getId(), Arrays.asList(new ReportedStudylogAbility(ability4), new ReportedStudylogAbility(ability5)))));
    return ReportFixture.builder().member(member).title("test report").description("test report").graph(new AbilityGraph(graphAbilities)).member(member).studylogs(reportedStudylogs).build();
}
Also used : GraphAbility(wooteco.prolog.report.domain.report.abilitygraph.GraphAbility) ReportedStudylogAbility(wooteco.prolog.report.domain.report.studylog.ReportedStudylogAbility) Ability(wooteco.prolog.report.domain.ablity.Ability) GraphAbilities(wooteco.prolog.report.domain.report.abilitygraph.GraphAbilities) ReportedStudylog(wooteco.prolog.report.domain.report.studylog.ReportedStudylog) ReportedStudylogs(wooteco.prolog.report.domain.report.studylog.ReportedStudylogs) AbilityGraph(wooteco.prolog.report.domain.report.abilitygraph.AbilityGraph) GraphAbility(wooteco.prolog.report.domain.report.abilitygraph.GraphAbility) Level(wooteco.prolog.studylog.domain.Level) Mission(wooteco.prolog.studylog.domain.Mission) ReportedStudylog(wooteco.prolog.report.domain.report.studylog.ReportedStudylog) Studylog(wooteco.prolog.studylog.domain.Studylog) ReportedStudylogAbility(wooteco.prolog.report.domain.report.studylog.ReportedStudylogAbility)

Example 2 with Ability

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

the class ReportServiceTest method setAbilities.

private void setAbilities(Member member) {
    Ability parent1 = abilityRepository.save(AbilityFixture.parentAbility1(member));
    abilityRepository.save(AbilityFixture.childAbility1(member, parent1));
    Ability parent2 = abilityRepository.save(AbilityFixture.parentAbility2(member));
    abilityRepository.save(AbilityFixture.childAbility2(member, parent2));
    Ability parent3 = abilityRepository.save(AbilityFixture.parentAbility3(member));
    abilityRepository.save(AbilityFixture.childAbility3(member, parent3));
}
Also used : Ability(wooteco.prolog.report.domain.ablity.Ability)

Example 3 with Ability

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

the class AbilityService method createAbility.

@Transactional
public void createAbility(Long memberId, AbilityCreateRequest request) {
    Member member = memberService.findById(memberId);
    Ability ability = extractAbility(member, request);
    abilityRepository.save(ability);
}
Also used : DefaultAbility(wooteco.prolog.report.domain.ablity.DefaultAbility) Ability(wooteco.prolog.report.domain.ablity.Ability) Member(wooteco.prolog.member.domain.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Ability

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

the class AbilityService method extractParentAbility.

private Ability extractParentAbility(Member member, List<Ability> abilities, String name, String description, String color) {
    Ability parentAbility = Ability.parent(name, description, color, member);
    parentAbility.validateDuplicateName(abilities);
    parentAbility.validateDuplicateColor(abilities);
    return parentAbility;
}
Also used : DefaultAbility(wooteco.prolog.report.domain.ablity.DefaultAbility) Ability(wooteco.prolog.report.domain.ablity.Ability)

Example 5 with Ability

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

the class AbilityService method updateAbility.

@Transactional
public List<AbilityResponse> updateAbility(Long memberId, AbilityUpdateRequest request) {
    Ability legacyAbility = findAbilityByIdAndMemberId(request.getId(), memberId);
    Ability updateAbility = request.toEntity();
    List<Ability> abilities = findByMemberId(memberId);
    legacyAbility.updateWithValidation(updateAbility, abilities);
    return findAbilitiesByMemberId(memberId);
}
Also used : DefaultAbility(wooteco.prolog.report.domain.ablity.DefaultAbility) Ability(wooteco.prolog.report.domain.ablity.Ability) 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