-
Notifications
You must be signed in to change notification settings - Fork 2
Added logic for creation, mangemnet and display of case links #1527
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
base: master
Are you sure you want to change the base?
Changes from all commits
6d15c22
e0a2d81
931e7ea
645a043
e84bdcd
0f64f6a
9519c00
67afd9e
a925e2f
aeddb7a
4d49560
d2115fa
c1966d3
81d21cd
91f8f06
993ccf4
6e13ebb
ac43cd0
3922036
cbdee92
ce7a640
26e23f7
b011d5a
1139553
f8d4e88
354c908
05939c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.accesscontrol; | ||
|
|
||
| import com.google.common.collect.HashMultimap; | ||
| import com.google.common.collect.SetMultimap; | ||
| import uk.gov.hmcts.ccd.sdk.api.HasAccessControl; | ||
| import uk.gov.hmcts.ccd.sdk.api.HasRole; | ||
| import uk.gov.hmcts.ccd.sdk.api.Permission; | ||
|
|
||
| import static uk.gov.hmcts.reform.pcs.ccd.accesscontrol.UserRole.PCS_CASE_WORKER; | ||
| import static uk.gov.hmcts.reform.pcs.ccd.accesscontrol.UserRole.PCS_SOLICITOR; | ||
|
|
||
| public class CaseLinkingAccess implements HasAccessControl { | ||
|
|
||
|
|
||
| @Override | ||
| public SetMultimap<HasRole, Permission> getGrants() { | ||
| SetMultimap<HasRole, Permission> grants = HashMultimap.create(); | ||
| grants.putAll(PCS_SOLICITOR, Permission.CRU); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the Delete missing for permissions ? In the event - CreateCaseLink class, solicitor has full CRUD access.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The access profile in CaseLinkinAccess is applied to the fields in PCSCase (for updating cases) do not need the Delete permission in association with the events CreateCaseLink and MaintainLinkCase. In the event class CreateCaseLink, we only need the permissions CRU, whereas in the event class MaintainLinkCase, we need the Delete permission as well. Hence I will remove the Delete permission in CreateCaseLink and keep it in MaintainLinkCase. I will keep CRU in CaseLinkinAccess class |
||
| grants.put(PCS_CASE_WORKER, Permission.R); | ||
|
|
||
| return grants; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.entity; | ||
|
|
||
| import jakarta.persistence.CascadeType; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import jakarta.persistence.OneToMany; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| @Entity | ||
| @Table(name = "case_link") | ||
| @Setter | ||
| @Getter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class CaseLinkEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.UUID) | ||
| private UUID id; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "case_id") | ||
| private PcsCaseEntity pcsCase; | ||
|
|
||
| @Column(name = "linked_case_reference", nullable = false) | ||
| private Long linkedCaseReference; | ||
|
|
||
| @Column(name = "ccd_list_id") | ||
| private String ccdListId; | ||
|
|
||
| @OneToMany(mappedBy = "caseLink", | ||
| cascade = CascadeType.ALL, | ||
| orphanRemoval = true) | ||
| @Builder.Default | ||
| private List<CaseLinkReasonEntity> reasons = new ArrayList<>(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.entity; | ||
|
|
||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
|
|
||
| import java.util.UUID; | ||
|
|
||
| @Entity | ||
| @Table(name = "case_link_reason") | ||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Builder | ||
| public class CaseLinkReasonEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.UUID) | ||
| private UUID id; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY, optional = false) | ||
| @JoinColumn(name = "case_link_id") | ||
| private CaseLinkEntity caseLink; | ||
|
|
||
| @Column(name = "reason_code", nullable = false) | ||
| private String reasonCode; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.event; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Component; | ||
| import uk.gov.hmcts.ccd.sdk.api.CCDConfig; | ||
| import uk.gov.hmcts.ccd.sdk.api.DecentralisedConfigBuilder; | ||
| import uk.gov.hmcts.ccd.sdk.api.EventPayload; | ||
| import uk.gov.hmcts.ccd.sdk.api.Permission; | ||
| import uk.gov.hmcts.ccd.sdk.api.callback.SubmitResponse; | ||
| import uk.gov.hmcts.reform.pcs.ccd.accesscontrol.UserRole; | ||
| import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.State; | ||
| import uk.gov.hmcts.reform.pcs.ccd.service.PcsCaseService; | ||
|
|
||
| @Component | ||
| @Slf4j | ||
| @AllArgsConstructor | ||
| public class CreateCaseLink implements CCDConfig<PCSCase, State, UserRole> { | ||
|
|
||
| private final PcsCaseService pcsCaseService; | ||
|
|
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra space |
||
| @Override | ||
| public void configureDecentralised(DecentralisedConfigBuilder<PCSCase, State, UserRole> configBuilder) { | ||
| new PageBuilder(configBuilder | ||
| .decentralisedEvent(EventId.createCaseLink.name(), this::submit) | ||
| .forAllStates() | ||
| .name("Link cases") | ||
| .description("To link related cases") | ||
| .grant(Permission.R, UserRole.PCS_CASE_WORKER) | ||
| .grant(Permission.CRU,UserRole.PCS_SOLICITOR)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space needed |
||
| .page("createCaseLink") | ||
| .pageLabel("Case Link") | ||
| .optional(PCSCase::getCaseLinks,"LinkedCasesComponentLauncher = \"DONOTSHOW\"",null,true) | ||
| .optional(PCSCase::getLinkedCasesComponentLauncher, | ||
| null,null,null,null,"#ARGUMENT(CREATE,LinkedCases)"); | ||
|
|
||
| } | ||
|
|
||
| private SubmitResponse<State> submit(EventPayload<PCSCase, State> eventPayload) { | ||
| long caseReference = eventPayload.caseReference(); | ||
| PCSCase pcsCase = eventPayload.caseData(); | ||
|
|
||
| log.info("Caseworker created case link for {}", caseReference); | ||
|
|
||
| pcsCaseService.patchCaseLinks(caseReference, pcsCase); | ||
|
|
||
| return SubmitResponse.defaultResponse(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.event; | ||
|
|
||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Component; | ||
| import uk.gov.hmcts.ccd.sdk.api.CCDConfig; | ||
| import uk.gov.hmcts.ccd.sdk.api.DecentralisedConfigBuilder; | ||
| import uk.gov.hmcts.ccd.sdk.api.EventPayload; | ||
| import uk.gov.hmcts.ccd.sdk.api.Permission; | ||
| import uk.gov.hmcts.ccd.sdk.api.callback.SubmitResponse; | ||
| import uk.gov.hmcts.reform.pcs.ccd.accesscontrol.UserRole; | ||
| import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.PCSCase; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.State; | ||
| import uk.gov.hmcts.reform.pcs.ccd.service.PcsCaseService; | ||
|
|
||
| @Component | ||
| @Slf4j | ||
| @AllArgsConstructor | ||
| public class MaintainLinkCase implements CCDConfig<PCSCase, State, UserRole> { | ||
|
|
||
| private final PcsCaseService pcsCaseService; | ||
|
|
||
| @Override | ||
| public void configureDecentralised(DecentralisedConfigBuilder<PCSCase, State, UserRole> configBuilder) { | ||
| new PageBuilder(configBuilder | ||
| .decentralisedEvent(EventId.maintainCaseLink.name(), this::submit) | ||
| .forAllStates() | ||
| .name("Manage case links") | ||
| .description("To manage link related cases") | ||
| .grant(Permission.R, UserRole.PCS_CASE_WORKER) | ||
| .grant(Permission.CRUD, UserRole.PCS_SOLICITOR)) | ||
| .page("maintainCaseLink") | ||
| .pageLabel("Case Link") | ||
| .optional(PCSCase::getCaseLinks, "LinkedCasesComponentLauncher = \"DONOTSHOW\"", null, true) | ||
| .optional(PCSCase::getLinkedCasesComponentLauncher, | ||
| null, null, null, null, "#ARGUMENT(UPDATE,LinkedCases)"); | ||
| } | ||
|
|
||
|
|
||
| private SubmitResponse<State> submit(EventPayload<PCSCase, State> eventPayload) { | ||
| long caseReference = eventPayload.caseReference(); | ||
| PCSCase pcsCase = eventPayload.caseData(); | ||
|
|
||
| log.info("Caseworker updated case link for {}", caseReference); | ||
|
|
||
| pcsCaseService.patchCaseLinks(caseReference, pcsCase); | ||
|
|
||
| return SubmitResponse.defaultResponse(); | ||
| } | ||
|
|
||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would returning an immutable set be approriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this matches what the other Access classes have at the moment, so if there was to be a change then it should be done to all of them. Perhaps as a separate house keeping ticket?