generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PI-2025 Add contact for booking number change
- Loading branch information
1 parent
b095b8f
commit 9d8e5e5
Showing
8 changed files
with
190 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...ison-identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/Contact.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package uk.gov.justice.digital.hmpps.entity | ||
|
||
import jakarta.persistence.* | ||
import org.hibernate.annotations.Immutable | ||
import org.springframework.data.annotation.CreatedBy | ||
import org.springframework.data.annotation.CreatedDate | ||
import org.springframework.data.annotation.LastModifiedBy | ||
import org.springframework.data.annotation.LastModifiedDate | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import uk.gov.justice.digital.hmpps.exception.NotFoundException | ||
import java.time.ZonedDateTime | ||
|
||
@Entity | ||
@EntityListeners(AuditingEntityListener::class) | ||
@SequenceGenerator(name = "contact_id_seq", sequenceName = "contact_id_seq", allocationSize = 1) | ||
class Contact( | ||
@Id | ||
@Column(name = "contact_id") | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "contact_id_seq") | ||
val id: Long = 0, | ||
|
||
@Column(name = "offender_id") | ||
val personId: Long, | ||
|
||
@Column | ||
val eventId: Long, | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "contact_type_id") | ||
val type: ContactType, | ||
|
||
@Lob | ||
val notes: String, | ||
|
||
@Column(name = "probation_area_id") | ||
val providerId: Long, | ||
|
||
@Column(updatable = false) | ||
val teamId: Long, | ||
|
||
@Column(updatable = false) | ||
val staffId: Long, | ||
|
||
@Column(name = "contact_date") | ||
val date: ZonedDateTime = ZonedDateTime.now(), | ||
|
||
@Column(name = "contact_start_time") | ||
val startTime: ZonedDateTime = ZonedDateTime.now(), | ||
|
||
@Column(name = "soft_deleted", columnDefinition = "number") | ||
val softDeleted: Boolean = false, | ||
|
||
@Version | ||
@Column(name = "row_version") | ||
val version: Long = 0, | ||
|
||
@Column | ||
val partitionAreaId: Long = 0, | ||
|
||
@CreatedDate | ||
var createdDatetime: ZonedDateTime = ZonedDateTime.now(), | ||
|
||
@CreatedBy | ||
var createdByUserId: Long = 0, | ||
|
||
@LastModifiedBy | ||
var lastUpdatedUserId: Long = 0, | ||
|
||
@LastModifiedDate | ||
var lastUpdatedDatetime: ZonedDateTime = ZonedDateTime.now() | ||
) | ||
|
||
@Entity | ||
@Immutable | ||
@Table(name = "r_contact_type") | ||
class ContactType( | ||
@Id | ||
@Column(name = "contact_type_id") | ||
val id: Long, | ||
|
||
val code: String | ||
) { | ||
companion object { | ||
const val CUSTODY_UPDATE = "EDSS" | ||
} | ||
} | ||
|
||
interface ContactRepository : JpaRepository<Contact, Long> | ||
interface ContactTypeRepository : JpaRepository<ContactType, Long> { | ||
fun findByCode(code: String): ContactType? | ||
} | ||
|
||
fun ContactTypeRepository.getByCode(code: String): ContactType = | ||
findByCode(code) ?: throw NotFoundException("ContactType", "code", code) |
43 changes: 43 additions & 0 deletions
43
...identifier-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/entity/OrderManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package uk.gov.justice.digital.hmpps.entity | ||
|
||
import jakarta.persistence.Column | ||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
import org.hibernate.annotations.Immutable | ||
import org.hibernate.annotations.SQLRestriction | ||
import org.springframework.data.jpa.repository.JpaRepository | ||
import uk.gov.justice.digital.hmpps.exception.NotFoundException | ||
|
||
@Entity | ||
@Immutable | ||
@SQLRestriction("soft_deleted = 0 and active_flag = 1") | ||
class OrderManager( | ||
@Id | ||
@Column(name = "order_manager_id", nullable = false) | ||
val id: Long, | ||
|
||
@Column | ||
val eventId: Long, | ||
|
||
@Column(name = "allocation_staff_id") | ||
val staffId: Long, | ||
|
||
@Column(name = "allocation_team_id") | ||
val teamId: Long, | ||
|
||
@Column(name = "probation_area_id") | ||
val providerId: Long, | ||
|
||
@Column(name = "active_flag", columnDefinition = "number") | ||
val active: Boolean = true, | ||
|
||
@Column(columnDefinition = "number", nullable = false) | ||
val softDeleted: Boolean = false | ||
) | ||
|
||
interface OrderManagerRepository : JpaRepository<OrderManager, Long> { | ||
fun findByEventId(eventId: Long): OrderManager? | ||
} | ||
|
||
fun OrderManagerRepository.getByEventId(eventId: Long): OrderManager = | ||
findByEventId(eventId) ?: throw NotFoundException("OrderManager", "eventId", eventId) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters