Skip to content

Commit

Permalink
CCMSPUI-379 Fixed broken tests in ClientsControllerTest and ClientDet…
Browse files Browse the repository at this point in the history
…ailsMapperImplTest

Signed-off-by: Jamie Briggs <jamie.briggs@digital.justice.gov.uk>
  • Loading branch information
Jamie Briggs committed Feb 18, 2025
1 parent d304203 commit 4cb6221
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CREATE TABLE XXCCMS.XXCCMS_GET_CLIENT_DETAILS_V (
COUNTRY_OF_ORIGIN VARCHAR2(3),
MARITAL_STATUS VARCHAR2(30),
-- CONTACTS XML SYS.XMLTYPE(64) --
-- ADDRESS XML SYS.XMLTYPE(64) --
ADDRESS CLOB,
CORRESPONDENCE_METHOD VARCHAR2(150),
DISABILITY_TYPE VARCHAR2(150),
CORRESPONDENCE_LANGUAGE VARCHAR2(150),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,16 @@ public class NotificationInfo {
@OneToMany(mappedBy = "notificationId", fetch = FetchType.LAZY)
private List<NotificationDocument> documents;

@Column(name = "PERSON_LAST_NAME", length = 150)
private String personLastName;
@OneToMany(mappedBy = "notificationId", fetch = FetchType.LAZY)
private List<NotificationAttachment> attachments;

@OneToMany(mappedBy = "notificationId", fetch = FetchType.LAZY)
private List<NotificationAction> actions;

@Column(name = "EVIDENCE_ALLOWED_IND")
@Convert(converter = BooleanStringConverter.class)
private Boolean evidenceAllowedIndicator;

@Lob
@Column(name = "NOTES")
private String notes;

@Lob
@Column(name = "UPLOADED_DOCUMENTS")
private String uploadedDocuments;

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Page<ClientDetail> findAll(final String firstName, final String surname,
final Pageable pageable) {

final String searchCaseQuery =
"SELECT * FROM XXCCMS.XXCCMS_GET_CLIENT_DETAILS_V"
"SELECT * FROM XXCCMS.XXCCMS_GET_CLIENT_DETAILS_V "
+ getFilterSql(firstName, surname, dateOfBirth, gender, clientReferenceNumber,
homeOfficeReference, nationalInsuranceNumber)
+ getSortSql(pageable)
Expand Down Expand Up @@ -124,7 +124,7 @@ private static String getFilterSql(final String firstName, final String surnameA
sj.add("UPPER(NI_NUMBER) LIKE '%"
+ sanitizeForSql(nationalInsuranceNumber.toUpperCase()) + "%'");
}
return sj.length() > 0 ? "WHERE " + sj : "";
return sj.length() > 0 ? "WHERE " + sj + " " : "";
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
Expand All @@ -29,10 +28,11 @@
* @see Pageable
*/
@Component
@RequiredArgsConstructor
public final class NotificationSearchRepository {
public final class NotificationSearchRepository extends BaseEntityManagerRepository{

private final EntityManager entityManager;
public NotificationSearchRepository(EntityManager entityManager) {
super(entityManager);
}

/**
* Retrieves a paginated list of NotificationInfo entities from the database, applying the
Expand Down Expand Up @@ -107,22 +107,25 @@ private static String getFilterSql(Long providerId,
StringJoiner sj = new StringJoiner(" AND ");
// Provider firm party id


sj.add("WHERE PROVIDERFIRM_ID = " + providerId);
// Case reference number
if (stringNotEmpty(caseReferenceNumber)) {
sj.add("LSC_CASE_REF_REFERENCE LIKE '%" + caseReferenceNumber + "%'");
sj.add("LSC_CASE_REF_REFERENCE LIKE '%" + sanitizeForSql(caseReferenceNumber) + "%'");
}
// Provider case reference
if (stringNotEmpty(providerCaseReference)) {
sj.add("UPPER(PROVIDER_CASE_REFERENCE) LIKE '%" + providerCaseReference.toUpperCase() + "%'");
sj.add("UPPER(PROVIDER_CASE_REFERENCE) LIKE '%" + sanitizeForSql(
providerCaseReference.toUpperCase()) + "%'");
}
// Assigned to user ID
if (stringNotEmpty(assignedToUser)) {
sj.add("UPPER(ASSIGNED_TO) LIKE '%" + assignedToUser.toUpperCase() + "%'");
sj.add("UPPER(ASSIGNED_TO) LIKE '%" + sanitizeForSql(assignedToUser.toUpperCase()) + "%'");
}
// Client Surname
if (stringNotEmpty(clientSurname)) {
sj.add("UPPER(PERSON_LAST_NAME) LIKE '%" + clientSurname.toUpperCase() + "%'");
sj.add(
"UPPER(PERSON_LAST_NAME) LIKE '%" + sanitizeForSql(clientSurname.toUpperCase()) + "%'");
}
// Fee Earner ID
if (!Objects.isNull(feeEarnerId)) {
Expand All @@ -133,7 +136,7 @@ private static String getFilterSql(Long providerId,
sj.add("IS_OPEN = 'true'");
}
if (stringNotEmpty(notificationType)) {
sj.add("ACTION_NOTIFICATION_IND = '" + notificationType + "'");
sj.add("ACTION_NOTIFICATION_IND = '" + sanitizeForSql(notificationType) + "'");
}
if (Objects.nonNull(assignedDateFrom)) {
sj.add("DATE_ASSIGNED >= TO_DATE('" + assignedDateFrom + "', 'YYYY-MM-DD')");
Expand All @@ -145,19 +148,4 @@ private static String getFilterSql(Long providerId,
}


private static boolean stringNotEmpty(String value) {
return value != null && !value.isEmpty();
}

private static String getSortSql(Pageable pageable) {
if (pageable.getSort().isEmpty()) {
return " ";
}

StringJoiner sortJoiner = new StringJoiner(", ", " ORDER BY ", " ");
pageable.getSort().forEach(order ->
sortJoiner.add(order.getProperty() + " " + order.getDirection().name()));
return sortJoiner.toString();
}

}

0 comments on commit 4cb6221

Please sign in to comment.