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

RIA-8102 Create new events and rework FTPA resident event #1912

Merged
merged 3 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -3,11 +3,14 @@
import com.fasterxml.jackson.annotation.JsonValue;

public enum FtpaResidentJudgeDecisionOutcomeType {
PARTIALLY_GRANTED("partiallyGranted"),

GRANTED("granted"),
PARTIALLY_GRANTED("partiallyGranted"),
REFUSED("refused"),
APPLICATION_NOT_ADMITTED("notAdmitted"),
WITHDRAWN("withdrawn"),
REHEARD_RULE35("reheardRule35"),
REHEARD_RULE32("reheardRule32"),
REMADE_RULE31("remadeRule31"),
REMADE_RULE32("remadeRule32");

@JsonValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static uk.gov.hmcts.reform.iacaseapi.domain.entities.Parties.RESPONDENT;

import java.util.Optional;

import org.springframework.stereotype.Component;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.*;
import uk.gov.hmcts.reform.iacaseapi.domain.entities.ccd.Event;
Expand All @@ -28,7 +29,7 @@ public boolean canHandle(
requireNonNull(callback, "callback must not be null");

return callbackStage == PreSubmitCallbackStage.MID_EVENT
&& (callback.getEvent() == Event.LEADERSHIP_JUDGE_FTPA_DECISION || callback.getEvent() == Event.RESIDENT_JUDGE_FTPA_DECISION);
&& (callback.getEvent() == Event.LEADERSHIP_JUDGE_FTPA_DECISION || callback.getEvent() == Event.RESIDENT_JUDGE_FTPA_DECISION);
}

public PreSubmitCallbackResponse<AsylumCase> handle(
Expand All @@ -49,13 +50,12 @@ public PreSubmitCallbackResponse<AsylumCase> handle(
.orElseThrow(() -> new IllegalStateException("FtpaApplicantType is not present"));

Optional<String> ftpaRjDecisionOutcomeType = asylumCase.read(ftpaApplicantType.equals(APPELLANT.toString())
? FTPA_APPELLANT_RJ_DECISION_OUTCOME_TYPE
: FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, String.class);
? FTPA_APPELLANT_RJ_DECISION_OUTCOME_TYPE
: FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, String.class);

if (!HandlerUtils.isRepJourney(asylumCase) && ftpaRjDecisionOutcomeType.isPresent()) {
String ftpaRjDecisionOutcomeTypeValue = ftpaRjDecisionOutcomeType.get();
if (ftpaRjDecisionOutcomeTypeValue.equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE35.toString())
|| ftpaRjDecisionOutcomeTypeValue.equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE32.toString())
|| ftpaRjDecisionOutcomeTypeValue.equals(FtpaResidentJudgeDecisionOutcomeType.REMADE_RULE32.toString())) {
PreSubmitCallbackResponse<AsylumCase> response = new PreSubmitCallbackResponse<>(asylumCase);
response.addError("For Legal Representative Journey Only");
Expand All @@ -75,7 +75,7 @@ public PreSubmitCallbackResponse<AsylumCase> handle(
asylumCasePreSubmitCallbackResponse.addError("You've made an invalid request. There is no appellant FTPA application to record the decision.");
return asylumCasePreSubmitCallbackResponse;
} else if ((callback.getEvent() == Event.LEADERSHIP_JUDGE_FTPA_DECISION || callback.getEvent() == Event.RESIDENT_JUDGE_FTPA_DECISION)
&& ftpaApplicantType.equals(RESPONDENT.toString()) && !ftpaSubmitted.isPresent()) {
&& ftpaApplicantType.equals(RESPONDENT.toString()) && !ftpaSubmitted.isPresent()) {

asylumCasePreSubmitCallbackResponse.addError("You've made an invalid request. There is no respondent FTPA application to record the decision.");
return asylumCasePreSubmitCallbackResponse;
Expand All @@ -93,18 +93,12 @@ public PreSubmitCallbackResponse<AsylumCase> handle(

private void setResidentJudgeDecisionPagesVisibility(AsylumCase asylumCase) {

final YesOrNo isFtpaAppellantNoticeOfDecisionSetAside = asylumCase.read(IS_FTPA_APPELLANT_NOTICE_OF_DECISION_SET_ASIDE, YesOrNo.class).orElse(YesOrNo.NO);
final String ftpaAppellantRjDecisionOutcomeType = asylumCase.read(FTPA_APPELLANT_RJ_DECISION_OUTCOME_TYPE, String.class).orElse("");

final YesOrNo isFtpaRespondentNoticeOfDecisionSetAside = asylumCase.read(IS_FTPA_RESPONDENT_NOTICE_OF_DECISION_SET_ASIDE, YesOrNo.class).orElse(YesOrNo.NO);
final String ftpaRespondentRjDecisionOutcomeType = asylumCase.read(FTPA_RESPONDENT_RJ_DECISION_OUTCOME_TYPE, String.class).orElse("");

// Page 3
setNoticeOfDecisionSetAsideVisibility(asylumCase, ftpaAppellantRjDecisionOutcomeType, ftpaRespondentRjDecisionOutcomeType);

// Page 4
setDecisionObjectionsPageVisibility(asylumCase, isFtpaAppellantNoticeOfDecisionSetAside, ftpaAppellantRjDecisionOutcomeType,
isFtpaRespondentNoticeOfDecisionSetAside, ftpaRespondentRjDecisionOutcomeType);
setNoticeOfDecisionSetAsideVisibility(asylumCase, ftpaAppellantRjDecisionOutcomeType, ftpaRespondentRjDecisionOutcomeType);

// Page 5
setDecisionReasonsNotesVisibility(asylumCase, ftpaAppellantRjDecisionOutcomeType, ftpaRespondentRjDecisionOutcomeType);
Expand All @@ -115,17 +109,13 @@ private void setResidentJudgeDecisionPagesVisibility(AsylumCase asylumCase) {

private void setDecisionListingVisibility(AsylumCase asylumCase, String ftpaAppellantRjDecisionOutcomeType, String ftpaRespondentRjDecisionOutcomeType) {

if (ftpaAppellantRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE35.toString())
|| ftpaAppellantRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE32.toString())) {

if (ftpaAppellantRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE35.toString())) {
asylumCase.write(AsylumCaseFieldDefinition.FTPA_APPELLANT_DECISION_LISTING_VISIBLE, YesOrNo.YES);
} else {
asylumCase.write(AsylumCaseFieldDefinition.FTPA_APPELLANT_DECISION_LISTING_VISIBLE, YesOrNo.NO);
}

if (ftpaRespondentRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE35.toString())
|| ftpaRespondentRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE32.toString())) {

if (ftpaRespondentRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE35.toString())) {
asylumCase.write(AsylumCaseFieldDefinition.FTPA_RESPONDENT_DECISION_LISTING_VISIBLE, YesOrNo.YES);
} else {
asylumCase.write(AsylumCaseFieldDefinition.FTPA_RESPONDENT_DECISION_LISTING_VISIBLE, YesOrNo.NO);
Expand Down Expand Up @@ -173,31 +163,6 @@ private void setFtpaDecisionReasonsNotesVisibility(AsylumCase asylumCase) {
}
}

private void setDecisionObjectionsPageVisibility(
final AsylumCase asylumCase,
final YesOrNo isFtpaAppellantNoticeOfDecisionSetAside,
final String ftpaAppellantRjDecisionOutcomeType,
final YesOrNo isFtpaRespondentNoticeOfDecisionSetAside,
final String ftpaRespondentRjDecisionOutcomeType
) {

if (isFtpaAppellantNoticeOfDecisionSetAside.equals(YesOrNo.YES)
|| ftpaAppellantRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE35.toString())) {

asylumCase.write(AsylumCaseFieldDefinition.FTPA_APPELLANT_DECISION_OBJECTIONS_VISIBLE, YesOrNo.YES);
} else {
asylumCase.write(AsylumCaseFieldDefinition.FTPA_APPELLANT_DECISION_OBJECTIONS_VISIBLE, YesOrNo.NO);
}

if (isFtpaRespondentNoticeOfDecisionSetAside.equals(YesOrNo.YES)
|| ftpaRespondentRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE35.toString())) {

asylumCase.write(AsylumCaseFieldDefinition.FTPA_RESPONDENT_DECISION_OBJECTIONS_VISIBLE, YesOrNo.YES);
} else {
asylumCase.write(AsylumCaseFieldDefinition.FTPA_RESPONDENT_DECISION_OBJECTIONS_VISIBLE, YesOrNo.NO);
}
}

private void setNoticeOfDecisionSetAsideVisibility(
final AsylumCase asylumCase,
final String ftpaAppellantRjDecisionOutcomeType,
Expand All @@ -206,7 +171,8 @@ private void setNoticeOfDecisionSetAsideVisibility(

if (ftpaAppellantRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.GRANTED.toString())
|| ftpaAppellantRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.PARTIALLY_GRANTED.toString())
|| ftpaAppellantRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REFUSED.toString())) {
|| ftpaAppellantRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REFUSED.toString())
|| ftpaAppellantRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.APPLICATION_NOT_ADMITTED.toString())) {

asylumCase.write(AsylumCaseFieldDefinition.FTPA_APPELLANT_NOTICE_OF_DECISION_SET_ASIDE_VISIBLE, YesOrNo.YES);
} else {
Expand All @@ -215,7 +181,8 @@ private void setNoticeOfDecisionSetAsideVisibility(

if (ftpaRespondentRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.GRANTED.toString())
|| ftpaRespondentRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.PARTIALLY_GRANTED.toString())
|| ftpaRespondentRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REFUSED.toString())) {
|| ftpaRespondentRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.REFUSED.toString())
|| ftpaRespondentRjDecisionOutcomeType.equals(FtpaResidentJudgeDecisionOutcomeType.APPLICATION_NOT_ADMITTED.toString())) {

asylumCase.write(AsylumCaseFieldDefinition.FTPA_RESPONDENT_NOTICE_OF_DECISION_SET_ASIDE_VISIBLE, YesOrNo.YES);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ public PreSubmitCallbackResponse<AsylumCase> handle(PreSubmitCallbackStage callb

boolean setAsideRespondentDecisionExists =
ftpaRespondentRjDecisionOutcomeType.isPresent()
&& (ftpaRespondentRjDecisionOutcomeType.get().equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE32.toString())
|| ftpaRespondentRjDecisionOutcomeType.get().equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE35.toString())
&& (ftpaRespondentRjDecisionOutcomeType.get().equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE35.toString())
|| ftpaRespondentRjDecisionOutcomeType.get().equals(FtpaResidentJudgeDecisionOutcomeType.REMADE_RULE32.toString()));

boolean setAsideAppellantDecisionExists =
ftpaAppellantRjDecisionOutcomeType.isPresent()
&& (ftpaAppellantRjDecisionOutcomeType.get().equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE32.toString())
|| ftpaAppellantRjDecisionOutcomeType.get().equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE35.toString())
&& (ftpaAppellantRjDecisionOutcomeType.get().equals(FtpaResidentJudgeDecisionOutcomeType.REHEARD_RULE35.toString())
|| ftpaAppellantRjDecisionOutcomeType.get().equals(FtpaResidentJudgeDecisionOutcomeType.REMADE_RULE32.toString()));

if (setAsideRespondentDecisionExists || setAsideAppellantDecisionExists) {
Expand Down
Loading
Loading