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

CIV-15230 LR notification stay update requested #5621

Merged
merged 5 commits into from
Oct 17, 2024
Merged
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 @@ -136,6 +136,7 @@ public enum CaseEvent {
MANAGE_STAY(USER),
DISMISS_CASE(USER),
STAY_LIFTED(USER),
STAY_UPDATE_REQUESTED(USER),
PARTIAL_REMISSION_HWF_GRANTED(USER),
ASSIGN_CASE_TO_APPLICANT_SOLICITOR1(CAMUNDA),
ASSIGN_CASE_TO_APPLICANT1(CAMUNDA),
Expand Down Expand Up @@ -516,7 +517,10 @@ public enum CaseEvent {
CREATE_DASHBOARD_NOTIFICATION_STAY_CASE_DEFENDANT(CAMUNDA),
NOTIFY_CLAIMANT_STAY_LIFTED(CAMUNDA),
NOTIFY_DEFENDANT_STAY_LIFTED(CAMUNDA),
NOTIFY_DEFENDANT2_STAY_LIFTED(CAMUNDA);
NOTIFY_DEFENDANT2_STAY_LIFTED(CAMUNDA),
NOTIFY_CLAIMANT_STAY_UPDATE_REQUESTED(CAMUNDA),
NOTIFY_DEFENDANT_STAY_UPDATE_REQUESTED(CAMUNDA),
NOTIFY_DEFENDANT2_STAY_UPDATE_REQUESTED(CAMUNDA);

private final UserType userType;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification;

import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.notify.NotificationService;
import uk.gov.hmcts.reform.civil.notify.NotificationsProperties;

public abstract class AbstractNotifyManageStayClaimantHandler extends AbstractNotifyManageStayHandler {

public AbstractNotifyManageStayClaimantHandler(NotificationService notificationService, NotificationsProperties notificationsProperties) {
super(notificationService, notificationsProperties);
}

@Override
protected String getRecipient(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
return caseData.isApplicantLiP()
? caseData.getClaimantUserDetails().getEmail()
: caseData.getApplicantSolicitor1UserDetails().getEmail();
}

@Override
protected boolean isLiP(CaseData caseData) {
return caseData.isApplicantLiP();
}

@Override
protected String getPartyName(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
return caseData.getApplicant1().getPartyName();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification;

import uk.gov.hmcts.reform.civil.callback.CallbackParams;
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 static java.util.Objects.nonNull;

public abstract class AbstractNotifyManageStayDefendantHandler extends AbstractNotifyManageStayHandler {

public AbstractNotifyManageStayDefendantHandler(NotificationService notificationService, NotificationsProperties notificationsProperties) {
super(notificationService, notificationsProperties);
}

@Override
protected String getPartyName(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
return isRespondentSolicitor2(callbackParams)
? caseData.getRespondent2().getPartyName()
: caseData.getRespondent1().getPartyName();
}

@Override
protected String getRecipient(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
if (caseData.isRespondent1LiP() && nonNull(caseData.getRespondent1().getPartyEmail())) {
return caseData.getRespondent1().getPartyEmail();
} else {
if (isRespondentSolicitor2(callbackParams)) {
return caseData.getRespondentSolicitor2EmailAddress();
}
return caseData.getRespondentSolicitor1EmailAddress();
}
}

@Override
protected boolean isLiP(CaseData caseData) {
return caseData.isRespondent1LiP();
}

protected abstract boolean isRespondentSolicitor2(CallbackParams callbackParams);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.RequiredArgsConstructor;
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.model.CaseData;
Expand All @@ -11,12 +12,19 @@

import java.util.Map;

import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;

@RequiredArgsConstructor
public abstract class AbstractNotifyStayLiftedHandler extends CallbackHandler implements NotificationData {
public abstract class AbstractNotifyManageStayHandler extends CallbackHandler implements NotificationData {

protected final NotificationService notificationService;
protected final NotificationsProperties notificationsProperties;

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

public CallbackResponse sendNotification(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
if (isLiP(caseData)) { // TODO: remove when lip notification is developed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification;

import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.civil.callback.Callback;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
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_CLAIMANT_STAY_LIFTED;

@Service
public class NotifyClaimantStayLiftedHandler extends AbstractNotifyStayLiftedHandler {
public class NotifyClaimantStayLiftedHandler extends AbstractNotifyManageStayClaimantHandler {

private static final String TASK_ID = "NotifyClaimantStayLifted";
private static final String REFERENCE_TEMPLATE = "stay-lifted-claimant-notification-%s";
Expand All @@ -35,32 +31,9 @@ public String camundaActivityId(CallbackParams callbackParams) {
return TASK_ID;
}

@Override
protected String getRecipient(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
return caseData.isApplicantLiP()
? caseData.getClaimantUserDetails().getEmail()
: caseData.getApplicantSolicitor1UserDetails().getEmail();
}

@Override
protected boolean isLiP(CaseData caseData) {
return caseData.isApplicantLiP();
}

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

@Override
protected String getPartyName(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
return caseData.getApplicant1().getPartyName();
}

@Override
public Map<String, Callback> callbacks() {
return Map.of(callbackKey(ABOUT_TO_SUBMIT), this::sendNotification);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification;

import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
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 static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_CLAIMANT_STAY_UPDATE_REQUESTED;

@Service
public class NotifyClaimantStayUpdateRequestedHandler extends AbstractNotifyManageStayClaimantHandler {

private static final String TASK_ID = "NotifyClaimantStayUpdateRequested";
private static final String REFERENCE_TEMPLATE = "stay-update-requested-claimant-notification-%s";
private static final List<CaseEvent> EVENTS = List.of(NOTIFY_CLAIMANT_STAY_UPDATE_REQUESTED);

public NotifyClaimantStayUpdateRequestedHandler(NotificationService notificationService, NotificationsProperties notificationsProperties) {
super(notificationService, notificationsProperties);
}

@Override
protected String getReferenceTemplate() {
return REFERENCE_TEMPLATE;
}

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

@Override
protected String getNotificationTemplate(CaseData caseData) {
if (isLiP(caseData)) {
// TODO: add lip template
return null;
} else {
return notificationsProperties.getNotifyLRStayUpdateRequested();
}
}

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

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification;

import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.civil.callback.Callback;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
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 java.util.Objects.nonNull;
import static uk.gov.hmcts.reform.civil.callback.CallbackType.ABOUT_TO_SUBMIT;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_DEFENDANT2_STAY_LIFTED;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_DEFENDANT_STAY_LIFTED;

@Service
public class NotifyDefendantStayLiftedHandler extends AbstractNotifyStayLiftedHandler {
public class NotifyDefendantStayLiftedHandler extends AbstractNotifyManageStayDefendantHandler {

private static final String TASK_ID = "NotifyDefendantStayLifted";
private static final String TASK_ID_DEFENDANT_2 = "NotifyDefendant2StayLifted";
Expand All @@ -34,37 +29,6 @@ protected String getReferenceTemplate() {
return REFERENCE_TEMPLATE;
}

@Override
protected String getRecipient(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
if (caseData.isRespondent1LiP() && nonNull(caseData.getRespondent1().getPartyEmail())) {
return caseData.getRespondent1().getPartyEmail();
} else {
if (isRespondentSolicitor2(callbackParams)) {
return caseData.getRespondentSolicitor2EmailAddress();
}
return caseData.getRespondentSolicitor1EmailAddress();
}
}

@Override
protected boolean isLiP(CaseData caseData) {
return caseData.isRespondent1LiP();
}

@Override
protected String getPartyName(CallbackParams callbackParams) {
CaseData caseData = callbackParams.getCaseData();
return isRespondentSolicitor2(callbackParams)
? caseData.getRespondent2().getPartyName()
: caseData.getRespondent1().getPartyName();
}

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

@Override
public String camundaActivityId(CallbackParams callbackParams) {
if (isRespondentSolicitor2(callbackParams)) {
Expand All @@ -79,7 +43,8 @@ public List<CaseEvent> handledEvents() {
return EVENTS;
}

private boolean isRespondentSolicitor2(CallbackParams callbackParams) {
@Override
protected boolean isRespondentSolicitor2(CallbackParams callbackParams) {
CaseEvent caseEvent = CaseEvent.valueOf(callbackParams.getRequest().getEventId());
return NOTIFY_DEFENDANT2_STAY_LIFTED.equals(caseEvent);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification;

import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
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 static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_DEFENDANT2_STAY_UPDATE_REQUESTED;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.NOTIFY_DEFENDANT_STAY_UPDATE_REQUESTED;

@Service
public class NotifyDefendantStayUpdateRequestedHandler extends AbstractNotifyManageStayDefendantHandler {

private static final String TASK_ID = "NotifyDefendantStayUpdateRequested";
private static final String TASK_ID_DEFENDANT_2 = "NotifyDefendant2StayUpdateRequested";
private static final String REFERENCE_TEMPLATE = "stay-update-requested-defendant-notification-%s";
private static final List<CaseEvent> EVENTS = List.of(NOTIFY_DEFENDANT_STAY_UPDATE_REQUESTED,
NOTIFY_DEFENDANT2_STAY_UPDATE_REQUESTED);

public NotifyDefendantStayUpdateRequestedHandler(NotificationService notificationService, NotificationsProperties notificationsProperties) {
super(notificationService, notificationsProperties);
}

@Override
protected String getReferenceTemplate() {
return REFERENCE_TEMPLATE;
}

@Override
protected String getNotificationTemplate(CaseData caseData) {
if (isLiP(caseData)) {
// TODO: add lip template
return null;
} else {
return notificationsProperties.getNotifyLRStayUpdateRequested();
}
}

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

@Override
public String camundaActivityId(CallbackParams callbackParams) {
if (isRespondentSolicitor2(callbackParams)) {
return TASK_ID_DEFENDANT_2;
} else {
return TASK_ID;
}
}

@Override
protected boolean isRespondentSolicitor2(CallbackParams callbackParams) {
CaseEvent caseEvent = CaseEvent.valueOf(callbackParams.getRequest().getEventId());
return NOTIFY_DEFENDANT2_STAY_UPDATE_REQUESTED.equals(caseEvent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static uk.gov.hmcts.reform.civil.callback.CallbackType.SUBMITTED;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.MANAGE_STAY;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.STAY_LIFTED;
import static uk.gov.hmcts.reform.civil.callback.CaseEvent.STAY_UPDATE_REQUESTED;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -73,6 +74,7 @@ private CallbackResponse manageStay(CallbackParams callbackParams) {
caseDataBuilder.businessProcess(BusinessProcess.ready(STAY_LIFTED));
newState = STATE_MAP.getOrDefault(caseData.getPreStayState(), caseData.getCcdState());
} else {
caseDataBuilder.businessProcess(BusinessProcess.ready(STAY_UPDATE_REQUESTED));
newState = caseData.getCcdState();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,4 +642,7 @@ public class NotificationsProperties {

@NotEmpty
private String notifyLRStayLifted;

@NotEmpty
private String notifyLRStayUpdateRequested;
}
Loading
Loading