diff --git a/listing-command/listing-command-api/pom.xml b/listing-command/listing-command-api/pom.xml
index 92b9f91e1..fbcf6471c 100644
--- a/listing-command/listing-command-api/pom.xml
+++ b/listing-command/listing-command-api/pom.xml
@@ -4,7 +4,7 @@
listing-command
uk.gov.moj.cpp.listing
- 17.104.4-SNAPSHOT
+ 17.104.4-MIG-SNAPSHOT
4.0.0
diff --git a/listing-command/listing-command-api/src/main/java/uk/gov/moj/cpp/listing/command/api/ListingCommandApi.java b/listing-command/listing-command-api/src/main/java/uk/gov/moj/cpp/listing/command/api/ListingCommandApi.java
index 5ca66cedd..52e04c4ec 100644
--- a/listing-command/listing-command-api/src/main/java/uk/gov/moj/cpp/listing/command/api/ListingCommandApi.java
+++ b/listing-command/listing-command-api/src/main/java/uk/gov/moj/cpp/listing/command/api/ListingCommandApi.java
@@ -78,6 +78,7 @@ public class ListingCommandApi {
private static final String LISTING_COMMAND_DELETE_HEARING = "listing.command.delete-hearing";
private static final String LISTING_COMMAND_DELETE_PREVIOUS_HEARINGS_AND_CREATE_NEXT_HEARING = "listing.command.delete-previous-hearings-and-create-next-hearing";
private static final String LISTING_COMMAND_UPDATE_HEARING_DAY_COURT_SCHEDULE = "listing.command.update-hearing-day-court-schedule";
+ private static final String LISTING_COMMAND_MIGRATE_CROWN_HEARINGS_TO_COURTSCHEDULES = "listing.command.migrate-crown-hearings-to-courtschedules";
public static final String LISTING_COMMAND_UPDATE_HEARING_ADD_CASE_BDF = "listing.command.update-hearing-add-case-bdf";
private static final Logger LOGGER = LoggerFactory.getLogger(ListingCommandApi.class);
private static final String PROSECUTION_CASES = "prosecutionCases";
@@ -422,6 +423,12 @@ public void handleUpdateHearingDayCourtSchedule(JsonEnvelope envelope) {
envelope.payload()));
}
+ @Handles("listing.migrate-crown-hearings-to-courtschedules")
+ public void handleMigrateCrownHearingsToCourtSchedules(JsonEnvelope envelope) {
+ sender.send(envelopeFrom(metadataFrom(envelope.metadata()).withName(LISTING_COMMAND_MIGRATE_CROWN_HEARINGS_TO_COURTSCHEDULES),
+ envelope.payload()));
+ }
+
@Handles("listing.mark-unallocated-hearing-as-duplicate")
public void handleMarkUnallocatedHearingAsDuplicate(final JsonEnvelope envelope) {
sender.send(envelopeFrom(metadataFrom(envelope.metadata()).withName(LISTING_COMMAND_DUPLICATE_UNALLOCATED_HEARING),
diff --git a/listing-command/listing-command-api/src/main/resources/uk/gov/moj/cpp/listing/command/api/accesscontrol/listing-command-api.drl b/listing-command/listing-command-api/src/main/resources/uk/gov/moj/cpp/listing/command/api/accesscontrol/listing-command-api.drl
index f87b40a53..918a89668 100644
--- a/listing-command/listing-command-api/src/main/resources/uk/gov/moj/cpp/listing/command/api/accesscontrol/listing-command-api.drl
+++ b/listing-command/listing-command-api/src/main/resources/uk/gov/moj/cpp/listing/command/api/accesscontrol/listing-command-api.drl
@@ -202,6 +202,15 @@ rule "Command - API - Action - listing.update-hearing-day-court-schedule"
$outcome.setSuccess(true);
end
+rule "Command - API - Action - listing.migrate-crown-hearings-to-courtschedules"
+ when
+ $outcome: Outcome();
+ $action: Action(name == "listing.migrate-crown-hearings-to-courtschedules");
+ eval(userAndGroupProvider.isSystemUser($action))
+ then
+ $outcome.setSuccess(true);
+end
+
rule "Command - API - Action - listing.mark-unallocated-hearing-as-duplicate"
when
$outcome: Outcome();
diff --git a/listing-command/listing-command-api/src/raml/json/listing.migrate-crown-hearings-to-courtschedules.json b/listing-command/listing-command-api/src/raml/json/listing.migrate-crown-hearings-to-courtschedules.json
new file mode 100644
index 000000000..a46c20600
--- /dev/null
+++ b/listing-command/listing-command-api/src/raml/json/listing.migrate-crown-hearings-to-courtschedules.json
@@ -0,0 +1,30 @@
+{
+ "hearings": [
+ {
+ "hearingId": "4182b7c6-6393-43f8-97ea-9a7e58b72ba4",
+ "hearingDayCourtSchedules": [
+ {
+ "hearingDate": "2026-06-22",
+ "courtScheduleId": "df44e775-d809-4836-a14d-5a9f7c2078c1"
+ }
+ ]
+ },
+ {
+ "hearingId": "7c2b9e10-4d33-4a8e-9b21-0a1f5c6d7e88",
+ "hearingDayCourtSchedules": [
+ {
+ "hearingDate": "2026-07-14",
+ "courtScheduleId": "1b9a4f02-77c1-4e0a-8d3b-2c5e9f10a644"
+ },
+ {
+ "hearingDate": "2026-07-15",
+ "courtScheduleId": "2c0b5103-88d2-4f1b-9e4c-3d6fa021b755"
+ },
+ {
+ "hearingDate": "2026-07-16",
+ "courtScheduleId": "3d1c6214-99e3-401c-af5d-4e70b132c866"
+ }
+ ]
+ }
+ ]
+}
diff --git a/listing-command/listing-command-api/src/raml/json/schema/listing.migrate-crown-hearings-to-courtschedules.json b/listing-command/listing-command-api/src/raml/json/schema/listing.migrate-crown-hearings-to-courtschedules.json
new file mode 100644
index 000000000..2751f7b74
--- /dev/null
+++ b/listing-command/listing-command-api/src/raml/json/schema/listing.migrate-crown-hearings-to-courtschedules.json
@@ -0,0 +1,18 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://justice.gov.uk/listing/courts/listing.migrate-crown-hearings-to-courtschedules.json",
+ "type": "object",
+ "properties": {
+ "hearings": {
+ "type": "array",
+ "minItems": 1,
+ "items": {
+ "$ref": "http://justice.gov.uk/listing/courts/migrate-crown-hearing.json"
+ }
+ }
+ },
+ "required": [
+ "hearings"
+ ],
+ "additionalProperties": false
+}
diff --git a/listing-command/listing-command-api/src/raml/listing-command-api.raml b/listing-command/listing-command-api/src/raml/listing-command-api.raml
index f0d378ebe..68aefb4d7 100644
--- a/listing-command/listing-command-api/src/raml/listing-command-api.raml
+++ b/listing-command/listing-command-api/src/raml/listing-command-api.raml
@@ -315,6 +315,25 @@ protocols: [ HTTP, HTTPS ]
202:
description: Request accepted
+/migrate-crown-hearings-to-courtschedules:
+ post:
+ description: |
+ Bulk-assign courtScheduleId to CROWN hearing days during court-schedule migration.
+ For each hearing, sets only the courtScheduleId on the matching hearing day; all other attributes are unchanged.
+ ...
+ (mapping):
+ requestType: application/vnd.listing.migrate-crown-hearings-to-courtschedules+json
+ name: listing.migrate-crown-hearings-to-courtschedules
+ ...
+ body:
+ application/vnd.listing.migrate-crown-hearings-to-courtschedules+json:
+ schema: !include json/schema/listing.migrate-crown-hearings-to-courtschedules.json
+ example: !include json/listing.migrate-crown-hearings-to-courtschedules.json
+
+ responses:
+ 202:
+ description: Request accepted
+
/delete-hearing/{hearingId}:
post:
description: |
diff --git a/listing-command/listing-command-api/src/test/java/uk/gov/moj/cpp/listing/command/api/ListingAccessControlTest.java b/listing-command/listing-command-api/src/test/java/uk/gov/moj/cpp/listing/command/api/ListingAccessControlTest.java
index 9f8b3351e..444b866f8 100644
--- a/listing-command/listing-command-api/src/test/java/uk/gov/moj/cpp/listing/command/api/ListingAccessControlTest.java
+++ b/listing-command/listing-command-api/src/test/java/uk/gov/moj/cpp/listing/command/api/ListingAccessControlTest.java
@@ -44,6 +44,7 @@ public class ListingAccessControlTest extends BaseDroolsAccessControlTest {
private static final String ACTION_CREATE_LISTING_NOTE = "listing.command.create-listing-note";
private static final String ACTION_DELETE_LISTING_NOTE = "listing.command.delete-listing-note";
private static final String ACTION_MARK_UNALLOCATED_HEARING_AS_DUPLICATE = "listing.mark-unallocated-hearing-as-duplicate";
+ private static final String ACTION_MIGRATE_CROWN_HEARINGS_TO_COURTSCHEDULES = "listing.migrate-crown-hearings-to-courtschedules";
private static final String ACTION_DELETE_HEARING = "listing.command.delete-hearing";
private static final String ACTION_DELETE_PREVIOUS_HEARINGS_AND_CREATE_NEXT_HEARING = "listing.delete-previous-hearings-and-create-next-hearing";
@@ -266,6 +267,26 @@ public void shouldNotAllowNonSystemUserToMarkUnallocatedHearingAsDuplicate() {
assertFailureOutcome(results);
}
+ @Test
+ public void shouldAllowSystemUserToMigrateCrownHearingsToCourtSchedules() {
+ final Action action = createActionFor(ACTION_MIGRATE_CROWN_HEARINGS_TO_COURTSCHEDULES);
+ given(userAndGroupProvider.isSystemUser(action)).willReturn(true);
+
+ final ExecutionResults results = executeRulesWith(action);
+
+ assertSuccessfulOutcome(results);
+ }
+
+ @Test
+ public void shouldNotAllowNonSystemUserToMigrateCrownHearingsToCourtSchedules() {
+ final Action action = createActionFor(ACTION_MIGRATE_CROWN_HEARINGS_TO_COURTSCHEDULES);
+ given(userAndGroupProvider.isSystemUser(action)).willReturn(false);
+
+ final ExecutionResults results = executeRulesWith(action);
+
+ assertFailureOutcome(results);
+ }
+
@Test
public void shouldOnlyAllowHMCTSusersToEditNote() {
diff --git a/listing-command/listing-command-api/src/test/java/uk/gov/moj/cpp/listing/command/api/ListingCommandApiTest.java b/listing-command/listing-command-api/src/test/java/uk/gov/moj/cpp/listing/command/api/ListingCommandApiTest.java
index cd85ad3df..7e4fdb2d9 100644
--- a/listing-command/listing-command-api/src/test/java/uk/gov/moj/cpp/listing/command/api/ListingCommandApiTest.java
+++ b/listing-command/listing-command-api/src/test/java/uk/gov/moj/cpp/listing/command/api/ListingCommandApiTest.java
@@ -883,6 +883,22 @@ public void shouldDeleteListingNote() {
assertThat(senderJsonEnvelopeCaptor.getValue().metadata().name(), is("listing.command.handler.delete-listing-note"));
}
+ @Test
+ public void shouldForwardMigrateCrownHearingsToCourtSchedulesToCommandHandler() {
+ final JsonEnvelope command = mock(JsonEnvelope.class);
+ final MetadataBuilder metadataBuilder = metadataWithRandomUUID("listing.migrate-crown-hearings-to-courtschedules");
+ when(command.metadata()).thenReturn(metadataBuilder.build());
+ final JsonObject payload = mock(JsonObject.class);
+ when(command.payload()).thenReturn(payload);
+
+ final ArgumentCaptor senderEnvelopeCaptor = forClass(Envelope.class);
+ listingCommandApi.handleMigrateCrownHearingsToCourtSchedules(command);
+
+ verify(sender).send(senderEnvelopeCaptor.capture());
+ assertThat(senderEnvelopeCaptor.getValue().metadata().name(), is("listing.command.migrate-crown-hearings-to-courtschedules"));
+ assertThat(senderEnvelopeCaptor.getValue().payload(), is(payload));
+ }
+
@Test
public void shouldEditNote() {
final JsonEnvelope command = mock(JsonEnvelope.class);
diff --git a/listing-command/listing-command-handler/pom.xml b/listing-command/listing-command-handler/pom.xml
index 31b6987c0..d93cbf343 100644
--- a/listing-command/listing-command-handler/pom.xml
+++ b/listing-command/listing-command-handler/pom.xml
@@ -3,7 +3,7 @@
listing-command
uk.gov.moj.cpp.listing
- 17.104.4-SNAPSHOT
+ 17.104.4-MIG-SNAPSHOT
4.0.0
diff --git a/listing-command/listing-command-handler/src/main/java/uk/gov/moj/cpp/listing/command/handler/ListingCommandHandler.java b/listing-command/listing-command-handler/src/main/java/uk/gov/moj/cpp/listing/command/handler/ListingCommandHandler.java
index a9ecb14dd..ca7b8012e 100644
--- a/listing-command/listing-command-handler/src/main/java/uk/gov/moj/cpp/listing/command/handler/ListingCommandHandler.java
+++ b/listing-command/listing-command-handler/src/main/java/uk/gov/moj/cpp/listing/command/handler/ListingCommandHandler.java
@@ -187,6 +187,7 @@ public class ListingCommandHandler {
public static final String HEARING_ID = "hearingId";
private static final String HEARING_DAY_COURT_SCHEDULES = "hearingDayCourtSchedules";
+ private static final String HEARINGS = "hearings";
private static final String PROSECUTION_CASE = "prosecutionCase";
public static final String OUCODE = "oucode";
@@ -1423,15 +1424,32 @@ public void correctHearingDaysWithoutCourtCentre(final JsonEnvelope commandEnvel
public void updateHearingDayCourtSchedule(final JsonEnvelope commandEnvelope) throws EventStreamException {
final JsonObject payload = commandEnvelope.payloadAsJsonObject();
final UUID hearingId = fromString(payload.getString(HEARING_ID));
+ final List hearingDayCourtSchedules = toHearingDayCourtSchedules(payload);
+ updateHearingEventStream(commandEnvelope,
+ hearingId,
+ hearing -> hearing.raiseHearingDayCourtSchedulesUpdated(hearingId, hearingDayCourtSchedules));
+ }
+
+ @Handles("listing.command.migrate-crown-hearings-to-courtschedules")
+ public void migrateCrownHearingsToCourtSchedules(final JsonEnvelope commandEnvelope) throws EventStreamException {
+ final JsonObject payload = commandEnvelope.payloadAsJsonObject();
+ for (final JsonObject hearing : payload.getJsonArray(HEARINGS).getValuesAs(JsonObject.class)) {
+ final UUID hearingId = fromString(hearing.getString(HEARING_ID));
+ final List hearingDayCourtSchedules = toHearingDayCourtSchedules(hearing);
+ final EventStream eventStream = eventSource.getStreamById(hearingId);
+ final Hearing hearingAggregate = aggregateService.get(eventStream, Hearing.class);
+ appendEventsToStream(commandEnvelope, eventStream,
+ hearingAggregate.raiseCrownHearingMigratedToCourtSchedule(hearingId, hearingDayCourtSchedules));
+ }
+ }
+
+ private List toHearingDayCourtSchedules(final JsonObject source) {
final List hearingDayCourtSchedules = new ArrayList<>();
- payload.getJsonArray(HEARING_DAY_COURT_SCHEDULES)
+ source.getJsonArray(HEARING_DAY_COURT_SCHEDULES)
.getValuesAs(JsonObject.class)
- .stream()
.forEach(hearingDayCourtSchedule -> hearingDayCourtSchedules.add(
jsonObjectConverter.convert(hearingDayCourtSchedule, HearingDayCourtSchedule.class)));
- updateHearingEventStream(commandEnvelope,
- hearingId,
- hearing -> hearing.raiseHearingDayCourtSchedulesUpdated(hearingId, hearingDayCourtSchedules));
+ return hearingDayCourtSchedules;
}
@Handles("listing.command.update-cps-prosecutor-with-associated-hearings")
diff --git a/listing-command/listing-command-handler/src/raml/json/listing.command.migrate-crown-hearings-to-courtschedules.json b/listing-command/listing-command-handler/src/raml/json/listing.command.migrate-crown-hearings-to-courtschedules.json
new file mode 100644
index 000000000..a46c20600
--- /dev/null
+++ b/listing-command/listing-command-handler/src/raml/json/listing.command.migrate-crown-hearings-to-courtschedules.json
@@ -0,0 +1,30 @@
+{
+ "hearings": [
+ {
+ "hearingId": "4182b7c6-6393-43f8-97ea-9a7e58b72ba4",
+ "hearingDayCourtSchedules": [
+ {
+ "hearingDate": "2026-06-22",
+ "courtScheduleId": "df44e775-d809-4836-a14d-5a9f7c2078c1"
+ }
+ ]
+ },
+ {
+ "hearingId": "7c2b9e10-4d33-4a8e-9b21-0a1f5c6d7e88",
+ "hearingDayCourtSchedules": [
+ {
+ "hearingDate": "2026-07-14",
+ "courtScheduleId": "1b9a4f02-77c1-4e0a-8d3b-2c5e9f10a644"
+ },
+ {
+ "hearingDate": "2026-07-15",
+ "courtScheduleId": "2c0b5103-88d2-4f1b-9e4c-3d6fa021b755"
+ },
+ {
+ "hearingDate": "2026-07-16",
+ "courtScheduleId": "3d1c6214-99e3-401c-af5d-4e70b132c866"
+ }
+ ]
+ }
+ ]
+}
diff --git a/listing-command/listing-command-handler/src/raml/json/schema/listing.command.migrate-crown-hearings-to-courtschedules.json b/listing-command/listing-command-handler/src/raml/json/schema/listing.command.migrate-crown-hearings-to-courtschedules.json
new file mode 100644
index 000000000..03d2325f7
--- /dev/null
+++ b/listing-command/listing-command-handler/src/raml/json/schema/listing.command.migrate-crown-hearings-to-courtschedules.json
@@ -0,0 +1,18 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "id": "http://justice.gov.uk/listing/courts/listing.command.migrate-crown-hearings-to-courtschedules.json",
+ "type": "object",
+ "properties": {
+ "hearings": {
+ "type": "array",
+ "minItems": 1,
+ "items": {
+ "$ref": "http://justice.gov.uk/listing/courts/migrate-crown-hearing.json"
+ }
+ }
+ },
+ "required": [
+ "hearings"
+ ],
+ "additionalProperties": false
+}
diff --git a/listing-command/listing-command-handler/src/raml/listing-command-handler.messaging.raml b/listing-command/listing-command-handler/src/raml/listing-command-handler.messaging.raml
index cb7060834..b400b48b1 100644
--- a/listing-command/listing-command-handler/src/raml/listing-command-handler.messaging.raml
+++ b/listing-command/listing-command-handler/src/raml/listing-command-handler.messaging.raml
@@ -225,6 +225,10 @@ baseUri: message://command/handler/message/listing
schema: !include json/schema/listing.command.update-hearing-day-court-schedule.json
example: !include json/listing.command.update-hearing-day-court-schedule.json
+ application/vnd.listing.command.migrate-crown-hearings-to-courtschedules+json:
+ schema: !include json/schema/listing.command.migrate-crown-hearings-to-courtschedules.json
+ example: !include json/listing.command.migrate-crown-hearings-to-courtschedules.json
+
application/vnd.listing.command.mark-hearing-as-duplicate+json:
example: !include json/listing.command.mark-hearing-as-duplicate.json
schema: !include json/schema/listing.command.mark-hearing-as-duplicate.json
diff --git a/listing-command/listing-command-handler/src/test/java/uk/gov/moj/cpp/listing/command/handler/ListingCommandHandlerTest.java b/listing-command/listing-command-handler/src/test/java/uk/gov/moj/cpp/listing/command/handler/ListingCommandHandlerTest.java
index 3b377d10a..b86d501f0 100644
--- a/listing-command/listing-command-handler/src/test/java/uk/gov/moj/cpp/listing/command/handler/ListingCommandHandlerTest.java
+++ b/listing-command/listing-command-handler/src/test/java/uk/gov/moj/cpp/listing/command/handler/ListingCommandHandlerTest.java
@@ -4025,6 +4025,34 @@ public void shouldHandleUpdateHearingDaysWithoutCourtSchedule() throws EventStre
verify(hearing).raiseHearingDayCourtSchedulesUpdated(any(), any());
}
+ @Test
+ public void shouldMigrateCrownHearingsToCourtSchedulesForEachHearing() throws EventStreamException, IOException {
+ final UUID hearingId1 = randomUUID();
+ final UUID hearingId2 = randomUUID();
+ final String daysJson1 = "[{\"hearingDate\":\"2026-06-22\",\"courtScheduleId\":\"df44e775-d809-4836-a14d-5a9f7c2078c1\"}]";
+ final String daysJson2 = "[{\"hearingDate\":\"2026-07-14\",\"courtScheduleId\":\"1b9a4f02-77c1-4e0a-8d3b-2c5e9f10a644\"},{\"hearingDate\":\"2026-07-15\",\"courtScheduleId\":\"2c0b5103-88d2-4f1b-9e4c-3d6fa021b755\"}]";
+
+ final JsonArray hearings = createArrayBuilder()
+ .add(createObjectBuilder()
+ .add("hearingId", hearingId1.toString())
+ .add("hearingDayCourtSchedules", objectMapper.readValue(daysJson1, JsonArray.class)))
+ .add(createObjectBuilder()
+ .add("hearingId", hearingId2.toString())
+ .add("hearingDayCourtSchedules", objectMapper.readValue(daysJson2, JsonArray.class)))
+ .build();
+ final JsonObject payload = createObjectBuilder().add("hearings", hearings).build();
+
+ final JsonEnvelope commandEnvelope = envelopeFrom(metadataWithRandomUUID("listing.command.migrate-crown-hearings-to-courtschedules"), payload);
+ when(eventSource.getStreamById(any(UUID.class))).thenReturn(eventStream);
+
+ listingCommandHandler.migrateCrownHearingsToCourtSchedules(commandEnvelope);
+
+ verify(eventSource).getStreamById(hearingId1);
+ verify(eventSource).getStreamById(hearingId2);
+ verify(hearing, times(2)).raiseCrownHearingMigratedToCourtSchedule(any(), any());
+ verify(eventStream, times(2)).append(any());
+ }
+
private void shouldRequestPublicationOfACourtListForAllCrownCourtsAsExpected(final LocalDate dayOfRequest, final LocalDate expectedListingDate) {
fixClock(dayOfRequest.atStartOfDay().toInstant(ZoneOffset.UTC));
diff --git a/listing-command/pom.xml b/listing-command/pom.xml
index 86f034bb8..5afc966ce 100644
--- a/listing-command/pom.xml
+++ b/listing-command/pom.xml
@@ -3,7 +3,7 @@
listing-parent
uk.gov.moj.cpp.listing
- 17.104.4-SNAPSHOT
+ 17.104.4-MIG-SNAPSHOT
4.0.0
diff --git a/listing-common/pom.xml b/listing-common/pom.xml
index 1bb1ffe37..0a38b191b 100644
--- a/listing-common/pom.xml
+++ b/listing-common/pom.xml
@@ -3,7 +3,7 @@
listing-parent
uk.gov.moj.cpp.listing
- 17.104.4-SNAPSHOT
+ 17.104.4-MIG-SNAPSHOT
4.0.0
diff --git a/listing-domain/listing-domain-aggregate/pom.xml b/listing-domain/listing-domain-aggregate/pom.xml
index 590c55d9a..463757ffd 100644
--- a/listing-domain/listing-domain-aggregate/pom.xml
+++ b/listing-domain/listing-domain-aggregate/pom.xml
@@ -3,7 +3,7 @@
listing-domain
uk.gov.moj.cpp.listing
- 17.104.4-SNAPSHOT
+ 17.104.4-MIG-SNAPSHOT
4.0.0
diff --git a/listing-domain/listing-domain-aggregate/src/main/java/uk/gov/moj/cpp/listing/domain/aggregate/Hearing.java b/listing-domain/listing-domain-aggregate/src/main/java/uk/gov/moj/cpp/listing/domain/aggregate/Hearing.java
index 2c7984aed..dcebdf9ee 100644
--- a/listing-domain/listing-domain-aggregate/src/main/java/uk/gov/moj/cpp/listing/domain/aggregate/Hearing.java
+++ b/listing-domain/listing-domain-aggregate/src/main/java/uk/gov/moj/cpp/listing/domain/aggregate/Hearing.java
@@ -89,6 +89,7 @@
import uk.gov.justice.listing.events.HearingAllocatedForListing;
import uk.gov.justice.listing.events.HearingAllocatedForListingV2;
import uk.gov.justice.listing.events.HearingChangesSaved;
+import uk.gov.justice.listing.events.CrownHearingMigratedToCourtschedule;
import uk.gov.justice.listing.events.HearingDayCourtSchedule;
import uk.gov.justice.listing.events.HearingDayCourtScheduleUpdated;
import uk.gov.justice.listing.events.HearingDaysCancelled;
@@ -260,6 +261,7 @@ public Object apply(final Object event) {
when(NonDefaultDaysAssignedToHearing.class).apply(this::onNonDefaultDaysAssignedToHearing),
when(HearingDaysChangedForHearing.class).apply(this::onHearingDaysChangedForHearing),
when(HearingDayCourtScheduleUpdated.class).apply(this::onHearingDayCourtScheduleUpdated),
+ when(CrownHearingMigratedToCourtschedule.class).apply(this::onCrownHearingMigratedToCourtSchedule),
when(HearingDaysCancelled.class).apply(this::onHearingDaysCancelledForHearing),
when(JurisdictionChangedForHearing.class).apply(this::onJurisdictionChangedForHearing),
when(JudiciaryAssignedToHearing.class).apply(this::onJudiciaryAssignedToHearing),
@@ -3177,8 +3179,14 @@ private void onHearingDaysWithoutCourtCentreCorrected(final HearingDaysWithoutCo
}
private void onHearingDayCourtScheduleUpdated(final HearingDayCourtScheduleUpdated hearingDayCourtScheduleUpdated) {
- final List hearingDayCourtSchedules = hearingDayCourtScheduleUpdated.getHearingDayCourtSchedules();
+ mergeCourtScheduleIdsByHearingDate(hearingDayCourtScheduleUpdated.getHearingDayCourtSchedules());
+ }
+
+ private void onCrownHearingMigratedToCourtSchedule(final CrownHearingMigratedToCourtschedule crownHearingMigratedToCourtschedule) {
+ mergeCourtScheduleIdsByHearingDate(crownHearingMigratedToCourtschedule.getHearingDayCourtSchedules());
+ }
+ private void mergeCourtScheduleIdsByHearingDate(final List hearingDayCourtSchedules) {
if (isEmpty(hearingDayCourtSchedules) || isEmpty(hearingDays)) {
return;
}
@@ -3413,6 +3421,14 @@ public Stream