From 7c3fce4064945d78a5f7ca6871bba84eeb126e96 Mon Sep 17 00:00:00 2001 From: Jamie Briggs Date: Mon, 13 Jan 2025 18:06:00 +0000 Subject: [PATCH] CCMSPUI-383 Added javadocs and fixed checkstyle issues. Signed-off-by: Jamie Briggs --- .../ccms/data/mapper/CaseSearchMapper.java | 25 +++++++++++++++++++ .../ccms/data/mapper/NotificationsMapper.java | 8 +++--- .../data/repository/CaseSearchRepository.java | 15 +++++++++++ .../repository/NotificationRepository.java | 4 +-- .../CaseSearchSpecification.java | 15 ++++++----- .../NotificationSpecification.java | 3 ++- .../ccms/data/service/CaseSearchService.java | 10 +++++--- 7 files changed, 63 insertions(+), 17 deletions(-) diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapper.java b/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapper.java index a133e41..b82c7c1 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapper.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/CaseSearchMapper.java @@ -7,9 +7,26 @@ import uk.gov.laa.ccms.data.model.CaseDetails; import uk.gov.laa.ccms.data.model.CaseSummary; +/** + * Interface responsible for mapping {@link CaseSearch} objects to {@link CaseSummary}, or + * {@link CaseDetails} when paginated. This interface utilizes MapStruct for transformation. + * + * @see CaseSearch + * @see CaseDetails + * @see CaseSummary + * + * @author Jamie Briggs + */ @Mapper(componentModel = "spring") public interface CaseSearchMapper { + /** + * Maps a {@link CaseSearch} object to a {@link CaseSummary} object. + * + * @param search the source {@link CaseSearch} object to be mapped. + * + * @return a {@link CaseSummary} object containing the mapped case. + */ @Mapping(target = "caseReferenceNumber", source = "lscCaseReference") @Mapping(target = "providerCaseReferenceNumber", source = "cisCaseReference") @Mapping(target = "feeEarnerName", source = "feeEarner") @@ -20,5 +37,13 @@ public interface CaseSearchMapper { @Mapping(target = "client.surname", source = "personLastName") CaseSummary toCaseSummary(CaseSearch search); + /** + * Maps a {@link Page} of {@link CaseSearch} objects to a {@link CaseDetails} object. + * + * @param searchResults a {@link Page} containing {@link CaseSearch} entities to be mapped. + * + * @return a {@link CaseDetails} object containing the mapped case details along with pagination + * details. + */ CaseDetails toCaseDetails(Page searchResults); } diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/NotificationsMapper.java b/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/NotificationsMapper.java index fa74434..f1fec3f 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/NotificationsMapper.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/NotificationsMapper.java @@ -37,10 +37,10 @@ public interface NotificationsMapper { /** - * Maps a Page of Notification objects to a Notifications object. + * Maps a {@link Page} of {@link Notification} objects to a {@link Notifications} object. * - * @param notificationPage a Page containing Notification entities to be mapped - * @return a Notifications object containing the mapped notifications along + * @param notificationPage a {@link Page} containing {@link Notification} entities to be mapped + * @return a {@link Notifications} object containing the mapped notifications along * with pagination details */ Notifications mapToNotificationsList(Page notificationPage); @@ -49,7 +49,7 @@ public interface NotificationsMapper { * Maps a Notification object to a {@link uk.gov.laa.ccms.data.model.Notification} object. * * @param notification the source Notification object to be mapped - * @return the mapped uk.gov.laa.ccms.data.model.Notification object + * @return the mapped {@link uk.gov.laa.ccms.data.model.Notification} object */ @Mapping(target = "notes", source = "notes", qualifiedByName = "formatNotes") @Mapping(target = "uploadedDocuments", source = "uploadedDocuments", diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/CaseSearchRepository.java b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/CaseSearchRepository.java index 0fbc2fe..b314380 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/CaseSearchRepository.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/CaseSearchRepository.java @@ -4,6 +4,21 @@ import org.springframework.stereotype.Repository; import uk.gov.laa.ccms.data.entity.CaseSearch; +/** + * Repository interface for accessing {@link CaseSearch} entities. + * + *

This repository extends the {@link ReadOnlyRepository} interface, + * it supports read-only operations for the {@link CaseSearch} entity. + * This repository also extends {@link JpaSpecificationExecutor}, which + * allows the use of {@link org.springframework.data.jpa.domain.Specification} + * to filter easier.

+ * + * @see CaseSearch + * @see ReadOnlyRepository + * @see org.springframework.data.jpa.domain.Specification + * + * @author Jamie Briggs + */ @Repository public interface CaseSearchRepository extends ReadOnlyRepository, JpaSpecificationExecutor { diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/NotificationRepository.java b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/NotificationRepository.java index 06c342b..52efde8 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/NotificationRepository.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/NotificationRepository.java @@ -11,13 +11,13 @@ *

This repository extends the {@link ReadOnlyRepository} interface, * it supports read-only operations for the {@link Notification} entity. * This repository also extends {@link JpaSpecificationExecutor}, which - * allows the use of ${@link org.springframework.data.jpa.domain.Specification} + * allows the use of {@link org.springframework.data.jpa.domain.Specification} * to filter easier.

* - * @author Jamie Briggs * @see Notification * @see ReadOnlyRepository * @see org.springframework.data.jpa.domain.Specification + * @author Jamie Briggs */ @Repository public interface NotificationRepository extends ReadOnlyRepository, diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/CaseSearchSpecification.java b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/CaseSearchSpecification.java index 9cf44c5..06ac7aa 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/CaseSearchSpecification.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/CaseSearchSpecification.java @@ -49,14 +49,17 @@ private CaseSearchSpecification() { * an AND logic. * * @param providerFirmPartyId the provider firm party ID to filter by (exact match). - * @param caseReferenceNumber the case reference number to filter by (optional, partial match). - * @param providerCaseReference the provider case reference to filter by (optional, partial match). + * @param caseReferenceNumber the case reference number to filter by + * (optional, partial match). + * @param providerCaseReference the provider case + * reference to filter by (optional, partial match). * @param caseStatus the case status to filter by (optional, exact match). - * @param clientSurname the client surname to filter by (optional, partial match, case-insensitive). + * @param clientSurname the client + * surname to filter by (optional, partial match, case-insensitive). * @param feeEarnerId the fee earner ID to filter by (optional, exact match). * @param officeId the office ID to filter by (optional, exact match). * @return a {@link Specification} object encapsulating the filtering logic for - * {@link CaseSearch} entities. + * {@link CaseSearch} entities. */ public static Specification withFilters(final long providerFirmPartyId, final String caseReferenceNumber, @@ -84,10 +87,10 @@ public static Specification withFilters(final long providerFirmParty predicates.add(criteriaBuilder.like(criteriaBuilder.lower(root.get("personLastName")), "%" + clientSurname.toLowerCase() + "%")); } - if(Objects.nonNull(feeEarnerId)){ + if (Objects.nonNull(feeEarnerId)) { predicates.add(criteriaBuilder.equal(root.get("feeEarnerPartyId"), feeEarnerId)); } - if(Objects.nonNull(officeId)){ + if (Objects.nonNull(officeId)) { predicates.add(criteriaBuilder.equal(root.get("providerOfficePartyId"), officeId)); } // Combine all predicates with AND diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/NotificationSpecification.java b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/NotificationSpecification.java index 0dc466d..e9a59ec 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/NotificationSpecification.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/repository/specification/NotificationSpecification.java @@ -50,7 +50,8 @@ private NotificationSpecification() {} * an AND logic. * * @param caseReferenceNumber the case reference number to filter by (optional, partial match). - * @param providerCaseReference the provider case reference to filter by (optional, partial match). + * @param providerCaseReference the provider case reference to filter + * by (optional, partial match). * @param assignedToUserId the user ID assigned to the notification (optional, exact match). * @param clientSurname the client's surname to filter by (optional, partial match). * @param feeEarnerId the ID of the fee earner to filter by (optional, exact match). diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/service/CaseSearchService.java b/data-service/src/main/java/uk/gov/laa/ccms/data/service/CaseSearchService.java index 9c55324..d340e40 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/service/CaseSearchService.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/service/CaseSearchService.java @@ -34,14 +34,16 @@ public class CaseSearchService { * @param feeEarnerId the ID of the fee earner associated with the case * @param officeId the ID of the office handling the case * @param pageable the pagination information for retrieving a paged list of cases - * @return an {@code Optional} containing the matching {@code CaseDetails} or empty if no results are found + * @return an {@link Optional} containing the matching {@link CaseDetails} or + * empty if no results are found */ public Optional getCases(long providerFirmPartyId, String caseReferenceNumber, String providerCaseReference, String caseStatus, String clientSurname, Long feeEarnerId, - Long officeId, Pageable pageable){ + Long officeId, Pageable pageable) { Page cases = caseSearchRepository.findAll( - CaseSearchSpecification.withFilters(providerFirmPartyId, caseReferenceNumber, providerCaseReference, - caseStatus, clientSurname, feeEarnerId, officeId), pageable); + CaseSearchSpecification.withFilters(providerFirmPartyId, caseReferenceNumber, + providerCaseReference, caseStatus, clientSurname, feeEarnerId, officeId), + pageable); CaseDetails caseDetails = caseSearchMapper.toCaseDetails(cases); return Optional.ofNullable(caseDetails); }