diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpoint.java index 6c73bd1c..36c955ca 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpoint.java @@ -128,7 +128,7 @@ public PaginatedResult openingSearch( */ @GetMapping("/categories") public List getOpeningCategories( - @RequestParam(value = "includeExpired", required = false) + @RequestParam(value = "includeExpired", required = false, defaultValue = "true") Boolean includeExpired) { boolean addExpired = Boolean.TRUE.equals(includeExpired); return openCategoryCodeService.findAllCategories(addExpired); @@ -152,7 +152,7 @@ public List getOpeningOrgUnits() { */ @GetMapping("/org-units-by-code") public List getOpeningOrgUnitsByCode( - @RequestParam(value = "orgUnitCodes", required = true) + @RequestParam(value = "orgUnitCodes") String[] codes) { return orgUnitService.findAllOrgUnitsByCode(Arrays.asList(codes)); } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/entity/OpenCategoryCodeEntity.java b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/entity/OpenCategoryCodeEntity.java index 5e165d51..22616b90 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/entity/OpenCategoryCodeEntity.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/entity/OpenCategoryCodeEntity.java @@ -4,6 +4,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.Table; +import jakarta.persistence.Transient; import java.time.LocalDate; import lombok.AllArgsConstructor; import lombok.Builder; @@ -38,4 +39,9 @@ public class OpenCategoryCodeEntity { @Column(name = "UPDATE_TIMESTAMP", nullable = false) private LocalDate updateTimestamp; + + @Transient + public boolean isExpired() { + return expiryDate != null && LocalDate.now().isAfter(expiryDate); + } } diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/service/OpenCategoryCodeService.java b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/service/OpenCategoryCodeService.java index 656ad467..6336e8b8 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/service/OpenCategoryCodeService.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/service/OpenCategoryCodeService.java @@ -10,7 +10,9 @@ import org.apache.commons.lang3.BooleanUtils; import org.springframework.stereotype.Service; -/** This class contains methods to handle Opening Categories. */ +/** + * This class contains methods to handle Opening Categories. + */ @Slf4j @Service @RequiredArgsConstructor @@ -38,7 +40,13 @@ public List findAllCategories(boolean includeExpired) { ); return openCategoryCodes .stream() - .map(entity -> new CodeDescriptionDto(entity.getCode(), entity.getDescription())) + .map(entity -> new CodeDescriptionDto( + entity.getCode(), + entity.isExpired() + ? entity.getDescription() + " (Expired)" + : entity.getDescription() + ) + ) .toList(); } }