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

BR-34 #9

Merged
merged 2 commits into from
Feb 21, 2025
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 @@ -40,9 +40,7 @@ data class BreachNoticeEntity(
var nextAppointmentDate: LocalDateTime? = null,
var nextAppointmentLocation: String? = null,
var nextAppointmentOfficer: String? = null,
@OneToOne(cascade = [CascadeType.ALL], orphanRemoval = true)
@JoinColumn(name = "next_appointment_contact_id", unique = true)
var nextAppointmentContact: BreachNoticeContactEntity? = null,
var nextAppointmentId: Long? = null,
var completedDate: LocalDateTime? = null,
@CreatedBy
var createdByUser: String? = null,
Expand All @@ -68,4 +66,6 @@ data class BreachNoticeEntity(
val breachNoticeContactList: List<BreachNoticeContactEntity> = emptyList(),
@OneToMany(cascade = [CascadeType.ALL], orphanRemoval = true, mappedBy = "breachNotice")
val breachNoticeRequirementList: List<BreachNoticeRequirementEntity> = emptyList(),
var optionalNumberChecked: Boolean? = null,
var optionalNumber: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ data class BreachNotice(
val nextAppointmentDate: LocalDateTime? = null,
val nextAppointmentLocation: String? = null,
val nextAppointmentOfficer: String? = null,
val nextAppointmentContact: BreachNoticeContact? = null,
val nextAppointmentId: Long? = null,
val completedDate: LocalDateTime? = null,
val offenderAddress: Address? = null,
val replyAddress: Address? = null,
Expand All @@ -37,4 +37,6 @@ data class BreachNotice(
val breachNoticeContactList: List<BreachNoticeContact> = emptyList(),
@field:JsonSetter(nulls = Nulls.AS_EMPTY)
val breachNoticeRequirementList: List<BreachNoticeRequirement> = emptyList(),
val optionalNumberChecked: Boolean? = null,
val optionalNumber: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ data class BreachNoticeDetails(
val nextAppointmentDate: LocalDateTime? = null,
val nextAppointmentLocation: String? = null,
val nextAppointmentOfficer: String? = null,
val nextAppointmentContact: BreachNoticeContact? = null,
val nextAppointmentId: Long? = null,
val completedDate: LocalDateTime? = null,
val offenderAddress: Address? = null,
val replyAddress: Address? = null,
Expand All @@ -39,4 +39,6 @@ data class BreachNoticeDetails(
val breachNoticeContactList: List<BreachNoticeContact> = emptyList(),
@field:JsonSetter(nulls = Nulls.AS_EMPTY)
val breachNoticeRequirementList: List<BreachNoticeRequirement> = emptyList(),
val optionalNumberChecked: Boolean? = null,
val optionalNumber: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class BreachNoticeService(
nextAppointmentDate = nextAppointmentDate,
nextAppointmentLocation = nextAppointmentLocation,
nextAppointmentOfficer = nextAppointmentOfficer,
nextAppointmentContact = nextAppointmentContact?.toEntity(existingEntity.nextAppointmentContact),
nextAppointmentId = nextAppointmentId,
completedDate = completedDate,
offenderAddress = offenderAddress?.toEntity(existingEntity.offenderAddress),
replyAddress = replyAddress?.toEntity(existingEntity.replyAddress),
Expand Down Expand Up @@ -115,7 +115,7 @@ class BreachNoticeService(
nextAppointmentDate = nextAppointmentDate,
nextAppointmentLocation = nextAppointmentLocation,
nextAppointmentOfficer = nextAppointmentOfficer,
nextAppointmentContact = nextAppointmentContact?.toEntity(),
nextAppointmentId = nextAppointmentId,
completedDate = completedDate,
offenderAddress = offenderAddress?.toEntity(),
replyAddress = replyAddress?.toEntity(),
Expand All @@ -125,6 +125,8 @@ class BreachNoticeService(
nextAppointmentSaved = nextAppointmentSaved,
useDefaultAddress = useDefaultAddress,
useDefaultReplyAddress = useDefaultReplyAddress,
optionalNumberChecked = optionalNumberChecked,
optionalNumber = optionalNumber,
breachNoticeRequirementList = breachNoticeRequirementList.map { it.toEntity() },
breachNoticeContactList = breachNoticeContactList.map { it.toEntity() },
)
Expand All @@ -148,7 +150,7 @@ class BreachNoticeService(
nextAppointmentDate = nextAppointmentDate,
nextAppointmentLocation = nextAppointmentLocation,
nextAppointmentOfficer = nextAppointmentOfficer,
nextAppointmentContact = nextAppointmentContact?.toModel(),
nextAppointmentId = nextAppointmentId,
completedDate = completedDate,
offenderAddress = offenderAddress?.toModel(),
replyAddress = replyAddress?.toModel(),
Expand All @@ -160,6 +162,8 @@ class BreachNoticeService(
useDefaultReplyAddress = useDefaultReplyAddress,
breachNoticeContactList = breachNoticeContactList.map { it.toModel() },
breachNoticeRequirementList = breachNoticeRequirementList.map { it.toModel() },
optionalNumberChecked = optionalNumberChecked,
optionalNumber = optionalNumber,
)

fun getBreachNoticeById(uuid: UUID) = breachNoticeRepository.findById(uuid).getOrNull()?.let {
Expand All @@ -182,6 +186,7 @@ class BreachNoticeService(
nextAppointmentDate = it.nextAppointmentDate,
nextAppointmentLocation = it.nextAppointmentLocation,
nextAppointmentOfficer = it.nextAppointmentOfficer,
nextAppointmentId = it.nextAppointmentId,
completedDate = it.completedDate,
offenderAddress = it.offenderAddress?.toModel(),
replyAddress = it.replyAddress?.toModel(),
Expand All @@ -193,7 +198,8 @@ class BreachNoticeService(
useDefaultReplyAddress = it.useDefaultReplyAddress,
breachNoticeContactList = it.breachNoticeContactList.map { it.toModel() },
breachNoticeRequirementList = it.breachNoticeRequirementList.map { it.toModel() },

optionalNumberChecked = it.optionalNumberChecked,
optionalNumber = it.optionalNumber,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE public.breach_notice DROP CONSTRAINT xfk1_breach_notice_contact;
ALTER TABLE public.breach_notice DROP COLUMN next_appointment_contact_id;
ALTER TABLE public.breach_notice ADD optional_number_checked boolean NULL;
ALTER TABLE public.breach_notice ADD optional_number varchar(255) NULL;
ALTER TABLE public.breach_notice ADD next_appointment_id integer NULL;

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BreachNoticeCrudTests : IntegrationTestBase() {
nextAppointmentDate = LocalDateTime.now(),
nextAppointmentLocation = "NXT_LOCATION",
nextAppointmentOfficer = "APPT_OFFICER",
nextAppointmentContact = null,
nextAppointmentId = null,
completedDate = LocalDateTime.now(),
offenderAddress = Address(
addressId = 25,
Expand Down Expand Up @@ -143,7 +143,7 @@ class BreachNoticeCrudTests : IntegrationTestBase() {
nextAppointmentDate = LocalDateTime.now(),
nextAppointmentLocation = "NXT_LOCATION",
nextAppointmentOfficer = "APPT_OFFICER",
nextAppointmentContact = null,
nextAppointmentId = null,
completedDate = LocalDateTime.now(),
offenderAddress = Address(
addressId = 25,
Expand Down