Skip to content

Commit

Permalink
Updated the way we show the jurors location to only show if they are …
Browse files Browse the repository at this point in the history
…checked in or on a trial (#745)
  • Loading branch information
Ben-Edwards-cgi authored Aug 23, 2024
1 parent f7eca9a commit 3257bf3
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public JurorOverviewResponseDto(JurorPool jurorPool,
if (todayAppearance.isPresent() && todayAppearance.get().getTimeOut() != null) {
this.location = null;
} else {
this.location = getLocationFromPanel(panelRepository, jurorPool);
this.location = getLocationFromPanel(panelRepository, jurorPool, this.checkedInTodayTime != null);
}


Expand Down Expand Up @@ -158,12 +158,16 @@ public JurorOverviewResponseDto(JurorPool jurorPool,
}

@JsonIgnore
private String getLocationFromPanel(PanelRepository panelRepository, JurorPool jurorPool) {
return getActivePanel(panelRepository, jurorPool)
.map(panel -> panel.getTrial().getCourtroom().getDescription())
.orElse(Optional.ofNullable(jurorPool.getCourt().getAssemblyRoom())
private String getLocationFromPanel(PanelRepository panelRepository, JurorPool jurorPool, boolean hasAppearance) {
Optional<String> locationFromPanel = getActivePanel(panelRepository, jurorPool)
.map(panel -> panel.getTrial().getCourtroom().getDescription());

if (locationFromPanel.isPresent() || !hasAppearance) {
return locationFromPanel.orElse(null);
}
return Optional.ofNullable(jurorPool.getCourt().getAssemblyRoom())
.map(Courtroom::getDescription)
.orElse(null));
.orElse(null);
}

private Optional<Panel> getActivePanel(PanelRepository panelRepository, JurorPool jurorPool) {
Expand Down

0 comments on commit 3257bf3

Please sign in to comment.