Skip to content

Commit

Permalink
CCMSPUI-383 Added javadocs and fixed checkstyle issues.
Browse files Browse the repository at this point in the history
Signed-off-by: Jamie Briggs <[email protected]>
  • Loading branch information
JamieBriggs-MoJ committed Jan 13, 2025
1 parent 1e63f09 commit 7c3fce4
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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<CaseSearch> searchResults);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Notification> notificationPage);
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
import org.springframework.stereotype.Repository;
import uk.gov.laa.ccms.data.entity.CaseSearch;

/**
* Repository interface for accessing {@link CaseSearch} entities.
*
* <p>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.</p>
*
* @see CaseSearch
* @see ReadOnlyRepository
* @see org.springframework.data.jpa.domain.Specification
*
* @author Jamie Briggs
*/
@Repository
public interface CaseSearchRepository extends ReadOnlyRepository<CaseSearch, Long>,
JpaSpecificationExecutor<CaseSearch> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
* <p>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.</p>
*
* @author Jamie Briggs
* @see Notification
* @see ReadOnlyRepository
* @see org.springframework.data.jpa.domain.Specification
* @author Jamie Briggs
*/
@Repository
public interface NotificationRepository extends ReadOnlyRepository<Notification, Long>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CaseSearch> withFilters(final long providerFirmPartyId,
final String caseReferenceNumber,
Expand Down Expand Up @@ -84,10 +87,10 @@ public static Specification<CaseSearch> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CaseDetails> getCases(long providerFirmPartyId, String caseReferenceNumber,
String providerCaseReference, String caseStatus, String clientSurname, Long feeEarnerId,
Long officeId, Pageable pageable){
Long officeId, Pageable pageable) {
Page<CaseSearch> 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);
}
Expand Down

0 comments on commit 7c3fce4

Please sign in to comment.