Skip to content

Commit

Permalink
CIV-9993 Hearing party MCI (#3285)
Browse files Browse the repository at this point in the history
* Added new ManageContactInformation callback handler and event and whitelisted it within the AllowedFlowState service.

* Added new ManageContactInformation callback handler and event and whitelisted it within the AllowedFlowState service.

* CIV-9992 add options for manage contact information

* revert accidental commit

* add utils test

* update utils test

* add test scenarios for handler

* update handler tests

* add IDs to party options

* changed name of some variables

* added chosenpartytype and chosenpartyid to determine what to show on page 2, wip on applicant/defendant pages

* adding tests ManageContactInformationUtilsTest

* changed some keys, updated tests

* experts and witnesses form wip

* show experts on ui

* make id fields public

* Cherry picked the 3 main commits from CIV-3216
Added partyID to dq witness and expert objects. Enabled the initialisation on party Ids in DQ witnesses and experts and copied partyIDs into their relative case level counterparts

Moved changes behind hmc toggle

Fixed duplicate append call

* Updated experts and witnesses to have mappings

* changed utils class back to static and removed mocks

* Fixed witnesses

* fixed litigation friend

* fixed capability to delete all experts/witnesses and add new expert/witnesses when never existed before

* postcode

* removed unnecessary lines and imports

* fixed data going missing for applicant 1 for party id

* fixed claim details tab

* added ccd data store image in charts

* fixed test

* Update values.preview.template.yaml

---------

Co-authored-by: GarethLancaster <[email protected]>
Co-authored-by: sankaviv1 <[email protected]>
Co-authored-by: Gareth Lancaster <[email protected]>
Co-authored-by: TurkingtonL <[email protected]>
Co-authored-by: sankaviv1 <[email protected]>
Co-authored-by: AhsanZX97 <[email protected]>
  • Loading branch information
7 people authored Nov 10, 2023
1 parent 63d47db commit 6a276fc
Show file tree
Hide file tree
Showing 8 changed files with 1,362 additions and 72 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,13 @@ public boolean isApplicantNotRepresented() {
private final List<Element<PartyFlagStructure>> applicantWitnesses;
private final List<Element<PartyFlagStructure>> respondent1Witnesses;
private final List<Element<PartyFlagStructure>> respondent2Witnesses;
private final List<Element<PartyFlagStructure>> applicantSolOrgIndividuals;
private final List<Element<PartyFlagStructure>> respondent1SolOrgIndividuals;
private final List<Element<PartyFlagStructure>> applicant1SolOrgIndividuals;
private final List<Element<PartyFlagStructure>> applicant1LRIndividuals;
private final List<Element<PartyFlagStructure>> respondent1LRIndividuals;
private final List<Element<PartyFlagStructure>> respondent2LRIndividuals;
private final List<Element<PartyFlagStructure>> applicant1OrgIndividuals;
private final List<Element<PartyFlagStructure>> applicant2OrgIndividuals;
private final List<Element<PartyFlagStructure>> respondent1OrgIndividuals;
private final List<Element<PartyFlagStructure>> respondent2OrgIndividuals;

private List<DisposalAndTrialHearingDJToggle> disposalHearingDisclosureOfDocumentsDJToggle;
private List<DisposalAndTrialHearingDJToggle> disposalHearingWitnessOfFactDJToggle;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package uk.gov.hmcts.reform.civil.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -11,17 +10,18 @@
import java.util.List;

@Data
@Builder
@Builder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
public class UpdateDetailsForm {

@JsonProperty("partyChosen")
private DynamicList partyChosen;

@JsonProperty("additionalUnavailableDates")
private List<Element<UnavailableDate>> additionalUnavailableDates;

@JsonProperty("hidePartyChoice")
private String partyChosenId;
private String partyChosenType;
private YesOrNo hidePartyChoice;
private List<Element<UnavailableDate>> additionalUnavailableDates;
private List<Element<UpdatePartyDetailsForm>> updateExpertsDetailsForm;
private List<Element<UpdatePartyDetailsForm>> updateWitnessesDetailsForm;
private YesOrNo manageContactDetailsEventUsed;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package uk.gov.hmcts.reform.civil.model;

import lombok.Builder;
import lombok.Data;

@Data
@Builder(toBuilder = true)
public class UpdatePartyDetailsForm {

private String firstName;
private String lastName;
private String phoneNumber;
private String emailAddress;
private String partyId;
private String fieldOfExpertise;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@

import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.Party;
import uk.gov.hmcts.reform.civil.model.UpdatePartyDetailsForm;
import uk.gov.hmcts.reform.civil.model.common.DynamicListElement;
import uk.gov.hmcts.reform.civil.model.common.Element;
import uk.gov.hmcts.reform.civil.model.dq.Expert;
import uk.gov.hmcts.reform.civil.model.dq.Experts;
import uk.gov.hmcts.reform.civil.model.dq.Witness;
import uk.gov.hmcts.reform.civil.model.dq.Witnesses;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

import static uk.gov.hmcts.reform.civil.enums.YesOrNo.YES;
import static uk.gov.hmcts.reform.civil.model.Party.Type.COMPANY;
import static uk.gov.hmcts.reform.civil.model.Party.Type.ORGANISATION;
import static uk.gov.hmcts.reform.civil.model.common.DynamicListElement.dynamicElementFromCode;
import static uk.gov.hmcts.reform.civil.utils.ElementUtils.unwrapElements;
import static uk.gov.hmcts.reform.civil.utils.ElementUtils.wrapElements;

public class ManageContactInformationUtils {

Expand All @@ -34,30 +40,30 @@ private ManageContactInformationUtils() {
private static final String ORG_INDIVIDUALS = "Individuals attending for the organisation";
private static final String LEGAL_REP_INDIVIDUALS = "Individuals attending for the legal representative";

private static final String CLAIMANT_ONE_ID = "CLAIMANT_1";
private static final String CLAIMANT_ONE_LITIGATION_FRIEND_ID = "CLAIMANT_1_LITIGATIONFRIEND";
private static final String CLAIMANT_ONE_LEGAL_REP_INDIVIDUALS_ID = "CLAIMANT_1_INDIVIDUALSSOLICITORORG";
private static final String CLAIMANT_ONE_ORG_INDIVIDUALS_ID = "CLAIMANT_1_INDIVIDUALSORG";
private static final String CLAIMANT_ONE_WITNESSES_ID = "CLAIMANT_1_WITNESSES";
private static final String CLAIMANT_ONE_EXPERTS_ID = "CLAIMANT_1_EXPERTS";

private static final String CLAIMANT_TWO_ID = "CLAIMANT_2";
private static final String CLAIMANT_TWO_LITIGATION_FRIEND_ID = "CLAIMANT_2_LITIGATIONFRIEND";
private static final String CLAIMANT_TWO_ORG_INDIVIDUALS_ID = "CLAIMANT_1_INDIVIDUALSORG";

private static final String DEFENDANT_ONE_ID = "DEFENDANT_1";
private static final String DEFENDANT_ONE_LITIGATION_FRIEND_ID = "DEFENDANT_1_LITIGATIONFRIEND";
private static final String DEFENDANT_ONE_LEGAL_REP_INDIVIDUALS_ID = "DEFENDANT_1_INDIVIDUALSSOLICITORORG";
private static final String DEFENDANT_ONE_ORG_INDIVIDUALS_ID = "DEFENDANT_1_INDIVIDUALSORG";
private static final String DEFENDANT_ONE_WITNESSES_ID = "DEFENDANT_1_WITNESSES";
private static final String DEFENDANT_ONE_EXPERTS_ID = "DEFENDANT_1_EXPERTS";

private static final String DEFENDANT_TWO_ID = "DEFENDANT_2";
private static final String DEFENDANT_TWO_LITIGATION_FRIEND_ID = "DEFENDANT_2_LITIGATIONFRIEND";
private static final String DEFENDANT_TWO_LEGAL_REP_INDIVIDUALS_ID = "DEFENDANT_2_INDIVIDUALSSOLICITORORG";
private static final String DEFENDANT_TWO_ORG_INDIVIDUALS_ID = "DEFENDANT_2_INDIVIDUALSORG";
private static final String DEFENDANT_TWO_WITNESSES_ID = "DEFENDANT_2_WITNESSES";
private static final String DEFENDANT_TWO_EXPERTS_ID = "DEFENDANT_2_EXPERTS";
public static final String CLAIMANT_ONE_ID = "CLAIMANT_1";
public static final String CLAIMANT_ONE_LITIGATION_FRIEND_ID = "CLAIMANT_1_LITIGATION_FRIEND";
public static final String CLAIMANT_ONE_LEGAL_REP_INDIVIDUALS_ID = "CLAIMANT_1_LR_INDIVIDUALS";
public static final String CLAIMANT_ONE_ORG_INDIVIDUALS_ID = "CLAIMANT_1_ORGANISATION_INDIVIDUALS";
public static final String CLAIMANT_ONE_WITNESSES_ID = "CLAIMANT_1_WITNESSES";
public static final String CLAIMANT_ONE_EXPERTS_ID = "CLAIMANT_1_EXPERTS";

public static final String CLAIMANT_TWO_ID = "CLAIMANT_2";
public static final String CLAIMANT_TWO_LITIGATION_FRIEND_ID = "CLAIMANT_2_LITIGATION_FRIEND";
public static final String CLAIMANT_TWO_ORG_INDIVIDUALS_ID = "CLAIMANT_2_ORGANISATION_INDIVIDUALS";

public static final String DEFENDANT_ONE_ID = "DEFENDANT_1";
public static final String DEFENDANT_ONE_LITIGATION_FRIEND_ID = "DEFENDANT_1_LITIGATION_FRIEND";
public static final String DEFENDANT_ONE_LEGAL_REP_INDIVIDUALS_ID = "DEFENDANT_1_LR_INDIVIDUALS";
public static final String DEFENDANT_ONE_ORG_INDIVIDUALS_ID = "DEFENDANT_1_ORGANISATION_INDIVIDUALS";
public static final String DEFENDANT_ONE_WITNESSES_ID = "DEFENDANT_1_WITNESSES";
public static final String DEFENDANT_ONE_EXPERTS_ID = "DEFENDANT_1_EXPERTS";

public static final String DEFENDANT_TWO_ID = "DEFENDANT_2";
public static final String DEFENDANT_TWO_LITIGATION_FRIEND_ID = "DEFENDANT_2_LITIGATION_FRIEND";
public static final String DEFENDANT_TWO_LEGAL_REP_INDIVIDUALS_ID = "DEFENDANT_2_LR_INDIVIDUALS";
public static final String DEFENDANT_TWO_ORG_INDIVIDUALS_ID = "DEFENDANT_2_ORGANISATION_INDIVIDUALS";
public static final String DEFENDANT_TWO_WITNESSES_ID = "DEFENDANT_2_WITNESSES";
public static final String DEFENDANT_TWO_EXPERTS_ID = "DEFENDANT_2_EXPERTS";

public static void addApplicant1Options(List<DynamicListElement> list, CaseData caseData, boolean isAdmin) {
addApplicant1PartyOptions(list, caseData);
Expand Down Expand Up @@ -95,6 +101,178 @@ public static void addDefendant2Options(List<DynamicListElement> list, CaseData
addDefendant2ExpertsAndWitnesses(list, caseData, isAdmin);
}

public static String appendUserAndType(String partyChosen, CaseData caseData, boolean isAdmin) {
String user = isAdmin ? "ADMIN" : "LR";

switch (partyChosen) {
case (CLAIMANT_ONE_ID): {
return formatId(partyChosen, user, caseData.getApplicant1());
}
case(CLAIMANT_TWO_ID): {
return formatId(partyChosen, user, caseData.getApplicant2());
}
case (DEFENDANT_ONE_ID): {
return formatId(partyChosen, user, caseData.getRespondent1());
}
case(DEFENDANT_TWO_ID): {
return formatId(partyChosen, user, caseData.getRespondent2());
}
case(CLAIMANT_ONE_LITIGATION_FRIEND_ID):
case(CLAIMANT_TWO_LITIGATION_FRIEND_ID):
case(DEFENDANT_ONE_LITIGATION_FRIEND_ID):
case(DEFENDANT_TWO_LITIGATION_FRIEND_ID): {
return formatId(partyChosen, user);
}
default: {
throw new IllegalArgumentException("Manage Contact Information party chosen ID does not exist");
}
}
}

public static List<Element<UpdatePartyDetailsForm>> mapExpertsToUpdatePartyDetailsForm(List<Element<Expert>> experts) {
List<Element<UpdatePartyDetailsForm>> newExperts = new ArrayList<>();

if (experts != null) {
for (Element<Expert> party : experts) {
Expert expert = party.getValue();
newExperts.addAll(wrapElements(UpdatePartyDetailsForm.builder()
.firstName(expert.getFirstName())
.lastName(expert.getLastName())
.emailAddress(expert.getEmailAddress())
.phoneNumber(expert.getPhoneNumber())
.fieldOfExpertise(expert.getFieldOfExpertise())
.partyId(expert.getPartyID()) //this will need to be added in new ticket
.build()));
}
}
return newExperts;
}

public static List<Element<Expert>> mapUpdatePartyDetailsFormToDQExperts(List<Element<Expert>> existingDQExperts, List<Element<UpdatePartyDetailsForm>> formExperts) {
List<Element<Expert>> newExperts = new ArrayList<>();
List<Expert> experts = unwrapElements(existingDQExperts);

if (formExperts != null) {
for (Element<UpdatePartyDetailsForm> form : formExperts) {
UpdatePartyDetailsForm formExpert = form.getValue();

Expert dqExpert = experts.stream()
.filter(e -> e.getPartyID().equals(formExpert.getPartyId()))
.findFirst()
.orElse(null);

if (dqExpert != null && dqExpert.getPartyID() != null) {
// if id already exists in dq
newExperts.addAll(wrapElements(dqExpert.toBuilder()
.firstName(formExpert.getFirstName())
.lastName(formExpert.getLastName())
.emailAddress(formExpert.getEmailAddress())
.phoneNumber(formExpert.getPhoneNumber())
.fieldOfExpertise(formExpert.getFieldOfExpertise())
.build()));
} else {
// if id doesn't exist in dq means it is a newly added expert
newExperts.addAll(wrapElements(Expert.builder()
.firstName(formExpert.getFirstName())
.lastName(formExpert.getLastName())
.emailAddress(formExpert.getEmailAddress())
.phoneNumber(formExpert.getPhoneNumber())
.fieldOfExpertise(formExpert.getFieldOfExpertise())
.dateAdded(LocalDate.now())
.eventAdded("Manage Contact Information Event")
.partyID(null) //CIV-10382
.build()));
// Replace above to this in CIV-10382
// newExperts.addAll(wrapElements(appendWithNewPartyIds(Expert.builder()
// .firstName(formExpert.getFirstName())
// .lastName(formExpert.getLastName())
// .emailAddress(formExpert.getEmailAddress())
// .phoneNumber(formExpert.getPhoneNumber())
// .fieldOfExpertise(formExpert.getFieldOfExpertise())
// .dateAdded(LocalDate.now())
// .eventAdded("Manage Contact Information Event")
// .build())));
}
}
}

return newExperts;
}

public static List<Element<UpdatePartyDetailsForm>> mapWitnessesToUpdatePartyDetailsForm(List<Element<Witness>> witnesses) {
List<Element<UpdatePartyDetailsForm>> newWitnesses = new ArrayList<>();

if (witnesses != null) {
for (Element<Witness> party : witnesses) {
Witness witness = party.getValue();
newWitnesses.addAll(wrapElements(UpdatePartyDetailsForm.builder()
.firstName(witness.getFirstName())
.lastName(witness.getLastName())
.emailAddress(witness.getEmailAddress())
.phoneNumber(witness.getPhoneNumber())
.partyId(witness.getPartyID())
.build()));
}
}
return newWitnesses;
}

public static List<Element<Witness>> mapUpdatePartyDetailsFormToDQWitnesses(List<Element<Witness>> existingDQWitnesses, List<Element<UpdatePartyDetailsForm>> formWitnesses) {
List<Element<Witness>> newWitnesses = new ArrayList<>();
List<Witness> witnesses = unwrapElements(existingDQWitnesses);

if (formWitnesses != null) {
for (Element<UpdatePartyDetailsForm> form : formWitnesses) {
UpdatePartyDetailsForm formWitness = form.getValue();

Witness dqWitness = witnesses.stream()
.filter(w -> w.getPartyID().equals(formWitness.getPartyId()))
.findFirst()
.orElse(null);

// if id already exists in dq
if (dqWitness != null && dqWitness.getPartyID() != null) {
newWitnesses.addAll(wrapElements(dqWitness.toBuilder()
.firstName(formWitness.getFirstName())
.lastName(formWitness.getLastName())
.emailAddress(formWitness.getEmailAddress())
.phoneNumber(formWitness.getPhoneNumber())
.build()));
} else {
// if id doesn't exist in dq means it is a newly added witness
newWitnesses.addAll(wrapElements(Witness.builder()
.firstName(formWitness.getFirstName())
.lastName(formWitness.getLastName())
.emailAddress(formWitness.getEmailAddress())
.phoneNumber(formWitness.getPhoneNumber())
.dateAdded(LocalDate.now())
.eventAdded("Manage Contact Information Event")
.partyID(null) //CIV-10382
.build()));
// Replace above to this in CIV-10382
// newWitnesses.addAll(wrapElements(appendWithNewPartyIds(Witness.builder()
// .firstName(formWitness.getFirstName())
// .lastName(formWitness.getLastName())
// .emailAddress(formWitness.getEmailAddress())
// .phoneNumber(formWitness.getPhoneNumber())
// .dateAdded(LocalDate.now())
// .eventAdded("Manage Contact Information Event")
// .build())));
}
}
}

return newWitnesses;
}

private static String formatId(String partyChosen, String isAdmin, Party party) {
return String.format("%s_%s_%s", partyChosen, isAdmin, party.getType().toString());
}

private static String formatId(String partyChosen, String isAdmin) {
return String.format("%s_%s", partyChosen, isAdmin);
}

private static void addApplicant1PartyOptions(List<DynamicListElement> list, CaseData caseData) {
// applicant 1 party name
list.add(dynamicElementFromCode(CLAIMANT_ONE_ID,
Expand Down
Loading

0 comments on commit 6a276fc

Please sign in to comment.