Skip to content

Commit

Permalink
Task/js 12a (#838)
Browse files Browse the repository at this point in the history
* JS-12a PaperRespond Thirdparty

* JS-12a PaperRespond Thirdparty bureau update

* JS-12 amend thirdparty api

* task/JS-12a thirdparty api updates
  • Loading branch information
EPatterson1 authored Jan 7, 2025
1 parent 19b5af2 commit 504ea13
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,28 @@ public static class CjsEmployment {
@Schema(description = "Response submitted by a third party")
public static class ThirdParty {

@JsonProperty("thirdPartyFName")
@Schema(description = "Third party firstname")
private String thirdPartyFName;

@JsonProperty("thirdPartyLName")
@Schema(description = "Third party lastname")
private String thirdPartyLName;

@JsonProperty("thirdPartyPhone")
@Schema(description = "Third party main phone number")
@Pattern(regexp = PHONE_NO_REGEX)
private String mainPhone;

@JsonProperty("otherPhone")
@Schema(description = "Third party alternative phone number")
private String otherPhone;

@JsonProperty("thirdPartyEmail")
@Schema(description = "Third party email address")
@Pattern(regexp = EMAIL_ADDRESS_REGEX)
private String emailAddress;

@JsonProperty("relationship")
@Schema(description = "Third party relationship to the juror")
private String relationship;
Expand All @@ -252,6 +274,19 @@ public static class ThirdParty {
@Schema(description = "Third party reason")
private String thirdPartyReason;

@JsonProperty("thirdPartyOtherReason")
@Schema(description = "Third party other reason")
private String thirdPartyOtherReason;

@Schema(description = "Whether the juror's email details should be used (false = use third party details)")
@Builder.Default
private Boolean useJurorEmailDetails = Boolean.TRUE;

@Schema(description = "Whether the juror's phone details should be used (false = use third party details)")
@Builder.Default
private Boolean useJurorPhoneDetails = Boolean.TRUE;


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand Down Expand Up @@ -342,12 +343,35 @@ public static class CjsEmployment {
private String cjsEmployerDetails;
}

@Builder
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Schema(description = "Response submitted by a third party")
public static class ThirdParty {

@JsonProperty("thirdPartyFName")
@Schema(description = "Third party firstname")
private String thirdPartyFName;

@JsonProperty("thirdPartyLName")
@Schema(description = "Third party lastname")
private String thirdPartyLName;

@JsonProperty("thirdPartyPhone")
@Schema(description = "Third party main phone number")
@Pattern(regexp = PHONE_NO_REGEX)
private String mainPhone;

@JsonProperty("otherPhone")
@Schema(description = "Third party alternative phone number")
private String otherPhone;

@JsonProperty("thirdPartyEmail")
@Schema(description = "Third party email address")
@Pattern(regexp = EMAIL_ADDRESS_REGEX)
private String emailAddress;

@JsonProperty("relationship")
@Schema(description = "Third party relationship to the juror")
private String relationship;
Expand All @@ -356,6 +380,19 @@ public static class ThirdParty {
@Schema(description = "Third party reason")
private String thirdPartyReason;

@JsonProperty("thirdPartyOtherReason")
@Schema(description = "Third party other reason")
private String thirdPartyOtherReason;

@Schema(description = "Whether the juror's email details should be used (false = use third party details)")
@Builder.Default
private Boolean useJurorEmailDetails = Boolean.TRUE;

@Schema(description = "Whether the juror's phone details should be used (false = use third party details)")
@Builder.Default
private Boolean useJurorPhoneDetails = Boolean.TRUE;


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -126,11 +127,44 @@ public class AbstractJurorResponse extends Address implements Serializable {
@Column(name = "convictions")
private Boolean convictions;

@Column(name = "thirdparty_fname")
private String thirdPartyFName;

@Column(name = "thirdparty_lname")
private String thirdPartyLName;

@Column(name = "relationship")
@Length(max = 50)
@Pattern(regexp = NO_PIPES_REGEX)
private String relationship;

@Column(name = "main_phone")
private String mainPhone;

@Column(name = "other_phone")
private String otherPhone;

@Column(name = "email_address")
private String emailAddress;

@Column(name = "thirdparty_reason")
@Pattern(regexp = NO_PIPES_REGEX)
@Length(max = 1000)
private String thirdPartyReason;

@Column(name = "thirdparty_other_reason")
@Pattern(regexp = NO_PIPES_REGEX)
private String thirdPartyOtherReason;

@Column(name = "juror_phone_details")
@Builder.Default
private Boolean jurorPhoneDetails = Boolean.TRUE;

@Column(name = "juror_email_details")
@Builder.Default
private Boolean jurorEmailDetails = Boolean.TRUE;



@Column(name = "reasonable_adjustments_arrangements")
@Length(max = ValidationConstants.REASONABLE_ADJUSTMENT_MESSAGE_LENGTH_MAX)
Expand All @@ -143,10 +177,7 @@ public class AbstractJurorResponse extends Address implements Serializable {
@Column(name = "completed_at")
private LocalDateTime completedAt;

@Column(name = "relationship")
@Length(max = 50)
@Pattern(regexp = NO_PIPES_REGEX)
private String relationship;


@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "staff_login")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,18 @@ private JurorPaperResponseDetailDto copyPaperResponseRecordIntoDto(PaperResponse
jurorPaperResponseDetailDto.setNotes(juror.getNotes());

// copy third party
jurorPaperResponseDetailDto.setThirdParty(new JurorPaperResponseDetailDto.ThirdParty(
jurorPaperResponse.getRelationship(), jurorPaperResponse.getThirdPartyReason()
));
jurorPaperResponseDetailDto.setThirdParty(
new JurorPaperResponseDetailDto.ThirdParty(
jurorPaperResponse.getThirdPartyFName(),
jurorPaperResponse.getThirdPartyLName(),
jurorPaperResponse.getMainPhone(),
jurorPaperResponse.getOtherPhone(),
jurorPaperResponse.getEmailAddress(),
jurorPaperResponse.getRelationship(),
jurorPaperResponse.getThirdPartyReason(),
jurorPaperResponse.getThirdPartyOtherReason(),
jurorPaperResponse.getJurorPhoneDetails(),
jurorPaperResponse.getJurorEmailDetails()));

// copy address details
copyAddressToDto(jurorPaperResponse, jurorPaperResponseDetailDto);
Expand Down Expand Up @@ -378,8 +387,16 @@ private PaperResponse createJurorPaperResponseEntity(JurorPaperResponseDto paper
// set up third party details
JurorPaperResponseDto.ThirdParty thirdParty = paperResponseDto.getThirdParty();
if (thirdParty != null) {
jurorPaperResponse.setThirdPartyFName(thirdParty.getThirdPartyFName());
jurorPaperResponse.setThirdPartyLName(thirdParty.getThirdPartyLName());
jurorPaperResponse.setRelationship(thirdParty.getRelationship());
jurorPaperResponse.setMainPhone(thirdParty.getMainPhone());
jurorPaperResponse.setOtherPhone(thirdParty.getOtherPhone());
jurorPaperResponse.setEmailAddress(thirdParty.getEmailAddress());
jurorPaperResponse.setThirdPartyReason(thirdParty.getThirdPartyReason());
jurorPaperResponse.setThirdPartyOtherReason(thirdParty.getThirdPartyOtherReason());
jurorPaperResponse.setJurorPhoneDetails(thirdParty.getUseJurorPhoneDetails());
jurorPaperResponse.setJurorEmailDetails(thirdParty.getUseJurorEmailDetails());
}

// set up eligibility criteria
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,12 @@ private void recordJurorPoolRespondedHistory(String jurorNumber, String auditorU

private void mergeThirdPartyDetails(AbstractJurorResponse abstractJurorResponse, Juror juror) {
if (StringUtils.isNotBlank(abstractJurorResponse.getThirdPartyReason())
|| StringUtils.isNotBlank(abstractJurorResponse.getThirdPartyOtherReason())
|| StringUtils.isNotBlank(abstractJurorResponse.getEmailAddress())
|| StringUtils.isNotBlank(abstractJurorResponse.getMainPhone())
|| StringUtils.isNotBlank(abstractJurorResponse.getOtherPhone())
|| StringUtils.isNotBlank(abstractJurorResponse.getFirstName())
|| StringUtils.isNotBlank(abstractJurorResponse.getLastName())
|| StringUtils.isNotBlank(abstractJurorResponse.getRelationship())) {
if (abstractJurorResponse instanceof DigitalResponse digitalResponse) {
jurorThirdPartyService.createOrUpdateThirdParty(juror, digitalResponse);
Expand All @@ -414,7 +420,7 @@ private void mergeThirdPartyDetails(AbstractJurorResponse abstractJurorResponse,

@Override
public String getThirdPartyOtherReason() {
return null;
return abstractJurorResponse.getThirdPartyOtherReason();
}

@Override
Expand All @@ -424,17 +430,17 @@ public String getThirdPartyReason() {

@Override
public String getThirdPartyEmailAddress() {
return null;
return abstractJurorResponse.getEmailAddress();
}

@Override
public String getThirdPartyOtherPhone() {
return null;
return abstractJurorResponse.getOtherPhone();
}

@Override
public String getThirdPartyMainPhone() {
return null;
return abstractJurorResponse.getMainPhone();
}

@Override
Expand All @@ -444,22 +450,22 @@ public String getThirdPartyRelationship() {

@Override
public String getThirdPartyLastName() {
return null;
return abstractJurorResponse.getThirdPartyLName();
}

@Override
public String getThirdPartyFirstName() {
return null;
return abstractJurorResponse.getThirdPartyFName();
}

@Override
public boolean isContactJurorByEmail() {
return true;
return abstractJurorResponse.getJurorEmailDetails();
}

@Override
public boolean isContactJurorByPhone() {
return true;
return abstractJurorResponse.getJurorPhoneDetails();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,24 @@ public interface JurorResponseService {
String ADDRESS_LINE5 = "address line 5";
String POSTCODE = "postcode";
String DATE_OF_BIRTH = "date of birth";

String THIRD_PARTY_FIRSTNAME = "third party first name";

String THIRD_PARTY_LASTNAME = "third party last name";

String THIRD_PARTY_MAIN_PHONE = "third party main phone";

String THIRD_PARTY_OTHER_PHONE = "third party other phone";

String THIRD_PARTY_EMAIL_ADDRESS = "third party email address";

Boolean THIRD_PARTY_CONTACT_JUROR_BY_PHONE = true;

Boolean THIRD_PARTY_CONTACT_JUROR_BY_EMAIL = true;

String THIRD_PARTY_RELATIONSHIP = "third party relationship";
String THIRD_PARTY_REASON = "third party reason";
String THIRD_PARTY_OTHER_REASON = "third party other reason";
String RESIDENCY = "residency";
String BAIL = "bail";
String EXCUSAL = "excusal";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,19 +227,55 @@ private void checkUpdatesToJurorThirdParty(AbstractJurorResponse jurorResponse,
JurorPaperResponseDto.ThirdParty thirdParty = jurorPersonalDetailsDto.getThirdParty();
if (thirdParty != null) {

if (hasValueChanged(jurorResponse.getThirdPartyFName(), thirdParty.getThirdPartyFName(),
THIRD_PARTY_FIRSTNAME, jurorNumber, replyMethod)) {
jurorResponse.setThirdPartyFName(thirdParty.getThirdPartyFName());
}
if (hasValueChanged(jurorResponse.getThirdPartyLName(), thirdParty.getThirdPartyLName(),
THIRD_PARTY_LASTNAME, jurorNumber, replyMethod)) {
jurorResponse.setThirdPartyLName(thirdParty.getThirdPartyLName());
}
if (hasValueChanged(jurorResponse.getMainPhone(),thirdParty.getMainPhone(),
THIRD_PARTY_MAIN_PHONE, jurorNumber, replyMethod)) {
jurorResponse.setMainPhone(thirdParty.getMainPhone());
}
if (hasValueChanged(jurorResponse.getOtherPhone(),thirdParty.getOtherPhone(),
THIRD_PARTY_OTHER_PHONE, jurorNumber, replyMethod)) {
jurorResponse.setOtherPhone(thirdParty.getOtherPhone());
}
if (hasValueChanged(jurorResponse.getEmailAddress(),thirdParty.getEmailAddress(),
THIRD_PARTY_EMAIL_ADDRESS, jurorNumber, replyMethod)) {
jurorResponse.setEmailAddress(thirdParty.getEmailAddress());
}

if (hasValueChanged(jurorResponse.getRelationship(), thirdParty.getRelationship(),
THIRD_PARTY_RELATIONSHIP, jurorNumber, replyMethod)) {
THIRD_PARTY_RELATIONSHIP, jurorNumber, replyMethod)) {
jurorResponse.setRelationship(thirdParty.getRelationship());
}

if (hasValueChanged(jurorResponse.getThirdPartyReason(),
thirdParty.getThirdPartyReason(), THIRD_PARTY_REASON, jurorNumber, replyMethod)) {
if (hasValueChanged(jurorResponse.getThirdPartyReason(),thirdParty.getThirdPartyReason(),
THIRD_PARTY_REASON, jurorNumber, replyMethod)) {
jurorResponse.setThirdPartyReason(thirdParty.getThirdPartyReason());
}
if (hasValueChanged(jurorResponse.getThirdPartyOtherReason(),thirdParty.getThirdPartyOtherReason(),
THIRD_PARTY_OTHER_REASON, jurorNumber, replyMethod)) {
jurorResponse.setThirdPartyOtherReason(thirdParty.getThirdPartyOtherReason());
}
if (hasValueChanged(jurorResponse.getJurorPhoneDetails(),thirdParty.getUseJurorPhoneDetails(),
String.valueOf(THIRD_PARTY_CONTACT_JUROR_BY_PHONE), jurorNumber, replyMethod)) {
jurorResponse.setJurorPhoneDetails(thirdParty.getUseJurorPhoneDetails());
}
if (hasValueChanged(jurorResponse.getJurorEmailDetails(),thirdParty.getUseJurorEmailDetails(),
String.valueOf(THIRD_PARTY_CONTACT_JUROR_BY_EMAIL), jurorNumber, replyMethod)) {
jurorResponse.setJurorEmailDetails(thirdParty.getUseJurorEmailDetails());

}
}
}
}



private void processStraightThroughResponse(AbstractJurorResponse jurorResponse,
JurorPool jurorPool, BureauJwtPayload payload) {
log.debug(String.format("Juror: %s. Enter juror processStraightThroughResponse", jurorPool.getJurorNumber()));
Expand Down
Loading

0 comments on commit 504ea13

Please sign in to comment.