From 5c72328b16811c683952792b668fabf45f1f966c Mon Sep 17 00:00:00 2001 From: Lias Kleisa Date: Thu, 23 May 2024 15:28:31 +0200 Subject: [PATCH] Sort alignment possibilities alphabetically --- .../business/ObjectiveBusinessService.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/ObjectiveBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/ObjectiveBusinessService.java index 03822c9c1d..85944e1332 100644 --- a/backend/src/main/java/ch/puzzle/okr/service/business/ObjectiveBusinessService.java +++ b/backend/src/main/java/ch/puzzle/okr/service/business/ObjectiveBusinessService.java @@ -57,15 +57,15 @@ public List getAlignmentPossibilities(Long quarterId) { List objectivesByQuarter = objectivePersistenceService.findObjectiveByQuarterId(quarterId); List alignmentDtoList = new ArrayList<>(); - List teamList = new ArrayList<>(); - objectivesByQuarter.forEach(objective -> teamList.add(objective.getTeam())); - Set set = new HashSet<>(teamList); - teamList.clear(); - teamList.addAll(set); + Set teamSet = new HashSet<>(); + objectivesByQuarter.forEach(objective -> teamSet.add(objective.getTeam())); + List teamList = new ArrayList<>(teamSet.stream().sorted(Comparator.comparing(Team::getName)).toList()); teamList.forEach(team -> { List 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 alignmentObjectDtos = new ArrayList<>(); filteredObjectiveList.forEach(objective -> { @@ -73,7 +73,9 @@ public List getAlignmentPossibilities(Long quarterId) { "O - " + objective.getTitle(), "objective"); alignmentObjectDtos.add(objectiveDto); - List keyResults = keyResultBusinessService.getAllKeyResultsByObjective(objective.getId()); + List 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");