diff --git a/pom.xml b/pom.xml index 652018abc3..62ffe4c74d 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ uk.gov.moj.cpp.sjp sjp-parent - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT pom diff --git a/sjp-command/pom.xml b/sjp-command/pom.xml index 3fb7981f83..d38a77af0a 100644 --- a/sjp-command/pom.xml +++ b/sjp-command/pom.xml @@ -3,7 +3,7 @@ sjp-parent uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-command/sjp-command-api/pom.xml b/sjp-command/sjp-command-api/pom.xml index dadb0c5bce..e68227b465 100644 --- a/sjp-command/sjp-command-api/pom.xml +++ b/sjp-command/sjp-command-api/pom.xml @@ -3,7 +3,7 @@ sjp-command uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-command/sjp-command-api/src/main/java/uk/gov/moj/cpp/sjp/command/api/SessionApi.java b/sjp-command/sjp-command-api/src/main/java/uk/gov/moj/cpp/sjp/command/api/SessionApi.java index 80d5fa0549..053ce8c51b 100644 --- a/sjp-command/sjp-command-api/src/main/java/uk/gov/moj/cpp/sjp/command/api/SessionApi.java +++ b/sjp-command/sjp-command-api/src/main/java/uk/gov/moj/cpp/sjp/command/api/SessionApi.java @@ -68,6 +68,12 @@ public void endSession(final JsonEnvelope envelope) { sender.send(enveloper.withMetadataFrom(envelope, "sjp.command.end-session").apply(envelope.payloadAsJsonObject())); } + @Handles("sjp.update-session-bdf") + public void updateSessionBdf(final JsonEnvelope updateSessionCommand) { + validateSessionId(updateSessionCommand); + sender.send(enveloper.withMetadataFrom(updateSessionCommand, "sjp.command.update-session-bdf").apply(updateSessionCommand.payloadAsJsonObject())); + } + @Handles("sjp.assign-next-case") public void assignNextCase(final JsonEnvelope assignCaseCommand) { sender.send(enveloper.withMetadataFrom(assignCaseCommand, "sjp.command.assign-next-case").apply(assignCaseCommand.payloadAsJsonObject())); diff --git a/sjp-command/sjp-command-api/src/main/resources/rules/command-session-api.drl b/sjp-command/sjp-command-api/src/main/resources/rules/command-session-api.drl index 945eb9c8f8..7531f3ffa9 100644 --- a/sjp-command/sjp-command-api/src/main/resources/rules/command-session-api.drl +++ b/sjp-command/sjp-command-api/src/main/resources/rules/command-session-api.drl @@ -25,6 +25,15 @@ rule "Command - Rule for end session" $outcome.setSuccess(true); end +rule "Command - Rule for update session" + when + $outcome: Outcome(); + $action: Action(name == "sjp.update-session-bdf"); + eval(userAndGroupProvider.isMemberOfAnyOfTheSuppliedGroups($action, RuleConstants.getSystemUsers())); + then + $outcome.setSuccess(true); +end + rule "Command - Rule for assigning case" when $outcome: Outcome(); diff --git a/sjp-command/sjp-command-api/src/raml/json/schema/sjp.update-session-bdf.json b/sjp-command/sjp-command-api/src/raml/json/schema/sjp.update-session-bdf.json new file mode 100644 index 0000000000..75fd8c3ac3 --- /dev/null +++ b/sjp-command/sjp-command-api/src/raml/json/schema/sjp.update-session-bdf.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "magistrate": { + "type": "string" + }, + "courtHouseCode": { + "type": "string" + }, + "courtHouseName": { + "type": "string" + }, + "localJusticeAreaNationalCourtCode": { + "type": "string" + }, + "type": { + "type": "string", + "enum": ["MAGISTRATE", "DELEGATED_POWERS", "AOCP"] + }, + "legalAdviserUserId": { + "$ref": "http://justice.gov.uk/domain/core/common/definitions.json#/definitions/uuid" + } + }, + "minProperties": 1, + "additionalProperties": false +} diff --git a/sjp-command/sjp-command-api/src/raml/json/sjp.update-session-bdf.json b/sjp-command/sjp-command-api/src/raml/json/sjp.update-session-bdf.json new file mode 100644 index 0000000000..41b546a756 --- /dev/null +++ b/sjp-command/sjp-command-api/src/raml/json/sjp.update-session-bdf.json @@ -0,0 +1,8 @@ +{ + "magistrate": "Alan Smith", + "courtHouseCode": "B01LY", + "courtHouseName": "Coventry Magistrates' Court", + "localJusticeAreaNationalCourtCode": "2924", + "type": "MAGISTRATE", + "legalAdviserUserId": "31ec3a16-8721-498c-8da5-f099390ee254" +} diff --git a/sjp-command/sjp-command-api/src/raml/sjp-command-api.raml b/sjp-command/sjp-command-api/src/raml/sjp-command-api.raml index 6b01825c49..a183296127 100644 --- a/sjp-command/sjp-command-api/src/raml/sjp-command-api.raml +++ b/sjp-command/sjp-command-api/src/raml/sjp-command-api.raml @@ -502,6 +502,9 @@ baseUri: http://localhost:8080/sjp-command-api/command/api/rest/sjp (mapping): requestType: application/vnd.sjp.assign-next-case+json name: sjp.assign-next-case + (mapping): + requestType: application/vnd.sjp.update-session-bdf+json + name: sjp.update-session-bdf ... body: application/vnd.sjp.start-session+json: @@ -511,6 +514,11 @@ baseUri: http://localhost:8080/sjp-command-api/command/api/rest/sjp !include json/schema/sjp.start-session.json application/vnd.sjp.end-session+json: !!null application/vnd.sjp.assign-next-case+json: !!null + application/vnd.sjp.update-session-bdf+json: + example: + !include json/sjp.update-session-bdf.json + schema: + !include json/schema/sjp.update-session-bdf.json responses: 202: description: Accepted diff --git a/sjp-command/sjp-command-controller/pom.xml b/sjp-command/sjp-command-controller/pom.xml index 41ed1c96c0..e89a949cdc 100644 --- a/sjp-command/sjp-command-controller/pom.xml +++ b/sjp-command/sjp-command-controller/pom.xml @@ -3,7 +3,7 @@ sjp-command uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-command/sjp-command-controller/src/main/java/uk/gov/moj/cpp/sjp/command/controller/NoActionController.java b/sjp-command/sjp-command-controller/src/main/java/uk/gov/moj/cpp/sjp/command/controller/NoActionController.java index 9731c88991..ce59da4c07 100644 --- a/sjp-command/sjp-command-controller/src/main/java/uk/gov/moj/cpp/sjp/command/controller/NoActionController.java +++ b/sjp-command/sjp-command-controller/src/main/java/uk/gov/moj/cpp/sjp/command/controller/NoActionController.java @@ -72,6 +72,11 @@ public void endSession(final JsonEnvelope envelope) { send(envelope); } + @Handles("sjp.command.update-session-bdf") + public void updateSessionBdf(final JsonEnvelope envelope) { + send(envelope); + } + @Handles("sjp.command.reset-aocp-session") public void resetAocpSession(final JsonEnvelope envelope) { send(envelope); diff --git a/sjp-command/sjp-command-controller/src/main/resources/rules/command-session.drl b/sjp-command/sjp-command-controller/src/main/resources/rules/command-session.drl index 8b651cd4c7..2239706273 100644 --- a/sjp-command/sjp-command-controller/src/main/resources/rules/command-session.drl +++ b/sjp-command/sjp-command-controller/src/main/resources/rules/command-session.drl @@ -19,6 +19,14 @@ rule "Command - Rule for end session" $outcome.setSuccess(true); end +rule "Command - Rule for update session" + when + $outcome: Outcome(); + $action: Action(name == "sjp.command.update-session-bdf"); + then + $outcome.setSuccess(true); +end + rule "Command - Rule for reset aocp session request" when $outcome: Outcome(); diff --git a/sjp-command/sjp-command-controller/src/raml/json/schema/sjp.command.update-session-bdf.json b/sjp-command/sjp-command-controller/src/raml/json/schema/sjp.command.update-session-bdf.json new file mode 100644 index 0000000000..649c08b1db --- /dev/null +++ b/sjp-command/sjp-command-controller/src/raml/json/schema/sjp.command.update-session-bdf.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://justice.gov.uk/json/schemas/domains/sjp/command/sjp.update-session-bdf.json", + "$ref": "http://justice.gov.uk/json/schemas/domains/sjp/commands/sjp.update-session-bdf.json" +} diff --git a/sjp-command/sjp-command-controller/src/raml/json/sjp.command.update-session-bdf.json b/sjp-command/sjp-command-controller/src/raml/json/sjp.command.update-session-bdf.json new file mode 100644 index 0000000000..c7c8d14af0 --- /dev/null +++ b/sjp-command/sjp-command-controller/src/raml/json/sjp.command.update-session-bdf.json @@ -0,0 +1,9 @@ +{ + "sessionId": "c70867c0-3d9b-4cd4-978d-056a2915bb75", + "magistrate": "Alan Smith", + "courtHouseCode": "B01LY", + "courtHouseName": "Coventry Magistrates' Court", + "localJusticeAreaNationalCourtCode": "2924", + "type": "MAGISTRATE", + "legalAdviserUserId": "31ec3a16-8721-498c-8da5-f099390ee254" +} diff --git a/sjp-command/sjp-command-controller/src/raml/sjp-command-controller.messaging.raml b/sjp-command/sjp-command-controller/src/raml/sjp-command-controller.messaging.raml index b3366901c4..adb0f6a706 100644 --- a/sjp-command/sjp-command-controller/src/raml/sjp-command-controller.messaging.raml +++ b/sjp-command/sjp-command-controller/src/raml/sjp-command-controller.messaging.raml @@ -82,6 +82,10 @@ version: v1 example: !include json/sjp.command.end-session.json schema: !include json/schema/sjp.command.end-session.json + application/vnd.sjp.command.update-session-bdf+json: + example: !include json/sjp.command.update-session-bdf.json + schema: !include json/schema/sjp.command.update-session-bdf.json + application/vnd.sjp.command.reset-aocp-session+json: !!null application/vnd.sjp.command.assign-next-case+json: diff --git a/sjp-command/sjp-command-handler/pom.xml b/sjp-command/sjp-command-handler/pom.xml index f2f299dd54..f18d027798 100644 --- a/sjp-command/sjp-command-handler/pom.xml +++ b/sjp-command/sjp-command-handler/pom.xml @@ -3,7 +3,7 @@ sjp-command uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-command/sjp-command-handler/src/main/java/uk/gov/moj/cpp/sjp/command/handler/SessionHandler.java b/sjp-command/sjp-command-handler/src/main/java/uk/gov/moj/cpp/sjp/command/handler/SessionHandler.java index 86f977a0af..ba515470e3 100644 --- a/sjp-command/sjp-command-handler/src/main/java/uk/gov/moj/cpp/sjp/command/handler/SessionHandler.java +++ b/sjp-command/sjp-command-handler/src/main/java/uk/gov/moj/cpp/sjp/command/handler/SessionHandler.java @@ -23,6 +23,7 @@ import uk.gov.justice.services.eventsourcing.source.core.exception.EventStreamException; import uk.gov.justice.services.messaging.JsonEnvelope; import uk.gov.justice.services.messaging.JsonObjects; +import uk.gov.moj.cpp.sjp.domain.SessionType; import uk.gov.moj.cpp.sjp.domain.aggregate.Session; import uk.gov.moj.cpp.sjp.event.session.ResetAocpSession; @@ -94,6 +95,21 @@ public void endSession(final JsonEnvelope endSessionCommand) throws EventStreamE applyToSessionAggregate(endSessionCommand, session -> session.endSession(sessionId, clock.now())); } + @Handles("sjp.command.update-session-bdf") + public void updateSessionBdf(final JsonEnvelope updateSessionCommand) throws EventStreamException { + final JsonObject updateSession = updateSessionCommand.payloadAsJsonObject(); + final UUID sessionId = UUID.fromString(updateSession.getString(SESSION_ID)); + final Optional magistrate = JsonObjects.getString(updateSession, MAGISTRATE); + final Optional courtHouseCode = JsonObjects.getString(updateSession, COURT_HOUSE_CODE); + final Optional courtHouseName = JsonObjects.getString(updateSession, COURT_HOUSE_NAME); + final Optional localJusticeAreaNationalCourtCode = JsonObjects.getString(updateSession, LOCAL_JUSTICE_AREA_NATIONAL_COURT_CODE); + final Optional type = JsonObjects.getString(updateSession, "type").map(SessionType::valueOf); + final Optional legalAdviserUserId = JsonObjects.getString(updateSession, "legalAdviserUserId").map(UUID::fromString); + + applyToSessionAggregate(updateSessionCommand, session -> + session.updateSessionBdf(sessionId, magistrate, courtHouseCode, courtHouseName, localJusticeAreaNationalCourtCode, type, legalAdviserUserId)); + } + @Handles("sjp.command.reset-aocp-session") public void resetAocpSessionRequest(final JsonEnvelope command) throws EventStreamException { diff --git a/sjp-command/sjp-command-handler/src/raml/json/schema/sjp.command.update-session-bdf.json b/sjp-command/sjp-command-handler/src/raml/json/schema/sjp.command.update-session-bdf.json new file mode 100644 index 0000000000..649c08b1db --- /dev/null +++ b/sjp-command/sjp-command-handler/src/raml/json/schema/sjp.command.update-session-bdf.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://justice.gov.uk/json/schemas/domains/sjp/command/sjp.update-session-bdf.json", + "$ref": "http://justice.gov.uk/json/schemas/domains/sjp/commands/sjp.update-session-bdf.json" +} diff --git a/sjp-command/sjp-command-handler/src/raml/json/sjp.command.update-session-bdf.json b/sjp-command/sjp-command-handler/src/raml/json/sjp.command.update-session-bdf.json new file mode 100644 index 0000000000..c7c8d14af0 --- /dev/null +++ b/sjp-command/sjp-command-handler/src/raml/json/sjp.command.update-session-bdf.json @@ -0,0 +1,9 @@ +{ + "sessionId": "c70867c0-3d9b-4cd4-978d-056a2915bb75", + "magistrate": "Alan Smith", + "courtHouseCode": "B01LY", + "courtHouseName": "Coventry Magistrates' Court", + "localJusticeAreaNationalCourtCode": "2924", + "type": "MAGISTRATE", + "legalAdviserUserId": "31ec3a16-8721-498c-8da5-f099390ee254" +} diff --git a/sjp-command/sjp-command-handler/src/raml/sjp-command-handler.messaging.raml b/sjp-command/sjp-command-handler/src/raml/sjp-command-handler.messaging.raml index 4423815d7f..28891bce76 100644 --- a/sjp-command/sjp-command-handler/src/raml/sjp-command-handler.messaging.raml +++ b/sjp-command/sjp-command-handler/src/raml/sjp-command-handler.messaging.raml @@ -84,6 +84,10 @@ version: v1 schema: !include json/schema/sjp.command.end-session.json example: !include json/sjp.command.end-session.json + application/vnd.sjp.command.update-session-bdf+json: + schema: !include json/schema/sjp.command.update-session-bdf.json + example: !include json/sjp.command.update-session-bdf.json + application/vnd.sjp.command.assign-next-case+json: schema: !include json/schema/sjp.command.assign-next-case.json example: !include json/sjp.command.assign-next-case.json diff --git a/sjp-command/sjp-command-handler/src/test/java/uk/gov/moj/cpp/sjp/command/handler/SessionHandlerTest.java b/sjp-command/sjp-command-handler/src/test/java/uk/gov/moj/cpp/sjp/command/handler/SessionHandlerTest.java index 235f2a3be6..699b73ee8d 100644 --- a/sjp-command/sjp-command-handler/src/test/java/uk/gov/moj/cpp/sjp/command/handler/SessionHandlerTest.java +++ b/sjp-command/sjp-command-handler/src/test/java/uk/gov/moj/cpp/sjp/command/handler/SessionHandlerTest.java @@ -40,6 +40,7 @@ import uk.gov.justice.services.messaging.JsonEnvelope; import uk.gov.justice.services.messaging.MetadataBuilder; import uk.gov.justice.services.test.utils.common.helper.StoppedClock; +import uk.gov.moj.cpp.sjp.domain.SessionType; import uk.gov.moj.cpp.sjp.domain.aggregate.Session; import uk.gov.moj.cpp.sjp.event.session.DelegatedPowersSessionEnded; import uk.gov.moj.cpp.sjp.event.session.DelegatedPowersSessionStarted; @@ -47,6 +48,7 @@ import uk.gov.moj.cpp.sjp.event.session.MagistrateSessionStarted; import uk.gov.moj.cpp.sjp.event.session.ResetAocpSession; import uk.gov.moj.cpp.sjp.event.session.SessionEnded; +import uk.gov.moj.cpp.sjp.event.session.SessionUpdatedBdf; import java.time.ZonedDateTime; import java.time.temporal.ChronoUnit; @@ -73,6 +75,7 @@ public class SessionHandlerTest { private static final String START_SESSION_COMMAND = "sjp.command.start-session"; private static final String END_SESSION_COMMAND = "sjp.command.end-session"; private static final String RESET_SESSION_COMMAND = "sjp.command.reset-aocp-session"; + private static final String UPDATE_SESSION_BDF_COMMAND = "sjp.command.update-session-bdf"; @Mock private EventSource eventSource; @@ -98,7 +101,8 @@ public class SessionHandlerTest { MagistrateSessionEnded.class, DelegatedPowersSessionStarted.class, DelegatedPowersSessionEnded.class, - ResetAocpSession.class); + ResetAocpSession.class, + SessionUpdatedBdf.class); @Spy private Clock clock = new StoppedClock(ZonedDateTime.now(UTC)); @@ -131,7 +135,8 @@ public void shouldHandleSessionCommands() { .with(allOf( method("startSession").thatHandles(START_SESSION_COMMAND), method("endSession").thatHandles(END_SESSION_COMMAND), - method("resetAocpSessionRequest").thatHandles(RESET_SESSION_COMMAND) + method("resetAocpSessionRequest").thatHandles(RESET_SESSION_COMMAND), + method("updateSessionBdf").thatHandles(UPDATE_SESSION_BDF_COMMAND) ))); } @@ -249,6 +254,88 @@ public void shouldResetSession() throws EventStreamException { } + @Test + public void shouldUpdateSessionBdfWithAllFields() throws EventStreamException { + + final String magistrate = randomAlphanumeric(20); + final UUID legalAdviserUserId = randomUUID(); + + final JsonEnvelope updateSessionCommand = envelopeFrom(metadataWithRandomUUID(UPDATE_SESSION_BDF_COMMAND), + createObjectBuilder() + .add("sessionId", sessionId.toString()) + .add("magistrate", magistrate) + .add("courtHouseCode", courtHouseCode) + .add("courtHouseName", courtHouseName) + .add("localJusticeAreaNationalCourtCode", localJusticeAreaNationalCourtCode) + .add("type", SessionType.MAGISTRATE.name()) + .add("legalAdviserUserId", legalAdviserUserId.toString()) + .build()); + + final SessionUpdatedBdf sessionUpdatedBdf = new SessionUpdatedBdf(sessionId, Optional.of(magistrate), Optional.of(courtHouseCode), Optional.of(courtHouseName), + Optional.of(localJusticeAreaNationalCourtCode), Optional.of(SessionType.MAGISTRATE), Optional.of(legalAdviserUserId)); + + when(eventSource.getStreamById(sessionId)).thenReturn(sessionEventStream); + when(aggregateService.get(sessionEventStream, Session.class)).thenReturn(session); + when(session.updateSessionBdf(sessionId, Optional.of(magistrate), Optional.of(courtHouseCode), Optional.of(courtHouseName), + Optional.of(localJusticeAreaNationalCourtCode), Optional.of(SessionType.MAGISTRATE), Optional.of(legalAdviserUserId))) + .thenReturn(Stream.of(sessionUpdatedBdf)); + + sessionHandler.updateSessionBdf(updateSessionCommand); + + assertThat(sessionEventStream, eventStreamAppendedWith( + streamContaining( + jsonEnvelope( + withMetadataEnvelopedFrom(updateSessionCommand) + .withName(SessionUpdatedBdf.EVENT_NAME), + payloadIsJson(allOf( + withJsonPath("$.sessionId", equalTo(sessionId.toString())), + withJsonPath("$.magistrate", equalTo(magistrate)), + withJsonPath("$.courtHouseCode", equalTo(courtHouseCode)), + withJsonPath("$.courtHouseName", equalTo(courtHouseName)), + withJsonPath("$.localJusticeAreaNationalCourtCode", equalTo(localJusticeAreaNationalCourtCode)), + withJsonPath("$.type", equalTo(SessionType.MAGISTRATE.name())), + withJsonPath("$.legalAdviserUserId", equalTo(legalAdviserUserId.toString())) + )))))); + } + + @Test + public void shouldUpdateSessionBdfWithOnlyMagistrate() throws EventStreamException { + + final String magistrate = randomAlphanumeric(20); + + final JsonEnvelope updateSessionCommand = envelopeFrom(metadataWithRandomUUID(UPDATE_SESSION_BDF_COMMAND), + createObjectBuilder() + .add("sessionId", sessionId.toString()) + .add("magistrate", magistrate) + .build()); + + final SessionUpdatedBdf sessionUpdatedBdf = new SessionUpdatedBdf(sessionId, Optional.of(magistrate), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty()); + + when(eventSource.getStreamById(sessionId)).thenReturn(sessionEventStream); + when(aggregateService.get(sessionEventStream, Session.class)).thenReturn(session); + when(session.updateSessionBdf(sessionId, Optional.of(magistrate), Optional.empty(), Optional.empty(), + Optional.empty(), Optional.empty(), Optional.empty())) + .thenReturn(Stream.of(sessionUpdatedBdf)); + + sessionHandler.updateSessionBdf(updateSessionCommand); + + assertThat(sessionEventStream, eventStreamAppendedWith( + streamContaining( + jsonEnvelope( + withMetadataEnvelopedFrom(updateSessionCommand) + .withName(SessionUpdatedBdf.EVENT_NAME), + payloadIsJson(allOf( + withJsonPath("$.sessionId", equalTo(sessionId.toString())), + withJsonPath("$.magistrate", equalTo(magistrate)), + withoutJsonPath("$.courtHouseCode"), + withoutJsonPath("$.courtHouseName"), + withoutJsonPath("$.localJusticeAreaNationalCourtCode"), + withoutJsonPath("$.type"), + withoutJsonPath("$.legalAdviserUserId") + )))))); + } + private void shouldEndSession(final SessionEnded sessionEnded) throws EventStreamException { final JsonEnvelope endSessionCommand = envelopeFrom(metadataWithRandomUUID(END_SESSION_COMMAND), createObjectBuilder().add("sessionId", sessionEnded.getSessionId().toString()).build()); diff --git a/sjp-domain/pom.xml b/sjp-domain/pom.xml index c3732ae460..4a0ff362db 100644 --- a/sjp-domain/pom.xml +++ b/sjp-domain/pom.xml @@ -5,7 +5,7 @@ uk.gov.moj.cpp.sjp sjp-parent - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT sjp-domain diff --git a/sjp-domain/sjp-domain-aggregate/pom.xml b/sjp-domain/sjp-domain-aggregate/pom.xml index 424fec42f2..2096b92bd3 100644 --- a/sjp-domain/sjp-domain-aggregate/pom.xml +++ b/sjp-domain/sjp-domain-aggregate/pom.xml @@ -5,7 +5,7 @@ uk.gov.moj.cpp.sjp sjp-domain - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT sjp-domain-aggregate diff --git a/sjp-domain/sjp-domain-aggregate/src/main/java/uk/gov/moj/cpp/sjp/domain/aggregate/Session.java b/sjp-domain/sjp-domain-aggregate/src/main/java/uk/gov/moj/cpp/sjp/domain/aggregate/Session.java index c788b3ad15..9a2408bdcc 100644 --- a/sjp-domain/sjp-domain-aggregate/src/main/java/uk/gov/moj/cpp/sjp/domain/aggregate/Session.java +++ b/sjp-domain/sjp-domain-aggregate/src/main/java/uk/gov/moj/cpp/sjp/domain/aggregate/Session.java @@ -19,6 +19,7 @@ import uk.gov.moj.cpp.sjp.event.session.DelegatedPowersSessionStarted; import uk.gov.moj.cpp.sjp.event.session.MagistrateSessionEnded; import uk.gov.moj.cpp.sjp.event.session.MagistrateSessionStarted; +import uk.gov.moj.cpp.sjp.event.session.SessionUpdatedBdf; import uk.gov.moj.cpp.sjp.event.session.SessionStarted; import java.time.ZonedDateTime; @@ -106,6 +107,26 @@ public Stream startAocpSession( return apply(streamBuilder.build()); } + public Stream updateSessionBdf( + final UUID sessionId, + final Optional magistrate, + final Optional courtHouseCode, + final Optional courtHouseName, + final Optional localJusticeAreaNationalCourtCode, + final Optional type, + final Optional legalAdviserUserId) { + + final Stream.Builder streamBuilder = Stream.builder(); + + if (sessionState == SessionState.NOT_EXISTING) { + LOGGER.warn("Session can not be updated - session {} does not exist", sessionId); + } else { + streamBuilder.add(new SessionUpdatedBdf(sessionId, magistrate, courtHouseCode, courtHouseName, localJusticeAreaNationalCourtCode, type, legalAdviserUserId)); + } + + return apply(streamBuilder.build()); + } + public Stream endSession(final UUID sessionId, final ZonedDateTime endedAt) { final Stream.Builder streamBuilder = Stream.builder(); @@ -174,6 +195,13 @@ public Object apply(final Object event) { sessionType = AOCP; prosecutors = sessionStarted.getProsecutors(); }), + when(SessionUpdatedBdf.class).apply(sessionUpdated -> { + sessionUpdated.getMagistrate().ifPresent(value -> magistrate = value); + sessionUpdated.getCourtHouseCode().ifPresent(value -> courtHouseCode = value); + sessionUpdated.getCourtHouseName().ifPresent(value -> courtHouseName = value); + sessionUpdated.getLocalJusticeAreaNationalCourtCode().ifPresent(value -> localJusticeAreaNationalCourtCode = value); + sessionUpdated.getType().ifPresent(value -> sessionType = value); + }), when(MagistrateSessionEnded.class).apply(sessionEnded -> sessionState = SessionState.ENDED), when(DelegatedPowersSessionEnded.class).apply(sessionEnded -> sessionState = SessionState.ENDED), when(AocpSessionEnded.class).apply(sessionEnded -> sessionState = SessionState.ENDED), diff --git a/sjp-domain/sjp-domain-common/pom.xml b/sjp-domain/sjp-domain-common/pom.xml index 83352fdb01..a0277651b9 100644 --- a/sjp-domain/sjp-domain-common/pom.xml +++ b/sjp-domain/sjp-domain-common/pom.xml @@ -5,7 +5,7 @@ uk.gov.moj.cpp.sjp sjp-domain - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT diff --git a/sjp-domain/sjp-domain-event-processor/pom.xml b/sjp-domain/sjp-domain-event-processor/pom.xml index 3a22aa980f..e53cf5bfd3 100644 --- a/sjp-domain/sjp-domain-event-processor/pom.xml +++ b/sjp-domain/sjp-domain-event-processor/pom.xml @@ -3,7 +3,7 @@ sjp-domain uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-domain/sjp-domain-event/pom.xml b/sjp-domain/sjp-domain-event/pom.xml index b804fbee08..caf694e5e4 100644 --- a/sjp-domain/sjp-domain-event/pom.xml +++ b/sjp-domain/sjp-domain-event/pom.xml @@ -5,7 +5,7 @@ uk.gov.moj.cpp.sjp sjp-domain - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT sjp-domain-event diff --git a/sjp-domain/sjp-domain-event/src/main/java/uk/gov/moj/cpp/sjp/event/session/SessionUpdatedBdf.java b/sjp-domain/sjp-domain-event/src/main/java/uk/gov/moj/cpp/sjp/event/session/SessionUpdatedBdf.java new file mode 100644 index 0000000000..3b5617612a --- /dev/null +++ b/sjp-domain/sjp-domain-event/src/main/java/uk/gov/moj/cpp/sjp/event/session/SessionUpdatedBdf.java @@ -0,0 +1,76 @@ +package uk.gov.moj.cpp.sjp.event.session; + +import uk.gov.justice.domain.annotation.Event; +import uk.gov.moj.cpp.sjp.domain.SessionType; + +import java.util.Optional; +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +@Event(SessionUpdatedBdf.EVENT_NAME) +public class SessionUpdatedBdf { + + public static final String EVENT_NAME = "sjp.events.session-updated-bdf"; + + private final UUID sessionId; + + private final Optional magistrate; + + private final Optional courtHouseCode; + + private final Optional courtHouseName; + + private final Optional localJusticeAreaNationalCourtCode; + + private final Optional type; + + private final Optional legalAdviserUserId; + + @JsonCreator + public SessionUpdatedBdf( + @JsonProperty("sessionId") final UUID sessionId, + @JsonProperty("magistrate") final Optional magistrate, + @JsonProperty("courtHouseCode") final Optional courtHouseCode, + @JsonProperty("courtHouseName") final Optional courtHouseName, + @JsonProperty("localJusticeAreaNationalCourtCode") final Optional localJusticeAreaNationalCourtCode, + @JsonProperty("type") final Optional type, + @JsonProperty("legalAdviserUserId") final Optional legalAdviserUserId) { + this.sessionId = sessionId; + this.magistrate = magistrate; + this.courtHouseCode = courtHouseCode; + this.courtHouseName = courtHouseName; + this.localJusticeAreaNationalCourtCode = localJusticeAreaNationalCourtCode; + this.type = type; + this.legalAdviserUserId = legalAdviserUserId; + } + + public UUID getSessionId() { + return sessionId; + } + + public Optional getMagistrate() { + return magistrate; + } + + public Optional getCourtHouseCode() { + return courtHouseCode; + } + + public Optional getCourtHouseName() { + return courtHouseName; + } + + public Optional getLocalJusticeAreaNationalCourtCode() { + return localJusticeAreaNationalCourtCode; + } + + public Optional getType() { + return type; + } + + public Optional getLegalAdviserUserId() { + return legalAdviserUserId; + } +} diff --git a/sjp-domain/sjp-domain-prosecution/pom.xml b/sjp-domain/sjp-domain-prosecution/pom.xml index 49ed5c5d51..60e0092a04 100644 --- a/sjp-domain/sjp-domain-prosecution/pom.xml +++ b/sjp-domain/sjp-domain-prosecution/pom.xml @@ -4,7 +4,7 @@ sjp-domain uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT sjp-domain-prosecution diff --git a/sjp-domain/sjp-domain-transformation/pom.xml b/sjp-domain/sjp-domain-transformation/pom.xml index ca55ce3a73..04032b5c08 100644 --- a/sjp-domain/sjp-domain-transformation/pom.xml +++ b/sjp-domain/sjp-domain-transformation/pom.xml @@ -3,7 +3,7 @@ sjp-domain uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-domain/sjp-domain-transformation/sjp-domain-transformation-anonymise/pom.xml b/sjp-domain/sjp-domain-transformation/sjp-domain-transformation-anonymise/pom.xml index d75ad27447..334628c3ed 100644 --- a/sjp-domain/sjp-domain-transformation/sjp-domain-transformation-anonymise/pom.xml +++ b/sjp-domain/sjp-domain-transformation/sjp-domain-transformation-anonymise/pom.xml @@ -3,7 +3,7 @@ sjp-domain-transformation uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-domain/sjp-domain-transformation/sjp-domain-transformation-postcode/pom.xml b/sjp-domain/sjp-domain-transformation/sjp-domain-transformation-postcode/pom.xml index 655863a63b..17bced114e 100644 --- a/sjp-domain/sjp-domain-transformation/sjp-domain-transformation-postcode/pom.xml +++ b/sjp-domain/sjp-domain-transformation/sjp-domain-transformation-postcode/pom.xml @@ -3,7 +3,7 @@ sjp-domain-transformation uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-event-sources/pom.xml b/sjp-event-sources/pom.xml index fdf178715c..0d15ebf6b0 100644 --- a/sjp-event-sources/pom.xml +++ b/sjp-event-sources/pom.xml @@ -3,7 +3,7 @@ sjp-parent uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT ../pom.xml 4.0.0 diff --git a/sjp-event/pom.xml b/sjp-event/pom.xml index d224b33788..6f62a96028 100644 --- a/sjp-event/pom.xml +++ b/sjp-event/pom.xml @@ -3,7 +3,7 @@ sjp-parent uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-event/sjp-event-indexer/pom.xml b/sjp-event/sjp-event-indexer/pom.xml index 6c6f91b2ea..9372dc99d7 100644 --- a/sjp-event/sjp-event-indexer/pom.xml +++ b/sjp-event/sjp-event-indexer/pom.xml @@ -3,7 +3,7 @@ sjp-event uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-event/sjp-event-listener/pom.xml b/sjp-event/sjp-event-listener/pom.xml index b11f0a92aa..80453d4264 100644 --- a/sjp-event/sjp-event-listener/pom.xml +++ b/sjp-event/sjp-event-listener/pom.xml @@ -3,7 +3,7 @@ sjp-event uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-event/sjp-event-listener/src/main/java/uk/gov/moj/cpp/sjp/event/listener/SessionListener.java b/sjp-event/sjp-event-listener/src/main/java/uk/gov/moj/cpp/sjp/event/listener/SessionListener.java index b0c9205ee1..c222d11d95 100644 --- a/sjp-event/sjp-event-listener/src/main/java/uk/gov/moj/cpp/sjp/event/listener/SessionListener.java +++ b/sjp-event/sjp-event-listener/src/main/java/uk/gov/moj/cpp/sjp/event/listener/SessionListener.java @@ -1,5 +1,6 @@ package uk.gov.moj.cpp.sjp.event.listener; +import static java.util.Optional.ofNullable; import static uk.gov.justice.services.core.annotation.Component.EVENT_LISTENER; import uk.gov.justice.services.common.converter.JsonObjectToObjectConverter; @@ -13,6 +14,7 @@ import uk.gov.moj.cpp.sjp.event.session.DelegatedPowersSessionStarted; import uk.gov.moj.cpp.sjp.event.session.MagistrateSessionEnded; import uk.gov.moj.cpp.sjp.event.session.MagistrateSessionStarted; +import uk.gov.moj.cpp.sjp.event.session.SessionUpdatedBdf; import uk.gov.moj.cpp.sjp.persistence.entity.Session; import uk.gov.moj.cpp.sjp.persistence.repository.SessionRepository; @@ -99,6 +101,20 @@ public void handleAocpSessionStarted(final JsonEnvelope event) { } + @Transactional + @Handles(SessionUpdatedBdf.EVENT_NAME) + public void handleSessionUpdatedBdf(final JsonEnvelope sessionUpdatedEvent) { + final JsonObject sessionUpdated = sessionUpdatedEvent.payloadAsJsonObject(); + final Session session = sessionRepository.findBy(UUID.fromString(sessionUpdated.getString(SESSION_ID))); + + ofNullable(sessionUpdated.getString("magistrate", null)).ifPresent(session::setMagistrate); + ofNullable(sessionUpdated.getString(COURT_HOUSE_CODE, null)).ifPresent(session::setCourtHouseCode); + ofNullable(sessionUpdated.getString(COURT_HOUSE_NAME, null)).ifPresent(session::setCourtHouseName); + ofNullable(sessionUpdated.getString(LEGAL_JUSTICE_AREA_NATIONAL_COURT_CODE, null)).ifPresent(session::setLocalJusticeAreaNationalCourtCode); + ofNullable(sessionUpdated.getString("type", null)).ifPresent(type -> session.setType(SessionType.valueOf(type))); + ofNullable(sessionUpdated.getString("legalAdviserUserId", null)).ifPresent(legalAdviserUserId -> session.setLegalAdviserUserId(UUID.fromString(legalAdviserUserId))); + } + @Transactional @Handles(DelegatedPowersSessionEnded.EVENT_NAME) public void handleDelegatedPowersSessionEnded(final JsonEnvelope delegatedPowersSessionEnded) { diff --git a/sjp-event/sjp-event-listener/src/test/java/uk/gov/moj/cpp/sjp/event/listener/SessionListenerTest.java b/sjp-event/sjp-event-listener/src/test/java/uk/gov/moj/cpp/sjp/event/listener/SessionListenerTest.java index 30a87121a0..693d7ff88d 100644 --- a/sjp-event/sjp-event-listener/src/test/java/uk/gov/moj/cpp/sjp/event/listener/SessionListenerTest.java +++ b/sjp-event/sjp-event-listener/src/test/java/uk/gov/moj/cpp/sjp/event/listener/SessionListenerTest.java @@ -5,6 +5,9 @@ import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static uk.gov.justice.services.messaging.JsonEnvelope.envelopeFrom; @@ -28,6 +31,7 @@ import uk.gov.moj.cpp.sjp.event.session.DelegatedPowersSessionStarted; import uk.gov.moj.cpp.sjp.event.session.MagistrateSessionEnded; import uk.gov.moj.cpp.sjp.event.session.MagistrateSessionStarted; +import uk.gov.moj.cpp.sjp.event.session.SessionUpdatedBdf; import uk.gov.moj.cpp.sjp.persistence.entity.Session; import uk.gov.moj.cpp.sjp.persistence.repository.SessionRepository; @@ -270,7 +274,8 @@ public void shouldHandlesQuery() { method("handleDelegatedPowersSessionStarted").thatHandles(DelegatedPowersSessionStarted.EVENT_NAME), method("handleMagistrateSessionStarted").thatHandles(MagistrateSessionStarted.EVENT_NAME), method("handleDelegatedPowersSessionEnded").thatHandles(DelegatedPowersSessionEnded.EVENT_NAME), - method("handleMagistrateSessionEnded").thatHandles(MagistrateSessionEnded.EVENT_NAME) + method("handleMagistrateSessionEnded").thatHandles(MagistrateSessionEnded.EVENT_NAME), + method("handleSessionUpdatedBdf").thatHandles(SessionUpdatedBdf.EVENT_NAME) ))); } @@ -336,6 +341,53 @@ public void shouldHandleAocpStartedEvent() { assertThat(session.getProsecutors().get(1), equalTo(DVL)); } + @Test + public void shouldHandleSessionUpdatedBdfEventWithAllFields() { + + final JsonEnvelope sessionUpdatedBdf = envelopeFrom(metadataWithRandomUUID(SessionUpdatedBdf.EVENT_NAME), + createObjectBuilder() + .add("sessionId", sessionId.toString()) + .add("magistrate", magistrate) + .add("courtHouseCode", courtHouseCode) + .add("courtHouseName", courtHouseName) + .add("localJusticeAreaNationalCourtCode", localJusticeAreaNationalCourtCode) + .add("type", SessionType.MAGISTRATE.name()) + .add("legalAdviserUserId", legalAdviserUserId.toString()) + .build()); + + when(sessionRepository.findBy(sessionId)).thenReturn(existingSession); + + sessionListener.handleSessionUpdatedBdf(sessionUpdatedBdf); + + verify(existingSession).setMagistrate(magistrate); + verify(existingSession).setCourtHouseCode(courtHouseCode); + verify(existingSession).setCourtHouseName(courtHouseName); + verify(existingSession).setLocalJusticeAreaNationalCourtCode(localJusticeAreaNationalCourtCode); + verify(existingSession).setType(SessionType.MAGISTRATE); + verify(existingSession).setLegalAdviserUserId(legalAdviserUserId); + } + + @Test + public void shouldNotUpdateFieldsAbsentFromSessionUpdatedBdfEvent() { + + final JsonEnvelope sessionUpdatedBdf = envelopeFrom(metadataWithRandomUUID(SessionUpdatedBdf.EVENT_NAME), + createObjectBuilder() + .add("sessionId", sessionId.toString()) + .add("magistrate", magistrate) + .build()); + + when(sessionRepository.findBy(sessionId)).thenReturn(existingSession); + + sessionListener.handleSessionUpdatedBdf(sessionUpdatedBdf); + + verify(existingSession).setMagistrate(magistrate); + verify(existingSession, never()).setCourtHouseCode(anyString()); + verify(existingSession, never()).setCourtHouseName(anyString()); + verify(existingSession, never()).setLocalJusticeAreaNationalCourtCode(anyString()); + verify(existingSession, never()).setType(any(SessionType.class)); + verify(existingSession, never()).setLegalAdviserUserId(any(UUID.class)); + } + @Test public void shouldHandleAocpEndedEvent() { diff --git a/sjp-event/sjp-event-listener/src/yaml/json/schema/sjp.events.session-updated-bdf.json b/sjp-event/sjp-event-listener/src/yaml/json/schema/sjp.events.session-updated-bdf.json new file mode 100644 index 0000000000..e06cc9e558 --- /dev/null +++ b/sjp-event/sjp-event-listener/src/yaml/json/schema/sjp.events.session-updated-bdf.json @@ -0,0 +1,5 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://justice.gov.uk/json/schemas/domains/sjp/event/session-updated-bdf.json", + "$ref": "http://justice.gov.uk/json/schemas/domains/sjp/events/session-updated-bdf.json" +} diff --git a/sjp-event/sjp-event-listener/src/yaml/subscriptions-descriptor.yaml b/sjp-event/sjp-event-listener/src/yaml/subscriptions-descriptor.yaml index d6899ac9f2..156ef961ad 100644 --- a/sjp-event/sjp-event-listener/src/yaml/subscriptions-descriptor.yaml +++ b/sjp-event/sjp-event-listener/src/yaml/subscriptions-descriptor.yaml @@ -137,6 +137,9 @@ subscriptions_descriptor: - name: sjp.events.aocp-session-started schema_uri: http://justice.gov.uk/json/schemas/domains/sjp/event/aocp-session-started.json + - name: sjp.events.session-updated-bdf + schema_uri: http://justice.gov.uk/json/schemas/domains/sjp/event/session-updated-bdf.json + - name: sjp.events.magistrate-session-ended schema_uri: http://justice.gov.uk/json/schemas/domains/sjp/event/magistrate-session-ended.json diff --git a/sjp-event/sjp-event-processor/pom.xml b/sjp-event/sjp-event-processor/pom.xml index 4843550093..798af54451 100644 --- a/sjp-event/sjp-event-processor/pom.xml +++ b/sjp-event/sjp-event-processor/pom.xml @@ -3,7 +3,7 @@ sjp-event uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-healthchecks/pom.xml b/sjp-healthchecks/pom.xml index 5f142a8cdc..d3c06f18a1 100644 --- a/sjp-healthchecks/pom.xml +++ b/sjp-healthchecks/pom.xml @@ -3,7 +3,7 @@ sjp-parent uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-integration-test/pom.xml b/sjp-integration-test/pom.xml index 038bb5d42c..abfe1a1b87 100644 --- a/sjp-integration-test/pom.xml +++ b/sjp-integration-test/pom.xml @@ -4,7 +4,7 @@ uk.gov.moj.cpp.sjp sjp-parent - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-json/pom.xml b/sjp-json/pom.xml index 69c4af04fe..10b00eeddb 100644 --- a/sjp-json/pom.xml +++ b/sjp-json/pom.xml @@ -2,7 +2,7 @@ sjp-parent uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-json/src/main/resources/json/schema/commands/update-session-bdf.json b/sjp-json/src/main/resources/json/schema/commands/update-session-bdf.json new file mode 100644 index 0000000000..8577a30ec2 --- /dev/null +++ b/sjp-json/src/main/resources/json/schema/commands/update-session-bdf.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://justice.gov.uk/json/schemas/domains/sjp/commands/sjp.update-session-bdf.json", + "type": "object", + "properties": { + "sessionId": { + "$ref": "http://justice.gov.uk/domain/core/common/definitions.json#/definitions/uuid" + }, + "magistrate": { + "type": "string" + }, + "courtHouseCode": { + "type": "string" + }, + "courtHouseName": { + "type": "string" + }, + "localJusticeAreaNationalCourtCode": { + "type": "string" + }, + "type": { + "type": "string", + "enum": ["MAGISTRATE", "DELEGATED_POWERS", "AOCP"] + }, + "legalAdviserUserId": { + "$ref": "http://justice.gov.uk/domain/core/common/definitions.json#/definitions/uuid" + } + }, + "required": [ + "sessionId" + ], + "additionalProperties": false +} diff --git a/sjp-json/src/main/resources/json/schema/events/session-updated-bdf.json b/sjp-json/src/main/resources/json/schema/events/session-updated-bdf.json new file mode 100644 index 0000000000..fdeb0548d2 --- /dev/null +++ b/sjp-json/src/main/resources/json/schema/events/session-updated-bdf.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "http://justice.gov.uk/json/schemas/domains/sjp/events/session-updated-bdf.json", + "type": "object", + "properties": { + "sessionId": { + "$ref": "http://justice.gov.uk/domain/core/common/definitions.json#/definitions/uuid" + }, + "magistrate": { + "type": "string" + }, + "courtHouseCode": { + "type": "string" + }, + "courtHouseName": { + "type": "string" + }, + "localJusticeAreaNationalCourtCode": { + "type": "string" + }, + "type": { + "type": "string", + "enum": ["MAGISTRATE", "DELEGATED_POWERS", "AOCP"] + }, + "legalAdviserUserId": { + "$ref": "http://justice.gov.uk/domain/core/common/definitions.json#/definitions/uuid" + } + }, + "required": [ + "sessionId" + ], + "additionalProperties": false +} diff --git a/sjp-query/pom.xml b/sjp-query/pom.xml index 4725d6246c..ddc3f68b69 100644 --- a/sjp-query/pom.xml +++ b/sjp-query/pom.xml @@ -3,7 +3,7 @@ sjp-parent uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-query/sjp-query-api/pom.xml b/sjp-query/sjp-query-api/pom.xml index e4bef09201..4f8eb6f005 100644 --- a/sjp-query/sjp-query-api/pom.xml +++ b/sjp-query/sjp-query-api/pom.xml @@ -3,7 +3,7 @@ sjp-query uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-query/sjp-query-view/pom.xml b/sjp-query/sjp-query-view/pom.xml index a366309409..a4620b4f8a 100644 --- a/sjp-query/sjp-query-view/pom.xml +++ b/sjp-query/sjp-query-view/pom.xml @@ -3,7 +3,7 @@ sjp-query uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-service/pom.xml b/sjp-service/pom.xml index 7370eac278..87a1a83f65 100644 --- a/sjp-service/pom.xml +++ b/sjp-service/pom.xml @@ -5,7 +5,7 @@ uk.gov.moj.cpp.sjp sjp-parent - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT sjp-service war diff --git a/sjp-viewstore/pom.xml b/sjp-viewstore/pom.xml index 1363d57a66..fe34d0df14 100644 --- a/sjp-viewstore/pom.xml +++ b/sjp-viewstore/pom.xml @@ -3,7 +3,7 @@ sjp-parent uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 sjp-viewstore diff --git a/sjp-viewstore/sjp-viewstore-liquibase/pom.xml b/sjp-viewstore/sjp-viewstore-liquibase/pom.xml index 531a107335..a353a01794 100644 --- a/sjp-viewstore/sjp-viewstore-liquibase/pom.xml +++ b/sjp-viewstore/sjp-viewstore-liquibase/pom.xml @@ -5,7 +5,7 @@ uk.gov.moj.cpp.sjp sjp-viewstore - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT sjp-viewstore-liquibase diff --git a/sjp-viewstore/sjp-viewstore-persistence/pom.xml b/sjp-viewstore/sjp-viewstore-persistence/pom.xml index 418bd4ef8b..7c61a36898 100644 --- a/sjp-viewstore/sjp-viewstore-persistence/pom.xml +++ b/sjp-viewstore/sjp-viewstore-persistence/pom.xml @@ -3,7 +3,7 @@ sjp-viewstore uk.gov.moj.cpp.sjp - 17.104.194-SNAPSHOT + 17.104.194-REL-3RD-LINE-2627-SNAPSHOT 4.0.0 diff --git a/sjp-viewstore/sjp-viewstore-persistence/src/main/java/uk/gov/moj/cpp/sjp/persistence/entity/Session.java b/sjp-viewstore/sjp-viewstore-persistence/src/main/java/uk/gov/moj/cpp/sjp/persistence/entity/Session.java index a4580d75da..e9eaa24c39 100644 --- a/sjp-viewstore/sjp-viewstore-persistence/src/main/java/uk/gov/moj/cpp/sjp/persistence/entity/Session.java +++ b/sjp-viewstore/sjp-viewstore-persistence/src/main/java/uk/gov/moj/cpp/sjp/persistence/entity/Session.java @@ -116,14 +116,26 @@ public String getCourtHouseCode() { return courtHouseCode; } + public void setCourtHouseCode(final String courtHouseCode) { + this.courtHouseCode = courtHouseCode; + } + public String getCourtHouseName() { return courtHouseName; } + public void setCourtHouseName(final String courtHouseName) { + this.courtHouseName = courtHouseName; + } + public String getLocalJusticeAreaNationalCourtCode() { return localJusticeAreaNationalCourtCode; } + public void setLocalJusticeAreaNationalCourtCode(final String localJusticeAreaNationalCourtCode) { + this.localJusticeAreaNationalCourtCode = localJusticeAreaNationalCourtCode; + } + public SessionType getType() { return type; } @@ -132,6 +144,10 @@ public Optional getMagistrate() { return Optional.ofNullable(magistrate); } + public void setMagistrate(final String magistrate) { + this.magistrate = magistrate; + } + public ZonedDateTime getStartedAt() { return startedAt; }