-
Notifications
You must be signed in to change notification settings - Fork 2
added event seperate to additionalDocumenets #1865
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
Merged
Merged
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
ff2713b
added event seperate to additionalDocumenets
fudge88 bdb562a
fixed test
fudge88 f7e4d12
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 54d5961
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 4a0f4a0
ccd label
fudge88 e1ef3af
annotation fix
fudge88 c162f70
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 7555997
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 6a9df4b
merged master - gen apps
fudge88 ce5c129
Merge branch 'HDPI-6159-upload-additional-doc-event' of github.com:hm…
fudge88 df1917d
docmuemnt name service from 1839, refactored start call back, genappi…
fudge88 0c68703
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 86e251e
uuid to string type
fudge88 14690ca
checkstyle fix
fudge88 77fc89d
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 9250628
supress sonar warnings fixed test
fudge88 dc98d33
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 24e3f4e
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
mazzopardi2 cb3e905
merge conflict
fudge88 ef04149
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
marianadpereira 56d4053
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
mazzopardi2 89d559c
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 710e3e1
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 f063659
null guard
fudge88 068b18a
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 b04166e
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 609ade5
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 68e1800
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 39b8665
updated appsubmitteddate
fudge88 0db0494
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 e6d3660
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 7ccf6c9
Merge branches 'HDPI-6159-upload-additional-doc-event' and 'HDPI-6159…
fudge88 b449ba4
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 b739797
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 60b34a1
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 9216b92
trigger CI
fudge88 45ad8a8
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 5968c0e
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 5d3f414
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
lovelin-07 41eda3b
Trigger preview redeploy
mazzopardi2 c3da421
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
mazzopardi2 493676e
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 e69087f
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 96b257a
HDPI-7064 - document id needs to be set where applicable
guygrewal77 621438d
HDPI-7064 - Sonar Qube fix to return empty list instead of null.
guygrewal77 f8c9307
Merge branch 'master' into HDPI-7064-document-id-null-bug
guygrewal77 0342f46
HDPI-7064 - Unit test fix
guygrewal77 30f85c4
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
mazzopardi2 3e11055
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 156dd70
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 d1a8353
Merge branch 'master' into HDPI-7064-document-id-null-bug
guygrewal77 20c0d2d
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 0284a86
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 fad4622
Merge branch 'HDPI-7064-document-id-null-bug' into HDPI-6159-upload-a…
fudge88 a264029
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 4ae3742
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 cda8a35
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
Rupali754 a418b7d
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 6ac8dcb
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
Rupali754 db4b0ba
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
adusumillipraveen 3f81072
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 ba4f1d9
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 faccdf1
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 798b20b
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
Rupali754 233d7c6
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
lovelin-07 7a3e859
test commit
fudge88 5c2b0ab
updated vars to genapps new vars
fudge88 f679115
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 bf7202f
Hdpi 7026 without notice doc upload flow for dashboard (#1945)
fudge88 d4508ae
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 c670ed8
Merge branch 'master' into HDPI-6159-upload-additional-doc-event
fudge88 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
16 changes: 16 additions & 0 deletions
16
src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/documentupload/DocumentUploadCategory.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,16 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.domain.documentupload; | ||
|
|
||
| import uk.gov.hmcts.ccd.sdk.api.HasLabel; | ||
|
|
||
| public enum DocumentUploadCategory implements HasLabel { | ||
|
|
||
| ADJOURN_HEARING_APPLICATION, | ||
| SUSPEND_EVICTION_APPLICATION, | ||
| SET_ASIDE_ORDER_APPLICATION, | ||
| GENERAL_APPLICATION; | ||
|
|
||
| @Override | ||
| public String getLabel() { | ||
| return name(); | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
src/main/java/uk/gov/hmcts/reform/pcs/ccd/domain/documentupload/DocumentUploadDetails.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,40 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.domain.documentupload; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
| 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.ListValue; | ||
| import uk.gov.hmcts.ccd.sdk.type.YesOrNo; | ||
| import uk.gov.hmcts.reform.pcs.ccd.accesscontrol.DefendantAccess; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Builder | ||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @JsonInclude(Include.NON_NULL) | ||
| public class DocumentUploadDetails { | ||
|
|
||
| @CCD( | ||
| access = {DefendantAccess.class}, | ||
| searchable = false | ||
| ) | ||
| private YesOrNo showRelatedApplicationsPage; | ||
|
|
||
| @CCD( | ||
| access = {DefendantAccess.class}, | ||
| searchable = false | ||
| ) | ||
| private List<ListValue<RelatedApplicationOption>> relatedApplicationOptions; | ||
|
|
||
| @CCD( | ||
| access = {DefendantAccess.class}, | ||
| searchable = false | ||
| ) | ||
| private String selectedRelatedApplicationId; | ||
| } |
22 changes: 22 additions & 0 deletions
22
...main/java/uk/gov/hmcts/reform/pcs/ccd/domain/documentupload/RelatedApplicationOption.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.documentupload; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| @Builder | ||
| @Data | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @JsonInclude(Include.NON_NULL) | ||
| public class RelatedApplicationOption { | ||
|
|
||
| private String genAppId; | ||
| private DocumentUploadCategory category; | ||
| private LocalDateTime submittedDate; | ||
| } |
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
149 changes: 149 additions & 0 deletions
149
src/main/java/uk/gov/hmcts/reform/pcs/ccd/event/citizen/UploadDocuments.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,149 @@ | ||
| package uk.gov.hmcts.reform.pcs.ccd.event.citizen; | ||
|
|
||
| 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.ccd.sdk.type.ListValue; | ||
| import uk.gov.hmcts.ccd.sdk.type.YesOrNo; | ||
| import uk.gov.hmcts.reform.pcs.ccd.ShowConditions; | ||
| import uk.gov.hmcts.reform.pcs.ccd.accesscontrol.UserRole; | ||
| 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.documentupload.DocumentUploadCategory; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.documentupload.DocumentUploadDetails; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.documentupload.RelatedApplicationOption; | ||
| import uk.gov.hmcts.reform.pcs.ccd.domain.genapp.GenAppType; | ||
| import uk.gov.hmcts.reform.pcs.ccd.entity.GenAppEntity; | ||
| 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.service.PcsCaseService; | ||
| import uk.gov.hmcts.reform.pcs.ccd.service.document.DocumentService; | ||
| import uk.gov.hmcts.reform.pcs.ccd.service.genapp.GenAppVisibilityService; | ||
| import uk.gov.hmcts.reform.pcs.ccd.service.party.PartyService; | ||
| import uk.gov.hmcts.reform.pcs.security.SecurityContextService; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import java.util.UUID; | ||
|
|
||
| import static uk.gov.hmcts.reform.pcs.ccd.event.EventId.uploadDocuments; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
| @AllArgsConstructor | ||
| public class UploadDocuments implements CCDConfig<PCSCase, State, UserRole> { | ||
|
|
||
| private final PcsCaseService pcsCaseService; | ||
| private final PartyService partyService; | ||
| private final SecurityContextService securityContextService; | ||
| private final DocumentService documentService; | ||
| private final GenAppVisibilityService genAppVisibilityService; | ||
|
|
||
| @Override | ||
| public void configureDecentralised(DecentralisedConfigBuilder<PCSCase, State, UserRole> configBuilder) { | ||
| configBuilder | ||
| .decentralisedEvent(uploadDocuments.name(), this::submit, this::start) | ||
| .forStates(State.CASE_ISSUED) | ||
| .name("Upload additional documents") | ||
| .showCondition(ShowConditions.NEVER_SHOW) | ||
| .grant(Permission.CRU, UserRole.DEFENDANT); | ||
| } | ||
|
|
||
| private PCSCase start(EventPayload<PCSCase, State> eventPayload) { | ||
| long caseReference = eventPayload.caseReference(); | ||
| PCSCase caseData = eventPayload.caseData(); | ||
|
|
||
| if (caseData.getDocumentUploadDetails() == null) { | ||
| caseData.setDocumentUploadDetails(new DocumentUploadDetails()); | ||
| } | ||
|
|
||
| PcsCaseEntity pcsCaseEntity = pcsCaseService.loadCase(caseReference); | ||
| UUID currentUserId = securityContextService.getCurrentUserId(); | ||
|
|
||
| List<ListValue<RelatedApplicationOption>> options = | ||
| visibleGenAppsForUser(pcsCaseEntity, currentUserId).stream() | ||
| .map(this::toOption) | ||
| .filter(Objects::nonNull) | ||
| .toList(); | ||
|
|
||
| caseData.getDocumentUploadDetails().setRelatedApplicationOptions(new ArrayList<>(options)); | ||
|
|
||
| caseData.getDocumentUploadDetails().setShowRelatedApplicationsPage( | ||
| options.isEmpty() ? YesOrNo.NO : YesOrNo.YES); | ||
|
|
||
| return caseData; | ||
| } | ||
|
|
||
| private List<GenAppEntity> visibleGenAppsForUser(PcsCaseEntity pcsCaseEntity, UUID currentUserId) { | ||
| return genAppVisibilityService.getVisibleGenAppsToUser(pcsCaseEntity.getGenApps(), currentUserId); | ||
| } | ||
|
|
||
| private ListValue<RelatedApplicationOption> toOption(GenAppEntity genApp) { | ||
| DocumentUploadCategory category = mapGenAppTypeToCategory(genApp.getType()); | ||
| if (category == null) { | ||
| return null; | ||
| } | ||
| RelatedApplicationOption option = RelatedApplicationOption.builder() | ||
| .genAppId(genApp.getId().toString()) | ||
| .category(category) | ||
| .submittedDate(genApp.getApplicationSubmittedDate()) | ||
| .build(); | ||
| return ListValue.<RelatedApplicationOption>builder() | ||
| .id(genApp.getId().toString()) | ||
| .value(option) | ||
| .build(); | ||
| } | ||
|
|
||
| private DocumentUploadCategory mapGenAppTypeToCategory(GenAppType type) { | ||
| if (type == null) { | ||
| return null; | ||
|
fudge88 marked this conversation as resolved.
|
||
| } | ||
| return switch (type) { | ||
| case ADJOURN -> DocumentUploadCategory.ADJOURN_HEARING_APPLICATION; | ||
| case SET_ASIDE -> DocumentUploadCategory.SET_ASIDE_ORDER_APPLICATION; | ||
| case SOMETHING_ELSE -> DocumentUploadCategory.GENERAL_APPLICATION; | ||
| }; | ||
| } | ||
|
|
||
| private SubmitResponse<State> submit(EventPayload<PCSCase, State> eventPayload) { | ||
| long caseReference = eventPayload.caseReference(); | ||
| PCSCase caseData = eventPayload.caseData(); | ||
|
|
||
| PcsCaseEntity pcsCaseEntity = pcsCaseService.loadCase(caseReference); | ||
| UUID currentUserId = securityContextService.getCurrentUserId(); | ||
| PartyEntity uploadingParty = partyService.getPartyEntityByIdamId(currentUserId, caseReference); | ||
| GenAppEntity selectedGenApp = resolveSelectedGenApp(caseData, pcsCaseEntity, currentUserId); | ||
|
|
||
| documentService.linkAdditionalDocumentsToCase( | ||
| caseData.getUploadedAdditionalDocuments(), | ||
| pcsCaseEntity, | ||
| uploadingParty, | ||
| selectedGenApp | ||
| ); | ||
|
|
||
| return SubmitResponse.<State>builder().build(); | ||
| } | ||
|
|
||
| private GenAppEntity resolveSelectedGenApp(PCSCase caseData, PcsCaseEntity pcsCaseEntity, UUID currentUserId) { | ||
| DocumentUploadDetails details = caseData.getDocumentUploadDetails(); | ||
| if (details == null || details.getSelectedRelatedApplicationId() == null) { | ||
| return null; | ||
|
fudge88 marked this conversation as resolved.
|
||
| } | ||
| UUID selectedId; | ||
| try { | ||
| selectedId = UUID.fromString(details.getSelectedRelatedApplicationId()); | ||
| } catch (IllegalArgumentException e) { | ||
| return null; | ||
| } | ||
| return visibleGenAppsForUser(pcsCaseEntity, currentUserId).stream() | ||
| .filter(genApp -> selectedId.equals(genApp.getId())) | ||
| .findFirst() | ||
| .orElse(null); | ||
| } | ||
| } | ||
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
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.