-
Notifications
You must be signed in to change notification settings - Fork 2
HDPI-6636: Caseworker gen apps #2144
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
Open
libanAbdirahman1
wants to merge
9
commits into
master
Choose a base branch
from
HDPI-6636-Caseworker-genapps
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bc958df
HDPI-6636:WIP
libanAbdirahman1 cfa84d2
HDPI-6636:Adding tests and text area validation
libanAbdirahman1 7762c0c
Merge remote-tracking branch 'origin' into HDPI-6636-Caseworker-genapps
libanAbdirahman1 625ac69
HDPI-6636:Relocating nested complex type
libanAbdirahman1 ebc0ef5
HDPI-6636:Moving event, domain and page classes to caseworker subpack…
libanAbdirahman1 3aba89e
Merge remote-tracking branch 'origin' into HDPI-6636-Caseworker-genapps
libanAbdirahman1 73bb24b
Merge branch 'master' into HDPI-6636-Caseworker-genapps
scottstewart-sl 4071883
HDPI-6636:Adding gen app persistence on submit
libanAbdirahman1 8e868bf
HDPI-6636:Adding application submitted date to resolve NPE
libanAbdirahman1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/main/java/uk/gov/hmcts/reform/pcs/ccd/accesscontrol/CaseworkerRoles.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.accesscontrol; | ||
|
|
||
| public final class CaseworkerRoles { | ||
|
|
||
| public static final UserRole[] CASEWORKER_ROLES = { | ||
| UserRole.HEARING_CENTRE_TEAM_LEADER, | ||
| UserRole.HEARING_CENTRE_ADMIN, | ||
| }; | ||
|
|
||
| private CaseworkerRoles() { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/caseworker/EnterGenAppRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.domain.caseworker; | ||
|
|
||
| import com.fasterxml.jackson.databind.PropertyNamingStrategies; | ||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
| import uk.gov.hmcts.ccd.sdk.api.CCD; | ||
| import uk.gov.hmcts.ccd.sdk.type.FieldType; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.VerticalYesNo; | ||
|
|
||
| import java.time.LocalDate; | ||
|
|
||
| @Builder | ||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy.class) | ||
| public class EnterGenAppRequest { | ||
|
|
||
| @CCD(label = "What date was the application received?") | ||
| private LocalDate dateReceived; | ||
|
|
||
| @CCD(label = "Which type of application has the applicant made?") | ||
| private EnterGenAppType applicationTypeOption; | ||
|
|
||
| @CCD( | ||
| label = "Which categories apply?", | ||
| typeOverride = FieldType.TextArea | ||
| ) | ||
| private String somethingElseDetails; | ||
|
|
||
| @CCD(label = "Is there a hearing for this case in the next 14 days?") | ||
| private VerticalYesNo within14Days; | ||
|
|
||
| @CCD(label = "Has the applicant included a Help With Fees reference number on their application") | ||
| private VerticalYesNo appliedForHwf; | ||
|
|
||
| @CCD( | ||
| label = "Enter their Help with Fees reference number", | ||
| max = 60 | ||
| ) | ||
| private String hwfReference; | ||
|
|
||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/caseworker/EnterGenAppType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.domain.caseworker; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import uk.gov.hmcts.ccd.sdk.api.HasLabel; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.genapp.GenAppType; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public enum EnterGenAppType implements HasLabel { | ||
|
|
||
| ADJOURN("Adjourn"), | ||
| SET_ASIDE("Set aside"), | ||
| SOMETHING_ELSE("Something else"); | ||
|
|
||
| private final String label; | ||
|
|
||
| public GenAppType getStandardGenAppType() { | ||
| return GenAppType.valueOf(name()); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,5 +18,6 @@ public enum EventId { | |
| addCaseNote, | ||
| createFlags, | ||
| amendFlags, | ||
| claimIssuePayment | ||
| claimIssuePayment, | ||
| enterGenApp | ||
| } | ||
108 changes: 108 additions & 0 deletions
108
src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/caseworker/entergenapp/EnterGenApp.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.event.caseworker.entergenapp; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| 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.Event; | ||
| 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.ccd.sdk.type.DynamicList; | ||
| import uk.gov.hmcts.ccd.sdk.type.DynamicListElement; | ||
| 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.domain.VerticalYesNo; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.genapp.GenAppState; | ||
| import uk.gov.hmcts.reform.pcs.ccd.entity.ClaimEntity; | ||
| import uk.gov.hmcts.reform.pcs.ccd.entity.PcsCaseEntity; | ||
| import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyEntity; | ||
| import uk.gov.hmcts.reform.pcs.ccd.entity.party.PartyRole; | ||
| import uk.gov.hmcts.reform.pcs.ccd.page.caseworker.entergenapp.ApplicationDetails; | ||
| import uk.gov.hmcts.reform.pcs.ccd.page.caseworker.entergenapp.ApplicationFee; | ||
| import uk.gov.hmcts.reform.pcs.ccd.page.caseworker.entergenapp.HearingDate; | ||
| import uk.gov.hmcts.reform.pcs.ccd.service.PcsCaseService; | ||
| import uk.gov.hmcts.reform.pcs.ccd.service.genapp.GenAppService; | ||
| import uk.gov.hmcts.reform.pcs.ccd.service.party.PartyService; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import static uk.gov.hmcts.reform.pcs.ccd.accesscontrol.CaseworkerRoles.CASEWORKER_ROLES; | ||
| import static uk.gov.hmcts.reform.pcs.ccd.accesscontrol.JudicialHistoryRoles.JUDICIAL_HISTORY_ROLES; | ||
| import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.enterGenApp; | ||
|
|
||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class EnterGenApp implements CCDConfig<PCSCase, State, UserRole> { | ||
|
|
||
| private final PcsCaseService pcsCaseService; | ||
| private final PartyService partyService; | ||
| private final ApplicationDetails applicationDetails; | ||
| private final GenAppService genAppService; | ||
|
|
||
| @Override | ||
| public void configureDecentralised(DecentralisedConfigBuilder<PCSCase, State, UserRole> configBuilder) { | ||
| Event.EventBuilder<PCSCase, UserRole, State> eventBuilder = configBuilder | ||
| .decentralisedEvent(enterGenApp.name(), this::submit, this::start) | ||
| .forStates(State.CASE_ISSUED) | ||
| .name("Enter a general application") | ||
| .grant(Permission.CRU, CASEWORKER_ROLES) | ||
| .grantHistoryOnly(JUDICIAL_HISTORY_ROLES); | ||
|
|
||
| new PageBuilder(eventBuilder) | ||
| .add(applicationDetails) | ||
| .add(new HearingDate()) | ||
| .add(new ApplicationFee()); | ||
| } | ||
|
|
||
| private PCSCase start(EventPayload<PCSCase, State> eventPayload) { | ||
| PCSCase caseData = eventPayload.caseData(); | ||
|
|
||
| PcsCaseEntity pcsCaseEntity = pcsCaseService.loadCase(eventPayload.caseReference()); | ||
| ClaimEntity mainClaim = pcsCaseEntity.getClaims().getFirst(); | ||
|
|
||
| caseData.setPartyRadioList(buildApplicantPartyList(mainClaim)); | ||
|
|
||
| return caseData; | ||
| } | ||
|
|
||
| private DynamicList buildApplicantPartyList(ClaimEntity mainClaim) { | ||
| List<DynamicListElement> listItems = mainClaim.getClaimParties().stream() | ||
| .filter(claimPartyEntity -> claimPartyEntity.getRole() == PartyRole.CLAIMANT | ||
| || claimPartyEntity.getRole() == PartyRole.DEFENDANT) | ||
| .map(claimPartyEntity -> DynamicListElement.builder() | ||
| .code(claimPartyEntity.getParty().getId()) | ||
| .label("%s - %s".formatted( | ||
| buildPartyDisplayName(claimPartyEntity.getParty()), | ||
| partyService.getPartyLabel(mainClaim, claimPartyEntity.getParty().getId()) | ||
| )) | ||
| .build()) | ||
| .toList(); | ||
|
|
||
| return DynamicList.builder().listItems(listItems).build(); | ||
| } | ||
|
|
||
| private String buildPartyDisplayName(PartyEntity partyEntity) { | ||
| if (partyEntity.getNameKnown() == VerticalYesNo.NO) { | ||
| return "Person unknown"; | ||
| } | ||
| return partyService.getPartyName(partyEntity); | ||
| } | ||
|
|
||
| private SubmitResponse<State> submit(EventPayload<PCSCase, State> eventPayload) { | ||
| long caseReference = eventPayload.caseReference(); | ||
| PCSCase caseData = eventPayload.caseData(); | ||
|
|
||
| PcsCaseEntity pcsCaseEntity = pcsCaseService.loadCase(caseReference); | ||
| PartyEntity applicantParty = partyService.getPartyEntityByEntityId( | ||
| caseData.getPartyRadioList().getValueCode(), caseReference); | ||
|
|
||
| genAppService.createGenAppEntity( | ||
| caseData.getEnterGenAppRequest(), pcsCaseEntity, applicantParty, GenAppState.GEN_APP_ISSUED); | ||
|
|
||
| return SubmitResponse.<State>builder().build(); | ||
| } | ||
|
|
||
| } | ||
67 changes: 67 additions & 0 deletions
67
...main/java/uk/gov/hmcts/reform/pcs/ccd/page/caseworker/entergenapp/ApplicationDetails.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.page.caseworker.entergenapp; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import org.springframework.stereotype.Component; | ||
| import uk.gov.hmcts.ccd.sdk.api.CaseDetails; | ||
| import uk.gov.hmcts.ccd.sdk.api.callback.AboutToStartOrSubmitResponse; | ||
| import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; | ||
| 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.domain.caseworker.EnterGenAppRequest; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.caseworker.EnterGenAppType; | ||
| import uk.gov.hmcts.reform.pcs.ccd.service.TextAreaValidationService; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import static uk.gov.hmcts.reform.pcs.ccd.ShowConditions.fieldEquals; | ||
|
|
||
| @AllArgsConstructor | ||
| @Component | ||
| public class ApplicationDetails implements CcdPageConfiguration { | ||
|
|
||
| private static final String SOMETHING_ELSE_DETAILS_LABEL = "Which categories apply"; | ||
|
|
||
| private final TextAreaValidationService textAreaValidationService; | ||
|
|
||
| @Override | ||
| public void addTo(PageBuilder pageBuilder) { | ||
| pageBuilder | ||
| .page("applicationDetails", this::midEvent) | ||
| .pageLabel("Application details") | ||
| .label("applicationDetails-lineSeparator", "---") | ||
| .mandatory(PCSCase::getPartyRadioList) | ||
| .complex(PCSCase::getEnterGenAppRequest) | ||
| .mandatory(EnterGenAppRequest::getDateReceived) | ||
| .mandatory(EnterGenAppRequest::getApplicationTypeOption) | ||
| .mandatory( | ||
| EnterGenAppRequest::getSomethingElseDetails, | ||
| fieldEquals("enter_genapp_ApplicationTypeOption", EnterGenAppType.SOMETHING_ELSE) | ||
| ) | ||
| .done(); | ||
| } | ||
|
|
||
| private AboutToStartOrSubmitResponse<PCSCase, State> midEvent(CaseDetails<PCSCase, State> details, | ||
| CaseDetails<PCSCase, State> detailsBefore) { | ||
| PCSCase caseData = details.getData(); | ||
|
|
||
| List<String> validationErrors = validateSomethingElseDetails(caseData); | ||
|
|
||
| return textAreaValidationService.createValidationResponse(caseData, validationErrors); | ||
| } | ||
|
|
||
| private List<String> validateSomethingElseDetails(PCSCase caseData) { | ||
| EnterGenAppRequest enterGenAppRequest = caseData.getEnterGenAppRequest(); | ||
| if (enterGenAppRequest == null | ||
| || enterGenAppRequest.getApplicationTypeOption() != EnterGenAppType.SOMETHING_ELSE) { | ||
| return List.of(); | ||
| } | ||
|
|
||
| return textAreaValidationService.validateSingleTextArea( | ||
| enterGenAppRequest.getSomethingElseDetails(), | ||
| SOMETHING_ELSE_DETAILS_LABEL, | ||
| TextAreaValidationService.MEDIUM_TEXT_LIMIT | ||
| ); | ||
| } | ||
|
|
||
| } |
17 changes: 17 additions & 0 deletions
17
src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/caseworker/entergenapp/ApplicationFee.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.page.caseworker.entergenapp; | ||
|
|
||
| import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; | ||
| import uk.gov.hmcts.reform.pcs.ccd.common.PageBuilder; | ||
|
|
||
| public class ApplicationFee implements CcdPageConfiguration { | ||
|
|
||
| @Override | ||
| public void addTo(PageBuilder pageBuilder) { | ||
| pageBuilder | ||
| .page("applicationFee") | ||
| .pageLabel("Application fee") | ||
| .label("applicationFee-lineSeparator", "---") | ||
| .label("applicationFee-placeholder", "Application fee details(placeholder)"); | ||
| } | ||
|
|
||
| } |
25 changes: 25 additions & 0 deletions
25
src/main/java/uk/gov/hmcts/reform/pcs/ccd/page/caseworker/entergenapp/HearingDate.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.page.caseworker.entergenapp; | ||
|
|
||
| import uk.gov.hmcts.reform.pcs.ccd.common.CcdPageConfiguration; | ||
| 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.caseworker.EnterGenAppRequest; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.caseworker.EnterGenAppType; | ||
|
|
||
| import static uk.gov.hmcts.reform.pcs.ccd.ShowConditions.fieldEquals; | ||
|
|
||
| public class HearingDate implements CcdPageConfiguration { | ||
|
|
||
| @Override | ||
| public void addTo(PageBuilder pageBuilder) { | ||
| pageBuilder | ||
| .page("hearingDate") | ||
| .pageLabel("Hearing date") | ||
| .showCondition(fieldEquals("enter_genapp_ApplicationTypeOption", EnterGenAppType.ADJOURN)) | ||
| .label("hearingDate-lineSeparator", "---") | ||
| .complex(PCSCase::getEnterGenAppRequest) | ||
| .mandatory(EnterGenAppRequest::getWithin14Days) | ||
| .done(); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.