Skip to content

Commit

Permalink
Merge branch 'master' into feat/CIV-10568
Browse files Browse the repository at this point in the history
  • Loading branch information
bhagyashreesharma90 authored Nov 7, 2023
2 parents 083a3ba + 1a2b55e commit 1eb449f
Show file tree
Hide file tree
Showing 39 changed files with 1,399 additions and 223 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ configurations.all {
}

dependencies {
implementation 'com.github.hmcts:civil-commons:1.0.31'
implementation 'com.github.hmcts:civil-commons:1.0.33'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public enum BundleFileNameList {
QUESTIONS_TO("Questions to %s %s"),
REPLIES_FROM("Replies from %s %s"),
JOINT_STATEMENTS_OF_EXPERTS("Joint statement of experts %s %s %s"),
SKELETON_ARGUMENT("%s Skeleton argument %s");
SKELETON_ARGUMENT("%s Skeleton argument %s"),
PARTICULARS_OF_CLAIM("Particulars Of Claim %s");
String displayName;

public String getDisplayName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.enums.RespondentResponseTypeSpec;
import uk.gov.hmcts.reform.civil.enums.YesOrNo;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.SmallClaimMedicalLRspec;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.service.OrganisationService;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;
import uk.gov.hmcts.reform.civil.prd.model.Organisation;
import uk.gov.hmcts.reform.civil.service.OrganisationService;

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;

import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED;
Expand Down Expand Up @@ -70,7 +76,7 @@ public List<CaseEvent> handledEvents() {

private CallbackResponse notifyRespondentSolicitorForClaimantConfirmsToProceed(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
String template = null;
String template;
var recipient = isCcNotification(callbackParams)
? caseData.getApplicantSolicitor1UserDetails().getEmail()
: caseData.getRespondentSolicitor1EmailAddress();
Expand Down Expand Up @@ -103,9 +109,7 @@ private CallbackResponse notifyRespondentSolicitorForClaimantConfirmsToProceed(C
return AboutToStartOrSubmitCallbackResponse.builder().build();
}
if (SPEC_CLAIM.equals(caseData.getCaseAccessCategory())) {
template = isCcNotification(callbackParams)
? notificationsProperties.getClaimantSolicitorConfirmsToProceedSpec()
: notificationsProperties.getRespondentSolicitorNotifyToProceedSpec();
template = getSpecTemplate(callbackParams, caseData);
} else {
template = notificationsProperties.getClaimantSolicitorConfirmsToProceed();
}
Expand All @@ -123,6 +127,50 @@ private CallbackResponse notifyRespondentSolicitorForClaimantConfirmsToProceed(C
return AboutToStartOrSubmitCallbackResponse.builder().build();
}

private String getSpecTemplate(CallbackParams callbackParams, CaseData caseData) {
String template;
if (isCcNotification(callbackParams)) {
if (rejectedAll(caseData) && mediationRejected(caseData)) {
template = notificationsProperties.getClaimantSolicitorConfirmsToProceedSpecWithAction();
} else {
template = notificationsProperties.getClaimantSolicitorConfirmsToProceedSpec();
}
} else {
if (rejectedAll(caseData) && mediationRejected(caseData)) {
template = notificationsProperties.getRespondentSolicitorNotifyToProceedSpecWithAction();
} else {
template = notificationsProperties.getRespondentSolicitorNotifyToProceedSpec();
}
}
return template;
}

/**
* Consider that reject all is true if any respondent rejected all the claim.
*
* @param caseData the case data of a spec claim
* @return true if and only if at least one respondent rejected all the claim
*/
private boolean rejectedAll(CaseData caseData) {
return caseData.getRespondent1ClaimResponseTypeForSpec() == RespondentResponseTypeSpec.FULL_DEFENCE
|| caseData.getRespondent2ClaimResponseTypeForSpec() == RespondentResponseTypeSpec.FULL_DEFENCE;
}

/**
* Mediation is applicable only when all parties are willing to try it.
*
* @param caseData a spec claim
* @return true if and only if at least one party did not agree to mediation
*/
private boolean mediationRejected(CaseData caseData) {
return Stream.of(
caseData.getResponseClaimMediationSpecRequired(),
caseData.getResponseClaimMediationSpec2Required(),
Optional.ofNullable(caseData.getApplicant1ClaimMediationSpecRequired())
.map(SmallClaimMedicalLRspec::getHasAgreedFreeMediation).orElse(null)
).filter(Objects::nonNull).anyMatch(YesOrNo.NO::equals);
}

@Override
public Map<String, String> addProperties(CaseData caseData) {
return Map.of(
Expand Down Expand Up @@ -158,12 +206,12 @@ private boolean isRespondentSolicitor2Notification(CallbackParams callbackParams
}

//finding legal org name
private String getLegalOrganisationName(CaseData caseData, CaseEvent caseEvent) {
private String getLegalOrganisationName(CaseData caseData, CaseEvent caseEvent) {
String organisationID;
if (caseEvent.equals(NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED_CC)) {
organisationID = caseData.getApplicant1OrganisationPolicy().getOrganisation().getOrganisationID();
} else {
organisationID = caseEvent.equals(NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED)
organisationID = caseEvent.equals(NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIMANT_CONFIRMS_TO_PROCEED)
? caseData.getRespondent1OrganisationPolicy().getOrganisation().getOrganisationID()
: caseData.getRespondent2OrganisationPolicy().getOrganisation().getOrganisationID();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
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;
import static uk.gov.hmcts.reform.civil.enums.MultiPartyScenario.getMultiPartyScenario;
import static uk.gov.hmcts.reform.civil.enums.RespondentResponsePartAdmissionPaymentTimeLRspec.BY_SET_DATE;
import static uk.gov.hmcts.reform.civil.enums.RespondentResponsePartAdmissionPaymentTimeLRspec.IMMEDIATELY;
import static uk.gov.hmcts.reform.civil.enums.RespondentResponsePartAdmissionPaymentTimeLRspec.SUGGESTION_OF_REPAYMENT_PLAN;
import static uk.gov.hmcts.reform.civil.utils.PartyUtils.buildPartiesReferences;
import static uk.gov.hmcts.reform.civil.utils.PartyUtils.getPartyNameBasedOnType;

Expand Down Expand Up @@ -159,7 +161,11 @@ private void sendNotificationToSolicitorSpec(CaseData caseData, String recipient
String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference())
);
} else if (caseEvent.equals(NOTIFY_APPLICANT_SOLICITOR1_FOR_DEFENDANT_RESPONSE_CC)) {
emailTemplate = notificationsProperties.getRespondentSolicitorDefendantResponseForSpec();
if (MultiPartyScenario.getMultiPartyScenario(caseData).equals(ONE_V_TWO_TWO_LEGAL_REP)) {
emailTemplate = notificationsProperties.getRespondentSolicitorDefendantResponseForSpec();
} else {
emailTemplate = getTemplateForSpecOtherThan1v2DS(caseData);
}
if (caseData.getRespondent1ResponseDate() == null || !MultiPartyScenario.getMultiPartyScenario(caseData)
.equals(ONE_V_TWO_TWO_LEGAL_REP)) {
notificationService.sendMail(
Expand All @@ -171,7 +177,11 @@ private void sendNotificationToSolicitorSpec(CaseData caseData, String recipient
}

} else {
emailTemplate = notificationsProperties.getRespondentSolicitorDefendantResponseForSpec();
if (MultiPartyScenario.getMultiPartyScenario(caseData).equals(ONE_V_TWO_TWO_LEGAL_REP)) {
emailTemplate = notificationsProperties.getRespondentSolicitorDefendantResponseForSpec();
} else {
emailTemplate = getTemplateForSpecOtherThan1v2DS(caseData);
}
notificationService.sendMail(
recipient,
emailTemplate,
Expand All @@ -181,6 +191,23 @@ private void sendNotificationToSolicitorSpec(CaseData caseData, String recipient
}
}

private String getTemplateForSpecOtherThan1v2DS(CaseData caseData) {

String emailTemplate;
if ((caseData.getDefenceAdmitPartPaymentTimeRouteRequired() == IMMEDIATELY
|| caseData.getDefenceAdmitPartPaymentTimeRouteRequired() == BY_SET_DATE
|| caseData.getDefenceAdmitPartPaymentTimeRouteRequired() == SUGGESTION_OF_REPAYMENT_PLAN)
&&
(RespondentResponseTypeSpec.PART_ADMISSION.equals(caseData.getRespondent1ClaimResponseTypeForSpec()))
) {
emailTemplate = notificationsProperties.getRespondentSolicitorDefResponseSpecWithClaimantAction();
} else {
emailTemplate = notificationsProperties.getRespondentSolicitorDefendantResponseForSpec();
}

return emailTemplate;
}

@Override
public Map<String, String> addProperties(CaseData caseData) {
if (getMultiPartyScenario(caseData).equals(ONE_V_ONE) || getMultiPartyScenario(caseData).equals(TWO_V_ONE)) {
Expand Down Expand Up @@ -216,10 +243,10 @@ public Map<String, String> addPropertiesSpec(CaseData caseData, CaseEvent caseEv
+ " " + caseData.getRespondToClaimAdmitPartLRspec().getWhenWillThisAmountBePaid().getMonth()
+ " " + caseData.getRespondToClaimAdmitPartLRspec().getWhenWillThisAmountBePaid().getYear();
return Map.of(
CLAIM_LEGAL_ORG_NAME_SPEC, getLegalOrganisationName(caseData, caseEvent),
CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(),
RESPONDENT_NAME, getPartyNameBasedOnType(caseData.getApplicant1()),
WHEN_WILL_BE_PAID_IMMEDIATELY, shouldBePaidBy
CLAIM_LEGAL_ORG_NAME_SPEC, getLegalOrganisationName(caseData, caseEvent),
CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(),
RESPONDENT_NAME, getPartyNameBasedOnType(caseData.getApplicant1()),
WHEN_WILL_BE_PAID_IMMEDIATELY, shouldBePaidBy
);
} else {
return Map.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import uk.gov.hmcts.reform.civil.enums.CaseState;
import uk.gov.hmcts.reform.civil.model.BusinessProcess;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.service.citizenui.ResponseOneVOneShowTagService;

import java.time.LocalDateTime;
import java.util.Collections;
Expand All @@ -31,12 +32,14 @@ public class ClaimantResponseCuiCallbackHandler extends CallbackHandler {

private static final List<CaseEvent> EVENTS = Collections.singletonList(CLAIMANT_RESPONSE_CUI);

private final ResponseOneVOneShowTagService responseOneVOneService;

private final ObjectMapper objectMapper;

@Override
protected Map<String, Callback> callbacks() {
return Map.of(
callbackKey(ABOUT_TO_START), this::emptyCallbackResponse,
callbackKey(ABOUT_TO_START), this::populateCaseData,
callbackKey(ABOUT_TO_SUBMIT), this::aboutToSubmit,
callbackKey(SUBMITTED), this::emptySubmittedCallbackResponse
);
Expand All @@ -47,6 +50,16 @@ public List<CaseEvent> handledEvents() {
return EVENTS;
}

private CallbackResponse populateCaseData(CallbackParams callbackParams) {
var caseData = callbackParams.getCaseData();
CaseData.CaseDataBuilder<?, ?> updatedCaseData = caseData.toBuilder();
updatedCaseData.showResponseOneVOneFlag(responseOneVOneService.setUpOneVOneFlow(caseData));

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

private CallbackResponse aboutToSubmit(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
CaseData updatedData = caseData.toBuilder()
Expand All @@ -64,11 +77,13 @@ private CallbackResponse aboutToSubmit(CallbackParams callbackParams) {
}

private void updateClaimEndState(AboutToStartOrSubmitCallbackResponse.AboutToStartOrSubmitCallbackResponseBuilder response, CaseData updatedData) {

if (updatedData.hasClaimantAgreedToFreeMediation()) {
response.state(CaseState.IN_MEDIATION.name());
} else if (updatedData.hasApplicantRejectedRepaymentPlan() && updatedData.getRespondent1().isCompanyOROrganisation()) {
response.state(CaseState.PROCEEDS_IN_HERITAGE_SYSTEM.name());
} else {
response.state(CaseState.JUDICIAL_REFERRAL.name());
}
}

}
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
Loading

0 comments on commit 1eb449f

Please sign in to comment.