Skip to content

Commit

Permalink
Revert back to cas2 domain events
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones-moj committed Jan 22, 2025
1 parent 0953102 commit 8a63490
Show file tree
Hide file tree
Showing 18 changed files with 82 additions and 783 deletions.
9 changes: 0 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,6 @@ registerAdditionalOpenApiGenerateTask(
useTags = true,
)

registerAdditionalOpenApiGenerateTask(
name = "openApiGenerateCas2v2DomainEvents",
ymlPath = "$rootDir/src/main/resources/static/cas2v2-domain-events-api.yml",
apiPackageName = "uk.gov.justice.digital.hmpps.approvedpremisesapi.api",
modelPackageName = "uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2v2.model",
useTags = true,
)

registerAdditionalOpenApiGenerateTask(
name = "openApiGenerateCas3DomainEvents",
ymlPath = "$rootDir/src/main/resources/static/cas3-domain-events-api.yml",
Expand Down Expand Up @@ -420,7 +412,6 @@ tasks.get("openApiGenerate").dependsOn(
"openApiGenerateDomainEvents",
"openApiGenerateCas3DomainEvents",
"openApiGenerateCas2DomainEvents",
"openApiGenerateCas2v2DomainEvents",
"openApiPreCompilation",
"openApiGenerateCas1Namespace",
"openApiGenerateCas2Namespace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class DomainEventUrlConfig {
DomainEventType.APPROVED_PREMISES_ASSESSMENT_INFO_REQUESTED -> cas1["assessment-info-requested-detail"]
DomainEventType.CAS2_APPLICATION_SUBMITTED -> cas2["application-submitted-event-detail"]
DomainEventType.CAS2_APPLICATION_STATUS_UPDATED -> cas2["application-status-updated-event-detail"]
DomainEventType.CAS2V2_APPLICATION_SUBMITTED -> cas2v2["application-submitted-event-detail"]
DomainEventType.CAS2V2_APPLICATION_STATUS_UPDATED -> cas2v2["application-status-updated-event-detail"]
DomainEventType.CAS3_BOOKING_CANCELLED -> cas3["booking-cancelled-event-detail"]
DomainEventType.CAS3_BOOKING_CONFIRMED -> cas3["booking-confirmed-event-detail"]
DomainEventType.CAS3_BOOKING_PROVISIONALLY_MADE -> cas3["booking-provisionally-made-event-detail"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import java.time.OffsetDateTime
import java.util.UUID
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas1.model.EventType as Cas1EventType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2.model.EventType as Cas2EventType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2v2.model.EventType as Cas2v2EventType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas3.model.EventType as Cas3EventType

@Repository
Expand Down Expand Up @@ -334,18 +333,6 @@ enum class DomainEventType(
"An assessor has updated the status of a CAS2 application",
null,
),
CAS2V2_APPLICATION_SUBMITTED(
DomainEventCas.CAS2v2,
Cas2v2EventType.applicationSubmitted.value,
"An application has been submitted for a CAS2 placement",
null,
),
CAS2V2_APPLICATION_STATUS_UPDATED(
DomainEventCas.CAS2v2,
Cas2v2EventType.applicationStatusUpdated.value,
"An assessor has updated the status of a CAS2 application",
null,
),
CAS3_BOOKING_CANCELLED(
DomainEventCas.CAS3,
Cas3EventType.bookingCancelled.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import jakarta.transaction.Transactional
import org.springframework.beans.factory.annotation.Value
import org.springframework.data.repository.findByIdOrNull
import org.springframework.stereotype.Service
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2v2.model.Cas2v2ApplicationSubmittedEvent
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2v2.model.Cas2v2ApplicationSubmittedEventDetails
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2v2.model.Cas2v2ApplicationSubmittedEventDetailsSubmittedBy
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2v2.model.Cas2v2StaffMember
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2v2.model.EventType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2v2.model.PersonReference
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2.model.Cas2ApplicationSubmittedEvent
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2.model.Cas2ApplicationSubmittedEventDetails
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2.model.Cas2ApplicationSubmittedEventDetailsSubmittedBy
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2.model.Cas2StaffMember
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2.model.EventType
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.events.cas2.model.PersonReference
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.ApplicationOrigin
import uk.gov.justice.digital.hmpps.approvedpremisesapi.api.model.SubmitCas2v2Application
import uk.gov.justice.digital.hmpps.approvedpremisesapi.config.NotifyConfig
Expand All @@ -30,6 +30,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.EmailNotificationService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.UpstreamApiException
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas2.DomainEventService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.service.cas2.OffenderService
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.PageCriteria
import uk.gov.justice.digital.hmpps.approvedpremisesapi.util.getMetadata
Expand All @@ -45,7 +46,7 @@ class Cas2v2ApplicationService(
private val cas2v2JsonSchemaService: Cas2v2JsonSchemaService,
private val cas2OffenderService: OffenderService,
private val cas2v2UserAccessService: Cas2v2UserAccessService,
private val domainEventService: Cas2v2DomainEventService,
private val domainEventService: DomainEventService,
private val emailNotificationService: EmailNotificationService,
private val cas2v2AssessmentService: Cas2v2AssessmentService,
private val notifyConfig: NotifyConfig,
Expand Down Expand Up @@ -318,18 +319,18 @@ class Cas2v2ApplicationService(
val domainEventId = UUID.randomUUID()
val eventOccurredAt = application.submittedAt ?: OffsetDateTime.now()

domainEventService.saveCas2v2ApplicationSubmittedDomainEvent(
domainEventService.saveCas2ApplicationSubmittedDomainEvent(
DomainEvent(
id = domainEventId,
applicationId = application.id,
crn = application.crn,
nomsNumber = application.nomsNumber,
occurredAt = eventOccurredAt.toInstant(),
data = Cas2v2ApplicationSubmittedEvent(
data = Cas2ApplicationSubmittedEvent(
id = domainEventId,
timestamp = eventOccurredAt.toInstant(),
eventType = EventType.applicationSubmitted,
eventDetails = Cas2v2ApplicationSubmittedEventDetails(
eventDetails = Cas2ApplicationSubmittedEventDetails(
applicationId = application.id,
applicationUrl = applicationUrlTemplate
.replace("#id", application.id.toString()),
Expand All @@ -342,14 +343,14 @@ class Cas2v2ApplicationService(
preferredAreas = application.preferredAreas,
hdcEligibilityDate = application.hdcEligibilityDate,
conditionalReleaseDate = application.conditionalReleaseDate,
submittedBy = Cas2v2ApplicationSubmittedEventDetailsSubmittedBy(
staffMember = Cas2v2StaffMember(
staffIdentifier = application.createdByUser.staffIdentifier(),
submittedBy = Cas2ApplicationSubmittedEventDetailsSubmittedBy(
staffMember = Cas2StaffMember(
staffIdentifier = application.createdByUser.nomisStaffId ?: 0,
name = application.createdByUser.name,
username = application.createdByUser.username,
),
),
applicationOrigin = application.applicationOrigin.toString(),
cas2v2ApplicationOrigin = application.applicationOrigin.toString(),
),
),
),
Expand Down

This file was deleted.

Loading

0 comments on commit 8a63490

Please sign in to comment.