Skip to content

Commit

Permalink
Sort alignment possibilities alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
lkleisa committed May 23, 2024
1 parent 38a0863 commit 5c72328
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,25 @@ public List<AlignmentDto> getAlignmentPossibilities(Long quarterId) {
List<Objective> objectivesByQuarter = objectivePersistenceService.findObjectiveByQuarterId(quarterId);
List<AlignmentDto> alignmentDtoList = new ArrayList<>();

List<Team> teamList = new ArrayList<>();
objectivesByQuarter.forEach(objective -> teamList.add(objective.getTeam()));
Set<Team> set = new HashSet<>(teamList);
teamList.clear();
teamList.addAll(set);
Set<Team> teamSet = new HashSet<>();
objectivesByQuarter.forEach(objective -> teamSet.add(objective.getTeam()));
List<Team> teamList = new ArrayList<>(teamSet.stream().sorted(Comparator.comparing(Team::getName)).toList());

teamList.forEach(team -> {
List<Objective> filteredObjectiveList = objectivesByQuarter.stream()
.filter(objective -> objective.getTeam().equals(team)).toList();
.filter(objective -> objective.getTeam().equals(team)).toList().stream()
.sorted(Comparator.comparing(Objective::getTitle)).toList();

List<AlignmentObjectDto> alignmentObjectDtos = new ArrayList<>();

filteredObjectiveList.forEach(objective -> {
AlignmentObjectDto objectiveDto = new AlignmentObjectDto(objective.getId(),
"O - " + objective.getTitle(), "objective");
alignmentObjectDtos.add(objectiveDto);

List<KeyResult> keyResults = keyResultBusinessService.getAllKeyResultsByObjective(objective.getId());
List<KeyResult> keyResults = keyResultBusinessService.getAllKeyResultsByObjective(objective.getId())
.stream().sorted(Comparator.comparing(KeyResult::getTitle)).toList();

keyResults.forEach(keyResult -> {
AlignmentObjectDto keyResultDto = new AlignmentObjectDto(keyResult.getId(),
"KR - " + keyResult.getTitle(), "keyResult");
Expand Down

0 comments on commit 5c72328

Please sign in to comment.