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 21, 2023
2 parents 7c9a519 + 2f921e0 commit f05fb86
Show file tree
Hide file tree
Showing 37 changed files with 903 additions and 232 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.33'
implementation 'com.github.hmcts:civil-commons:1.0.34'
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
Binary file modified docker/docmosis/templates/CV-UNS-HNO-ENG-01196.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-HNO-ENG-01197.docx
Binary file not shown.
Binary file modified docker/docmosis/templates/CV-UNS-HNO-ENG-01198.docx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public enum CaseEvent {
NOTIFY_RESPONDENT_SOLICITOR2_FOR_LITIGATION_FRIEND_ADDED(CAMUNDA),
NOTIFY_APPLICANT_SOLICITOR1_FOR_LITIGATION_FRIEND_ADDED(CAMUNDA),
NOTIFY_RESPONDENT_SOLICITOR1_FOR_CASE_PROCEEDS_IN_CASEMAN(CAMUNDA),
NOTIFY_RESPONDENT_SOLICITOR2_FOR_CASE_PROCEEDS_IN_CASEMAN(CAMUNDA),
NOTIFY_APPLICANT_SOLICITOR1_FOR_CASE_PROCEEDS_IN_CASEMAN(CAMUNDA),
NOTIFY_APPLICANT_SOLICITOR1_FOR_CLAIM_DISMISSED(CAMUNDA),
NOTIFY_RESPONDENT_SOLICITOR1_FOR_CLAIM_DISMISSED(CAMUNDA),
Expand Down Expand Up @@ -300,6 +301,8 @@ public enum CaseEvent {
NOTIFY_LIP_RESPONDENT_CLAIMANT_CONFIRM_TO_PROCEED(CAMUNDA),
NOTIFY_LIP_APPLICANT_CLAIMANT_CONFIRM_TO_PROCEED(CAMUNDA),
TRIGGER_TASK_RECONFIG_GA(CAMUNDA);
NOTIFY_APPLICANT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT(CAMUNDA),
NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT(CAMUNDA);

private final UserType userType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.documentmanagement.model.CaseDocument;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.common.DynamicList;
import uk.gov.hmcts.reform.civil.model.common.DynamicListElement;
import uk.gov.hmcts.reform.civil.model.common.Element;
import uk.gov.hmcts.reform.civil.referencedata.LocationRefDataService;
import uk.gov.hmcts.reform.civil.referencedata.model.LocationRefData;
import uk.gov.hmcts.reform.civil.service.docmosis.hearing.HearingNoticeHmcGenerator;
import uk.gov.hmcts.reform.civil.service.hearingnotice.HearingNoticeCamundaService;
import uk.gov.hmcts.reform.civil.utils.HearingFeeUtils;
Expand All @@ -30,6 +34,7 @@
import static uk.gov.hmcts.reform.civil.utils.DateUtils.convertFromUTC;
import static uk.gov.hmcts.reform.civil.utils.ElementUtils.element;
import static uk.gov.hmcts.reform.civil.utils.HmcDataUtils.getHearingDays;
import static uk.gov.hmcts.reform.civil.utils.HmcDataUtils.getLocationRefData;

@Service
@RequiredArgsConstructor
Expand All @@ -45,6 +50,7 @@ public class GenerateHearingNoticeHmcHandler extends CallbackHandler {
private final HearingsService hearingsService;
private final HearingNoticeHmcGenerator hearingNoticeHmcGenerator;
private final ObjectMapper objectMapper;
private final LocationRefDataService locationRefDataService;

@Override
protected Map<String, Callback> callbacks() {
Expand All @@ -65,17 +71,20 @@ private CallbackResponse generateHearingNotice(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
CaseData.CaseDataBuilder<?, ?> caseDataBuilder = caseData.toBuilder();
String processInstanceId = caseData.getBusinessProcess().getProcessInstanceId();
String bearerToken = callbackParams.getParams().get(BEARER_TOKEN).toString();

var camundaVars = camundaService.getProcessVariables(processInstanceId);
var hearing = hearingsService.getHearingResponse(
callbackParams.getParams().get(BEARER_TOKEN).toString(),
bearerToken,
camundaVars.getHearingId()
);

var hearingStartDay = HmcDataUtils.getHearingStartDay(hearing);
var hearingStartDate = convertFromUTC(hearingStartDay.getHearingStartDateTime());
String hearingLocation = getHearingLocation(camundaVars.getHearingId(), hearing,
bearerToken, locationRefDataService);

buildDocument(callbackParams, caseDataBuilder, hearing);
buildDocument(callbackParams, caseDataBuilder, hearing, hearingLocation, camundaVars.getHearingId());

camundaService.setProcessVariables(
processInstanceId,
Expand All @@ -93,16 +102,22 @@ private CallbackResponse generateHearingNotice(CallbackParams callbackParams) {
.data(caseDataBuilder
.hearingDate(hearingStartDate.toLocalDate())
.hearingDueDate(HearingFeeUtils.calculateHearingDueDate(LocalDate.now(), hearingStartDate.toLocalDate()))
.hearingLocation(DynamicList.builder().value(DynamicListElement.builder()
.label(hearingLocation)
.build()).build())
.build().toMap(objectMapper))
.build();
}

private void buildDocument(CallbackParams callbackParams, CaseData.CaseDataBuilder<?, ?> caseDataBuilder, HearingGetResponse hearing) {
private void buildDocument(CallbackParams callbackParams, CaseData.CaseDataBuilder<?, ?> caseDataBuilder, HearingGetResponse hearing,
String hearingLocation, String hearingId) {
CaseData caseData = callbackParams.getCaseData();
List<CaseDocument> caseDocuments = hearingNoticeHmcGenerator.generate(
caseData,
hearing,
callbackParams.getParams().get(BEARER_TOKEN).toString()
callbackParams.getParams().get(BEARER_TOKEN).toString(),
hearingLocation,
hearingId
);
List<Element<CaseDocument>> systemGeneratedCaseDocuments = new ArrayList<>();
systemGeneratedCaseDocuments.add(element(caseDocuments.get(0)));
Expand All @@ -111,4 +126,17 @@ private void buildDocument(CallbackParams callbackParams, CaseData.CaseDataBuild
}
caseDataBuilder.hearingDocuments(systemGeneratedCaseDocuments);
}

private String getHearingLocation(String hearingId, HearingGetResponse hearing,
String bearerToken, LocationRefDataService locationRefDataService) {
LocationRefData hearingLocation = getLocationRefData(
hearingId,
HmcDataUtils.getHearingStartDay(hearing).getHearingVenueId(),
bearerToken,
locationRefDataService);
if (hearingLocation != null) {
return LocationRefDataService.getDisplayEntry(hearingLocation);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@

import java.util.List;
import java.util.Map;
import java.util.Optional;

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_CASE_PROCEEDS_IN_CASEMAN;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_RESPONDENT_SOLICITOR2_FOR_CASE_PROCEEDS_IN_CASEMAN;
import static uk.gov.hmcts.reform.civil.service.flowstate.FlowState.Main.CLAIM_NOTIFIED;
import static uk.gov.hmcts.reform.civil.utils.PartyUtils.buildPartiesReferences;

@Service
@RequiredArgsConstructor
public class CaseProceedsInCasemanRespondentNotificationHandler extends CallbackHandler implements NotificationData {

private static final List<CaseEvent> EVENTS = List.of(NOTIFY_RESPONDENT_SOLICITOR1_FOR_CASE_PROCEEDS_IN_CASEMAN);
private static final List<CaseEvent> EVENTS = List.of(
NOTIFY_RESPONDENT_SOLICITOR1_FOR_CASE_PROCEEDS_IN_CASEMAN,
NOTIFY_RESPONDENT_SOLICITOR2_FOR_CASE_PROCEEDS_IN_CASEMAN
);

public static final String TASK_ID = "CaseProceedsInCasemanNotifyRespondentSolicitor1";
public static final String TASK_ID1 = "CaseProceedsInCasemanNotifyRespondentSolicitor1";
public static final String TASK_ID2 = "CaseProceedsInCasemanNotifyRespondentSolicitor2";
private static final String REFERENCE_TEMPLATE = "case-proceeds-in-caseman-respondent-notification-%s";

private final NotificationService notificationService;
Expand All @@ -43,7 +49,12 @@ protected Map<String, Callback> callbacks() {

@Override
public String camundaActivityId(CallbackParams callbackParams) {
return TASK_ID;
if (NOTIFY_RESPONDENT_SOLICITOR1_FOR_CASE_PROCEEDS_IN_CASEMAN.name()
.equals(callbackParams.getRequest().getEventId())) {
return TASK_ID1;
} else {
return TASK_ID2;
}
}

@Override
Expand All @@ -55,12 +66,24 @@ private CallbackResponse notifyRespondentSolicitorForCaseProceedsInCaseman(Callb
CaseData caseData = callbackParams.getCaseData();

if (stateFlowEngine.hasTransitionedTo(callbackParams.getRequest().getCaseDetails(), CLAIM_NOTIFIED)) {
notificationService.sendMail(
caseData.getRespondentSolicitor1EmailAddress(),
notificationsProperties.getSolicitorCaseTakenOffline(),
addProperties(caseData),
String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference())
);

String emailAddress;
if (NOTIFY_RESPONDENT_SOLICITOR1_FOR_CASE_PROCEEDS_IN_CASEMAN.name()
.equals(callbackParams.getRequest().getEventId())) {
emailAddress = caseData.getRespondentSolicitor1EmailAddress();
} else {
emailAddress = caseData.getRespondentSolicitor2EmailAddress();
}
Optional.ofNullable(emailAddress).ifPresent(
email -> notificationService.sendMail(
email,
notificationsProperties.getSolicitorCaseTakenOffline(),
addProperties(caseData),
String.format(
REFERENCE_TEMPLATE,
caseData.getLegacyCaseReference()
)
));
}

return AboutToStartOrSubmitCallbackResponse.builder().build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse;
import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse;
import uk.gov.hmcts.reform.civil.callback.Callback;
import uk.gov.hmcts.reform.civil.callback.CallbackHandler;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.config.PinInPostConfiguration;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;

import java.util.List;
import java.util.Map;

import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_APPLICANT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT;
import static uk.gov.hmcts.reform.civil.utils.PartyUtils.getPartyNameBasedOnType;

@Service
@RequiredArgsConstructor
public class ClaimantLipRequestJudgementByAdmissionApplicantNotificationHandler extends CallbackHandler implements NotificationData {

private static final List<CaseEvent> EVENTS = List.of(
NOTIFY_APPLICANT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT);
public static final String TASK_ID = "RequestJudgementByAdmissionLipClaimantNotifyRespondent1";
private static final String REFERENCE_TEMPLATE = "request-judgement-by-admission-applicant-notification-%s";

private final NotificationService notificationService;
private final NotificationsProperties notificationsProperties;
private final PinInPostConfiguration pipInPostConfiguration;

@Override
protected Map<String, Callback> callbacks() {
return Map.of(
callbackKey(ABOUT_TO_SUBMIT),
this::notifyApplicant1ForRequestJudgementByAdmission
);
}

@Override
public String camundaActivityId(CallbackParams callbackParams) {
return TASK_ID;
}

@Override
public List<CaseEvent> handledEvents() {
return EVENTS;
}

private CallbackResponse notifyApplicant1ForRequestJudgementByAdmission(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();

if (!caseData.isLipvLipOneVOne() || caseData.getApplicant1Email() == null) {
return AboutToStartOrSubmitCallbackResponse.builder().build();
}

notificationService.sendMail(
addEmail(caseData),
notificationsProperties.getNotifyApplicantLipRequestJudgementByAdmissionNotificationTemplate(),
addProperties(caseData),
String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference())
);
return AboutToStartOrSubmitCallbackResponse.builder().build();
}

@Override
public Map<String, String> addProperties(CaseData caseData) {
return Map.of(
CLAIMANT_NAME, getPartyNameBasedOnType(caseData.getApplicant1()),
RESPONDENT_NAME, getPartyNameBasedOnType(caseData.getRespondent1()),
CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(),
FRONTEND_URL, pipInPostConfiguration.getCuiFrontEndUrl()
);
}

private String addEmail(CaseData caseData) {
return caseData.getApplicant1Email();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.ccd.client.model.AboutToStartOrSubmitCallbackResponse;
import uk.gov.hmcts.reform.ccd.client.model.CallbackResponse;
import uk.gov.hmcts.reform.civil.callback.Callback;
import uk.gov.hmcts.reform.civil.callback.CallbackHandler;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.config.PinInPostConfiguration;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;

import java.util.List;
import java.util.Map;

import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT;
import static uk.gov.hmcts.reform.civil.utils.PartyUtils.getPartyNameBasedOnType;

@Service
@RequiredArgsConstructor
public class ClaimantLipRequestJudgementByAdmissionRespondentNotificationHandler extends CallbackHandler implements NotificationData {

private static final List<CaseEvent> EVENTS = List.of(
NOTIFY_RESPONDENT1_FOR_REQUEST_JUDGEMENT_BY_ADMISSION_LIP_CLAIMANT);
public static final String TASK_ID = "RequestJudgementByAdmissionLipClaimantNotifyRespondent1";
private static final String REFERENCE_TEMPLATE = "request-judgement-by-admission-respondent-notification-%s";

private final NotificationService notificationService;
private final NotificationsProperties notificationsProperties;
private final PinInPostConfiguration pipInPostConfiguration;

@Override
protected Map<String, Callback> callbacks() {
return Map.of(
callbackKey(ABOUT_TO_SUBMIT),
this::notifyRespondent1ForRequestJudgementByAdmission
);
}

@Override
public String camundaActivityId(CallbackParams callbackParams) {
return TASK_ID;
}

@Override
public List<CaseEvent> handledEvents() {
return EVENTS;
}

private CallbackResponse notifyRespondent1ForRequestJudgementByAdmission(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();

if (!caseData.isLipvLipOneVOne() || caseData.getRespondent1().getPartyEmail() == null) {
return AboutToStartOrSubmitCallbackResponse.builder().build();
}

notificationService.sendMail(
addEmail(caseData),
notificationsProperties.getNotifyRespondentLipRequestJudgementByAdmissionNotificationTemplate(),
addProperties(caseData),
String.format(REFERENCE_TEMPLATE, caseData.getLegacyCaseReference())
);
return AboutToStartOrSubmitCallbackResponse.builder().build();
}

@Override
public Map<String, String> addProperties(CaseData caseData) {
return Map.of(
CLAIMANT_NAME, getPartyNameBasedOnType(caseData.getApplicant1()),
RESPONDENT_NAME, getPartyNameBasedOnType(caseData.getRespondent1()),
CLAIM_REFERENCE_NUMBER, caseData.getLegacyCaseReference(),
FRONTEND_URL, pipInPostConfiguration.getCuiFrontEndUrl()
);
}

private String addEmail(CaseData caseData) {
return caseData.getRespondent1().getPartyEmail();
}
}
Loading

0 comments on commit f05fb86

Please sign in to comment.