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

DIAC-86 generate amended hearing bundle event (similar functionality … #903

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
f03ac4f
DIAC-86 generate amended hearing bundle event (similar functionality …
nilay913 Jun 6, 2024
ee41a9c
DIAC-86 generate amended hearing bundle event (similar functionality …
nilay913 Jun 6, 2024
3f7a133
DIAC-86 updating tests
nilay913 Jun 6, 2024
1dbf772
DIAC-86 removing duplicated code and updating tests
nilay913 Jun 6, 2024
bab715e
DIAC-86 removing duplicated code and updating tests
nilay913 Jun 6, 2024
1e90eb4
DIAC-86 fix ?
nilay913 Jun 6, 2024
c9f8790
DIAC-86 stopping hearing bundle compounding by ignoring tag on genera…
nilay913 Jun 11, 2024
f697e05
DIAC-86 stopping hearing bundle compounding by ignoring tag on genera…
nilay913 Jun 11, 2024
296349e
DIAC-86 stopping hearing bundle compounding by ignoring tag on genera…
nilay913 Jun 11, 2024
c6040e1
DIAC-86 adding amended to hearing bundle file name if suitable
nilay913 Jun 13, 2024
d08a2b0
DIAC-86 adding amended to hearing bundle file name if suitable
nilay913 Jun 14, 2024
af64da9
DIAC-86 fixing customise and amended bundle missing aip docs
nilay913 Jun 17, 2024
f2ff651
DIAC-86 fixing customise and amended bundle missing aip docs
nilay913 Jun 17, 2024
cd2004c
Merge branch 'master' into DIAC-86
nilay913 Jun 19, 2024
b3ad308
DIAC-86 test fixes after merging in latest master
nilay913 Jun 19, 2024
cfe3afb
DIAC-86 minor improvements
nilay913 Jun 19, 2024
055902b
DIAC-86 sonarqube code smell fixes
nilay913 Jun 19, 2024
26ac2a9
DIAC-86 checkstyle fix
nilay913 Jun 19, 2024
c666643
Merge branch 'master' into DIAC-86
KleoG Jun 20, 2024
9b2e734
DIAC-86 BREAKING BUNDLE FOR TESTING
nilay913 Jul 11, 2024
9788362
Revert "DIAC-86 BREAKING BUNDLE FOR TESTING"
nilay913 Jul 17, 2024
d2ab66c
DIAC-86 potential fix for issue where reheard bundles are being seen …
nilay913 Jul 18, 2024
8d661c8
Merge branch 'master' into DIAC-86
nilay913 Jul 18, 2024
4f793f9
DIAC-86 potential fix to stop any hearing bundle tagged documents fro…
nilay913 Jul 19, 2024
8cc1f34
DIAC-86 functional test fix
nilay913 Jul 19, 2024
7d72a90
DIAC-86 slight fix
nilay913 Jul 19, 2024
abb7a7a
Revert "DIAC-86 functional test fix"
nilay913 Jul 19, 2024
c13b354
DIAC-86 fix to remove hearingBundles from customiseHearingBundle and …
nilay913 Jul 19, 2024
ba831f2
DIAC-86 fix retain dates and tags when restoring documents in collect…
nilay913 Jul 19, 2024
bd88fd2
DIAC-86 fix hiding reheard bundles in customise/amend bundle
nilay913 Jul 19, 2024
1893ed9
DIAC-86 functional test fix
nilay913 Jul 19, 2024
bcd3616
DIAC-86 fix for case of null tag
nilay913 Jul 19, 2024
7216c3d
Merge branch 'master' into DIAC-86
nilay913 Jul 25, 2024
b25142e
DIAC-86 test fix
nilay913 Jul 25, 2024
813eaa8
Merge branch 'master' into DIAC-86
nilay913 Aug 15, 2024
e32effa
Merge branch 'master' into DIAC-86
nilay913 Aug 16, 2024
d20c958
DIAC-86 changing all instance of amended to updated
nilay913 Aug 21, 2024
7a5b357
DIAC-86 removing bundle count
nilay913 Aug 21, 2024
9df7475
DIAC-86 removing bundle count
nilay913 Aug 21, 2024
7ce8186
DIAC-86 test fix
nilay913 Aug 21, 2024
a997fcc
DIAC-86 DocumentWithMetadata update with datetime
nilay913 Aug 22, 2024
f1f90d0
DIAC-86 fixing addendum documents not showing in non reheard
nilay913 Aug 27, 2024
946fddf
DIAC-86 adding new templates for updated hearing bundle to include ad…
nilay913 Aug 27, 2024
8dae1a5
DIAC-86 fix to restore datetimeuploaded when updating bundle
nilay913 Sep 4, 2024
9748592
Fix merge conflicts
alivenichoppa Oct 14, 2024
bcb391f
Disable flaky test
alivenichoppa Oct 14, 2024
9f7fd9e
fix checkstyle
alivenichoppa Oct 14, 2024
bf15ca8
Merge changes from master branch
alivenichoppa Oct 30, 2024
359887a
fix tests
alivenichoppa Oct 30, 2024
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
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
Loading