Skip to content

Commit

Permalink
Merge pull request #2715 from ministryofjustice/chore/rename-cas1-dom…
Browse files Browse the repository at this point in the history
…ain-events

Move DomainEventService to Cas1DomainEventService
  • Loading branch information
davidatkinsuk authored Dec 17, 2024
2 parents 848135f + 80791a8 commit 590df5a
Show file tree
Hide file tree
Showing 37 changed files with 87 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas1.model.Pl
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas1.model.RequestForPlacementAssessedEnvelope
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas1.model.RequestForPlacementCreatedEnvelope
import uk.gov.justice.digital.hmpps.approvedpremisesapi.problem.NotFoundProblem
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1DomainEventService
import java.util.UUID

@SuppressWarnings("TooManyFunctions")
@Service
class DomainEventsController(
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
) : EventsApiDelegate {
override fun eventsApplicationSubmittedEventIdGet(eventId: UUID) = getDomainEvent<ApplicationSubmittedEnvelope>(eventId)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.Cas1SpaceBook
import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.DomainEventType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.DomainEvent
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.DomainEventSummary
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1PlacementRequestDomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.javaConstantNameToSentence
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.toUiDateTimeFormat
Expand All @@ -28,7 +28,7 @@ import java.util.UUID
@SuppressWarnings("TooManyFunctions")
@Component
class DomainEventDescriber(
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
private val assessmentClarificationNoteRepository: AssessmentClarificationNoteRepository,
private val bookingRepository: BookingRepository,
private val cas1SpaceBookingRepository: Cas1SpaceBookingRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.DomainEventEn
import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.DomainEventType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.reporting.model.ApprovedPremisesApplicationMetricsSummaryDto
import uk.gov.justice.digital.hmpps.approvedpremisesapi.reporting.model.DailyMetricReportRow
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1ReportService
import java.time.LocalDate

class DailyMetricsReportGenerator(
private val domainEvents: List<DomainEventEntity>,
private val applications: List<ApprovedPremisesApplicationMetricsSummaryDto>,
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
) : ReportGenerator<LocalDate, DailyMetricReportRow, Cas1ReportService.MonthSpecificReportParams>(DailyMetricReportRow::class) {
override fun filter(properties: Cas1ReportService.MonthSpecificReportParams): (LocalDate) -> Boolean = {
true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.cas1.Cas1Deli
import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.cas1.Cas1DeliusBookingImportRepository
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.DomainEvent
import uk.gov.justice.digital.hmpps.approvedpremisesapi.seed.SeedJob
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.EnvironmentService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.toLocalDate
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.toLocalDateTime
import java.time.LocalDate
Expand All @@ -45,7 +45,7 @@ class Cas1BookingToSpaceBookingSeedJob(
private val spaceBookingRepository: Cas1SpaceBookingRepository,
private val bookingRepository: BookingRepository,
private val domainEventRepository: DomainEventRepository,
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
private val userRepository: UserRepository,
private val transactionTemplate: TransactionTemplate,
private val cas1DeliusBookingImportRepository: Cas1DeliusBookingImportRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package uk.gov.justice.digital.hmpps.approvedpremisesapi.seed.cas1
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import uk.gov.justice.digital.hmpps.approvedpremisesapi.seed.SeedJob
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1DomainEventService
import java.util.UUID

@Component
class Cas1DomainEventReplaySeedJob(
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
) : SeedJob<Cas1DomainEventReplaySeedCsvRow>(
requiredHeaders = setOf(
"domain_event_id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.results.CasResult
import uk.gov.justice.digital.hmpps.approvedpremisesapi.results.ValidatableActionResult
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1ApplicationDomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1ApplicationEmailService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.WithdrawableState
import uk.gov.justice.digital.hmpps.approvedpremisesapi.transformer.ApplicationTimelineNoteTransformer
import uk.gov.justice.digital.hmpps.approvedpremisesapi.transformer.ApplicationTimelineTransformer
Expand Down Expand Up @@ -87,7 +88,7 @@ class ApplicationService(
private val offlineApplicationRepository: OfflineApplicationRepository,
private val applicationTimelineNoteService: ApplicationTimelineNoteService,
private val applicationTimelineNoteTransformer: ApplicationTimelineNoteTransformer,
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
private val cas3DomainEventService: uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas3.DomainEventService,
private val apDeliusContextApiClient: ApDeliusContextApiClient,
private val applicationTeamCodeRepository: ApplicationTeamCodeRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.results.CasResult
import uk.gov.justice.digital.hmpps.approvedpremisesapi.results.ValidatableActionResult
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1AssessmentDomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1AssessmentEmailService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1PlacementRequestEmailService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.allocations.UserAllocator
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.PageCriteria
Expand All @@ -75,7 +76,7 @@ class AssessmentService(
private val assessmentReferralHistoryNoteRepository: AssessmentReferralHistoryNoteRepository,
private val referralRejectionReasonRepository: ReferralRejectionReasonRepository,
private val jsonSchemaService: JsonSchemaService,
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
private val offenderService: OffenderService,
private val apDeliusContextApiClient: ApDeliusContextApiClient,
private val placementRequestService: PlacementRequestService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.client.ClientResult
import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.AppealEntity
import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.ApprovedPremisesApplicationEntity
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.DomainEvent
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.UrlTemplate
import java.util.UUID

@Service
class Cas1AppealDomainEventService(
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
private val apDeliusContextApiClient: ApDeliusContextApiClient,
@Value("\${url-templates.frontend.application}") private val applicationUrlTemplate: UrlTemplate,
@Value("\${url-templates.frontend.application-appeal}") private val applicationAppealUrlTemplate: UrlTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.community.Offender
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.deliuscontext.CaseDetail
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.deliuscontext.StaffDetail
import uk.gov.justice.digital.hmpps.approvedpremisesapi.results.AuthorisableActionResult
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.OffenderService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.transformer.DomainEventTransformer
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.UrlTemplate
Expand All @@ -37,7 +36,7 @@ import java.util.UUID

@Service
class Cas1ApplicationDomainEventService(
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
private val offenderService: OffenderService,
private val apDeliusContextApiClient: ApDeliusContextApiClient,
private val domainEventTransformer: DomainEventTransformer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.UserEntity
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.DomainEvent
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.asApprovedPremisesType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.community.OffenderDetailSummary
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.UrlTemplate
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.toLocalDateTime
import java.time.Instant
import java.util.UUID

@Service
class Cas1AssessmentDomainEventService(
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
private val apDeliusContextApiClient: ApDeliusContextApiClient,
@Value("\${url-templates.frontend.application}") private val applicationUrlTemplate: UrlTemplate,
@Value("\${url-templates.frontend.assessment}") private val assessmentUrlTemplate: UrlTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.UserQualifica
import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.cas1.Cas1ApplicationFacade
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.DomainEvent
import uk.gov.justice.digital.hmpps.approvedpremisesapi.results.AuthorisableActionResult
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.OffenderService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.UrlTemplate
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.mapOfNonNullValues
Expand All @@ -41,7 +40,7 @@ import java.util.UUID

@Service
class Cas1BookingDomainEventService(
val domainEventService: DomainEventService,
val domainEventService: Cas1DomainEventService,
val offenderService: OffenderService,
val apDeliusContextApiClient: ApDeliusContextApiClient,
@Value("\${url-templates.frontend.application}") private val applicationUrlTemplate: UrlTemplate,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package uk.gov.justice.digital.hmpps.approvedpremisesapi.service
package uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1

import com.fasterxml.jackson.databind.ObjectMapper
import jakarta.transaction.Transactional
Expand Down Expand Up @@ -37,14 +37,16 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.domainevent.SnsEve
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.domainevent.SnsEventPersonReference
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.domainevent.SnsEventPersonReferenceCollection
import uk.gov.justice.digital.hmpps.approvedpremisesapi.problem.NotFoundProblem
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1DomainEventMigrationService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.ConfiguredDomainEventWorker
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.UserService
import java.time.OffsetDateTime
import java.time.ZoneOffset
import java.util.UUID
import kotlin.reflect.KClass

@SuppressWarnings("TooManyFunctions")
@Service
class DomainEventService(
class Cas1DomainEventService(
private val objectMapper: ObjectMapper,
private val domainEventRepository: DomainEventRepository,
val domainEventWorker: ConfiguredDomainEventWorker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.PlacementAppl
import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.PlacementType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.UserEntity
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.DomainEvent
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.transformer.DomainEventTransformer
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.UrlTemplate
import java.time.Instant
import java.util.UUID

@Component
class Cas1PlacementApplicationDomainEventService(
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
private val domainEventTransformer: DomainEventTransformer,
private val apDeliusContextApiClient: ApDeliusContextApiClient,
@Value("\${url-templates.frontend.application}") private val applicationUrlTemplate: UrlTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas1.model.Re
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas1.model.RequestForPlacementType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.PlacementRequestEntity
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.DomainEvent
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.PlacementRequestSource
import uk.gov.justice.digital.hmpps.approvedpremisesapi.transformer.DomainEventTransformer
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.UrlTemplate
Expand All @@ -22,7 +21,7 @@ import java.util.UUID

@Service
class Cas1PlacementRequestDomainEventService(
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
private val domainEventTransformer: DomainEventTransformer,
@Value("\${url-templates.frontend.application}") private val applicationUrlTemplate: UrlTemplate,
val clock: Clock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.reporting.model.Approved
import uk.gov.justice.digital.hmpps.approvedpremisesapi.reporting.properties.LostBedReportProperties
import uk.gov.justice.digital.hmpps.approvedpremisesapi.reporting.util.CsvJdbcResultSetConsumer
import uk.gov.justice.digital.hmpps.approvedpremisesapi.reporting.util.ExcelJdbcResultSetConsumer
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.toLocalDate
import java.io.OutputStream
import java.time.LocalDate
Expand All @@ -42,7 +41,7 @@ class Cas1ReportService(
private val domainEventRepository: DomainEventRepository,
private val lostBedsRepository: LostBedsRepository,
private val cas1OutOfServiceBedRepository: Cas1OutOfServiceBedRepository,
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
private val placementApplicationEntityReportRowRepository: PlacementApplicationEntityReportRowRepository,
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.UserEntity
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.DomainEvent
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.PersonSummaryInfoResult
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.deliuscontext.CaseSummary
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.OffenderService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.transformer.ApplicationTimelineTransformer
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.UrlTemplate
Expand All @@ -46,7 +45,7 @@ class Cas1SpaceBookingManagementDomainEventServiceConfig(

@Service
class Cas1SpaceBookingManagementDomainEventService(
val domainEventService: DomainEventService,
val domainEventService: Cas1DomainEventService,
val offenderService: OffenderService,
private val cas1SpaceBookingManagementConfig: Cas1SpaceBookingManagementDomainEventServiceConfig,
private val applicationTimelineTransformer: ApplicationTimelineTransformer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.ApprovedPremi
import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.TriggerSourceType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.ApprovedPremisesApplicationStatus
import uk.gov.justice.digital.hmpps.approvedpremisesapi.model.DomainEvent
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1DomainEventService
import java.time.Instant
import java.util.UUID

@Service
class Cas1ExpiredApplicationsScheduledJob(
private val domainEventService: DomainEventService,
private val domainEventService: Cas1DomainEventService,
private val applicationRepository: ApplicationRepository,
private val transactionTemplate: TransactionTemplate,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.bodyAsObject
import java.time.ZoneOffset
import java.util.UUID

class DomainEventTest : InitialiseDatabasePerClassTestBase() {
class Cas1DomainEventTest : InitialiseDatabasePerClassTestBase() {
@Autowired
lateinit var domainEventUrlConfig: DomainEventUrlConfig

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import uk.gov.justice.digital.hmpps.approvedpremisesapi.jpa.entity.UserRole
import uk.gov.justice.digital.hmpps.approvedpremisesapi.reporting.generator.DailyMetricsReportGenerator
import uk.gov.justice.digital.hmpps.approvedpremisesapi.reporting.model.ApprovedPremisesApplicationMetricsSummaryDto
import uk.gov.justice.digital.hmpps.approvedpremisesapi.reporting.model.DailyMetricReportRow
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas1.Cas1ReportService.MonthSpecificReportParams
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.toLocalDateTime
import java.time.LocalDate
Expand All @@ -37,7 +37,7 @@ import java.util.UUID
class DailyMetricsReportTest : IntegrationTestBase() {

@Autowired
lateinit var domainEventService: DomainEventService
lateinit var domainEventService: Cas1DomainEventService

@Test
fun `Get daily metrics report for returns 403 Forbidden if user does not have access`() {
Expand Down
Loading

0 comments on commit 590df5a

Please sign in to comment.