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

Dtscci 1461 plus database #6192

Draft
wants to merge 40 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
79e1d27
DTSCCI-1461:Dummy commmit
nigeldunne Jan 16, 2025
dfc764f
DTSCCI-1461 - Added new CaseEvent - NOTIFY_EVENT.
guygrewal77 Jan 17, 2025
a855cf5
DTSCCI-1461 - Unit test added for new notifier.
guygrewal77 Jan 17, 2025
7f05fcb
Merge branch 'master' into DTSCCI-1461
guygrewal77 Jan 17, 2025
1599746
DTSCCI-1461: add notifications for respondent solicitors
nigeldunne Jan 20, 2025
41e9be5
DTSCCI-1461: add notifications for respondent solicitors
nigeldunne Jan 20, 2025
cc0429d
DTSCCI-1461: add notifications for respondent solicitors
nigeldunne Jan 20, 2025
537748f
Merge branch 'master' into DTSCCI-1461
nigeldunne Jan 20, 2025
a0ea9ad
DTSCCI-1461: fix test
nigeldunne Jan 20, 2025
c4c6fb2
Merge remote-tracking branch 'origin/DTSCCI-1461' into DTSCCI-1461
nigeldunne Jan 20, 2025
1f879ee
DTSCCI-1461 - Created common framework for ending email notifications
guygrewal77 Jan 23, 2025
15b6503
DTSCCI-1461 - Created notification handler for Litigation Friend adde…
guygrewal77 Jan 23, 2025
18404cb
DTSCCI-1461 - Updated tests.
guygrewal77 Jan 23, 2025
930cb9f
DTSCCI-1461 - Fixes
guygrewal77 Jan 23, 2025
3b1a332
Merge branch 'master' into DTSCCI-1461
guygrewal77 Jan 23, 2025
d1e297d
DTSCCI-1461 - Fixes.
guygrewal77 Jan 23, 2025
6477fe0
Merge remote-tracking branch 'origin/DTSCCI-1461' into DTSCCI-1461
guygrewal77 Jan 23, 2025
e2efc65
DTSCCI-1461 - Refactoring to fix functional tests
guygrewal77 Jan 24, 2025
97f5fad
DTSCCI-1461 - Refactoring to fix functional tests
guygrewal77 Jan 24, 2025
f471ba9
DTSCCI-1461 - Refactoring to fix functional tests
guygrewal77 Jan 24, 2025
9663337
DTSCCI-1461 - Fixes
guygrewal77 Jan 24, 2025
8e82c13
Fix properties
gmmagruder Jan 24, 2025
69cf131
Merge branch 'master' into DTSCCI-1461
guygrewal77 Feb 5, 2025
04d6ce8
DTSCCI-1461: Further changes to notifier
ruban72 Feb 7, 2025
9a10bdd
Merge branch 'master' into DTSCCI-1461
guygrewal77 Feb 13, 2025
a155f0b
Merge branch 'master' into DTSCCI-1461
guygrewal77 Feb 14, 2025
f2265d1
DTSCCI-1461 Move template references to process-specific notifier
nigeldunne Feb 17, 2025
3240459
DTSCCI-1461 move interface implementation
nigeldunne Feb 17, 2025
eb53444
DTSCCI-1461 move notifyParties implementation to process-specific not…
nigeldunne Feb 18, 2025
86918d7
DTSCCI-1461 more tidying
nigeldunne Feb 18, 2025
62e3c37
DTSCCI-1461: make method public
nigeldunne Feb 18, 2025
3935059
WIP
nigeldunne Feb 18, 2025
6f2bd08
Add successful tasks
EllisD-B Feb 20, 2025
25b23dc
retry count entity int
EllisD-B Feb 20, 2025
aad5a37
"Fix" test
nigeldunne Feb 20, 2025
709aa28
Fix checkStyle
nigeldunne Feb 20, 2025
8725dfb
Add mock
nigeldunne Feb 21, 2025
ce3051b
sonar exclude
nigeldunne Feb 21, 2025
2b70762
fix pact tests
EllisD-B Feb 21, 2025
505bff9
fix test
nigeldunne Feb 21, 2025
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ sonarqube {
property "sonar.cpd.exclusions", "**/*DocumentManagementService.java, **/*Spec*.java, **/*CcdDashboardClaimantClaimMatcher.java, **/*CcdDashboardDefendantClaimMatcher.java"
property "sonar.exclusions", "**/hmc/model/**, **/model/hearingvalues/**, **/handler/callback/camunda/dashboardnotifications/claimant/CCJRequestedDashboardNotificationHandler.java, **/handler/callback/camunda/dashboardnotifications/claimant/ClaimantCCJResponseNotificationHandler.java" +
", **/handler/callback/camunda/dashboardnotifications/claimant/ClaimantResponseNotificationHandler.java, **/utils/**, **/filters/**, **/handler/callback/camunda/dashboardnotifications/defendant/MoreTimeRequestedDashboardNotificationDefendantHandler.java, **/handler/callback/camunda/dashboardnotifications/claimant/ClaimantMediationSuccessfulDashboardNotificationHandler.java, **/handler/callback/camunda/dashboardnotifications/claimant/ClaimSettledDashboardNotificationHandler.java, **/handler/callback/camunda/dashboardnotifications/claimant/HearingScheduledClaimantNotificationHandler.java, **/handler/callback/camunda/dashboardnotifications/defendant/SettleClaimPaidInFullDefendantDashboardNotificationHandler.java, **/handler/callback/camunda/dashboardnotifications/defendant/DefendantNotifyDiscontinuanceDashboardNotificationHandler.java" +
",**/utils/CaseQueriesUtil.java, **/handler/callback/user/RaiseQueryCallbackHandler.java, **/handler/callback/user/RespondQueryCallbackHandler.java"
",**/utils/CaseQueriesUtil.java, **/handler/callback/user/RaiseQueryCallbackHandler.java, **/handler/callback/user/RespondQueryCallbackHandler.java, **/notification/handlers/Notifier.java"
property "sonar.host.url", "https://sonar.reform.hmcts.net/"
property "sonar.web.javaOpts", "-Xmx2G"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package uk.gov.hmcts.reform.dashboard.entities;

import com.vladmihalcea.hibernate.type.array.StringArrayType;
import io.swagger.v3.oas.annotations.media.Schema;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
import java.time.OffsetDateTime;
import java.util.List;
import java.util.UUID;

@lombok.Data
@lombok.Builder(toBuilder = true)
@lombok.NoArgsConstructor
@lombok.AllArgsConstructor
@Entity
@Table(name = "notification_exception_record", schema = "dbs")
@TypeDefs({
@TypeDef(
name = "string-array",
typeClass = StringArrayType.class
)
})
public class NotificationExceptionRecordEntity implements Serializable {

@Serial
private static final long serialVersionUID = 8313686152850559308L;

@Id
@NotNull
@Schema(name = "id")
private UUID id;

@Schema(name = "reference")
private String reference;

@Schema(name = "task_id")
private String taskId;

@Schema(name = "party_type")
private String partyType;

@Schema(name = "successful_actions")
@Type(type = "string-array")
@Column(
name = "successful_actions",
columnDefinition = "text[]"
)
private List<String> successfulActions;

@Schema(name = "retry_count")
private int retryCount;

@Schema(name = "created_at")
private OffsetDateTime createdAt;

@Schema(name = "updated_on")
private OffsetDateTime updatedOn;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package uk.gov.hmcts.reform.dashboard.repositories;

import uk.gov.hmcts.reform.dashboard.entities.NotificationExceptionRecordEntity;

import java.util.Optional;
import java.util.UUID;

import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface NotificationExceptionRecordRepository extends CrudRepository<NotificationExceptionRecordEntity, UUID> {

Optional<NotificationExceptionRecordEntity> findByReferenceAndTaskId(String reference, String taskId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public enum CaseEvent {
NOTIFY_CLAIM_SET_ASIDE_JUDGMENT_DEFENDANT1(CAMUNDA),
NOTIFY_CLAIM_SET_ASIDE_JUDGMENT_DEFENDANT1_LIP(CAMUNDA),
NOTIFY_CLAIM_SET_ASIDE_JUDGMENT_DEFENDANT2(CAMUNDA),
NOTIFY_EVENT(CAMUNDA),
SEND_SET_ASIDE_JUDGEMENT_IN_ERROR_LETTER_TO_LIP_DEFENDANT1(CAMUNDA),
POST_JO_DEFENDANT1_PIN_IN_LETTER(CAMUNDA),
JUDGMENT_BY_ADMISSION_DEFENDANT1_PIN_IN_LETTER(CAMUNDA),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package uk.gov.hmcts.reform.civil.handler.callback.camunda.notification;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.notification.handlers.AddDefendantLitigationFriendNotifier;

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_EVENT;

@Service
@RequiredArgsConstructor
@Slf4j
public class LitigationFriendAddedNotificationHandler extends CallbackHandler {

private static final List<CaseEvent> EVENTS = List.of(NOTIFY_EVENT);

public static final String TASK_ID = "LitigationFriendAddedNotifier";

private final AddDefendantLitigationFriendNotifier addDefendantLitigationFriendNotifier;

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

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

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

private CallbackResponse notifyForLitigationFriendAdded(CallbackParams callbackParams) {
addDefendantLitigationFriendNotifier.notifyParties(callbackParams.getCaseData(), TASK_ID);

return AboutToStartOrSubmitCallbackResponse.builder().build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package uk.gov.hmcts.reform.civil.model;

public enum NotificationParty {
APPLICANT_1,
APPLICANT_2,
DEFENDANT_1,
DEFENDANT_2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package uk.gov.hmcts.reform.civil.notification.handlers;

import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;
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 uk.gov.hmcts.reform.civil.service.OrganisationService;
import uk.gov.hmcts.reform.civil.service.flowstate.SimpleStateFlowEngine;
import uk.gov.hmcts.reform.dashboard.repositories.NotificationExceptionRecordRepository;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import static uk.gov.hmcts.reform.civil.model.NotificationParty.APPLICANT_1;
import static uk.gov.hmcts.reform.civil.model.NotificationParty.DEFENDANT_1;
import static uk.gov.hmcts.reform.civil.model.NotificationParty.DEFENDANT_2;
import static uk.gov.hmcts.reform.civil.service.flowstate.FlowFlag.TWO_RESPONDENT_REPRESENTATIVES;
import static uk.gov.hmcts.reform.civil.utils.NotificationUtils.buildPartiesReferencesEmailSubject;
import static uk.gov.hmcts.reform.civil.utils.NotificationUtils.getApplicantLegalOrganizationName;
import static uk.gov.hmcts.reform.civil.utils.NotificationUtils.getLegalOrganizationNameForRespondent;

@Component
@Slf4j
public class AddDefendantLitigationFriendNotifier extends Notifier {

private static final String REFERENCE_TEMPLATE_APPLICANT = "litigation-friend-added-applicant-notification-%s";
private static final String REFERENCE_TEMPLATE_RESPONDENT = "litigation-friend-added-respondent-notification-%s";

public AddDefendantLitigationFriendNotifier(NotificationService notificationService,
NotificationsProperties notificationsProperties,
OrganisationService organisationService,
SimpleStateFlowEngine stateFlowEngine,
NotificationExceptionRecordRepository exceptionRecordRepository) {
super(notificationService, notificationsProperties, organisationService, stateFlowEngine, exceptionRecordRepository);
}

@Override
public Map<String, String> addProperties(CaseData caseData) {
return new HashMap<>(Map.of(
CLAIM_REFERENCE_NUMBER, caseData.getCcdCaseReference().toString(),
PARTY_REFERENCES, buildPartiesReferencesEmailSubject(caseData)
));
}

@Override
@NotNull
protected Set<EmailDTO> getPartiesToNotify(final CaseData caseData) {
Set<EmailDTO> partiesToEmail = new HashSet<>();
partiesToEmail.add(getApplicant(caseData));
partiesToEmail.addAll(getRespondents(caseData));
return partiesToEmail;
}

private EmailDTO getApplicant(CaseData caseData) {
Map<String, String> properties = addProperties(caseData);
properties.put(CLAIM_LEGAL_ORG_NAME_SPEC, getApplicantLegalOrganizationName(caseData, organisationService));
return EmailDTO.builder()
.targetEmail(caseData.getApplicantSolicitor1UserDetails().getEmail())
.party(APPLICANT_1)
.emailTemplate(notificationsProperties.getSolicitorLitigationFriendAdded())
.parameters(properties)
.reference(String.format(REFERENCE_TEMPLATE_APPLICANT, caseData.getLegacyCaseReference()))
.build();
}

private Set<EmailDTO> getRespondents(CaseData caseData) {
Set<EmailDTO> recipients = new HashSet<>();
recipients.add(getRespondent(caseData, true));
if (stateFlowEngine.evaluate(caseData).isFlagSet(TWO_RESPONDENT_REPRESENTATIVES)) {
recipients.add(getRespondent(caseData, false));
}

return recipients;
}

private EmailDTO getRespondent(CaseData caseData, boolean isRespondent1) {
Map<String, String> properties = addProperties(caseData);
properties.put(CLAIM_LEGAL_ORG_NAME_SPEC, getLegalOrganizationNameForRespondent(caseData,
isRespondent1, organisationService));

return EmailDTO.builder()
.targetEmail(isRespondent1 ? caseData.getRespondentSolicitor1EmailAddress() : caseData.getRespondentSolicitor2EmailAddress())
.emailTemplate(notificationsProperties.getSolicitorLitigationFriendAdded())
.parameters(properties)
.party(isRespondent1 ? DEFENDANT_1 : DEFENDANT_2)
.reference(String.format(REFERENCE_TEMPLATE_RESPONDENT, caseData.getLegacyCaseReference()))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package uk.gov.hmcts.reform.civil.notification.handlers;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import uk.gov.hmcts.reform.civil.model.NotificationParty;

import java.util.Map;

@Data
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class EmailDTO {

private String targetEmail;
private NotificationParty party;
private String emailTemplate;
private Map<String, String> parameters;
private String reference;
}
Loading
Loading