Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DFR-3434 Refactor list for hearing data #1968

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private Map<String, Object> createCaseData() {
caseData.getContactDetailsWrapper().setRespondentLname("Respondent");
caseData.setDivorceCaseNumber("DD12D12345");
caseData.getRegionWrapper().getDefaultCourtList().setBristolCourtList(BristolCourt.BRISTOL_CIVIL_AND_FAMILY_JUSTICE_CENTRE);
caseData.setHearingDate(HEARING_DATE);
caseData.getListForHearingWrapper().setHearingDate(HEARING_DATE);
caseData.getContactDetailsWrapper().setSolicitorReference("Test Sol Reference");
caseData.setChangeOrganisationRequestField(ChangeOrganisationRequest
.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public GenericAboutToStartOrSubmitCallbackResponse<FinremCaseData> handle(Finrem
EventType.LIST_FOR_HEARING, caseId);
FinremCaseData caseData = caseDetails.getData();
List<String> errors = new ArrayList<>();
if (caseData.getAdditionalHearingDocumentsOption().isYes()) {
CaseDocument additionalListOfHearingDocument = caseData.getAdditionalListOfHearingDocuments();
if (caseData.getListForHearingWrapper().getAdditionalHearingDocumentsOption().isYes()) {
CaseDocument additionalListOfHearingDocument = caseData.getListForHearingWrapper()
.getAdditionalListOfHearingDocuments();
service.validateEncryptionOnUploadedDocument(additionalListOfHearingDocument,
caseId, errors, userAuthorisation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public GenericAboutToStartOrSubmitCallbackResponse<FinremCaseData> handle(Finrem

FinremCaseDetails caseDetails = callbackRequest.getCaseDetails();
FinremCaseData caseData = callbackRequest.getCaseDetails().getData();
if (caseData.getAdditionalHearingDocumentsOption() == null) {
caseData.setAdditionalHearingDocumentsOption(YesOrNo.NO);
if (caseData.getListForHearingWrapper().getAdditionalHearingDocumentsOption() == null) {
caseData.getListForHearingWrapper().setAdditionalHearingDocumentsOption(YesOrNo.NO);
}
caseData.setPartiesOnCase(partyService.getAllActivePartyList(caseDetails));
return GenericAboutToStartOrSubmitCallbackResponse.<FinremCaseData>builder().data(caseData).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseType;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ListForHearingWrapper;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.AdditionalHearingDocumentService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.CaseDataService;
import uk.gov.hmcts.reform.finrem.caseorchestration.service.GenerateCoverSheetService;
Expand Down Expand Up @@ -73,11 +74,12 @@ public GenericAboutToStartOrSubmitCallbackResponse<FinremCaseData> handle(Finrem
return GenericAboutToStartOrSubmitCallbackResponse.<FinremCaseData>builder().errors(errors).build();
}

if (finremCaseData.getAdditionalListOfHearingDocuments() != null) {
CaseDocument caseDocument = objectMapper.convertValue(finremCaseData.getAdditionalListOfHearingDocuments(),
ListForHearingWrapper listForHearingWrapper = finremCaseData.getListForHearingWrapper();
if (listForHearingWrapper.getAdditionalListOfHearingDocuments() != null) {
CaseDocument caseDocument = objectMapper.convertValue(listForHearingWrapper.getAdditionalListOfHearingDocuments(),
CaseDocument.class);
CaseDocument pdfDocument = additionalHearingDocumentService.convertToPdf(caseDocument, userAuthorisation, caseId);
finremCaseData.setAdditionalListOfHearingDocuments(pdfDocument);
listForHearingWrapper.setAdditionalListOfHearingDocuments(pdfDocument);
}
CaseDetails caseDetails = finremCaseDetailsMapper.mapToCaseDetails(finremCaseDetails);
if (hearingDocumentService.alreadyHadFirstHearing(finremCaseDetails)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class HearingDatePopulatedValidator {

public List<String> validateHearingDate(FinremCaseData finremCaseData) {
List<String> errors = new ArrayList<>();
if (finremCaseData.getHearingDate() == null) {
if (finremCaseData.getListForHearingWrapper().getHearingDate() == null) {
log.info("Hearing date for Case ID: {} not found", finremCaseData.getCcdCaseId());
errors.add("Missing hearing date.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ public Optional<CaseDocument> getLatestAdditionalHearingDocument(Map<String, Obj
}

public Optional<CaseDocument> getLatestAdditionalHearingDocument(FinremCaseData caseData) {
List<AdditionalHearingDocumentCollection> additionalHearingDocuments = caseData.getAdditionalHearingDocuments();
List<AdditionalHearingDocumentCollection> additionalHearingDocuments = caseData.getListForHearingWrapper()
.getAdditionalHearingDocuments();
Optional<AdditionalHearingDocumentCollection> documentCollection
= ofNullable(additionalHearingDocuments)
.orElse(emptyList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RepresentationUpdate;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.RepresentationUpdateHistoryCollection;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ListForHearingWrapper;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.intevener.IntervenerDetails;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.notification.NotificationRequest;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.wrapper.SolicitorCaseDataKeysWrapper;
Expand Down Expand Up @@ -133,7 +134,10 @@ private NotificationRequest buildNotificationRequest(FinremCaseDetails caseDetai
log.info("selectedCourt is {} for case ID: {}", notificationRequest.getSelectedCourt(),
notificationRequest.getCaseReferenceNumber());
}
notificationRequest.setHearingType(caseData.getHearingType() != null ? caseData.getHearingType().getId() : "");
ListForHearingWrapper listForHearingWrapper = caseData.getListForHearingWrapper();
notificationRequest.setHearingType(listForHearingWrapper.getHearingType() != null
? listForHearingWrapper.getHearingType().getId()
: "");
notificationRequest.setIsNotDigital(caseDataKeysWrapper.getSolicitorIsNotDigitalKey());

return notificationRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public DocumentTemplateDetails buildDocumentTemplateDetails(FinremCaseDetails ca
.courtAddress(courtDetails.getCourtAddress())
.courtEmail(courtDetails.getEmail())
.courtPhone(courtDetails.getPhoneNumber())
.hearingDate(String.valueOf(caseDetails.getData().getHearingDate()))
.hearingType(caseDetails.getData().getHearingType().getId())
.hearingDate(String.valueOf(caseDetails.getData().getListForHearingWrapper().getHearingDate()))
.hearingType(caseDetails.getData().getListForHearingWrapper().getHearingType().getId())
.hearingVenue(courtDetails.getCourtName())
.hearingLength(caseDetails.getData().getTimeEstimate())
.hearingTime(caseDetails.getData().getHearingTime())
.hearingLength(caseDetails.getData().getListForHearingWrapper().getTimeEstimate())
.hearingTime(caseDetails.getData().getListForHearingWrapper().getHearingTime())
.additionalHearingDated(new Date())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseData;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.FinremCaseDetails;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.CourtListWrapper;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ListForHearingWrapper;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.letterdetails.DocumentTemplateDetails;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.letterdetails.FormCLetterDetails;

Expand All @@ -21,7 +22,8 @@ public FormCLetterDetailsMapper(CourtDetailsMapper courtDetailsMapper, ObjectMap
@Override
public DocumentTemplateDetails buildDocumentTemplateDetails(FinremCaseDetails caseDetails, CourtListWrapper courtList) {
FinremCaseData caseData = caseDetails.getData();
LocalDate hearingDate = caseData.getHearingDate();
ListForHearingWrapper listForHearingWrapper = caseData.getListForHearingWrapper();
LocalDate hearingDate = listForHearingWrapper.getHearingDate();
return FormCLetterDetails.builder()
.applicantFmName(caseData.getContactDetailsWrapper().getApplicantFmName())
.applicantLName(caseData.getContactDetailsWrapper().getApplicantLname())
Expand All @@ -34,9 +36,9 @@ public DocumentTemplateDetails buildDocumentTemplateDetails(FinremCaseDetails ca
.hearingDateLess14Days(String.valueOf(hearingDate.minusDays(14)))
.solicitorReference(caseData.getContactDetailsWrapper().getSolicitorReference())
.respondentSolicitorReference(caseData.getContactDetailsWrapper().getRespondentSolicitorReference())
.additionalInformationAboutHearing(caseData.getAdditionalInformationAboutHearing())
.hearingTime(caseData.getHearingTime())
.timeEstimate(caseData.getTimeEstimate())
.additionalInformationAboutHearing(caseData.getListForHearingWrapper().getAdditionalInformationAboutHearing())
.hearingTime(listForHearingWrapper.getHearingTime())
.timeEstimate(listForHearingWrapper.getTimeEstimate())
.formCCreatedDate(String.valueOf(LocalDate.now()))
.eventDatePlus21Days(String.valueOf(LocalDate.now().plusDays(21)))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public DocumentTemplateDetails buildDocumentTemplateDetails(FinremCaseDetails ca
.respondentLName(caseData.getContactDetailsWrapper().getRespondentLname())
.divorceCaseNumber(caseData.getDivorceCaseNumber())
.courtDetails(courtDetailsMapper.getCourtDetails(courtList))
.hearingDate(String.valueOf(caseData.getHearingDate()))
.hearingDate(String.valueOf(caseData.getListForHearingWrapper().getHearingDate()))
.solicitorReference(caseData.getContactDetailsWrapper().getSolicitorReference())
.respondentSolicitorReference(caseData.getContactDetailsWrapper().getRespondentSolicitorReference())
.hearingTime(caseData.getHearingTime())
.hearingTime(caseData.getListForHearingWrapper().getHearingTime())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.IntervenerOne;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.IntervenerThree;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.IntervenerTwo;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.ListForHearingWrapper;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.MiamWrapper;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.NatureApplicationWrapper;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper.OrderWrapper;
Expand Down Expand Up @@ -226,19 +227,13 @@ public class FinremCaseData implements HasCaseDocument {
private String familyMediatorServiceName1;
private String soleTraderName1;
private YesOrNo promptForAnyDocument;
private List<AdditionalHearingDocumentCollection> additionalHearingDocuments;
private List<HearingDirectionDetailsCollection> hearingDirectionDetailsCollection;
private List<DocumentCollection> hearingNoticeDocumentPack;
private List<DocumentCollection> hearingNoticesDocumentCollection;
private Map<String, Object> courtDetails;

private HearingTypeDirection hearingType;
private String timeEstimate;
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate hearingDate;
private String additionalInformationAboutHearing;
private String hearingTime;
@JsonUnwrapped
@Getter(AccessLevel.NONE)
private ListForHearingWrapper listForHearingWrapper;
private List<JudgeAllocated> judgeAllocated;
private YesOrNo applicationAllocatedTo;
private YesOrNo caseAllocatedTo;
Expand Down Expand Up @@ -386,9 +381,6 @@ public class FinremCaseData implements HasCaseDocument {
@JsonUnwrapped
@Getter(AccessLevel.NONE)
private BulkPrintCoversheetWrapper bulkPrintCoversheetWrapper;
private YesOrNo additionalHearingDocumentsOption;
private CaseDocument additionalListOfHearingDocuments;

@JsonProperty("typeOfDocument")
private ScannedDocumentTypeOption scannedDocsTypeOfDocument;
private List<ScannedDocumentCollection> applicantScanDocuments;
Expand Down Expand Up @@ -1018,4 +1010,11 @@ public DraftOrdersWrapper getDraftOrdersWrapper() {
return draftOrdersWrapper;
}

@JsonIgnore
public ListForHearingWrapper getListForHearingWrapper() {
if (listForHearingWrapper == null) {
listForHearingWrapper = new ListForHearingWrapper();
}
return listForHearingWrapper;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.wrapper;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.AdditionalHearingDocumentCollection;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.CaseDocument;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HasCaseDocument;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.HearingTypeDirection;
import uk.gov.hmcts.reform.finrem.caseorchestration.model.ccd.YesOrNo;

import java.time.LocalDate;
import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
@Data
@Builder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ListForHearingWrapper implements HasCaseDocument {
private HearingTypeDirection hearingType;
private String timeEstimate;
@JsonSerialize(using = LocalDateSerializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private LocalDate hearingDate;
private String hearingTime;
@JsonUnwrapped
@Getter(AccessLevel.NONE)
private HearingRegionWrapper hearingRegionWrapper;
private String additionalInformationAboutHearing;
private YesOrNo additionalHearingDocumentsOption;
private CaseDocument additionalListOfHearingDocuments;

private List<AdditionalHearingDocumentCollection> additionalHearingDocuments;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ public class RegionWrapper {
@Getter(AccessLevel.NONE)
GeneralApplicationRegionWrapper generalApplicationRegionWrapper;

@JsonUnwrapped
@Getter(AccessLevel.NONE)
HearingRegionWrapper hearingRegionWrapper;

@JsonIgnore
public AllocatedRegionWrapper getAllocatedRegionWrapper() {
if (allocatedRegionWrapper == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,13 @@ protected void addAdditionalHearingDocumentToCaseData(FinremCaseDetails caseDeta
.build();

FinremCaseData data = caseDetails.getData();
List<AdditionalHearingDocumentCollection> additionalHearingDocumentCollections
= Optional.ofNullable(data.getAdditionalHearingDocuments()).orElse(new ArrayList<>(1));
List<AdditionalHearingDocumentCollection> additionalHearingDocumentCollections = Optional.ofNullable(
data.getListForHearingWrapper().getAdditionalHearingDocuments())
.orElse(new ArrayList<>(1));

additionalHearingDocumentCollections.add(generatedDocumentData);

data.setAdditionalHearingDocuments(additionalHearingDocumentCollections);
data.getListForHearingWrapper().setAdditionalHearingDocuments(additionalHearingDocumentCollections);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ private DocumentCollection getDocumentCollectionObj(CaseDocument caseDocument) {
}

private void addAdditionalHearingDocument(FinremCaseData caseData, CaseDocument documentToAdd) {

List<AdditionalHearingDocumentCollection> additionalHearingDocuments
= Optional.ofNullable(caseData.getAdditionalHearingDocuments()).orElse(new ArrayList<>());
List<AdditionalHearingDocumentCollection> additionalHearingDocuments = Optional
.ofNullable(caseData.getListForHearingWrapper().getAdditionalHearingDocuments())
.orElse(new ArrayList<>());

AdditionalHearingDocumentCollection hearingDocumentCollection
= AdditionalHearingDocumentCollection.builder()
Expand All @@ -108,7 +108,7 @@ private void addAdditionalHearingDocument(FinremCaseData caseData, CaseDocument
.build()).build();
additionalHearingDocuments.add(hearingDocumentCollection);

caseData.setAdditionalHearingDocuments(additionalHearingDocuments);
caseData.getListForHearingWrapper().setAdditionalHearingDocuments(additionalHearingDocuments);
}

public void printHearingNoticePackAndSendToApplicantAndRespondent(CaseDetails caseDetails,
Expand Down
Loading