Skip to content

Commit

Permalink
Merge branch 'master' into feat/civ-11158
Browse files Browse the repository at this point in the history
  • Loading branch information
sankaviv1 authored Nov 7, 2023
2 parents 76c5900 + 1a2b55e commit 004ffc7
Show file tree
Hide file tree
Showing 22 changed files with 881 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED;
import static uk.gov.hmcts.reform.civil.callback.CallbackVersion.V_1;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CREATE_SDO;
import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES;
import static uk.gov.hmcts.reform.civil.enums.sdo.OrderDetailsPagesSectionsToggle.SHOW;
import static uk.gov.hmcts.reform.civil.enums.sdo.OrderType.DISPOSAL;
import static uk.gov.hmcts.reform.civil.helpers.DateFormatHelper.DATE;
import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element;
import static uk.gov.hmcts.reform.civil.utils.HearingUtils.getHearingNotes;
Expand Down Expand Up @@ -219,7 +222,7 @@ private CallbackResponse prePopulateOrderDetailsPages(CallbackParams callbackPar
updatedData.fastTrackMethodInPerson(locationsList);
updatedData.smallClaimsMethodInPerson(locationsList);

List<OrderDetailsPagesSectionsToggle> checkList = List.of(OrderDetailsPagesSectionsToggle.SHOW);
List<OrderDetailsPagesSectionsToggle> checkList = List.of(SHOW);
setCheckList(updatedData, checkList);

DisposalHearingJudgesRecital tempDisposalHearingJudgesRecital = DisposalHearingJudgesRecital.builder()
Expand Down Expand Up @@ -711,17 +714,21 @@ private DynamicList getLocationList(CallbackParams callbackParams,
));
DynamicList locationsList;
if (matchingLocation.isPresent()) {
locationsList = DynamicList.fromList(locations, LocationRefDataService::getDisplayEntry,
locationsList = DynamicList.fromList(locations, this::getLocationEpimms, LocationRefDataService::getDisplayEntry,
matchingLocation.get(), true
);
} else {
locationsList = DynamicList.fromList(locations, LocationRefDataService::getDisplayEntry,
locationsList = DynamicList.fromList(locations, this::getLocationEpimms, LocationRefDataService::getDisplayEntry,
null, true
);
}
return locationsList;
}

private String getLocationEpimms(LocationRefData location) {
return location.getEpimmsId();
}

private CallbackResponse setOrderDetailsFlags(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
CaseData.CaseDataBuilder updatedData = caseData.toBuilder();
Expand All @@ -732,9 +739,9 @@ private CallbackResponse setOrderDetailsFlags(CallbackParams callbackParams) {
updatedData.setFastTrackFlag(YesOrNo.NO).build();

if (SdoHelper.isSmallClaimsTrack(caseData)) {
updatedData.setSmallClaimsFlag(YesOrNo.YES).build();
updatedData.setSmallClaimsFlag(YES).build();
} else if (SdoHelper.isFastTrack(caseData)) {
updatedData.setFastTrackFlag(YesOrNo.YES).build();
updatedData.setFastTrackFlag(YES).build();
}

return AboutToStartOrSubmitCallbackResponse.builder()
Expand Down Expand Up @@ -836,18 +843,38 @@ private CallbackResponse submitSDO(CallbackParams callbackParams) {

dataBuilder.hearingNotes(getHearingNotes(caseData));

if (featureToggleService.isLocationWhiteListedForCaseProgression(
caseData.getCaseManagementLocation().getBaseLocation())) {
log.info("Case {} is whitelisted for case progression.", caseData.getCcdCaseReference());
} else {
log.info("Case {} is NOT whitelisted for case progression.", caseData.getCcdCaseReference());
if (featureToggleService.isEarlyAdoptersEnabled()) {
if (featureToggleService.isLocationWhiteListedForCaseProgression(
getEpimmsId(caseData))) {
log.info("Case {} is whitelisted for case progression.", caseData.getCcdCaseReference());
dataBuilder.eaCourtLocation(YES);
} else {
log.info("Case {} is NOT whitelisted for case progression.", caseData.getCcdCaseReference());
dataBuilder.eaCourtLocation(YesOrNo.NO);
}
}

System.out.println("before about to submit");

return AboutToStartOrSubmitCallbackResponse.builder()
.data(dataBuilder.build().toMap(objectMapper))
.build();
}

private String getEpimmsId(CaseData caseData) {

if (caseData.getOrderType() != null && caseData.getOrderType().equals(DISPOSAL)) {
return caseData.getDisposalHearingMethodInPerson().getValue().getCode();
}
if (SdoHelper.isFastTrack(caseData)) {
return caseData.getFastTrackMethodInPerson().getValue().getCode();
}
if (SdoHelper.isSmallClaimsTrack(caseData)) {
return caseData.getSmallClaimsMethodInPerson().getValue().getCode();
}
throw new IllegalArgumentException("Could not determine claim track");
}

private boolean nonNull(Object object) {
if (object != null) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.CaseNote;
import uk.gov.hmcts.reform.civil.model.common.Element;
import uk.gov.hmcts.reform.civil.model.documents.DocumentAndNote;
import uk.gov.hmcts.reform.civil.model.documents.DocumentWithName;
import uk.gov.hmcts.reform.civil.service.CaseNoteService;

import java.util.Collections;
Expand Down Expand Up @@ -59,7 +61,11 @@ private AboutToStartOrSubmitCallbackResponse removeCaseNoteType(CallbackParams c
var caseData = callbackParams.getCaseData();
CaseData.CaseDataBuilder<?, ?> caseDataBuilder = caseData.toBuilder();

caseDataBuilder.caseNoteType(null).build();
caseDataBuilder
.caseNoteType(null)
.documentAndNameToAdd(null)
.documentAndNoteToAdd(null)
.build();

return AboutToStartOrSubmitCallbackResponse.builder()
.data(caseDataBuilder.build().toMap(objectMapper))
Expand All @@ -84,6 +90,39 @@ private AboutToStartOrSubmitCallbackResponse populateSubmittedDateTime(CallbackP
.build();
}

if (caseData.getCaseNoteType().equals(CaseNoteType.DOCUMENT_ONLY)) {
List<Element<DocumentWithName>> documentAndNameToAdd = caseData.getDocumentAndNameToAdd();
List<Element<DocumentWithName>> documentAndNameCurrent = caseData.getDocumentAndName();

if (documentAndNameCurrent == null) {
documentAndNameCurrent = documentAndNameToAdd;
} else {
for (Element<DocumentWithName> document : documentAndNameToAdd) {
documentAndNameCurrent.add(document);
}
}
caseDataBuilder
.documentAndName(documentAndNameCurrent)
.build();
}

if (caseData.getCaseNoteType().equals(CaseNoteType.DOCUMENT_AND_NOTE)) {
List<Element<DocumentAndNote>> documentAndNoteToAdd = caseData.getDocumentAndNoteToAdd();
List<Element<DocumentAndNote>> documentAndNoteCurrent = caseData.getDocumentAndNote();

if (documentAndNoteCurrent == null) {
documentAndNoteCurrent = documentAndNoteToAdd;
} else {
for (Element<DocumentAndNote> document : documentAndNoteToAdd) {
documentAndNoteCurrent.add(document);
}
}
caseDataBuilder
.documentAndNote(documentAndNoteCurrent)
.build();

}

return AboutToStartOrSubmitCallbackResponse.builder()
.data(caseDataBuilder.build().toMap(objectMapper))
.build();
Expand Down Expand Up @@ -115,16 +154,16 @@ private String getHeader(CaseData caseData) {
private String getBody(CaseData caseData) {
StringBuilder stringBuilder = new StringBuilder();
if (null != caseData.getCaseNoteType() && caseData.getCaseNoteType().equals(CaseNoteType.DOCUMENT_ONLY)) {
IntStream.range(0, caseData.getDocumentAndName()
IntStream.range(0, caseData.getDocumentAndNameToAdd()
.size()).forEachOrdered(i -> stringBuilder.append("* ").append(
caseData.getDocumentAndName().get(i).getValue().getDocument().getDocumentFileName()).append("\n"));
caseData.getDocumentAndNameToAdd().get(i).getValue().getDocument().getDocumentFileName()).append("\n"));

return format(EVIDENCE_UPLOAD_BODY_ONE, stringBuilder);
}
if (caseData.getCaseNoteType().equals(CaseNoteType.DOCUMENT_AND_NOTE)) {
IntStream.range(0, caseData.getDocumentAndNote()
IntStream.range(0, caseData.getDocumentAndNoteToAdd()
.size()).forEachOrdered(i -> stringBuilder.append("* ").append(
caseData.getDocumentAndNote().get(i)
caseData.getDocumentAndNoteToAdd().get(i)
.getValue()
.getDocument()
.getDocumentFileName()).append("\n"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
import uk.gov.hmcts.reform.civil.config.ToggleConfiguration;
import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument;
import uk.gov.hmcts.reform.civil.documentmanagement.model.DocumentType;
import uk.gov.hmcts.reform.civil.enums.AllocatedTrack;
import uk.gov.hmcts.reform.civil.enums.CaseCategory;
import uk.gov.hmcts.reform.civil.enums.CaseState;
import uk.gov.hmcts.reform.civil.enums.DocCategory;
import uk.gov.hmcts.reform.civil.enums.MultiPartyScenario;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.helpers.LocationHelper;
import uk.gov.hmcts.reform.civil.model.BusinessProcess;
import uk.gov.hmcts.reform.civil.model.CaseData;
Expand All @@ -36,6 +34,7 @@
import uk.gov.hmcts.reform.civil.service.Time;
import uk.gov.hmcts.reform.civil.utils.AssignCategoryId;
import uk.gov.hmcts.reform.civil.utils.CaseFlagsInitialiser;
import uk.gov.hmcts.reform.civil.utils.JudicialReferralUtils;
import uk.gov.hmcts.reform.civil.utils.LocationRefDataUtil;
import uk.gov.hmcts.reform.civil.utils.UnavailabilityDatesUtils;
import uk.gov.hmcts.reform.civil.validation.UnavailableDateValidator;
Expand All @@ -56,7 +55,6 @@
import static uk.gov.hmcts.reform.civil.callback.CallbackType.MID;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.CLAIMANT_RESPONSE;
import static uk.gov.hmcts.reform.civil.enums.AllocatedTrack.getAllocatedTrack;
import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_TWO_ONE_LEGAL_REP;
import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.ONE_V_TWO_TWO_LEGAL_REP;
import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.TWO_V_ONE;
Expand Down Expand Up @@ -288,57 +286,12 @@ private CallbackResponse aboutToSubmit(CallbackParams callbackParams) {

return AboutToStartOrSubmitCallbackResponse.builder()
.data(builder.build().toMap(objectMapper))
.state((shouldMoveToJudicialReferral(caseData)
.state((JudicialReferralUtils.shouldMoveToJudicialReferral(caseData)
? CaseState.JUDICIAL_REFERRAL
: CaseState.PROCEEDS_IN_HERITAGE_SYSTEM).name())
.build();
}

/**
* Computes whether the case data should move to judicial referral or not.
*
* @param caseData a case data such that defendants rejected the claim, and claimant(s) wants to proceed
* vs all the defendants
* @return true if and only if the case should move to judicial referral
*/
public static boolean shouldMoveToJudicialReferral(CaseData caseData) {
CaseCategory caseCategory = caseData.getCaseAccessCategory();

if (CaseCategory.SPEC_CLAIM.equals(caseCategory)) {
MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData);
boolean addRespondent2 = YES.equals(caseData.getAddRespondent2());

return switch (multiPartyScenario) {
case ONE_V_ONE -> caseData.getApplicant1ProceedWithClaim() == YesOrNo.YES;
case TWO_V_ONE -> caseData.getApplicant1ProceedWithClaimSpec2v1() == YesOrNo.YES;
case ONE_V_TWO_ONE_LEGAL_REP -> addRespondent2
&& YES.equals(caseData.getRespondentResponseIsSame());
case ONE_V_TWO_TWO_LEGAL_REP -> addRespondent2
&& caseData.getRespondentResponseIsSame() == null;
};
} else {
AllocatedTrack allocatedTrack =
getAllocatedTrack(
CaseCategory.UNSPEC_CLAIM.equals(caseCategory)
? caseData.getClaimValue().toPounds()
: caseData.getTotalClaimAmount(),
caseData.getClaimType()
);
if (AllocatedTrack.MULTI_CLAIM.equals(allocatedTrack)) {
return false;
}
MultiPartyScenario multiPartyScenario = getMultiPartyScenario(caseData);
return switch (multiPartyScenario) {
case ONE_V_ONE -> caseData.getApplicant1ProceedWithClaim() == YesOrNo.YES;
case TWO_V_ONE -> caseData.getApplicant1ProceedWithClaimMultiParty2v1() == YES
&& caseData.getApplicant2ProceedWithClaimMultiParty2v1() == YES;
case ONE_V_TWO_ONE_LEGAL_REP, ONE_V_TWO_TWO_LEGAL_REP ->
caseData.getApplicant1ProceedWithClaimAgainstRespondent1MultiParty1v2() == YES
&& caseData.getApplicant1ProceedWithClaimAgainstRespondent2MultiParty1v2() == YES;
};
}
}

private void updateApplicants(CaseData caseData, CaseData.CaseDataBuilder builder, StatementOfTruth statementOfTruth) {
if (caseData.getApplicant1DQ() != null
&& caseData.getApplicant1DQ().getApplicant1DQFileDirectionsQuestionnaire() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import uk.gov.hmcts.reform.civil.service.citizenui.ResponseOneVOneShowTagService;
import uk.gov.hmcts.reform.civil.utils.CaseFlagsInitialiser;
import uk.gov.hmcts.reform.civil.utils.CourtLocationUtils;
import uk.gov.hmcts.reform.civil.utils.JudicialReferralUtils;
import uk.gov.hmcts.reform.civil.utils.MonetaryConversions;
import uk.gov.hmcts.reform.civil.utils.UnavailabilityDatesUtils;
import uk.gov.hmcts.reform.civil.validation.UnavailableDateValidator;
Expand Down Expand Up @@ -384,7 +385,7 @@ private void updateDQCourtLocations(CallbackParams callbackParams, CaseData case

private void putCaseStateInJudicialReferral(CaseData caseData, AboutToStartOrSubmitCallbackResponse.AboutToStartOrSubmitCallbackResponseBuilder response) {
if (caseData.isRespondentResponseFullDefence()
&& RespondToDefenceCallbackHandler.shouldMoveToJudicialReferral(caseData)) {
&& JudicialReferralUtils.shouldMoveToJudicialReferral(caseData)) {
response.state(CaseState.JUDICIAL_REFERRAL.name());
}
}
Expand Down
Loading

0 comments on commit 004ffc7

Please sign in to comment.