Skip to content

Commit

Permalink
Merge branch 'ia-case-documents-api-naba' into ia-case-documents-api-…
Browse files Browse the repository at this point in the history
…naba-aug-rebase3
  • Loading branch information
colmlynch60 authored Sep 4, 2023
2 parents d6404e7 + c6f3893 commit 19f89ff
Show file tree
Hide file tree
Showing 22 changed files with 1,048 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"description": "RIA-7331 Internal appellant ftpa decided - partially granted letter",
"request": {
"uri": "/asylum/ccdAboutToSubmit",
"credentials": "Judge",
"input": {
"id": 7331,
"eventId": "residentJudgeFtpaDecision",
"state": "ftpaSubmitted",
"caseData": {
"template": "minimal-internal-appeal-submitted.json",
"replacements": {
"appellantInDetention": "Yes",
"ftpaAppellantRjDecisionOutcomeType": "partiallyGranted",
"ftpaApplicantType": "appellant"
}
}
}
},
"expectation": {
"status": 200,
"errors": [],
"caseData": {
"template": "minimal-internal-appeal-submitted.json",
"replacements": {
"appellantInDetention": "Yes",
"ftpaAppellantRjDecisionOutcomeType": "partiallyGranted",
"ftpaApplicantType": "appellant",
"notificationAttachmentDocuments": [
{
"id": "1",
"value": {
"tag": "internalAppellantFtpaDecidedLetter",
"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_filename": "PA 12345 2019-Awan-appellant-ftpa-decided-partially-granted-letter.PDF",
"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/"
},
"suppliedBy": "",
"description": "",
"dateUploaded": "{$TODAY}"
}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"description": "RIA-7360 Internal HO ftpa decided - granted letter",
"request": {
"uri": "/asylum/ccdAboutToSubmit",
"credentials": "Judge",
"input": {
"id": 7360,
"eventId": "residentJudgeFtpaDecision",
"state": "ftpaSubmitted",
"caseData": {
"template": "minimal-internal-appeal-submitted.json",
"replacements": {
"appellantInDetention": "Yes",
"ftpaRespondentRjDecisionOutcomeType": "granted",
"ftpaApplicantType": "respondent"
}
}
}
},
"expectation": {
"status": 200,
"errors": [],
"caseData": {
"template": "minimal-internal-appeal-submitted.json",
"replacements": {
"appellantInDetention": "Yes",
"ftpaRespondentRjDecisionOutcomeType": "granted",
"ftpaApplicantType": "respondent",
"notificationAttachmentDocuments": [
{
"id": "1",
"value": {
"tag": "internalHoFtpaDecidedLetter",
"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_filename": "PA 12345 2019-Awan-ho-ftpa-decided-granted-letter.PDF",
"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/"
},
"suppliedBy": "",
"description": "",
"dateUploaded": "{$TODAY}"
}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"description": "RIA-7361 Internal HO ftpa decided - partially granted letter",
"request": {
"uri": "/asylum/ccdAboutToSubmit",
"credentials": "Judge",
"input": {
"id": 7361,
"eventId": "residentJudgeFtpaDecision",
"state": "ftpaSubmitted",
"caseData": {
"template": "minimal-internal-appeal-submitted.json",
"replacements": {
"appellantInDetention": "Yes",
"ftpaRespondentRjDecisionOutcomeType": "partiallyGranted",
"ftpaApplicantType": "respondent"
}
}
}
},
"expectation": {
"status": 200,
"errors": [],
"caseData": {
"template": "minimal-internal-appeal-submitted.json",
"replacements": {
"appellantInDetention": "Yes",
"ftpaRespondentRjDecisionOutcomeType": "partiallyGranted",
"ftpaApplicantType": "respondent",
"notificationAttachmentDocuments": [
{
"id": "1",
"value": {
"tag": "internalHoFtpaDecidedLetter",
"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_filename": "PA 12345 2019-Awan-ho-ftpa-decided-partially-granted-letter.PDF",
"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/"
},
"suppliedBy": "",
"description": "",
"dateUploaded": "{$TODAY}"
}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"description": "RIA-7362 Internal HO ftpa decided - refused letter",
"request": {
"uri": "/asylum/ccdAboutToSubmit",
"credentials": "Judge",
"input": {
"id": 7362,
"eventId": "residentJudgeFtpaDecision",
"state": "ftpaSubmitted",
"caseData": {
"template": "minimal-internal-appeal-submitted.json",
"replacements": {
"appellantInDetention": "Yes",
"ftpaRespondentRjDecisionOutcomeType": "refused",
"ftpaApplicantType": "respondent"
}
}
}
},
"expectation": {
"status": 200,
"errors": [],
"caseData": {
"template": "minimal-internal-appeal-submitted.json",
"replacements": {
"appellantInDetention": "Yes",
"ftpaRespondentRjDecisionOutcomeType": "refused",
"ftpaApplicantType": "respondent",
"notificationAttachmentDocuments": [
{
"id": "1",
"value": {
"tag": "internalHoFtpaDecidedLetter",
"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_filename": "PA 12345 2019-Awan-ho-ftpa-decided-refused-letter.PDF",
"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/"
},
"suppliedBy": "",
"description": "",
"dateUploaded": "{$TODAY}"
}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -562,14 +562,21 @@ public enum AsylumCaseDefinition {

DECIDE_AN_APPLICATION_ID(
"decideAnApplicationId", new TypeReference<String>(){}),

TRANSFER_OUT_OF_ADA_REASON(
"transferOutOfAdaReason", new TypeReference<String>(){}),

TRANSFER_OUT_OF_ADA_MORE_DETAILS(
"transferOutOfAdaMoreDetails", new TypeReference<String>(){}),

FTPA_APPELLANT_RJ_DECISION_OUTCOME_TYPE(
"ftpaAppellantRjDecisionOutcomeType", new TypeReference<FtpaDecisionOutcomeType>(){}),

FTPA_APPLICANT_TYPE(
"ftpaApplicantType", new TypeReference<String>(){});
"ftpaApplicantType", new TypeReference<String>(){}),

FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE(
"ftpaRespondentRjDecisionOutcomeType", new TypeReference<FtpaDecisionOutcomeType>(){});

private final String value;
private final TypeReference typeReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public enum DocumentTag {
INTERNAL_DETAINED_TRANSFER_OUT_OF_ADA_LETTER("internalDetainedTransferOutOfAdaLetter", CaseType.ASYLUM),
INTERNAL_FTPA_SUBMITTED_APPELLANT_LETTER("internalFtpaSubmittedAppellantLetter", CaseType.ASYLUM),
INTERNAL_APPELLANT_FTPA_DECIDED_LETTER("internalAppellantFtpaDecidedLetter", CaseType.ASYLUM),
INTERNAL_HO_FTPA_DECIDED_LETTER("internalHoFtpaDecidedLetter", CaseType.ASYLUM),

BAIL_SUBMISSION("bailSubmission", CaseType.BAIL),
BAIL_EVIDENCE("uploadTheBailEvidenceDocs", CaseType.BAIL),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public enum FtpaDecisionOutcomeType {

FTPA_GRANTED("granted"),
FTPA_PARTIALLY_GRANTED("partiallyGranted"),
FTPA_REFUSED("refused");
FTPA_REFUSED("refused"),
FTPA_NOT_ADMITTED("notAdmitted");

@JsonValue
private final String value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static java.util.Objects.requireNonNull;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.FtpaDecisionOutcomeType.FTPA_GRANTED;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.FtpaDecisionOutcomeType.*;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isAppellantInDetention;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isInternalCase;

Expand All @@ -26,34 +26,46 @@
public class InternalFtpaDecidedLetterGenerator implements PreSubmitCallbackHandler<AsylumCase> {

private final DocumentCreator<AsylumCase> internalAppellantFtpaDecidedGrantedLetter;
private final DocumentCreator<AsylumCase> internalAppellantFtpaDecidedPartiallyGrantedLetter;
private final DocumentCreator<AsylumCase> internalHoFtpaDecidedGrantedLetter;
private final DocumentCreator<AsylumCase> internalHoFtpaDecidedPartiallyGrantedLetter;
private final DocumentCreator<AsylumCase> internalHoFtpaDecidedRefusedLetter;
private final DocumentHandler documentHandler;
private final String ftpaApplicantAppellant = "appellant";

public InternalFtpaDecidedLetterGenerator(
@Qualifier("internalAppellantFtpaDecidedGrantedLetter") DocumentCreator<AsylumCase> internalAppellantFtpaDecidedGrantedLetter,
DocumentHandler documentHandler
@Qualifier("internalAppellantFtpaDecidedGrantedLetter") DocumentCreator<AsylumCase> internalAppellantFtpaDecidedGrantedLetter,
@Qualifier("internalAppellantFtpaDecidedPartiallyGrantedLetter") DocumentCreator<AsylumCase> internalAppellantFtpaDecidedPartiallyGrantedLetter,
@Qualifier("internalHoFtpaDecidedGrantedLetter") DocumentCreator<AsylumCase> internalHoFtpaDecidedGrantedLetter,
@Qualifier("internalHoFtpaDecidedPartiallyGrantedLetter") DocumentCreator<AsylumCase> internalHoFtpaDecidedPartiallyGrantedLetter,
@Qualifier("internalHoFtpaDecidedRefusedLetter") DocumentCreator<AsylumCase> internalHoFtpaDecidedRefusedLetter,
DocumentHandler documentHandler
) {
this.internalAppellantFtpaDecidedGrantedLetter = internalAppellantFtpaDecidedGrantedLetter;
this.internalAppellantFtpaDecidedPartiallyGrantedLetter = internalAppellantFtpaDecidedPartiallyGrantedLetter;
this.internalHoFtpaDecidedGrantedLetter = internalHoFtpaDecidedGrantedLetter;
this.internalHoFtpaDecidedPartiallyGrantedLetter = internalHoFtpaDecidedPartiallyGrantedLetter;
this.internalHoFtpaDecidedRefusedLetter = internalHoFtpaDecidedRefusedLetter;
this.documentHandler = documentHandler;
}

public boolean canHandle(
PreSubmitCallbackStage callbackStage,
Callback<AsylumCase> callback
PreSubmitCallbackStage callbackStage,
Callback<AsylumCase> callback
) {
requireNonNull(callbackStage, "callbackStage must not be null");
requireNonNull(callback, "callback must not be null");
AsylumCase asylumCase = callback.getCaseDetails().getCaseData();

return callbackStage == PreSubmitCallbackStage.ABOUT_TO_SUBMIT
&& callback.getEvent() == Event.RESIDENT_JUDGE_FTPA_DECISION
&& isInternalCase(asylumCase)
&& isAppellantInDetention(asylumCase);
&& callback.getEvent() == Event.RESIDENT_JUDGE_FTPA_DECISION
&& isInternalCase(asylumCase)
&& isAppellantInDetention(asylumCase);
}

public PreSubmitCallbackResponse<AsylumCase> handle(
PreSubmitCallbackStage callbackStage,
Callback<AsylumCase> callback
PreSubmitCallbackStage callbackStage,
Callback<AsylumCase> callback
) {
if (!canHandle(callbackStage, callback)) {
throw new IllegalStateException("Cannot handle callback");
Expand All @@ -63,27 +75,44 @@ public PreSubmitCallbackResponse<AsylumCase> handle(
final AsylumCase asylumCase = caseDetails.getCaseData();

Optional<FtpaDecisionOutcomeType> ftpaAppellantDecisionOutcomeType = asylumCase
.read(FTPA_APPELLANT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class);
.read(FTPA_APPELLANT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class);

Optional<FtpaDecisionOutcomeType> ftpaRespondentDecisionOutcomeType = asylumCase
.read(FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, FtpaDecisionOutcomeType.class);

Optional<String> ftpaApplicantType = asylumCase.read(FTPA_APPLICANT_TYPE, String.class);

Document documentForUpload;
DocumentTag documentTag;

if (ftpaApplicantType.equals(Optional.of(ftpaApplicantAppellant))) {
if (ftpaAppellantDecisionOutcomeType.equals(Optional.of(FTPA_GRANTED))) {
documentForUpload = internalAppellantFtpaDecidedGrantedLetter.create(caseDetails);
} else if (ftpaAppellantDecisionOutcomeType.equals(Optional.of(FTPA_PARTIALLY_GRANTED))) {
documentForUpload = internalAppellantFtpaDecidedPartiallyGrantedLetter.create(caseDetails);
} else {
return new PreSubmitCallbackResponse<>(asylumCase);
}
documentTag = DocumentTag.INTERNAL_APPELLANT_FTPA_DECIDED_LETTER;
} else {
return new PreSubmitCallbackResponse<>(asylumCase);
if (ftpaRespondentDecisionOutcomeType.equals(Optional.of(FTPA_GRANTED))) {
documentForUpload = internalHoFtpaDecidedGrantedLetter.create(caseDetails);
} else if (ftpaRespondentDecisionOutcomeType.equals(Optional.of(FTPA_PARTIALLY_GRANTED))) {
documentForUpload = internalHoFtpaDecidedPartiallyGrantedLetter.create(caseDetails);
} else if (ftpaRespondentDecisionOutcomeType.equals(Optional.of(FTPA_REFUSED))
|| ftpaRespondentDecisionOutcomeType.equals(Optional.of(FTPA_NOT_ADMITTED))) {
documentForUpload = internalHoFtpaDecidedRefusedLetter.create(caseDetails);
} else {
return new PreSubmitCallbackResponse<>(asylumCase);
}
documentTag = DocumentTag.INTERNAL_HO_FTPA_DECIDED_LETTER;
}

documentHandler.addWithMetadata(
asylumCase,
documentForUpload,
NOTIFICATION_ATTACHMENT_DOCUMENTS,
DocumentTag.INTERNAL_APPELLANT_FTPA_DECIDED_LETTER
asylumCase,
documentForUpload,
NOTIFICATION_ATTACHMENT_DOCUMENTS,
documentTag
);

return new PreSubmitCallbackResponse<>(asylumCase);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ private int bundlePositionIndex(DocumentWithMetadata document) {
log.warn("INTERNAL_FTPA_SUBMITTED_APPELLANT_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription());
return 52;
case INTERNAL_APPELLANT_FTPA_DECIDED_LETTER:
log.warn("INTERNAL_FTPA_DECIDED_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription());
log.warn("INTERNAL_FTPA_DECIDED_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription());
return 53;
case INTERNAL_HO_FTPA_DECIDED_LETTER:
log.warn("INTERNAL_HO_FTPA_DECIDED_LETTER tag should not be checked for bundle ordering, document desc: {}", document.getDescription());
return 54;
default:
throw new IllegalStateException("document has unknown tag: " + document.getTag() + ", description: " + document.getDescription());
}
Expand Down
Loading

0 comments on commit 19f89ff

Please sign in to comment.