| Total Complexity | 3 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | package com.osomapps.pt.goals; |
||
| 9 | @Service |
||
| 10 | class GoalService { |
||
| 11 | private final GoalRepository goalRepository; |
||
| 12 | private final DictionaryService dictionaryService; |
||
| 13 | |||
| 14 | GoalService(GoalRepository goalRepository, DictionaryService dictionaryService) { |
||
| 15 | this.goalRepository = goalRepository; |
||
| 16 | this.dictionaryService = dictionaryService; |
||
| 17 | } |
||
| 18 | |||
| 19 | List<GoalDTO> findAll() { |
||
| 20 | List<Goal> goals = goalRepository.findAll(); |
||
| 21 | return goals.stream() |
||
| 22 | .map( |
||
| 23 | goal -> |
||
| 24 | new GoalDTO() |
||
| 25 | .setId(goal.getId()) |
||
| 26 | .setTitle( |
||
| 27 | dictionaryService.getEnValue( |
||
| 28 | DictionaryName.goal_title, |
||
| 29 | goal.getDGoalTitle(), |
||
| 30 | null)) |
||
| 31 | .setTitle2( |
||
| 32 | dictionaryService.getEnValue( |
||
| 33 | DictionaryName.goal_title_2, |
||
| 34 | goal.getDGoalTitle2(), |
||
| 35 | null)) |
||
| 36 | .setType( |
||
| 37 | goal.getGoalType() == null |
||
| 38 | ? null |
||
| 39 | : goal.getGoalType().getName()) |
||
| 40 | .setParameters( |
||
| 41 | goal.getGoalParameters().stream() |
||
| 42 | .map(parameter -> parameter.getName()) |
||
| 43 | .collect(Collectors.toList()))) |
||
| 44 | .sorted((e1, e2) -> Long.compare(e1.getId(), e2.getId())) |
||
| 45 | .collect(Collectors.toList()); |
||
| 46 | } |
||
| 48 |