Skip to content

Commit

Permalink
DIAC-86 generate amended hearing bundle event (similar functionality … (
Browse files Browse the repository at this point in the history
#903)

* DIAC-86 generate amended hearing bundle event (similar functionality to customise hearing bundle but creates a new one)

* DIAC-86 generate amended hearing bundle event (similar functionality to customise hearing bundle but creates a new one)

* DIAC-86 updating tests

* DIAC-86 removing duplicated code and updating tests

* DIAC-86 removing duplicated code and updating tests

* DIAC-86 fix ?

* DIAC-86 stopping hearing bundle compounding by ignoring tag on generation

* DIAC-86 stopping hearing bundle compounding by ignoring tag on generation

* DIAC-86 stopping hearing bundle compounding by ignoring tag on generation

* DIAC-86 adding amended to hearing bundle file name if suitable

* DIAC-86 adding amended to hearing bundle file name if suitable

* DIAC-86 fixing customise and amended bundle missing aip docs

* DIAC-86 fixing customise and amended bundle missing aip docs

* DIAC-86 test fixes after merging in latest master

* DIAC-86 minor improvements

* DIAC-86 sonarqube code smell fixes

* DIAC-86 checkstyle fix

* DIAC-86 BREAKING BUNDLE FOR TESTING

* Revert "DIAC-86 BREAKING BUNDLE FOR TESTING"

This reverts commit 9b2e734.

* DIAC-86 potential fix for issue where reheard bundles are being seen as hearing notices

* DIAC-86 potential fix to stop any hearing bundle tagged documents from being visible in customiseHearingBundle and amendHearingBundle, so they wont have tags altered and will show correctly in frontend

* DIAC-86 functional test fix

* DIAC-86 slight fix

* Revert "DIAC-86 functional test fix"

This reverts commit 8cc1f34.

* DIAC-86 fix to remove hearingBundles from customiseHearingBundle and amendHearingBundle

* DIAC-86 fix retain dates and tags when restoring documents in collections

* DIAC-86 fix hiding reheard bundles in customise/amend bundle

* DIAC-86 functional test fix

* DIAC-86 fix for case of null tag

* DIAC-86 test fix

* DIAC-86 changing all instance of amended to updated

* DIAC-86 removing bundle count

* DIAC-86 removing bundle count

* DIAC-86 test fix

* DIAC-86 DocumentWithMetadata update with datetime

* DIAC-86 fixing addendum documents not showing in non reheard

* DIAC-86 adding new templates for updated hearing bundle to include addendum evidence before rehearing

* DIAC-86 fix to restore datetimeuploaded when updating bundle

* Disable flaky test

* fix checkstyle

* fix tests

* Update CustomiseHearingBundleHandler.java

---------

Co-authored-by: KleoG <[email protected]>
Co-authored-by: Aliveni Choppa <[email protected]>
Co-authored-by: alivenichoppa <[email protected]>
  • Loading branch information
4 people authored Dec 16, 2024
1 parent 19e96e8 commit 67d1405
Show file tree
Hide file tree
Showing 15 changed files with 826 additions and 468 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"description": "RIA-8721 AIP Update tribunal decision - AMENDED cover letter",
"description": "RIA-8721 AIP Update tribunal decision - UPDATED cover letter",
"request": {
"uri": "/asylum/ccdAboutToSubmit",
"credentials": "Judge",
Expand Down Expand Up @@ -39,7 +39,7 @@
"document": {
"document_url": "$/http.+\/documents/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/",
"document_binary_url": "$/http.+\/documents/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\/binary/",
"document_filename": "PA 12345 2018-Awan-Decision-and-reasons-Cover-letter-AMENDED.PDF"
"document_filename": "PA 12345 2018-Awan-Decision-and-reasons-Cover-letter-UPDATED.PDF"
},
"description": "",
"dateUploaded": "{$TODAY}"
Expand All @@ -56,7 +56,7 @@
"coverLetterDocument": {
"document_url": "$/http.+\/documents/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/",
"document_binary_url": "$/http.+\/documents/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\/binary/",
"document_filename": "PA 12345 2018-Awan-Decision-and-reasons-Cover-letter-AMENDED.PDF"
"document_filename": "PA 12345 2018-Awan-Decision-and-reasons-Cover-letter-UPDATED.PDF"
},
"dateCoverLetterDocumentUploaded": "{$TODAY}"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"description": "RIA-8721 Update tribunal decision - AMENDED cover letter",
"description": "RIA-8721 Update tribunal decision - UPDATED cover letter",
"request": {
"uri": "/asylum/ccdAboutToSubmit",
"credentials": "Judge",
Expand Down Expand Up @@ -45,7 +45,7 @@
"document": {
"document_url": "$/http.+\/documents/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/",
"document_binary_url": "$/http.+\/documents/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\/binary/",
"document_filename": "PA 11111 2019-Doe-Decision-and-reasons-Cover-letter-AMENDED.PDF"
"document_filename": "PA 11111 2019-Doe-Decision-and-reasons-Cover-letter-UPDATED.PDF"
},
"description": "",
"dateUploaded": "{$TODAY}"
Expand All @@ -62,7 +62,7 @@
"coverLetterDocument": {
"document_url": "$/http.+\/documents/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/",
"document_binary_url": "$/http.+\/documents/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\/binary/",
"document_filename": "PA 11111 2019-Doe-Decision-and-reasons-Cover-letter-AMENDED.PDF"
"document_filename": "PA 11111 2019-Doe-Decision-and-reasons-Cover-letter-UPDATED.PDF"
},
"dateCoverLetterDocumentUploaded": "{$TODAY}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum DocumentTag {
INTERNAL_ADA_SUITABILITY("internalAdaSuitability", CaseType.ASYLUM),
CASE_SUMMARY("caseSummary", CaseType.ASYLUM),
HEARING_BUNDLE("hearingBundle", CaseType.ASYLUM),
UPDATED_HEARING_BUNDLE("updatedHearingBundle", CaseType.ASYLUM),
ADDENDUM_EVIDENCE("addendumEvidence", CaseType.ASYLUM),
DECISION_AND_REASONS_DRAFT("decisionAndReasons", CaseType.ASYLUM),
REHEARD_DECISION_AND_REASONS_DRAFT("reheardDecisionAndReasons", CaseType.ASYLUM),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public enum Event {
ASYNC_STITCHING_COMPLETE("asyncStitchingComplete", CaseType.ASYLUM),
REQUEST_HEARING_REQUIREMENTS_FEATURE("requestHearingRequirementsFeature", CaseType.ASYLUM),
CUSTOMISE_HEARING_BUNDLE("customiseHearingBundle", CaseType.ASYLUM),
GENERATE_UPDATED_HEARING_BUNDLE("generateUpdatedHearingBundle", CaseType.ASYLUM),
GENERATE_DECISION_AND_REASONS("generateDecisionAndReasons", CaseType.ASYLUM),
ADA_SUITABILITY_REVIEW("adaSuitabilityReview", CaseType.ASYLUM),
SEND_DECISION_AND_REASONS("sendDecisionAndReasons", CaseType.ASYLUM),
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.Appender;
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.FeatureToggler;




@Component
public class CustomiseHearingBundlePreparer implements PreSubmitCallbackHandler<AsylumCase> {

Expand All @@ -41,7 +38,8 @@ public boolean canHandle(PreSubmitCallbackStage callbackStage, Callback<AsylumCa
requireNonNull(callback, "callback must not be null");

return callbackStage == PreSubmitCallbackStage.ABOUT_TO_START
&& callback.getEvent() == Event.CUSTOMISE_HEARING_BUNDLE;
&& (callback.getEvent() == Event.CUSTOMISE_HEARING_BUNDLE
|| callback.getEvent() == Event.GENERATE_UPDATED_HEARING_BUNDLE);
}

@Override
Expand All @@ -52,31 +50,35 @@ public PreSubmitCallbackResponse<AsylumCase> handle(PreSubmitCallbackStage callb

AsylumCase asylumCase = callback.getCaseDetails().getCaseData();

boolean isReheardCase = asylumCase.read(CASE_FLAG_SET_ASIDE_REHEARD_EXISTS, YesOrNo.class).map(flag -> flag.equals(YesOrNo.YES)).orElse(false)
&& featureToggler.getValue("reheard-feature", false);
boolean isUpdatedBundle = callback.getEvent() == Event.GENERATE_UPDATED_HEARING_BUNDLE;

prepareCustomDocuments(asylumCase, isReheardCase);
prepareCustomDocuments(asylumCase, isUpdatedBundle);

return new PreSubmitCallbackResponse<>(asylumCase);
}

public void prepareCustomDocuments(AsylumCase asylumCase, boolean isCaseReheard) {
boolean isOrWasAda = asylumCase.read(SUITABILITY_REVIEW_DECISION).isPresent();
boolean isRemittedPath = asylumCase.read(SOURCE_OF_REMITTAL, String.class).isPresent();
public void prepareCustomDocuments(AsylumCase asylumCase, boolean isUpdatedBundle) {
boolean isCaseReheard = asylumCase.read(CASE_FLAG_SET_ASIDE_REHEARD_EXISTS, YesOrNo.class).map(flag -> flag.equals(YesOrNo.YES)).orElse(false)
&& featureToggler.getValue("reheard-feature", false);
boolean isAipJourney = asylumCase
.read(JOURNEY_TYPE, JourneyType.class)
.map(type -> type == AIP).orElse(false);
getMappingFields(isCaseReheard, isOrWasAda, isRemittedPath).forEach((sourceField,targetField) ->
boolean isOrWasAda = asylumCase.read(SUITABILITY_REVIEW_DECISION).isPresent();
boolean isRemittedPath = asylumCase.read(SOURCE_OF_REMITTAL, String.class).isPresent();
Map<AsylumCaseDefinition, AsylumCaseDefinition> mappingFields = getMappingFields(isCaseReheard, isOrWasAda, isUpdatedBundle, isRemittedPath);
mappingFields.forEach((sourceField, targetField) ->
populateCustomCollections(asylumCase, sourceField, targetField, isAipJourney)
);
// Map does not accept duplicate keys, so need to process this separately
if (isCaseReheard) {
populateCustomCollections(asylumCase,ADDENDUM_EVIDENCE_DOCUMENTS, CUSTOM_RESP_ADDENDUM_EVIDENCE_DOCS, isAipJourney);
if (isRemittedPath) {
asylumCase.write(CUSTOM_LATEST_REMITTAL_DOCS, fetchLatestRemittalDocuments(asylumCase));
if (isCaseReheard || isUpdatedBundle) {
populateCustomCollections(asylumCase, ADDENDUM_EVIDENCE_DOCUMENTS, CUSTOM_RESP_ADDENDUM_EVIDENCE_DOCS, isAipJourney);
if (isCaseReheard) {
if (isRemittedPath) {
asylumCase.write(CUSTOM_LATEST_REMITTAL_DOCS, fetchLatestRemittalDocuments(asylumCase));
}
asylumCase.write(CUSTOM_REHEARD_HEARING_DOCS, fetchLatestReheardDocuments(asylumCase));
asylumCase.write(CUSTOM_FINAL_DECISION_AND_REASONS_DOCS, fetchLatestDecisionDocuments(asylumCase));
}
asylumCase.write(CUSTOM_REHEARD_HEARING_DOCS, fetchLatestReheardDocuments(asylumCase));
asylumCase.write(CUSTOM_FINAL_DECISION_AND_REASONS_DOCS, fetchLatestDecisionDocuments(asylumCase));
}
}

Expand Down Expand Up @@ -130,7 +132,8 @@ private List<IdValue<DocumentWithDescription>> getDocumentWithDescListFromMetaDa
private List<IdValue<DocumentWithDescription>> getDocumentWithDescListFromMetaDataWithoutBundles(List<IdValue<DocumentWithMetadata>> listDocumentWithMetaData) {
List<IdValue<DocumentWithDescription>> listDocumentWithDesc = new ArrayList<>();
for (IdValue<DocumentWithMetadata> documentWithMetadataIdValue : listDocumentWithMetaData) {
if (documentWithMetadataIdValue.getValue().getTag() != DocumentTag.HEARING_BUNDLE) {
if (documentWithMetadataIdValue.getValue().getTag() != DocumentTag.HEARING_BUNDLE &&
documentWithMetadataIdValue.getValue().getTag() != DocumentTag.UPDATED_HEARING_BUNDLE) {
listDocumentWithDesc = documentWithDescriptionAppender.append(
getDocumentWithDescFromMetaData(documentWithMetadataIdValue.getValue()), listDocumentWithDesc);
}
Expand Down Expand Up @@ -215,7 +218,8 @@ void populateCustomCollections(AsylumCase asylumCase, AsylumCaseDefinition sourc

for (IdValue<DocumentWithMetadata> documentWithMetadata : documents) {
if (documentWithMetadata.getValue().getTag() != null &&
documentWithMetadata.getValue().getTag() == DocumentTag.HEARING_BUNDLE) {
documentWithMetadata.getValue().getTag() == DocumentTag.HEARING_BUNDLE ||
documentWithMetadata.getValue().getTag() == DocumentTag.UPDATED_HEARING_BUNDLE) {
continue;
}
DocumentWithDescription newDocumentWithDescription =
Expand Down Expand Up @@ -243,7 +247,7 @@ void populateCustomCollections(AsylumCase asylumCase, AsylumCaseDefinition sourc

}

private Map<AsylumCaseDefinition,AsylumCaseDefinition> getMappingFields(boolean isReheardCase, boolean isOrWasAda, boolean isRemittedFeature) {
private Map<AsylumCaseDefinition, AsylumCaseDefinition> getMappingFields(boolean isReheardCase, boolean isOrWasAda, boolean isUpdatedBundle, boolean isRemittedFeature) {
Map<AsylumCaseDefinition, AsylumCaseDefinition> fieldMapping;
if (isReheardCase) {
fieldMapping = new HashMap<>(Map.of(
Expand All @@ -262,6 +266,9 @@ private Map<AsylumCaseDefinition,AsylumCaseDefinition> getMappingFields(boolean
LEGAL_REPRESENTATIVE_DOCUMENTS, CUSTOM_LEGAL_REP_DOCUMENTS,
ADDITIONAL_EVIDENCE_DOCUMENTS, CUSTOM_ADDITIONAL_EVIDENCE_DOCUMENTS,
RESPONDENT_DOCUMENTS, CUSTOM_RESPONDENT_DOCUMENTS));
if (isUpdatedBundle) {
fieldMapping.put(ADDENDUM_EVIDENCE_DOCUMENTS, CUSTOM_APP_ADDENDUM_EVIDENCE_DOCS);
}
if (isOrWasAda) {
//With Tribunal Documents
fieldMapping.put(TRIBUNAL_DOCUMENTS, CUSTOM_TRIBUNAL_DOCUMENTS);
Expand Down
Loading

0 comments on commit 67d1405

Please sign in to comment.