From 7238f4b8ebcffa232e403d35c2c367ea04c5dc5f Mon Sep 17 00:00:00 2001 From: akikrahman1 <149579836+akikrahman1@users.noreply.github.com> Date: Thu, 26 Sep 2024 17:03:12 +0100 Subject: [PATCH] Release1 (#757) * Updated made on call a required field. (#755) * Confirm attendance list is taking into account confirmed but returned trial attendances. This should only show the unconfirmed count. (#753) * Added restrictions to confirm attendance so prevent attendances from being confirmed multiple times. * Fixed tests * History stating jury attendance confirmed when return but do not confirm was selected (#752) * Fixed issue where jury attendance history would get created if you returned the panel but did not confirm attendance * Fixed tests * Added additional scheduler metrics (#575) * Added additional scheduler metrics * Added additional scheduler metrics * Added null or blank check when checking if an email / phone number exists * Minor tidy up * Fixed compile issue * Added validating in for invalid phone numbers or email addresses * Applied review comments * hotfix/JM-8102 fix for missing days (#756) * hotfix/JM-8102 fix for missing days * updated flyway migration name to avoid conflict * hotfix/JM-7928 update to utilisation report query (#758) * Updated electronic police check report header (#759) * Update V2_30__util_report_update.sql * Update V2_31__util_report_update.sql * renaming flyway migration to avoid sequence error on deployments * Feature/JM-8190 (#765) * task/JM-8193 (#763) * Task/JM-8191 Manually create a juror record (#764) * task/JM-8191 * task/JM-8191 * updates for test fix and styles * adding unit test * updated tests * Update JurorRecordServiceTest.java * Update JurorRecordControllerITest.java * JM-8196 Amend PNC View (#767) * Feature/jm 8181 (#768) * JM-8196 Amend PNC View * JM-8196 Amend PNC View * JM-8196 Amend PNC View * JM-8196 Amend PNC View remove spaces last_name * remove duplicate migration file * Task/JM-8188 Pre-mod userids preventing access to digital response records (#769) * task/JM-8188 Unable to view migrated digital responses * fixed checkStyle issue * JM-8196 Amend PNC View remove spaces last_name (#770) * cleared empty space * removing redundant spaces to make files same as interim1 --------- Co-authored-by: Ben Edwards <147524406+Ben-Edwards-cgi@users.noreply.github.com> Co-authored-by: Callum Young <148960132+callum-r-young@users.noreply.github.com> Co-authored-by: EPatterson1 <140503822+EPatterson1@users.noreply.github.com> --- build.gradle | 2 +- .../java/uk/gov/hmcts/juror/api/TestUtil.java | 1 + .../AuthenticationControllerITest.java | 5 +- .../CompleteServiceControllerITest.java | 6 +- .../JurorManagementControllerITest.java | 8 +- .../JurorRecordControllerITest.java | 191 +++++++++++++++++ .../controller/ManagePoolControllerITest.java | 2 +- .../moj/controller/TrialControllerITest.java | 4 +- .../ElectronicPoliceCheckReportITest.java | 2 +- ...leteServiceController_InitPoolsAtCourt.sql | 24 +-- ...agementController_poolsAtCourtLocation.sql | 22 +- .../JurorPaperResponse_initPaperResponse.sql | 2 +- ...orRecordController_bureauDigitalDetail.sql | 2 +- ...cordController_createManualJurorRecord.sql | 15 ++ ...estPoolController_poolsAtCourtLocation.sql | 40 ++-- .../UpdateAttendanceDetails.sql | 6 +- ...ontroller_initInformationRequestLetter.sql | 14 +- .../db/mod/reports/AbsencesReportITest.sql | 12 +- .../IncompleteServiceReportITest_typical.sql | 10 +- .../reports/JurySummoningMonitor_typical.sql | 86 ++++---- ...sonAttendingSummaryReportITest_typical.sql | 10 +- .../YieldPerformanceReportITest_typical.sql | 104 +++++----- .../resources/db/mod/truncate.sql | 1 + .../JurorCommsCronBatchController.java | 9 +- .../response/BureauJurorDetailDto.java | 13 +- .../scheduler/BureauBatchScheduler.java | 13 +- .../scheduler/UrgentStatusScheduler.java | 9 +- .../service/JurorCommsLetterServiceImpl.java | 49 ++--- .../JurorCommsSentToCourtServiceImpl.java | 119 ++++++----- .../JurorCommsWeeklyInfoServiceImpl.java | 43 ++-- .../JurorDashboardSmartSurveyImportImpl.java | 58 +++--- .../api/config/bureau/BureauJwtPayload.java | 20 +- .../api/juror/notify/NotifyAdapterImpl.java | 9 - ...ExcusedCompletedCourtCommsServiceImpl.java | 159 +++++++------- .../juror/service/MessagesServiceImpl.java | 53 +++-- .../moj/controller/JurorRecordController.java | 22 ++ .../JurorManualCreationRequestDto.java | 92 +++++++++ .../hmcts/juror/api/moj/domain/JurorPool.java | 2 +- .../juror/api/moj/domain/Permission.java | 5 + .../gov/hmcts/juror/api/moj/domain/User.java | 13 ++ .../hmcts/juror/api/moj/report/DataType.java | 2 +- .../repository/IAppearanceRepositoryImpl.java | 22 +- .../moj/repository/JurorRepositoryImpl.java | 3 +- .../JurorPaperResponseServiceImpl.java | 8 +- .../api/moj/service/JurorRecordService.java | 3 + .../moj/service/JurorRecordServiceImpl.java | 101 ++++++++- .../juror/api/moj/service/JwtServiceImpl.java | 4 +- .../moj/service/PoolCreateServiceImpl.java | 2 +- .../moj/service/trial/TrialServiceImpl.java | 8 +- .../hmcts/juror/api/moj/utils/NotifyUtil.java | 28 +++ .../juror/api/moj/utils/SecurityUtil.java | 6 + .../db/migrationv2/V2_32__on_call_updates.sql | 7 + .../V2_33__create_user_permission_table.sql | 9 + .../V2_34__amend_require_pnc_check_view.sql | 18 ++ .../api/config/BureauJwtPayloadTest.java | 10 +- .../moj/service/JurorRecordServiceTest.java | 194 +++++++++++++++++- .../service/trial/TrialServiceImplTest.java | 2 +- 57 files changed, 1213 insertions(+), 471 deletions(-) create mode 100644 src/integration-test/resources/db/JurorRecordController_createManualJurorRecord.sql create mode 100644 src/main/java/uk/gov/hmcts/juror/api/moj/controller/request/JurorManualCreationRequestDto.java create mode 100644 src/main/java/uk/gov/hmcts/juror/api/moj/domain/Permission.java create mode 100644 src/main/java/uk/gov/hmcts/juror/api/moj/utils/NotifyUtil.java create mode 100644 src/main/resources/db/migrationv2/V2_32__on_call_updates.sql create mode 100644 src/main/resources/db/migrationv2/V2_33__create_user_permission_table.sql create mode 100644 src/main/resources/db/migrationv2/V2_34__amend_require_pnc_check_view.sql diff --git a/build.gradle b/build.gradle index 3d60d8c5f..10419590e 100644 --- a/build.gradle +++ b/build.gradle @@ -287,7 +287,7 @@ pmdTest { maxFailures = 292 } pmdMain { - maxFailures = 763 + maxFailures = 752 } pmd { maxFailures = 0 diff --git a/src/integration-test/java/uk/gov/hmcts/juror/api/TestUtil.java b/src/integration-test/java/uk/gov/hmcts/juror/api/TestUtil.java index 9b424553a..1f970280a 100644 --- a/src/integration-test/java/uk/gov/hmcts/juror/api/TestUtil.java +++ b/src/integration-test/java/uk/gov/hmcts/juror/api/TestUtil.java @@ -99,6 +99,7 @@ public static String mintBureauJwt(final BureauJwtPayload payload, claimsMap.put("staff", payload.getStaff()); claimsMap.put("roles", payload.getRoles()); + claimsMap.put("permissions", payload.getPermissions()); claimsMap.put("userType", payload.getUserType()); claimsMap.put("activeUserType", payload.getActiveUserType() == null ? payload.getUserType() : payload.getActiveUserType()); diff --git a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/AuthenticationControllerITest.java b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/AuthenticationControllerITest.java index a27561f01..fe29df8ba 100644 --- a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/AuthenticationControllerITest.java +++ b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/AuthenticationControllerITest.java @@ -227,7 +227,7 @@ private void responseValidator(JwtDto response, assertThat(claims.getIssuedAt()).isAfter(new Date(clock.millis() - 60_000)); assertThat(claims) - .hasSize(13) + .hasSize(14) .containsEntry("owner", expectedJwtClaims.getOwner()) .containsEntry("email", expectedJwtClaims.getEmail()) .containsEntry("locCode", expectedJwtClaims.getLocCode()) @@ -241,7 +241,8 @@ private void responseValidator(JwtDto response, "courts", expectedJwtClaims.getStaff().getCourts() )) .containsEntry("roles", expectedJwtClaims.getRoles() - .stream().map(Enum::name).toList()); + .stream().map(Enum::name).toList()) + .containsEntry("permissions", List.of()); } @Test diff --git a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/CompleteServiceControllerITest.java b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/CompleteServiceControllerITest.java index 7477b394b..e2d10c736 100644 --- a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/CompleteServiceControllerITest.java +++ b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/CompleteServiceControllerITest.java @@ -43,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -74,8 +75,7 @@ private void validateJurorWasCompleted(LocalDate completionTime, String jurorNum JurorPool jurorPool = jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(jurorNumber, poolNumber); assertEquals(true, jurorPool.getIsActive(), "Juror pool should be active"); - assertEquals(false, jurorPool.getOnCall(), - "Juror pool should not be on call"); + assertFalse(jurorPool.isOnCall(), "Juror pool should not be on call"); assertEquals(IJurorStatus.COMPLETED, jurorPool.getStatus().getStatus(), "Juror pool status should be completed"); Juror juror = jurorPool.getJuror(); @@ -85,7 +85,7 @@ private void validateJurorWasCompleted(LocalDate completionTime, String jurorNum if (isDismissal) { assertThat(jurorPool.getNextDate()).isNull(); - assertThat(jurorPool.getOnCall()).isFalse(); + assertThat(jurorPool.isOnCall()).isFalse(); } List jurorHistories = jurorHistoryRepository.findByJurorNumberOrderById(jurorNumber); assertEquals(1, jurorHistories.size(), "Should only be one history entry"); diff --git a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/JurorManagementControllerITest.java b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/JurorManagementControllerITest.java index 065df049d..9924f413f 100644 --- a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/JurorManagementControllerITest.java +++ b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/JurorManagementControllerITest.java @@ -607,7 +607,7 @@ void updateAttendanceCheckOutAllJurors() { AttendanceDetailsResponse.Summary summary = response.getBody().getSummary(); assertThat(summary) .extracting(AttendanceDetailsResponse.Summary::getCheckedOut) - .isEqualTo(3L); + .isEqualTo(5L); assertThat(summary) .extracting(AttendanceDetailsResponse.Summary::getPanelled) @@ -1032,7 +1032,7 @@ void updateAttendanceNoShow() { AttendanceDetailsResponse.Summary summary = response.getBody().getSummary(); assertThat(summary) .extracting(AttendanceDetailsResponse.Summary::getCheckedIn) - .isEqualTo(4L); + .isEqualTo(5L); assertThat(summary) .extracting(AttendanceDetailsResponse.Summary::getAbsent) @@ -1282,7 +1282,7 @@ void updateAttendanceDateOnCallFlagUpdated() { // check the on-call flag before invoking the api Boolean onCallFlagBefore = - jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(JUROR6, POOL_NUMBER_415230101).getOnCall(); + jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(JUROR6, POOL_NUMBER_415230101).isOnCall(); assertThat(onCallFlagBefore).as("On-call flag should be True").isEqualTo(Boolean.TRUE); ResponseEntity responseEntity = @@ -1296,7 +1296,7 @@ void updateAttendanceDateOnCallFlagUpdated() { // verify the on-call flag was updated successfully Boolean onCallFlagAfter = - jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(JUROR6, POOL_NUMBER_415230101).getOnCall(); + jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(JUROR6, POOL_NUMBER_415230101).isOnCall(); assertThat(onCallFlagAfter).as("On-call flag should be False").isEqualTo(Boolean.FALSE); } diff --git a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/JurorRecordControllerITest.java b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/JurorRecordControllerITest.java index 44cf0acfc..b10765aa0 100644 --- a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/JurorRecordControllerITest.java +++ b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/JurorRecordControllerITest.java @@ -34,6 +34,7 @@ import uk.gov.hmcts.juror.api.moj.controller.request.FilterableJurorDetailsRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorAddressDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorCreateRequestDto; +import uk.gov.hmcts.juror.api.moj.controller.request.JurorManualCreationRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorNameDetailsDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorNotesRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorNumberAndPoolNumberDto; @@ -75,11 +76,13 @@ import uk.gov.hmcts.juror.api.moj.domain.JurorPool; import uk.gov.hmcts.juror.api.moj.domain.PaginatedList; import uk.gov.hmcts.juror.api.moj.domain.PendingJuror; +import uk.gov.hmcts.juror.api.moj.domain.Permission; import uk.gov.hmcts.juror.api.moj.domain.PoliceCheck; import uk.gov.hmcts.juror.api.moj.domain.PoolHistory; import uk.gov.hmcts.juror.api.moj.domain.PoolRequest; import uk.gov.hmcts.juror.api.moj.domain.Role; import uk.gov.hmcts.juror.api.moj.domain.SortMethod; +import uk.gov.hmcts.juror.api.moj.domain.User; import uk.gov.hmcts.juror.api.moj.domain.UserType; import uk.gov.hmcts.juror.api.moj.domain.jurorresponse.DigitalResponse; import uk.gov.hmcts.juror.api.moj.domain.jurorresponse.PaperResponse; @@ -118,9 +121,11 @@ import java.util.Arrays; import java.util.Collections; import java.util.Comparator; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Objects; +import java.util.Set; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -5324,6 +5329,192 @@ void markJurorAsRespondedBureauJurorNotFound() throws Exception { } + @Nested + @DisplayName("POST " + CreateManualJurorRecord.URL) + class CreateManualJurorRecord { + + private static final String URL = BASE_URL + "/create-juror-manual"; + + @Test + @Sql({"/db/mod/truncate.sql", "/db/JurorRecordController_createManualJurorRecord.sql"}) + void createManualJurorRecordPoolHappyPath() throws Exception { + String poolNumber = "415220502"; + final JurorManualCreationRequestDto requestDto = JurorManualCreationRequestDto.builder() + .poolNumber(poolNumber) + .locationCode("415") + .title("Mr") + .firstName("John") + .lastName("Smith") + .address(JurorAddressDto.builder() + .lineOne("1 High Street") + .lineTwo("Test") + .lineThree("Test") + .town("Chester") + .county("Test") + .postcode("CH1 2AB") + .build()) + .primaryPhone("01234567890") + .emailAddress("test@test.com") + .notes("A manually created juror") + .build(); + + Set roles = new HashSet<>(); + roles.add(Role.MANAGER); + Set permissions = new HashSet<>(); + permissions.add(Permission.CREATE_JUROR); + User user = User.builder() + .username("BUREAU_USER") + .roles(roles) + .permissions(permissions) + .build(); + + final BureauJwtPayload bureauJwtPayload = new BureauJwtPayload(user, UserType.BUREAU, "400", + Collections.singletonList(CourtLocation.builder() + .locCode("400") + .name("Bureau") + .owner("400") + .build())); + + httpHeaders.set(HttpHeaders.AUTHORIZATION, mintBureauJwt(bureauJwtPayload)); + + ResponseEntity response = + restTemplate.exchange(new RequestEntity<>(requestDto, httpHeaders, POST, + URI.create(URL)), String.class); + + assertThat(response.getStatusCode()) + .as("Expect the HTTP POST request to be CREATED") + .isEqualTo(HttpStatus.CREATED); + + validateCreatedJuror(poolNumber); + } + + private void validateCreatedJuror(String poolNumber) { + // expect this to be the first juror manually created for court 415 + Juror juror = jurorRepository.findByJurorNumber("041500001"); + assertThat(juror).isNotNull(); + assertThat(juror.getTitle()).isEqualTo("Mr"); + assertThat(juror.getFirstName()).isEqualTo("John"); + assertThat(juror.getLastName()).isEqualTo("Smith"); + assertThat(juror.getDateOfBirth()).isNull(); + assertThat(juror.getPhoneNumber()).isEqualTo("01234567890"); + assertThat(juror.getEmail()).isEqualTo("test@test.com"); + assertThat(juror.getNotes()).isEqualTo("A manually created juror"); + + assertThat(juror.getAddressLine1()).isEqualTo("1 High Street"); + assertThat(juror.getAddressLine2()).isEqualTo("Test"); + assertThat(juror.getAddressLine3()).isEqualTo("Test"); + assertThat(juror.getAddressLine4()).isEqualTo("Chester"); + assertThat(juror.getAddressLine5()).isEqualTo("Test"); + assertThat(juror.getPostcode()).isEqualTo("CH1 2AB"); + + JurorPool jurorPool = jurorPoolRepository.findByJurorJurorNumberAndPoolPoolNumber(juror.getJurorNumber(), + poolNumber); + assertThat(jurorPool).isNotNull(); + assertThat(jurorPool.getStatus().getStatus()).isEqualTo(IJurorStatus.SUMMONED); + assertThat(jurorPool.getOwner()).isEqualTo("400"); + assertThat(jurorPool.getNextDate()).isEqualTo(LocalDate.now().plusDays(10)); + assertThat(jurorPool.getPoolNumber()).isEqualTo(poolNumber); + + List jurorHistory = jurorHistoryRepository + .findByJurorNumberOrderById(juror.getJurorNumber()); + assertThat(jurorHistory).isNotEmpty(); + assertThat(jurorHistory.get(0).getHistoryCode()).isEqualTo(HistoryCodeMod.PRINT_SUMMONS); + + List letters = bulkPrintDataRepository.findByJurorNo(juror.getJurorNumber()); + assertThat(letters).isNotEmpty(); + BulkPrintData bulkPrintData = letters.get(0); + assertThat(bulkPrintData.getJurorNo()).isEqualTo(juror.getJurorNumber()); + assertThat(bulkPrintData.getFormAttribute().getFormType()).isEqualTo(FormCode.ENG_SUMMONS.getCode()); + } + + + @Test + void createManualJurorRecordBureauManagerNoCreateForbidden() throws Exception { + String poolNumber = "415220502"; + JurorManualCreationRequestDto requestDto = JurorManualCreationRequestDto.builder() + .poolNumber(poolNumber) + .locationCode("415") + .title("Mr") + .firstName("John") + .lastName("Smith") + .address(JurorAddressDto.builder() + .lineOne("1 High Street") + .lineTwo("Test") + .lineThree("Test") + .town("Chester") + .county("Test") + .postcode("CH1 2AB") + .build()) + .primaryPhone("01234567890") + .emailAddress("test@test.com") + .notes("A manually created juror") + .build(); + + Set roles = new HashSet<>(); + roles.add(Role.MANAGER); + Set permissions = new HashSet<>(); + User user = User.builder() + .username("BUREAU2") + .roles(roles) + .permissions(permissions) + .build(); + + BureauJwtPayload bureauJwtPayload = new BureauJwtPayload(user, UserType.BUREAU, "400", + Collections.singletonList(CourtLocation.builder() + .locCode("400") + .name("Bureau") + .owner("400") + .build())); + + httpHeaders.set(HttpHeaders.AUTHORIZATION, mintBureauJwt(bureauJwtPayload)); + + ResponseEntity response = + restTemplate.exchange(new RequestEntity<>(requestDto, httpHeaders, POST, + URI.create(URL)), String.class); + + assertThat(response.getStatusCode()) + .as("Expect the HTTP POST request to be FORBIDDEN") + .isEqualTo(HttpStatus.FORBIDDEN); + + } + + @Test + void createManualJurorRecordCourtUserForbidden() throws Exception { + String poolNumber = "415220502"; + JurorManualCreationRequestDto requestDto = JurorManualCreationRequestDto.builder() + .poolNumber(poolNumber) + .locationCode("415") + .title("Mr") + .firstName("John") + .lastName("Smith") + .address(JurorAddressDto.builder() + .lineOne("1 High Street") + .lineTwo("Test") + .lineThree("Test") + .town("Chester") + .county("Test") + .postcode("CH1 2AB") + .build()) + .primaryPhone("01234567890") + .emailAddress("test@test.com") + .notes("A manually created juror") + .build(); + + httpHeaders.set(HttpHeaders.AUTHORIZATION, initCourtsJwt("415", Collections.singletonList("415"), + UserType.COURT)); + + ResponseEntity response = + restTemplate.exchange(new RequestEntity<>(requestDto, httpHeaders, POST, + URI.create(URL)), String.class); + + assertThat(response.getStatusCode()) + .as("Expect the HTTP POST request to be FORBIDDEN") + .isEqualTo(HttpStatus.FORBIDDEN); + + } + + } + @Nested @DisplayName("Search for Juror records") @Sql({"/db/mod/truncate.sql", "/db/JurorRecordController_searchForJurorRecords.sql"}) diff --git a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/ManagePoolControllerITest.java b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/ManagePoolControllerITest.java index 4b14b9255..75aba4561 100644 --- a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/ManagePoolControllerITest.java +++ b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/ManagePoolControllerITest.java @@ -2147,7 +2147,7 @@ private void transferJurorPoolValidateNewlyCreatedJurorPool(String jurorNumber, assertThat(targetJurorPool.getEditTag()) .as(EXPECT_PROPERTY_TO_BE_USE_A_DEFAULT_VALUE) .isNull(); - assertThat(targetJurorPool.getOnCall()) + assertThat(targetJurorPool.isOnCall()) .as(EXPECT_PROPERTY_TO_BE_USE_A_DEFAULT_VALUE) .isFalse(); assertThat(targetJurorPool.getSmartCard()) diff --git a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/TrialControllerITest.java b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/TrialControllerITest.java index be3ee9a23..4fd238027 100644 --- a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/TrialControllerITest.java +++ b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/controller/TrialControllerITest.java @@ -800,8 +800,8 @@ void testReturnJuryNoConfirmAttendance() { "Expect status to be Responded").isEqualTo(IJurorStatus.RESPONDED); assertThat( jurorHistoryRepository.findByJurorNumberOrderById(panel.getJurorNumber()).size()) - .as("Expect two history item for juror " + panel.getJurorNumber()) - .isEqualTo(2); + .as("Expect one history item for juror " + panel.getJurorNumber()) + .isEqualTo(1); Appearance appearance = appearanceRepository.findByLocCodeAndJurorNumberAndAttendanceDate("415", panel.getJurorNumber(), diff --git a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/report/standard/ElectronicPoliceCheckReportITest.java b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/report/standard/ElectronicPoliceCheckReportITest.java index 9df528cd6..de3a3e70a 100644 --- a/src/integration-test/java/uk/gov/hmcts/juror/api/moj/report/standard/ElectronicPoliceCheckReportITest.java +++ b/src/integration-test/java/uk/gov/hmcts/juror/api/moj/report/standard/ElectronicPoliceCheckReportITest.java @@ -147,7 +147,7 @@ private StandardReportResponse buildResponse(String fromDate, String toDate, Sta .build(), StandardReportResponse.TableData.Heading.builder() .id("police_check_timed_out") - .name("Checks completed") + .name("Checks timed out") .dataType("Long") .headings(null) .build(), diff --git a/src/integration-test/resources/db/CompleteServiceController_InitPoolsAtCourt.sql b/src/integration-test/resources/db/CompleteServiceController_InitPoolsAtCourt.sql index 6b710503e..1195d3d14 100644 --- a/src/integration-test/resources/db/CompleteServiceController_InitPoolsAtCourt.sql +++ b/src/integration-test/resources/db/CompleteServiceController_InitPoolsAtCourt.sql @@ -105,18 +105,18 @@ INSERT INTO juror_mod.juror (juror_number, last_name, first_name, dob, address_l ('641800002', 'PERSON', 'TEST', '1990-05-16', '542 STREET NAME', 'ANYTOWN', 'CH1 2AN', true, null), ('641800003', 'PERSON', 'TEST', '1990-05-16', '542 STREET NAME', 'ANYTOWN', 'CH1 2AN', true, '2023-10-24'); -INSERT INTO juror_mod.juror_pool (owner, juror_number, pool_number, is_active, next_date, status, on_call) VALUES -('400', '641600001', '416230101', true, '2023-01-23', 2, null), -('416', '641600002', '416230103', true, '2023-01-23', 13, null), -('417', '641700001', '417230101', true, '2023-01-09', 13, null), -('417', '641700002', '417230101', true, '2023-01-09', 7, null), -('417', '641700003', '417230101', true, '2023-01-09', 2, null), -('417', '641700004', '417230101', true, '2023-01-09', 2, true), -('417', '641700005', '417230101', true, '2023-01-09', 4, null), -('417', '641700006', '417230101', true, '2023-01-09', 2, null), -('418', '641800001', '418230101', true, '2023-10-25', 2, null), -('418', '641800002', '418230102', true, '2023-10-23', 2, null), -('418', '641800003', '418230103', true, '2023-10-23', 13, null); +INSERT INTO juror_mod.juror_pool (owner, juror_number, pool_number, is_active, next_date, status) VALUES +('400', '641600001', '416230101', true, '2023-01-23', 2), +('416', '641600002', '416230103', true, '2023-01-23', 13), +('417', '641700001', '417230101', true, '2023-01-09', 13), +('417', '641700002', '417230101', true, '2023-01-09', 7), +('417', '641700003', '417230101', true, '2023-01-09', 2), +('417', '641700004', '417230101', true, '2023-01-09', 2), +('417', '641700005', '417230101', true, '2023-01-09', 4), +('417', '641700006', '417230101', true, '2023-01-09', 2), +('418', '641800001', '418230101', true, '2023-10-25', 2), +('418', '641800002', '418230102', true, '2023-10-23', 2), +('418', '641800003', '418230103', true, '2023-10-23', 13); INSERT INTO juror_mod.appearance (attendance_date,juror_number,pool_number,loc_code,f_audit,time_in,time_out,travel_time,appearance_stage,non_attendance) VALUES diff --git a/src/integration-test/resources/db/JurorManagementController_poolsAtCourtLocation.sql b/src/integration-test/resources/db/JurorManagementController_poolsAtCourtLocation.sql index 42acc10dd..a48472d56 100644 --- a/src/integration-test/resources/db/JurorManagementController_poolsAtCourtLocation.sql +++ b/src/integration-test/resources/db/JurorManagementController_poolsAtCourtLocation.sql @@ -112,18 +112,18 @@ INSERT INTO juror_mod.juror (juror_number, last_name, first_name, dob, address_l ('641800003', 'PERSON', 'TEST', '1990-05-16', '542 STREET NAME', 'ANYTOWN', 'CH1 2AN', true, '2023-10-24'); INSERT INTO juror_mod.juror_pool (owner, juror_number, pool_number, is_active, next_date, status, on_call) VALUES -('400', '641600001', '416230101', true, '2023-01-23', 2, null), -('416', '641600002', '416230103', true, '2023-01-23', 13, null), -('415', '641500001', '415230101', true, current_date - 10, 13, null), -('415', '641500002', '415230101', true, current_date - 10, 7, null), -('415', '641500003', '415230101', true, current_date - 10, 2, null), +('400', '641600001', '416230101', true, '2023-01-23', 2, false), +('416', '641600002', '416230103', true, '2023-01-23', 13, false), +('415', '641500001', '415230101', true, current_date - 10, 13, false), +('415', '641500002', '415230101', true, current_date - 10, 7, false), +('415', '641500003', '415230101', true, current_date - 10, 2, false), ('415', '641500004', '415230101', true, current_date - 10, 2, true), -('415', '641500005', '415230101', true, current_date - 10, 4, null), -('415', '641500006', '415230101', true, current_date - 10, 2, null), -('415', '641500007', '415230101', true, current_date - 10, 2, null), -('418', '641800001', '418230101', true, '2023-10-25', 2, null), -('418', '641800002', '418230102', true, '2023-10-23', 2, null), -('418', '641800003', '418230103', true, '2023-10-23', 13, null); +('415', '641500005', '415230101', true, current_date - 10, 4, false), +('415', '641500006', '415230101', true, current_date - 10, 2, false), +('415', '641500007', '415230101', true, current_date - 10, 2, false), +('418', '641800001', '418230101', true, '2023-10-25', 2, false), +('418', '641800002', '418230102', true, '2023-10-23', 2, false), +('418', '641800003', '418230103', true, '2023-10-23', 13, false); INSERT INTO juror_mod.appearance (attendance_date,juror_number,pool_number,loc_code,f_audit,time_in,time_out,travel_time,appearance_stage,non_attendance) VALUES (current_date,'641500003','415230101','415',123456789,'09:30:00',null,'01:12','CHECKED_IN',false); diff --git a/src/integration-test/resources/db/JurorPaperResponse_initPaperResponse.sql b/src/integration-test/resources/db/JurorPaperResponse_initPaperResponse.sql index 2ddb8b748..15d913dd8 100644 --- a/src/integration-test/resources/db/JurorPaperResponse_initPaperResponse.sql +++ b/src/integration-test/resources/db/JurorPaperResponse_initPaperResponse.sql @@ -50,7 +50,7 @@ VALUES ('415', '111111111', '415220502', true, CURRENT_DATE + interval '6 weeks' ('400', '121314151', '415220502', true, CURRENT_DATE + interval '6 weeks', 2); INSERT INTO juror_mod.juror_pool(juror_number, pool_number, "owner", user_edtq, is_active, status, times_sel, def_date, "location", no_attendances, no_attended, no_fta, no_awol, pool_seq, edit_tag, next_date, on_call, smart_card, was_deferred, deferral_code, id_checked, postpone, paid_cash, scan_code, last_update, reminder_sent, transfer_date, date_created) VALUES -('641500001', '415240601', '415', 'court-southwark', true, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0002', NULL, '2024-06-11', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-04-09 15:07:32.570', NULL, NULL, '2024-04-09 15:06:58.069'); +('641500001', '415240601', '415', 'court-southwark', true, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0002', NULL, '2024-06-11', false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-04-09 15:07:32.570', NULL, NULL, '2024-04-09 15:06:58.069'); INSERT INTO juror_mod.juror_pool(juror_number, pool_number, "owner", user_edtq, is_active, status, times_sel, def_date, "location", no_attendances, no_attended, no_fta, no_awol, pool_seq, edit_tag, next_date, on_call, smart_card, was_deferred, deferral_code, id_checked, postpone, paid_cash, scan_code, last_update, reminder_sent, transfer_date, date_created) VALUES ('641500001', '471240401', '471', 'court-southwark', true, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0001', NULL, '2024-04-29', false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-04-09 15:12:48.674', NULL, NULL, '2024-04-09 15:12:48.674'); diff --git a/src/integration-test/resources/db/JurorRecordController_bureauDigitalDetail.sql b/src/integration-test/resources/db/JurorRecordController_bureauDigitalDetail.sql index f896adb92..1498d7fbb 100644 --- a/src/integration-test/resources/db/JurorRecordController_bureauDigitalDetail.sql +++ b/src/integration-test/resources/db/JurorRecordController_bureauDigitalDetail.sql @@ -56,7 +56,7 @@ INSERT INTO juror_mod.juror_pool (owner, juror_number, pool_number, is_active, n ('400', '555555555', '457230801', true, '2022-05-03', 2); INSERT INTO juror_mod.juror_pool(juror_number, pool_number, "owner", user_edtq, is_active, status, times_sel, def_date, "location", no_attendances, no_attended, no_fta, no_awol, pool_seq, edit_tag, next_date, on_call, smart_card, was_deferred, deferral_code, id_checked, postpone, paid_cash, scan_code, last_update, reminder_sent, transfer_date, date_created) VALUES -('641500001', '415240601', '415', 'court-southwark', true, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0002', NULL, '2024-06-11', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-04-09 15:07:32.570', NULL, NULL, '2024-04-09 15:06:58.069'); +('641500001', '415240601', '415', 'court-southwark', true, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0002', NULL, '2024-06-11', false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-04-09 15:07:32.570', NULL, NULL, '2024-04-09 15:06:58.069'); INSERT INTO juror_mod.juror_pool(juror_number, pool_number, "owner", user_edtq, is_active, status, times_sel, def_date, "location", no_attendances, no_attended, no_fta, no_awol, pool_seq, edit_tag, next_date, on_call, smart_card, was_deferred, deferral_code, id_checked, postpone, paid_cash, scan_code, last_update, reminder_sent, transfer_date, date_created) VALUES ('641500001', '471240401', '471', 'court-southwark', true, 2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0001', NULL, '2024-04-29', false, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2024-04-09 15:12:48.674', NULL, NULL, '2024-04-09 15:12:48.674'); diff --git a/src/integration-test/resources/db/JurorRecordController_createManualJurorRecord.sql b/src/integration-test/resources/db/JurorRecordController_createManualJurorRecord.sql new file mode 100644 index 000000000..66e1ec077 --- /dev/null +++ b/src/integration-test/resources/db/JurorRecordController_createManualJurorRecord.sql @@ -0,0 +1,15 @@ +insert into juror_mod.users(created_by, updated_by, username, name, email) values +('BUREAU1', 'BUREAU1', 'BUREAU_USER', 'BUREAU_USER', 'BUREAU_USER@test.net'), +('BUREAU1', 'BUREAU1', 'BUREAU2', 'BUREAU USER2', 'BUREAU2@test.net'); + +INSERT INTO juror_mod.user_roles (username,"role") VALUES + ('BUREAU_USER','MANAGER'), + ('BUREAU2','MANAGER'); + +INSERT INTO juror_mod.user_permissions (username,"permission") VALUES + ('BUREAU_USER','CREATE_JUROR'); + +-- create a pool record owned by Bureau +INSERT INTO juror_mod.pool +(pool_no, "owner", return_date, total_no_required, no_requested, pool_type, loc_code, new_request, last_update) +VALUES ('415220502', '400', current_date + 10, 5, 5, 'CRO', '415', 'N', current_date - 1); \ No newline at end of file diff --git a/src/integration-test/resources/db/RequestPoolController_poolsAtCourtLocation.sql b/src/integration-test/resources/db/RequestPoolController_poolsAtCourtLocation.sql index 8ed90e210..48fbae21e 100644 --- a/src/integration-test/resources/db/RequestPoolController_poolsAtCourtLocation.sql +++ b/src/integration-test/resources/db/RequestPoolController_poolsAtCourtLocation.sql @@ -98,27 +98,27 @@ INSERT INTO juror_mod.juror (juror_number, last_name, first_name, dob, address_l ('641900001', 'PERSON1', 'TEST', '1990-05-16', '542 STREET NAME', 'ANYTOWN', 'CH1 2AN', true, null); INSERT INTO juror_mod.juror_pool (owner, juror_number, pool_number, is_active, next_date, status, on_call) VALUES -('400', '641600001', '416230101', true, '2023-01-23', 2, null), -('416', '641600002', '416230103', true, '2023-01-23', 13, null), -('417', '641700001', '417230101', true, '2023-01-09', 13, null), -('417', '641700002', '417230101', true, '2023-01-09', 7, null), -('417', '641700003', '417230101', true, '2023-01-09', 2, null), +('400', '641600001', '416230101', true, '2023-01-23', 2, false), +('416', '641600002', '416230103', true, '2023-01-23', 13, false), +('417', '641700001', '417230101', true, '2023-01-09', 13, false), +('417', '641700002', '417230101', true, '2023-01-09', 7, false), +('417', '641700003', '417230101', true, '2023-01-09', 2, false), ('417', '641700004', '417230101', true, '2023-01-09', 2, true), -('417', '641700005', '417230101', true, '2023-01-09', 4, null), -('417', '641700006', '417230101', true, '2023-01-09', 2, null), -('417', '641700007', '417230101', true, '2023-01-09', 2, null), -('417', '641700008', '417230101', true, '2023-01-09', 2, null), -('417', '641700009', '417230101', true, '2023-01-09', 3, null), -('417', '641700010', '417230101', true, '2023-01-09', 3, null), -('417', '641700011', '417230101', true, '2023-01-09', 4, null), -('417', '641700012', '417230101', true, '2023-01-09', 4, null), -('417', '641700013', '417230101', true, '2023-01-09', 4, null), -('417', '641700014', '417230101', true, '2023-01-09', 3, null), -('418', '641800001', '418230101', true, '2023-10-25', 2, null), -('418', '641800002', '418230102', true, '2023-10-23', 2, null), -('418', '641800003', '418230103', true, '2023-10-23', 2, null), -('418', '641800004', '418230102', true, '2023-10-23', 3, null), -('418', '641800005', '418230103', true, '2023-10-23', 4, null), +('417', '641700005', '417230101', true, '2023-01-09', 4, false), +('417', '641700006', '417230101', true, '2023-01-09', 2, false), +('417', '641700007', '417230101', true, '2023-01-09', 2, false), +('417', '641700008', '417230101', true, '2023-01-09', 2, false), +('417', '641700009', '417230101', true, '2023-01-09', 3, false), +('417', '641700010', '417230101', true, '2023-01-09', 3, false), +('417', '641700011', '417230101', true, '2023-01-09', 4, false), +('417', '641700012', '417230101', true, '2023-01-09', 4, false), +('417', '641700013', '417230101', true, '2023-01-09', 4, false), +('417', '641700014', '417230101', true, '2023-01-09', 3, false), +('418', '641800001', '418230101', true, '2023-10-25', 2, false), +('418', '641800002', '418230102', true, '2023-10-23', 2, false), +('418', '641800003', '418230103', true, '2023-10-23', 2, false), +('418', '641800004', '418230102', true, '2023-10-23', 3, false), +('418', '641800005', '418230103', true, '2023-10-23', 4, false), ('419', '641900001', '419230101', true, '2023-10-23', 2, true); INSERT INTO juror_mod.appearance (attendance_date,juror_number,pool_number,loc_code,f_audit,time_in,time_out,travel_time,appearance_stage,non_attendance) VALUES diff --git a/src/integration-test/resources/db/jurormanagement/UpdateAttendanceDetails.sql b/src/integration-test/resources/db/jurormanagement/UpdateAttendanceDetails.sql index d1b96e63d..c04625dd0 100644 --- a/src/integration-test/resources/db/jurormanagement/UpdateAttendanceDetails.sql +++ b/src/integration-test/resources/db/jurormanagement/UpdateAttendanceDetails.sql @@ -31,10 +31,10 @@ insert into juror_mod.juror_pool (owner, juror_number, pool_number, next_date, d --JUROR_MOD.APPEARANCE insert into juror_mod.appearance (attendance_date,juror_number,loc_code,time_in,time_out,non_attendance,appearance_stage,attendance_type) values -(current_date - interval '1 day','111111111','415','09:31:00',null,false,null,'FULL_DAY'), -(current_date - interval '2 days','111111111','415','09:30:00',null,false,null,'FULL_DAY'), +(current_date - interval '1 day','111111111','415','09:31:00',null,false,'CHECKED_IN','FULL_DAY'), +(current_date - interval '2 days','111111111','415','09:30:00',null,false,'CHECKED_IN','FULL_DAY'), (current_date - interval '2 days','222222222','415','09:30:00',null,false,'CHECKED_IN','FULL_DAY'), (current_date - interval '2 days','333333333','415','09:30:00',null,false,'CHECKED_IN','FULL_DAY'), -(current_date - interval '2 days','555555555','415',null,null,false,null,'FULL_DAY'), +(current_date - interval '2 days','555555555','415','06:30:00',null,false,'CHECKED_IN','FULL_DAY'), (current_date - interval '2 days','666666666','415','09:30:00',null,false,'CHECKED_IN','FULL_DAY'), (current_date - interval '2 days','777777777','415','15:53','12:30',false,'CHECKED_IN','FULL_DAY'); \ No newline at end of file diff --git a/src/integration-test/resources/db/letter/LetterController_initInformationRequestLetter.sql b/src/integration-test/resources/db/letter/LetterController_initInformationRequestLetter.sql index 0bffccdea..8705226aa 100644 --- a/src/integration-test/resources/db/letter/LetterController_initInformationRequestLetter.sql +++ b/src/integration-test/resources/db/letter/LetterController_initInformationRequestLetter.sql @@ -21,13 +21,13 @@ INSERT INTO juror_mod.juror (juror_number,poll_number,title,last_name,first_name ('641500216','216',NULL,'LNAMEONESIXT','FNAMEONESIX',NULL,'16 STREET NAME','ANYTOWN',NULL,NULL,NULL,'CH1 2AN',NULL,NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,false,'NOT_CHECKED','2024-06-11 13:57:15',NULL,NULL,NULL,NULL,0,'2024-06-03 15:33:11.314842',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,false,NULL,0,false,NULL); INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES - ('641500017','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0015',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:14:27.130294',true,NULL,'2024-06-03 12:00:23.127317'), - ('641500212','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0019',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.348805',NULL,NULL,'2024-06-03 15:33:11.348805'), - ('641500211','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0023',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.357346',NULL,NULL,'2024-06-03 15:33:11.357346'), - ('641500216','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0025',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.361174',NULL,NULL,'2024-06-03 15:33:11.361174'), - ('641500316','415240801','400','ADMINUSER',true,2,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,NULL,NULL,true,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',true,NULL,'2024-06-03 12:00:23.10279'), - ('641500316','415240804','400','ADMINUSER',false,7,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,NULL,NULL,NULL,'M',NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',NULL,NULL,'2024-06-03 12:00:23.10279'), - ('641500223','415240802','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0020',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-11 13:55:51.432707',true,NULL,'2024-06-03 15:33:11.351721'); + ('641500017','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0015',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:14:27.130294',true,NULL,'2024-06-03 12:00:23.127317'), + ('641500212','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0019',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.348805',NULL,NULL,'2024-06-03 15:33:11.348805'), + ('641500211','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0023',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.357346',NULL,NULL,'2024-06-03 15:33:11.357346'), + ('641500216','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0025',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.361174',NULL,NULL,'2024-06-03 15:33:11.361174'), + ('641500316','415240801','400','ADMINUSER',true,2,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,false,NULL,true,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',true,NULL,'2024-06-03 12:00:23.10279'), + ('641500316','415240804','400','ADMINUSER',false,7,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,false,NULL,NULL,'M',NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',NULL,NULL,'2024-06-03 12:00:23.10279'), + ('641500223','415240802','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0020',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-11 13:55:51.432707',true,NULL,'2024-06-03 15:33:11.351721'); INSERT INTO juror_mod.bulk_print_data (juror_no,creation_date,form_type,detail_rec,extracted_flag,digital_comms) VALUES ('641500017',current_date - 1,'5227','14 JUNE 2024 THE CROWN COURT AT CHESTER JURY CENTRAL SUMMONING BUREAU THE COURT SERVICE FREEPOST LON 19669 POCOCK STREET LONDON SE1 0YG 0845 3555567 PART 2 SECTION D FNAMEONESEVEN LNAMEONESEVEN 17 STREET NAME ANYTOWN CH3 2AR 641500017JURY MANAGER ',false,false), diff --git a/src/integration-test/resources/db/mod/reports/AbsencesReportITest.sql b/src/integration-test/resources/db/mod/reports/AbsencesReportITest.sql index 40d333fd1..190c7f8c5 100644 --- a/src/integration-test/resources/db/mod/reports/AbsencesReportITest.sql +++ b/src/integration-test/resources/db/mod/reports/AbsencesReportITest.sql @@ -19,17 +19,17 @@ INSERT INTO juror_mod.juror (juror_number,poll_number,title,last_name,first_name -- create juror_pool associative records INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES ('641500021','415240601','415','MODTESTBUREAU',true,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL, - current_date+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.702989',NULL,NULL,'2024-04-22 12:26:40.702987'), + current_date+1,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.702989',NULL,NULL,'2024-04-22 12:26:40.702987'), ('641500011','415240601','415','MODTESTBUREAU',true,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL, - current_date+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.757378',NULL,NULL,'2024-04-22 12:26:40.757376'), + current_date+1,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.757378',NULL,NULL,'2024-04-22 12:26:40.757376'), ('641500003','415240601','415','MODTESTCOURT',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL, - current_date+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:29:18.125891',NULL,NULL,'2024-04-22 12:26:40.788798'), + current_date+1,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:29:18.125891',NULL,NULL,'2024-04-22 12:26:40.788798'), ('641500009','415240602','415','MODTESTCOURT',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL, - current_date+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:29:18.125891',NULL,NULL,'2024-04-22 12:26:40.788798'), + current_date+1,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:29:18.125891',NULL,NULL,'2024-04-22 12:26:40.788798'), ('641500004','417240601','417','MODTESTCOURT',true,1,NULL,current_date+30,NULL,NULL,NULL,NULL,NULL,'0004',NULL, - current_date+2,NULL,NULL,NULL,'DC',NULL,NULL,NULL,NULL,'2024-04-22 12:30:25.628652',NULL,NULL,'2024-04-22 12:26:40.819485'), + current_date+2,false,NULL,NULL,'DC',NULL,NULL,NULL,NULL,'2024-04-22 12:30:25.628652',NULL,NULL,'2024-04-22 12:26:40.819485'), ('641500007','415240601','415','MODTESTCOURT',true,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0005',NULL, - current_date+2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 15:14:10.871528',NULL,NULL,'2024-04-22 12:26:40.848865'); + current_date+2,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 15:14:10.871528',NULL,NULL,'2024-04-22 12:26:40.848865'); INSERT INTO juror_mod.appearance (attendance_date,juror_number,pool_number,loc_code,f_audit,time_in,time_out,travel_time,appearance_stage,non_attendance,no_show,attendance_type) VALUES diff --git a/src/integration-test/resources/db/mod/reports/IncompleteServiceReportITest_typical.sql b/src/integration-test/resources/db/mod/reports/IncompleteServiceReportITest_typical.sql index 496704db3..4db81340d 100644 --- a/src/integration-test/resources/db/mod/reports/IncompleteServiceReportITest_typical.sql +++ b/src/integration-test/resources/db/mod/reports/IncompleteServiceReportITest_typical.sql @@ -14,15 +14,15 @@ INSERT INTO juror_mod.juror (juror_number,poll_number,title,last_name,first_name -- create juror_pool associative records INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES ('641500021','415240601','415','MODTESTBUREAU',true,4,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL, - current_date+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.702989',NULL,NULL,'2024-04-22 12:26:40.702987'), + current_date+1,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.702989',NULL,NULL,'2024-04-22 12:26:40.702987'), ('641500011','415240601','415','MODTESTBUREAU',true,3,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL, - current_date+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.757378',NULL,NULL,'2024-04-22 12:26:40.757376'), + current_date+1,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.757378',NULL,NULL,'2024-04-22 12:26:40.757376'), ('641500003','415240601','415','MODTESTCOURT',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL, - current_date+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:29:18.125891',NULL,NULL,'2024-04-22 12:26:40.788798'), + current_date+1,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:29:18.125891',NULL,NULL,'2024-04-22 12:26:40.788798'), ('641500004','415240601','415','MODTESTCOURT',true,7,NULL,current_date+30,NULL,NULL,NULL,NULL,NULL,'0004',NULL, - NULL,NULL,NULL,NULL,'DC',NULL,NULL,NULL,NULL,'2024-04-22 12:30:25.628652',NULL,NULL,'2024-04-22 12:26:40.819485'), + NULL,false,NULL,NULL,'DC',NULL,NULL,NULL,NULL,'2024-04-22 12:30:25.628652',NULL,NULL,'2024-04-22 12:26:40.819485'), ('641500007','415240601','415','MODTESTCOURT',true,13,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0005',NULL, - current_date-1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 15:14:10.871528',NULL,NULL,'2024-04-22 12:26:40.848865'); + current_date-1,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 15:14:10.871528',NULL,NULL,'2024-04-22 12:26:40.848865'); insert into juror_mod.appearance (attendance_date,juror_number,pool_number,loc_code,time_in,time_out,non_attendance,appearance_stage,attendance_type) values (current_date - interval '1 day','641500021','415240601','415',null,null,false,null,'ABSENT'), diff --git a/src/integration-test/resources/db/mod/reports/JurySummoningMonitor_typical.sql b/src/integration-test/resources/db/mod/reports/JurySummoningMonitor_typical.sql index 60b868a11..61c9e5961 100644 --- a/src/integration-test/resources/db/mod/reports/JurySummoningMonitor_typical.sql +++ b/src/integration-test/resources/db/mod/reports/JurySummoningMonitor_typical.sql @@ -59,53 +59,53 @@ INSERT INTO juror_mod.juror (juror_number,poll_number,title,last_name,first_name INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES - ('641500001','415240801','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0004',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:03:06.182449',NULL,NULL,'2024-06-03 12:00:23.099129'), - ('641500002','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0008',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:04:02.042',NULL,NULL,'2024-06-03 12:00:23.112002'), - ('641500003','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 13:43:17.407033',NULL,NULL,'2024-06-03 12:00:23.109013'), - ('641500004','415240801','400','ADMINUSER',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0011',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 13:48:07.182596',NULL,NULL,'2024-06-03 12:00:23.120384'), - ('641500006','415240801','400','ADMINUSER',false,7,NULL,'2024-08-27',NULL,NULL,NULL,NULL,NULL,'0014',NULL,NULL,NULL,NULL,NULL,'A',NULL,NULL,NULL,NULL,'2024-06-03 15:06:26.990034',NULL,NULL,'2024-06-03 12:00:23.125644'), - ('641500006','415240803','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,'2024-08-27',NULL,NULL,true,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:06:26.990177',NULL,NULL,'2024-06-03 12:00:23.125644'), - ('641500007','415240801','400','ADMINUSER',true,7,NULL,'2024-10-29',NULL,NULL,NULL,NULL,NULL,'0012',NULL,NULL,NULL,NULL,NULL,'P',NULL,true,NULL,NULL,'2024-06-03 15:16:19.119732',NULL,NULL,'2024-06-03 12:00:23.122108'), - ('641500008','415240803','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-27',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:02:08.187452',NULL,NULL,'2024-06-03 12:02:08.187451'), - ('641500010','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.08775',NULL,NULL,'2024-06-03 12:00:23.087748'), - ('641500011','415240801','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:50:04.734274',NULL,NULL,'2024-06-03 12:00:23.105914'); + ('641500001','415240801','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0004',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:03:06.182449',NULL,NULL,'2024-06-03 12:00:23.099129'), + ('641500002','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0008',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:04:02.042',NULL,NULL,'2024-06-03 12:00:23.112002'), + ('641500003','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 13:43:17.407033',NULL,NULL,'2024-06-03 12:00:23.109013'), + ('641500004','415240801','400','ADMINUSER',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0011',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 13:48:07.182596',NULL,NULL,'2024-06-03 12:00:23.120384'), + ('641500006','415240801','400','ADMINUSER',false,7,NULL,'2024-08-27',NULL,NULL,NULL,NULL,NULL,'0014',NULL,NULL,false,NULL,NULL,'A',NULL,NULL,NULL,NULL,'2024-06-03 15:06:26.990034',NULL,NULL,'2024-06-03 12:00:23.125644'), + ('641500006','415240803','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,'2024-08-27',false,NULL,true,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:06:26.990177',NULL,NULL,'2024-06-03 12:00:23.125644'), + ('641500007','415240801','400','ADMINUSER',true,7,NULL,'2024-10-29',NULL,NULL,NULL,NULL,NULL,'0012',NULL,NULL,false,NULL,NULL,'P',NULL,true,NULL,NULL,'2024-06-03 15:16:19.119732',NULL,NULL,'2024-06-03 12:00:23.122108'), + ('641500008','415240803','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-27',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:02:08.187452',NULL,NULL,'2024-06-03 12:02:08.187451'), + ('641500010','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.08775',NULL,NULL,'2024-06-03 12:00:23.087748'), + ('641500011','415240801','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:50:04.734274',NULL,NULL,'2024-06-03 12:00:23.105914'); INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES - ('641500012','415240801','400','ADMINUSER',true,7,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,NULL,NULL,NULL,'M',NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',NULL,NULL,'2024-06-03 12:00:23.10279'), - ('641500013','415240801','400','ADMINUSER',true,9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0009',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 10:32:33.668674',NULL,NULL,'2024-06-03 12:00:23.115231'), - ('641500016','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0010',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.118577',NULL,NULL,'2024-06-03 12:00:23.118576'), - ('641500017','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0015',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:14:27.130294',true,NULL,'2024-06-03 12:00:23.127317'), - ('641500018','415240801','400','MODTESTBUREAU',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0013',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:16:26.744714',NULL,NULL,'2024-06-03 12:00:23.123845'), - ('641500019','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0016',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.129403',NULL,NULL,'2024-06-03 12:00:23.129402'), - ('641500021','415240801','400','ADMINUSER',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:17:15.312749',NULL,NULL,'2024-06-03 12:00:23.091738'), - ('641500023','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.095433',NULL,NULL,'2024-06-03 12:00:23.095431'), - ('641500201','415240801','400','MODTESTBUREAU',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0018',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:29:39.953446',NULL,NULL,'2024-06-03 15:33:11.346417'), - ('641500202','415240801','400','MODTESTBUREAU',true,2,NULL,'2024-08-19',NULL,NULL,NULL,NULL,NULL,'0024',NULL,NULL,NULL,NULL,NULL,'B',NULL,NULL,NULL,NULL,'2024-06-04 11:34:46.391861',NULL,NULL,'2024-06-03 15:33:11.359236'); + ('641500012','415240801','400','ADMINUSER',true,7,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,false,NULL,NULL,'M',NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',NULL,NULL,'2024-06-03 12:00:23.10279'), + ('641500013','415240801','400','ADMINUSER',true,9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0009',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 10:32:33.668674',NULL,NULL,'2024-06-03 12:00:23.115231'), + ('641500016','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0010',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.118577',NULL,NULL,'2024-06-03 12:00:23.118576'), + ('641500017','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0015',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:14:27.130294',true,NULL,'2024-06-03 12:00:23.127317'), + ('641500018','415240801','400','MODTESTBUREAU',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0013',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:16:26.744714',NULL,NULL,'2024-06-03 12:00:23.123845'), + ('641500019','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0016',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.129403',NULL,NULL,'2024-06-03 12:00:23.129402'), + ('641500021','415240801','400','ADMINUSER',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:17:15.312749',NULL,NULL,'2024-06-03 12:00:23.091738'), + ('641500023','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.095433',NULL,NULL,'2024-06-03 12:00:23.095431'), + ('641500201','415240801','400','MODTESTBUREAU',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0018',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:29:39.953446',NULL,NULL,'2024-06-03 15:33:11.346417'), + ('641500202','415240801','400','MODTESTBUREAU',true,2,NULL,'2024-08-19',NULL,NULL,NULL,NULL,NULL,'0024',NULL,NULL,false,NULL,NULL,'B',NULL,NULL,NULL,NULL,'2024-06-04 11:34:46.391861',NULL,NULL,'2024-06-03 15:33:11.359236'); INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES - ('641500203','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0022',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.35552',NULL,NULL,'2024-06-03 15:33:11.35552'), - ('641500204','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0026',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.362183',NULL,NULL,'2024-06-03 15:33:11.362182'), - ('641500210','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0017',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.343885',NULL,NULL,'2024-06-03 15:33:11.343885'), - ('641500211','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0021',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.353662',NULL,NULL,'2024-06-03 15:33:11.353662'), - ('641500212','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0019',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.348805',NULL,NULL,'2024-06-03 15:33:11.348805'), - ('641500213','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0023',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.357346',NULL,NULL,'2024-06-03 15:33:11.357346'), - ('641500216','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0025',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.361174',NULL,NULL,'2024-06-03 15:33:11.361174'), - ('641500223','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0020',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.351721',NULL,NULL,'2024-06-03 15:33:11.351721'), - ('641500316','415240801','400','ADMINUSER',true,2,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,NULL,NULL,true,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',true,NULL,'2024-06-03 12:00:23.10279'), - ('641500316','415240804','400','ADMINUSER',false,7,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,NULL,NULL,NULL,'M',NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',NULL,NULL,'2024-06-03 12:00:23.10279'); + ('641500203','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0022',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.35552',NULL,NULL,'2024-06-03 15:33:11.35552'), + ('641500204','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0026',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.362183',NULL,NULL,'2024-06-03 15:33:11.362182'), + ('641500210','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0017',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.343885',NULL,NULL,'2024-06-03 15:33:11.343885'), + ('641500211','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0021',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.353662',NULL,NULL,'2024-06-03 15:33:11.353662'), + ('641500212','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0019',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.348805',NULL,NULL,'2024-06-03 15:33:11.348805'), + ('641500213','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0023',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.357346',NULL,NULL,'2024-06-03 15:33:11.357346'), + ('641500216','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0025',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.361174',NULL,NULL,'2024-06-03 15:33:11.361174'), + ('641500223','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0020',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.351721',NULL,NULL,'2024-06-03 15:33:11.351721'), + ('641500316','415240801','400','ADMINUSER',true,2,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,false,NULL,true,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',true,NULL,'2024-06-03 12:00:23.10279'), + ('641500316','415240804','400','ADMINUSER',false,7,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,false,NULL,NULL,'M',NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',NULL,NULL,'2024-06-03 12:00:23.10279'); INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES - ('641600045','416240801','416','MODTESTBUREAU',true,2,NULL,'2024-08-19',NULL,NULL,NULL,NULL,NULL,'0001',NULL,NULL,NULL,NULL,NULL,'B',NULL,NULL,NULL,NULL,'2024-06-04 11:43:59.388',NULL,'2024-06-04','2024-06-04 11:42:42.328'), - ('641600050','416240801','416','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:44:53.178',NULL,'2024-06-04','2024-06-04 11:42:42.343'), - ('641600051','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:49:15.104',true,'2024-06-04','2024-06-04 11:42:42.346'), - ('641600054','416240801','416','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:57:37.158',NULL,'2024-06-04','2024-06-04 11:42:42.334'), - ('641600057','416240801','400','MODTESTBUREAU',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:58:18.554',NULL,'2024-06-04','2024-06-04 11:42:42.331'), - ('641600058','416240801','400','MODTESTBUREAU',true,7,NULL,'2024-09-16',NULL,NULL,NULL,NULL,NULL,'0010',NULL,NULL,NULL,NULL,NULL,'A',NULL,NULL,NULL,NULL,'2024-06-04 11:59:20.157',NULL,'2024-06-04','2024-06-04 11:42:42.354'), - ('641600062','416240801','400','MODTESTBUREAU',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0008',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:59:44.483',NULL,'2024-06-04','2024-06-04 11:42:42.349'), - ('641600065','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0004',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.337',NULL,'2024-06-04','2024-06-04 11:42:42.337'), - ('641600066','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0005',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.341',NULL,'2024-06-04','2024-06-04 11:42:42.341'), - ('641600070','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0009',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.351',NULL,'2024-06-04','2024-06-04 11:42:42.351'); + ('641600045','416240801','416','MODTESTBUREAU',true,2,NULL,'2024-08-19',NULL,NULL,NULL,NULL,NULL,'0001',NULL,NULL,false,NULL,NULL,'B',NULL,NULL,NULL,NULL,'2024-06-04 11:43:59.388',NULL,'2024-06-04','2024-06-04 11:42:42.328'), + ('641600050','416240801','416','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:44:53.178',NULL,'2024-06-04','2024-06-04 11:42:42.343'), + ('641600051','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:49:15.104',true,'2024-06-04','2024-06-04 11:42:42.346'), + ('641600054','416240801','416','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:57:37.158',NULL,'2024-06-04','2024-06-04 11:42:42.334'), + ('641600057','416240801','400','MODTESTBUREAU',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:58:18.554',NULL,'2024-06-04','2024-06-04 11:42:42.331'), + ('641600058','416240801','400','MODTESTBUREAU',true,7,NULL,'2024-09-16',NULL,NULL,NULL,NULL,NULL,'0010',NULL,NULL,false,NULL,NULL,'A',NULL,NULL,NULL,NULL,'2024-06-04 11:59:20.157',NULL,'2024-06-04','2024-06-04 11:42:42.354'), + ('641600062','416240801','400','MODTESTBUREAU',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0008',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:59:44.483',NULL,'2024-06-04','2024-06-04 11:42:42.349'), + ('641600065','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0004',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.337',NULL,'2024-06-04','2024-06-04 11:42:42.337'), + ('641600066','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0005',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.341',NULL,'2024-06-04','2024-06-04 11:42:42.341'), + ('641600070','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0009',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.351',NULL,'2024-06-04','2024-06-04 11:42:42.351'); INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES - ('677400941','774240802','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,'2024-08-08',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:07:51.647878',NULL,NULL,'2024-06-06 12:07:51.647877'), - ('677400928','774240802','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-08',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:07:51.652351',NULL,NULL,'2024-06-06 12:07:51.65235'), - ('677400923','774240802','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-08',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:08:33.268403',NULL,NULL,'2024-06-06 12:07:51.640718'); + ('677400941','774240802','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,'2024-08-08',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:07:51.647878',NULL,NULL,'2024-06-06 12:07:51.647877'), + ('677400928','774240802','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-08',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:07:51.652351',NULL,NULL,'2024-06-06 12:07:51.65235'), + ('677400923','774240802','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-08',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:08:33.268403',NULL,NULL,'2024-06-06 12:07:51.640718'); insert into juror_mod.bureau_snapshot (juror_number,pool_number,"owner",user_edtq,is_active,status,def_date,pool_seq,edit_tag,next_date,was_deferred,deferral_code,postpone,scan_code,last_update,reminder_sent,transfer_date,date_created,excusal_code,acc_exc,police_check) VALUES diff --git a/src/integration-test/resources/db/mod/reports/PersonAttendingSummaryReportITest_typical.sql b/src/integration-test/resources/db/mod/reports/PersonAttendingSummaryReportITest_typical.sql index 306326e8e..46cfaefe1 100644 --- a/src/integration-test/resources/db/mod/reports/PersonAttendingSummaryReportITest_typical.sql +++ b/src/integration-test/resources/db/mod/reports/PersonAttendingSummaryReportITest_typical.sql @@ -14,12 +14,12 @@ INSERT INTO juror_mod.juror (juror_number,poll_number,title,last_name,first_name -- create juror_pool associative records INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES ('641500021','415240601','415','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL, - current_date+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.702989',NULL,NULL,'2024-04-22 12:26:40.702987'), + current_date+1,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.702989',NULL,NULL,'2024-04-22 12:26:40.702987'), ('641500011','415240601','415','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL, - current_date+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.757378',NULL,NULL,'2024-04-22 12:26:40.757376'), + current_date+1,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:26:40.757378',NULL,NULL,'2024-04-22 12:26:40.757376'), ('641500003','415240601','415','MODTESTCOURT',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL, - current_date+1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:29:18.125891',NULL,NULL,'2024-04-22 12:26:40.788798'), + current_date+1,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 12:29:18.125891',NULL,NULL,'2024-04-22 12:26:40.788798'), ('641500004','415240601','415','MODTESTCOURT',true,1,NULL,current_date+30,NULL,NULL,NULL,NULL,NULL,'0004',NULL, - current_date+2,NULL,NULL,NULL,'DC',NULL,NULL,NULL,NULL,'2024-04-22 12:30:25.628652',NULL,NULL,'2024-04-22 12:26:40.819485'), + current_date+2,false,NULL,NULL,'DC',NULL,NULL,NULL,NULL,'2024-04-22 12:30:25.628652',NULL,NULL,'2024-04-22 12:26:40.819485'), ('641500007','415240601','415','MODTESTCOURT',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0005',NULL, - current_date+2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 15:14:10.871528',NULL,NULL,'2024-04-22 12:26:40.848865'); \ No newline at end of file + current_date+2,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-04-22 15:14:10.871528',NULL,NULL,'2024-04-22 12:26:40.848865'); \ No newline at end of file diff --git a/src/integration-test/resources/db/mod/reports/YieldPerformanceReportITest_typical.sql b/src/integration-test/resources/db/mod/reports/YieldPerformanceReportITest_typical.sql index 68e4036ec..4ee515d96 100644 --- a/src/integration-test/resources/db/mod/reports/YieldPerformanceReportITest_typical.sql +++ b/src/integration-test/resources/db/mod/reports/YieldPerformanceReportITest_typical.sql @@ -69,62 +69,62 @@ INSERT INTO juror_mod.juror (juror_number,poll_number,title,last_name,first_name INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES - ('641500001','415240801','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0004',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:03:06.182449',NULL,NULL,'2024-06-03 12:00:23.099129'), - ('641500002','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0008',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:04:02.042',NULL,NULL,'2024-06-03 12:00:23.112002'), - ('641500003','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 13:43:17.407033',NULL,NULL,'2024-06-03 12:00:23.109013'), - ('641500004','415240801','400','ADMINUSER',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0011',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 13:48:07.182596',NULL,NULL,'2024-06-03 12:00:23.120384'), - ('641500006','415240801','400','ADMINUSER',false,7,NULL,'2024-08-27',NULL,NULL,NULL,NULL,NULL,'0014',NULL,NULL,NULL,NULL,NULL,'A',NULL,NULL,NULL,NULL,'2024-06-03 15:06:26.990034',NULL,NULL,'2024-06-03 12:00:23.125644'), - ('641500006','415240803','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,'2024-08-27',NULL,NULL,true,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:06:26.990177',NULL,NULL,'2024-06-03 12:00:23.125644'), - ('641500007','415240801','400','ADMINUSER',true,7,NULL,'2024-10-29',NULL,NULL,NULL,NULL,NULL,'0012',NULL,NULL,NULL,NULL,NULL,'P',NULL,true,NULL,NULL,'2024-06-03 15:16:19.119732',NULL,NULL,'2024-06-03 12:00:23.122108'), - ('641500008','415240803','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-27',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:02:08.187452',NULL,NULL,'2024-06-03 12:02:08.187451'), - ('641500010','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.08775',NULL,NULL,'2024-06-03 12:00:23.087748'), - ('641500011','415240801','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:50:04.734274',NULL,NULL,'2024-06-03 12:00:23.105914'); + ('641500001','415240801','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0004',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:03:06.182449',NULL,NULL,'2024-06-03 12:00:23.099129'), + ('641500002','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0008',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:04:02.042',NULL,NULL,'2024-06-03 12:00:23.112002'), + ('641500003','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 13:43:17.407033',NULL,NULL,'2024-06-03 12:00:23.109013'), + ('641500004','415240801','400','ADMINUSER',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0011',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 13:48:07.182596',NULL,NULL,'2024-06-03 12:00:23.120384'), + ('641500006','415240801','400','ADMINUSER',false,7,NULL,'2024-08-27',NULL,NULL,NULL,NULL,NULL,'0014',NULL,NULL,false,NULL,NULL,'A',NULL,NULL,NULL,NULL,'2024-06-03 15:06:26.990034',NULL,NULL,'2024-06-03 12:00:23.125644'), + ('641500006','415240803','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,'2024-08-27',false,NULL,true,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:06:26.990177',NULL,NULL,'2024-06-03 12:00:23.125644'), + ('641500007','415240801','400','ADMINUSER',true,7,NULL,'2024-10-29',NULL,NULL,NULL,NULL,NULL,'0012',NULL,NULL,false,NULL,NULL,'P',NULL,true,NULL,NULL,'2024-06-03 15:16:19.119732',NULL,NULL,'2024-06-03 12:00:23.122108'), + ('641500008','415240803','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-27',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:02:08.187452',NULL,NULL,'2024-06-03 12:02:08.187451'), + ('641500010','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.08775',NULL,NULL,'2024-06-03 12:00:23.087748'), + ('641500011','415240801','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:50:04.734274',NULL,NULL,'2024-06-03 12:00:23.105914'); INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES - ('641500012','415240801','400','ADMINUSER',true,7,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,NULL,NULL,NULL,'M',NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',NULL,NULL,'2024-06-03 12:00:23.10279'), - ('641500013','415240801','400','ADMINUSER',true,9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0009',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 10:32:33.668674',NULL,NULL,'2024-06-03 12:00:23.115231'), - ('641500016','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0010',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.118577',NULL,NULL,'2024-06-03 12:00:23.118576'), - ('641500017','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0015',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:14:27.130294',true,NULL,'2024-06-03 12:00:23.127317'), - ('641500018','415240801','400','MODTESTBUREAU',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0013',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:16:26.744714',NULL,NULL,'2024-06-03 12:00:23.123845'), - ('641500019','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0016',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.129403',NULL,NULL,'2024-06-03 12:00:23.129402'), - ('641500021','415240801','400','ADMINUSER',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:17:15.312749',NULL,NULL,'2024-06-03 12:00:23.091738'), - ('641500023','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.095433',NULL,NULL,'2024-06-03 12:00:23.095431'), - ('641500201','415240801','400','MODTESTBUREAU',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0018',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:29:39.953446',NULL,NULL,'2024-06-03 15:33:11.346417'), - ('641500202','415240801','400','MODTESTBUREAU',true,2,NULL,'2024-08-19',NULL,NULL,NULL,NULL,NULL,'0024',NULL,NULL,NULL,NULL,NULL,'B',NULL,NULL,NULL,NULL,'2024-06-04 11:34:46.391861',NULL,NULL,'2024-06-03 15:33:11.359236'); + ('641500012','415240801','400','ADMINUSER',true,7,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,false,NULL,NULL,'M',NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',NULL,NULL,'2024-06-03 12:00:23.10279'), + ('641500013','415240801','400','ADMINUSER',true,9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0009',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 10:32:33.668674',NULL,NULL,'2024-06-03 12:00:23.115231'), + ('641500016','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0010',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.118577',NULL,NULL,'2024-06-03 12:00:23.118576'), + ('641500017','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0015',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:14:27.130294',true,NULL,'2024-06-03 12:00:23.127317'), + ('641500018','415240801','400','MODTESTBUREAU',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0013',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:16:26.744714',NULL,NULL,'2024-06-03 12:00:23.123845'), + ('641500019','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0016',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.129403',NULL,NULL,'2024-06-03 12:00:23.129402'), + ('641500021','415240801','400','ADMINUSER',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:17:15.312749',NULL,NULL,'2024-06-03 12:00:23.091738'), + ('641500023','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 12:00:23.095433',NULL,NULL,'2024-06-03 12:00:23.095431'), + ('641500201','415240801','400','MODTESTBUREAU',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0018',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:29:39.953446',NULL,NULL,'2024-06-03 15:33:11.346417'), + ('641500202','415240801','400','MODTESTBUREAU',true,2,NULL,'2024-08-19',NULL,NULL,NULL,NULL,NULL,'0024',NULL,NULL,false,NULL,NULL,'B',NULL,NULL,NULL,NULL,'2024-06-04 11:34:46.391861',NULL,NULL,'2024-06-03 15:33:11.359236'); INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES - ('641500203','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0022',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.35552',NULL,NULL,'2024-06-03 15:33:11.35552'), - ('641500204','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0026',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.362183',NULL,NULL,'2024-06-03 15:33:11.362182'), - ('641500210','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0017',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.343885',NULL,NULL,'2024-06-03 15:33:11.343885'), - ('641500211','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0021',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.353662',NULL,NULL,'2024-06-03 15:33:11.353662'), - ('641500212','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0019',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.348805',NULL,NULL,'2024-06-03 15:33:11.348805'), - ('641500213','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0023',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.357346',NULL,NULL,'2024-06-03 15:33:11.357346'), - ('641500216','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0025',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.361174',NULL,NULL,'2024-06-03 15:33:11.361174'), - ('641500223','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0020',NULL,'2024-08-05',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.351721',NULL,NULL,'2024-06-03 15:33:11.351721'), - ('641500316','415240801','400','ADMINUSER',true,2,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,NULL,NULL,true,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',true,NULL,'2024-06-03 12:00:23.10279'), - ('641500316','415240804','400','ADMINUSER',false,7,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,NULL,NULL,NULL,'M',NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',NULL,NULL,'2024-06-03 12:00:23.10279'); + ('641500203','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0022',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.35552',NULL,NULL,'2024-06-03 15:33:11.35552'), + ('641500204','415240801','400','ADMINUSER',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0026',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.362183',NULL,NULL,'2024-06-03 15:33:11.362182'), + ('641500210','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0017',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.343885',NULL,NULL,'2024-06-03 15:33:11.343885'), + ('641500211','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0021',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.353662',NULL,NULL,'2024-06-03 15:33:11.353662'), + ('641500212','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0019',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.348805',NULL,NULL,'2024-06-03 15:33:11.348805'), + ('641500213','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0023',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.357346',NULL,NULL,'2024-06-03 15:33:11.357346'), + ('641500216','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0025',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.361174',NULL,NULL,'2024-06-03 15:33:11.361174'), + ('641500223','415240801','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0020',NULL,'2024-08-05',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:33:11.351721',NULL,NULL,'2024-06-03 15:33:11.351721'), + ('641500316','415240801','400','ADMINUSER',true,2,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,false,NULL,true,NULL,NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',true,NULL,'2024-06-03 12:00:23.10279'), + ('641500316','415240804','400','ADMINUSER',false,7,NULL,'2024-08-20',NULL,NULL,NULL,NULL,NULL,'0005',NULL,NULL,false,NULL,NULL,'M',NULL,NULL,NULL,NULL,'2024-06-03 15:57:45.605066',NULL,NULL,'2024-06-03 12:00:23.10279'); INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES - ('641600045','416240801','416','MODTESTBUREAU',true,2,NULL,'2024-08-19',NULL,NULL,NULL,NULL,NULL,'0001',NULL,NULL,NULL,NULL,NULL,'B',NULL,NULL,NULL,NULL,'2024-06-04 11:43:59.388',NULL,'2024-06-04','2024-06-04 11:42:42.328'), - ('641600050','416240801','416','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:44:53.178',NULL,'2024-06-04','2024-06-04 11:42:42.343'), - ('641600051','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:49:15.104',true,'2024-06-04','2024-06-04 11:42:42.346'), - ('641600054','416240801','416','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:57:37.158',NULL,'2024-06-04','2024-06-04 11:42:42.334'), - ('641600057','416240801','400','MODTESTBUREAU',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:58:18.554',NULL,'2024-06-04','2024-06-04 11:42:42.331'), - ('641600058','416240801','400','MODTESTBUREAU',true,7,NULL,'2024-09-16',NULL,NULL,NULL,NULL,NULL,'0010',NULL,NULL,NULL,NULL,NULL,'A',NULL,NULL,NULL,NULL,'2024-06-04 11:59:20.157',NULL,'2024-06-04','2024-06-04 11:42:42.354'), - ('641600062','416240801','400','MODTESTBUREAU',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0008',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:59:44.483',NULL,'2024-06-04','2024-06-04 11:42:42.349'), - ('641600065','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0004',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.337',NULL,'2024-06-04','2024-06-04 11:42:42.337'), - ('641600066','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0005',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.341',NULL,'2024-06-04','2024-06-04 11:42:42.341'), - ('641600070','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0009',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.351',NULL,'2024-06-04','2024-06-04 11:42:42.351'); + ('641600045','416240801','416','MODTESTBUREAU',true,2,NULL,'2024-08-19',NULL,NULL,NULL,NULL,NULL,'0001',NULL,NULL,false,NULL,NULL,'B',NULL,NULL,NULL,NULL,'2024-06-04 11:43:59.388',NULL,'2024-06-04','2024-06-04 11:42:42.328'), + ('641600050','416240801','416','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:44:53.178',NULL,'2024-06-04','2024-06-04 11:42:42.343'), + ('641600051','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:49:15.104',true,'2024-06-04','2024-06-04 11:42:42.346'), + ('641600054','416240801','416','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:57:37.158',NULL,'2024-06-04','2024-06-04 11:42:42.334'), + ('641600057','416240801','400','MODTESTBUREAU',true,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:58:18.554',NULL,'2024-06-04','2024-06-04 11:42:42.331'), + ('641600058','416240801','400','MODTESTBUREAU',true,7,NULL,'2024-09-16',NULL,NULL,NULL,NULL,NULL,'0010',NULL,NULL,false,NULL,NULL,'A',NULL,NULL,NULL,NULL,'2024-06-04 11:59:20.157',NULL,'2024-06-04','2024-06-04 11:42:42.354'), + ('641600062','416240801','400','MODTESTBUREAU',true,6,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0008',NULL,NULL,false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:59:44.483',NULL,'2024-06-04','2024-06-04 11:42:42.349'), + ('641600065','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0004',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.337',NULL,'2024-06-04','2024-06-04 11:42:42.337'), + ('641600066','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0005',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.341',NULL,'2024-06-04','2024-06-04 11:42:42.341'), + ('641600070','416240801','416','MODTESTBUREAU',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0009',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:42:42.351',NULL,'2024-06-04','2024-06-04 11:42:42.351'); INSERT INTO juror_mod.juror_pool (juror_number,pool_number,"owner",user_edtq,is_active,status,times_sel,def_date,"location",no_attendances,no_attended,no_fta,no_awol,pool_seq,edit_tag,next_date,on_call,smart_card,was_deferred,deferral_code,id_checked,postpone,paid_cash,scan_code,last_update,reminder_sent,transfer_date,date_created) VALUES - ('677400941','774240802','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,'2024-08-08',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:07:51.647878',NULL,NULL,'2024-06-06 12:07:51.647877'), - ('677400928','774240802','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-08',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:07:51.652351',NULL,NULL,'2024-06-06 12:07:51.65235'), - ('677400923','774240802','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-08',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:08:33.268403',NULL,NULL,'2024-06-06 12:07:51.640718'), - ('641700050','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:44:53.178',NULL,'2024-06-04','2024-06-04 11:42:42.343'), - ('641700051','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:49:15.104',true,'2024-06-04','2024-06-04 11:42:42.346'), - ('641700052','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:57:37.158',NULL,'2024-06-04','2024-06-04 11:42:42.334'), - ('641700053','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:44:53.178',NULL,'2024-06-04','2024-06-04 11:42:42.343'), - ('641700054','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:49:15.104',true,'2024-06-04','2024-06-04 11:42:42.346'), - ('641700055','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:57:37.158',NULL,'2024-06-04','2024-06-04 11:42:42.334'), - ('641700056','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:44:53.178',NULL,'2024-06-04','2024-06-04 11:42:42.343'), - ('641700057','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:49:15.104',true,'2024-06-04','2024-06-04 11:42:42.346'), - ('641700058','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-06',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:57:37.158',NULL,'2024-06-04','2024-06-04 11:42:42.334'); + ('677400941','774240802','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0002',NULL,'2024-08-08',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:07:51.647878',NULL,NULL,'2024-06-06 12:07:51.647877'), + ('677400928','774240802','400','ADMINUSER',true,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-08',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:07:51.652351',NULL,NULL,'2024-06-06 12:07:51.65235'), + ('677400923','774240802','400','ADMINUSER',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0001',NULL,'2024-08-08',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-06 12:08:33.268403',NULL,NULL,'2024-06-06 12:07:51.640718'), + ('641700050','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:44:53.178',NULL,'2024-06-04','2024-06-04 11:42:42.343'), + ('641700051','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:49:15.104',true,'2024-06-04','2024-06-04 11:42:42.346'), + ('641700052','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:57:37.158',NULL,'2024-06-04','2024-06-04 11:42:42.334'), + ('641700053','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:44:53.178',NULL,'2024-06-04','2024-06-04 11:42:42.343'), + ('641700054','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:49:15.104',true,'2024-06-04','2024-06-04 11:42:42.346'), + ('641700055','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:57:37.158',NULL,'2024-06-04','2024-06-04 11:42:42.334'), + ('641700056','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0006',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:44:53.178',NULL,'2024-06-04','2024-06-04 11:42:42.343'), + ('641700057','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0007',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:49:15.104',true,'2024-06-04','2024-06-04 11:42:42.346'), + ('641700058','417240801','400','MODTESTBUREAU',true,2,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'0003',NULL,'2024-08-06',false,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2024-06-04 11:57:37.158',NULL,'2024-06-04','2024-06-04 11:42:42.334'); insert into juror_mod.bureau_snapshot (juror_number,pool_number,"owner",user_edtq,is_active,status,def_date,pool_seq,edit_tag,next_date,was_deferred,deferral_code,postpone,scan_code,last_update,reminder_sent,transfer_date,date_created,excusal_code,acc_exc,police_check) VALUES diff --git a/src/integration-test/resources/db/mod/truncate.sql b/src/integration-test/resources/db/mod/truncate.sql index 1aaa94ce1..b8908bacd 100644 --- a/src/integration-test/resources/db/mod/truncate.sql +++ b/src/integration-test/resources/db/mod/truncate.sql @@ -37,6 +37,7 @@ DELETE FROM juror_mod.user_roles_audit; DELETE FROM juror_mod.user_courts_audit; DELETE FROM juror_mod.users_audit; +DELETE FROM juror_mod.user_permissions; DELETE FROM juror_mod.user_roles; DELETE FROM juror_mod.user_courts; DELETE FROM juror_mod.users; diff --git a/src/main/java/uk/gov/hmcts/juror/api/bureau/controller/JurorCommsCronBatchController.java b/src/main/java/uk/gov/hmcts/juror/api/bureau/controller/JurorCommsCronBatchController.java index f1ffa8df9..08801c332 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/bureau/controller/JurorCommsCronBatchController.java +++ b/src/main/java/uk/gov/hmcts/juror/api/bureau/controller/JurorCommsCronBatchController.java @@ -2,11 +2,11 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.util.Assert; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; @@ -21,16 +21,11 @@ @RequestMapping(value = "/api/v1/bureau/cron", produces = MediaType.APPLICATION_JSON_VALUE) @Slf4j @Tag(name = "Cron API", description = "Bureau Cron API") +@RequiredArgsConstructor(onConstructor_ = {@Autowired}) public class JurorCommsCronBatchController { private final BureauBatchScheduler bureauBatchScheduler; - @Autowired - public JurorCommsCronBatchController(final BureauBatchScheduler bureauBatchScheduler) { - Assert.notNull(bureauBatchScheduler, "BureauAuthenticationService cannot be null."); - this.bureauBatchScheduler = bureauBatchScheduler; - } - @GetMapping @Operation(summary = "/bureau/cron", description = "BureauBatchScheduler is called") diff --git a/src/main/java/uk/gov/hmcts/juror/api/bureau/controller/response/BureauJurorDetailDto.java b/src/main/java/uk/gov/hmcts/juror/api/bureau/controller/response/BureauJurorDetailDto.java index 31d52b76c..ba4750023 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/bureau/controller/response/BureauJurorDetailDto.java +++ b/src/main/java/uk/gov/hmcts/juror/api/bureau/controller/response/BureauJurorDetailDto.java @@ -7,6 +7,7 @@ import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; import uk.gov.hmcts.juror.api.moj.controller.response.jurorresponse.IJurorResponse; import uk.gov.hmcts.juror.api.moj.domain.ModJurorDetail; import uk.gov.hmcts.juror.api.moj.domain.User; @@ -25,6 +26,7 @@ * @see uk.gov.hmcts.juror.api.bureau.domain.BureauJurorDetail */ @Data +@Slf4j @NoArgsConstructor @AllArgsConstructor @Schema(description = "All Details available on a juror in the system ") @@ -423,8 +425,15 @@ public BureauJurorDetailDto(final ModJurorDetail jurorDetails) { this.excusalReason = jurorDetails.getExcusalReason(); this.useJurorEmailDetails = jurorDetails.getUseJurorEmailDetails(); this.useJurorPhoneDetails = jurorDetails.getUseJurorPhoneDetails(); - this.assignedStaffMember = jurorDetails.getAssignedStaffMember() != null - ? new StaffDto(jurorDetails.getAssignedStaffMember()) : null; + try { + this.assignedStaffMember = jurorDetails.getAssignedStaffMember() != null + ? new StaffDto(jurorDetails.getAssignedStaffMember()) + : null; + } catch (Exception e) { + log.error("Error setting assigned staff member for response for juror {}", + jurorDetails.getJurorNumber() + " -- " + e.getMessage()); + } + this.staffAssignmentDate = jurorDetails.getStaffAssignmentDate(); this.assignmentAllowed = jurorDetails.getAssignmentAllowed(); this.phoneLogs = jurorDetails.getContactLogs().stream().map(ContactLogDto::new).collect(Collectors.toList()); diff --git a/src/main/java/uk/gov/hmcts/juror/api/bureau/scheduler/BureauBatchScheduler.java b/src/main/java/uk/gov/hmcts/juror/api/bureau/scheduler/BureauBatchScheduler.java index ba178a09c..2033e3f1f 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/bureau/scheduler/BureauBatchScheduler.java +++ b/src/main/java/uk/gov/hmcts/juror/api/bureau/scheduler/BureauBatchScheduler.java @@ -1,11 +1,11 @@ package uk.gov.hmcts.juror.api.bureau.scheduler; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; -import org.springframework.util.Assert; import uk.gov.hmcts.juror.api.bureau.service.ScheduledService; import uk.gov.hmcts.juror.api.moj.client.contracts.SchedulerServiceClient; @@ -16,21 +16,12 @@ @Component @Slf4j +@RequiredArgsConstructor(onConstructor_ = {@Autowired}) public class BureauBatchScheduler { private final BureauBatchProcessFactory bureauBatchProcessFactory; private final SchedulerServiceClient schedulerServiceClient; - @Autowired - public BureauBatchScheduler( - final BureauBatchProcessFactory bureauBatchProcessFactory, - final SchedulerServiceClient schedulerServiceClient) { - Assert.notNull(bureauBatchProcessFactory, "BureauBatchProcessFactory cannot be null."); - this.bureauBatchProcessFactory = bureauBatchProcessFactory; - this.schedulerServiceClient = schedulerServiceClient; - - } - /** * General Entry point for externally hosted cron jobs. ( server crontab and not via springboot). */ diff --git a/src/main/java/uk/gov/hmcts/juror/api/bureau/scheduler/UrgentStatusScheduler.java b/src/main/java/uk/gov/hmcts/juror/api/bureau/scheduler/UrgentStatusScheduler.java index 26491ea2b..1ddc01fc0 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/bureau/scheduler/UrgentStatusScheduler.java +++ b/src/main/java/uk/gov/hmcts/juror/api/bureau/scheduler/UrgentStatusScheduler.java @@ -73,7 +73,8 @@ public SchedulerServiceClient.Result process() { SecurityUtil.BUREAU_OWNER); if (jurorDetails == null) { - log.error("Can not find active bureau owned juror pool for juror: " + backlogItem.getJurorNumber()); + log.error("Can not find active bureau owned juror pool for juror: {}", + backlogItem.getJurorNumber()); failedToFindJurorCount++; continue; } @@ -104,9 +105,9 @@ public SchedulerServiceClient.Result process() { ? SchedulerServiceClient.Result.Status.SUCCESS : SchedulerServiceClient.Result.Status.PARTIAL_SUCCESS, null, Map.of( - "TOTAL_PROCESSED", "" + totalResponsesProcessed, - "TOTAL_MARKED_URGENT", "" + totalUrgentResponses, - "TOTAL_FAILED_TO_FIND", "" + failedToFindJurorCount + "TOTAL_PROCESSED", String.valueOf(totalResponsesProcessed), + "TOTAL_MARKED_URGENT", String.valueOf(totalUrgentResponses), + "TOTAL_FAILED_TO_FIND", String.valueOf(failedToFindJurorCount) )); } diff --git a/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsLetterServiceImpl.java b/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsLetterServiceImpl.java index c2eede774..98d11e69a 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsLetterServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsLetterServiceImpl.java @@ -1,7 +1,7 @@ package uk.gov.hmcts.juror.api.bureau.service; import com.google.common.collect.Lists; -import io.jsonwebtoken.lang.Assert; +import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -15,6 +15,7 @@ import uk.gov.hmcts.juror.api.moj.domain.JurorPool; import uk.gov.hmcts.juror.api.moj.repository.BulkPrintDataRepository; import uk.gov.hmcts.juror.api.moj.repository.JurorPoolRepository; +import uk.gov.hmcts.juror.api.moj.utils.NotifyUtil; import uk.gov.hmcts.juror.api.moj.utils.SecurityUtil; import java.text.SimpleDateFormat; @@ -27,6 +28,7 @@ */ @Slf4j @Service +@AllArgsConstructor(onConstructor = @__(@Autowired)) public class JurorCommsLetterServiceImpl implements BureauProcessService { @@ -35,24 +37,6 @@ public class JurorCommsLetterServiceImpl implements BureauProcessService { private final BulkPrintDataRepository bulkPrintDataRepository; private final JurorPoolRepository jurorRepository; - @Autowired - public JurorCommsLetterServiceImpl( - final JurorCommsNotificationService jurorCommsNotificationService, - final BulkPrintDataNotifyCommsRepository bulkPrintDataNotifyCommsRepository, - final BulkPrintDataRepository bulkPrintDataRepository, - final JurorPoolRepository jurorRepository) { - Assert.notNull(jurorCommsNotificationService, "JurorCommsNotificationService cannot be null."); - Assert.notNull(bulkPrintDataRepository, "BulkPrintDataRepository cannot be null."); - Assert.notNull(bulkPrintDataNotifyCommsRepository, "BulkPrintDataNotifyCommsRepository cannot be null."); - Assert.notNull(jurorRepository, "JurorRepository cannot be null."); - - this.jurorCommsNotificationService = jurorCommsNotificationService; - this.bulkPrintDataRepository = bulkPrintDataRepository; - this.bulkPrintDataNotifyCommsRepository = bulkPrintDataNotifyCommsRepository; - this.jurorRepository = jurorRepository; - - } - /** * Implements a specific job execution. * Processes entries in the Juror.print_files table and sends the appropriate email notifications to @@ -71,9 +55,8 @@ public SchedulerServiceClient.Result process() { log.debug("jurorCommsPrintFiles {}", bulkPrintDataNotifyCommsList.size()); int commsSent = 0; int commsfailed = 0; + int invalidEmailAddress = 0; if (!bulkPrintDataNotifyCommsList.isEmpty()) { - - for (BulkPrintDataNotifyComms printFile : bulkPrintDataNotifyCommsList) { try { log.trace("LetterService : jurorNumber {}", printFile.getJurorNo()); @@ -93,18 +76,19 @@ public SchedulerServiceClient.Result process() { updatePrintFiles(printFile); commsSent++; } catch (JurorCommsNotificationServiceException e) { - log.error( - "Unable to send Letter comms for {} : {} {}", - printFile.getJurorNo(), - e.getMessage(), - e.getCause().toString() - ); - commsfailed++; + if (NotifyUtil.isInvalidEmailAddressError(e.getCause())) { + invalidEmailAddress++; + } else { + log.error( + "Unable to send Letter comms for {}", + printFile.getJurorNo(), e + ); + commsfailed++; + } } catch (Exception e) { commsfailed++; log.error("Letter Comms Processing : Juror Comms failed : {}", e.getMessage()); } - } log.info("LetterService : Summary, identified:{}, sent:{}, failed:{},", bulkPrintDataNotifyCommsList.size(), commsSent, commsfailed @@ -118,8 +102,11 @@ public SchedulerServiceClient.Result process() { commsfailed == 0 ? SchedulerServiceClient.Result.Status.SUCCESS : SchedulerServiceClient.Result.Status.PARTIAL_SUCCESS, null, - Map.of("COMMS_FAILED", "" + commsfailed, - "COMMNS_SENT", "" + commsSent)); + Map.of( + "COMMS_FAILED", String.valueOf(commsfailed), + "COMMNS_SENT", String.valueOf(commsSent), + "INVALID_EMAIL_ADDRESS", String.valueOf(invalidEmailAddress) + )); } /** diff --git a/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsSentToCourtServiceImpl.java b/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsSentToCourtServiceImpl.java index 42e714b5a..f40aa98ca 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsSentToCourtServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsSentToCourtServiceImpl.java @@ -3,7 +3,7 @@ import com.google.common.collect.Lists; import com.querydsl.core.types.dsl.BooleanExpression; -import io.jsonwebtoken.lang.Assert; +import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -16,17 +16,20 @@ import uk.gov.hmcts.juror.api.moj.repository.JurorPoolQueries; import uk.gov.hmcts.juror.api.moj.repository.JurorPoolRepository; import uk.gov.hmcts.juror.api.moj.service.AppSettingService; +import uk.gov.hmcts.juror.api.moj.utils.NotifyUtil; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Objects; /** * Implementation of {@link BureauProcessService}. */ @Slf4j @Service +@AllArgsConstructor(onConstructor = @__(@Autowired)) public class JurorCommsSentToCourtServiceImpl implements BureauProcessService { @@ -37,19 +40,6 @@ public class JurorCommsSentToCourtServiceImpl implements BureauProcessService { private final JurorPoolRepository jurorRepository; private final AppSettingService appSetting; - @Autowired - public JurorCommsSentToCourtServiceImpl( - final JurorCommsNotificationService jurorCommsNotificationService, - final AppSettingService appSetting, - final JurorPoolRepository jurorRepository) { - Assert.notNull(jurorCommsNotificationService, "JurorCommsNotificationService cannot be null."); - Assert.notNull(jurorRepository, "JurorRepository cannot be null."); - Assert.notNull(appSetting, "AppSettingService cannot be null."); - this.jurorCommsNotificationService = jurorCommsNotificationService; - this.appSetting = appSetting; - this.jurorRepository = jurorRepository; - } - /** * Implements a specific job execution. * Processes entries in the Juror table and sends the appropriate email notifications to @@ -70,26 +60,36 @@ public SchedulerServiceClient.Result process() { Integer notificationsSent; int errorCount = 0; + int errorInvalidEmailCount = 0; + int errorInvalidPhoneCount = 0; + int successCountEmail = 0; + int successCountSms = 0; + int errorCountEmail = 0; + int errorCountSms = 0; + int successCount = 0; for (JurorPool jurorDetail : jurordetailList) { notificationsSent = jurorDetail.getJuror().getNotifications(); log.trace("Sent To Court Comms Service : jurorNumber {}", jurorDetail.getJurorNumber()); + boolean isEmail = false; + boolean isSms = false; try { //Email if (jurorDetail.getJuror().getEmail() != null && !notificationsSent.equals(EMAIL_NOTIFICATION_SENT)) { + isEmail = true; jurorCommsNotificationService.sendJurorComms(jurorDetail, JurorCommsNotifyTemplateType.SENT_TO_COURT, null, null, false ); notificationsSent = EMAIL_NOTIFICATION_SENT; + successCountEmail++; } //Send SMS only if there has not been an email sent - if (jurorDetail.getJuror().getAltPhoneNumber() != null && !notificationsSent.equals( - EMAIL_NOTIFICATION_SENT) - && appSetting.getSendEmailOrSms() == SEND_EMAIL_OR_SMS) { - - + if (jurorDetail.getJuror().getAltPhoneNumber() != null + && !notificationsSent.equals(EMAIL_NOTIFICATION_SENT) + && Objects.equals(appSetting.getSendEmailOrSms(), SEND_EMAIL_OR_SMS)) { + isSms = true; jurorCommsNotificationService.sendJurorCommsSms( jurorDetail, JurorCommsNotifyTemplateType.SENT_TO_COURT, @@ -97,13 +97,13 @@ public SchedulerServiceClient.Result process() { null, true ); + successCountSms++; } // Send SMS if (jurorDetail.getJuror().getAltPhoneNumber() != null - && appSetting.getSendEmailOrSms() != SEND_EMAIL_OR_SMS) { - - + && !Objects.equals(appSetting.getSendEmailOrSms(), SEND_EMAIL_OR_SMS)) { + isSms = true; jurorCommsNotificationService.sendJurorCommsSms( jurorDetail, JurorCommsNotifyTemplateType.SENT_TO_COURT, @@ -111,29 +111,53 @@ public SchedulerServiceClient.Result process() { null, true ); - + successCountSms++; } //update regardless - stop processing next time. jurorDetail.getJuror().setNotifications(ALL_NOTIFICATION_SENT); notificationsSent = ALL_NOTIFICATION_SENT; update(jurorDetail); + successCount++; } catch (JurorCommsNotificationServiceException e) { - log.error( - "Unable to send sent to court comms for {} : {} {}", - jurorDetail.getJurorNumber(), - e.getMessage(), - e.getCause().toString() - ); - errorCount++; + boolean isError = false; + if (isEmail) { + if (NotifyUtil.isInvalidEmailAddressError(e.getCause())) { + errorInvalidEmailCount++; + } else { + isError = true; + errorCountEmail++; + } + } + if (isSms) { + if (NotifyUtil.isInvalidPhoneNumberError(e.getCause())) { + errorInvalidPhoneCount++; + } else { + isError = true; + errorCountSms++; + } + } + if (isError) { + errorCount++; + log.error( + "Unable to send sent to court comms for {}", + jurorDetail.getJurorNumber(), e + ); + } if (notificationsSent.equals(EMAIL_NOTIFICATION_SENT)) { jurorDetail.getJuror().setNotifications(notificationsSent); update(jurorDetail); } } catch (Exception e) { - log.error("Sent To Court Comms Processing : Juror Comms failed : {}", e.getMessage()); + log.error("Sent To Court Comms Processing : Juror Comms failed : {}", e.getMessage(), e); errorCount++; + if (isEmail) { + errorCountEmail++; + } + if (isSms) { + errorCountSms++; + } } } log.info("Sent To Court Comms Processing : Finished - {}", dateFormat.format(new Date())); @@ -141,7 +165,17 @@ public SchedulerServiceClient.Result process() { errorCount == 0 ? SchedulerServiceClient.Result.Status.SUCCESS : SchedulerServiceClient.Result.Status.PARTIAL_SUCCESS, null, - Map.of("ERROR_COUNT", "" + errorCount)); + Map.of( + "SUCCESS_COUNT_EMAIL", String.valueOf(successCountEmail), + "SUCCESS_COUNT_SMS", String.valueOf(successCountSms), + "ERROR_COUNT_EMAIL", String.valueOf(errorCountEmail), + "ERROR_COUNT_SMS", String.valueOf(errorCountSms), + "COUNT_INVALID_EMAIL", String.valueOf(errorInvalidEmailCount), + "COUNT_INVALID_PHONE", String.valueOf(errorInvalidPhoneCount), + "SUCCESS_COUNT", String.valueOf(successCount), + "ERROR_COUNT", String.valueOf(errorCount), + "TOTAL_JURORS", String.valueOf(jurordetailList.size()) + )); } /** @@ -149,26 +183,15 @@ public SchedulerServiceClient.Result process() { */ private void update(JurorPool jurorDetails) { try { - log.trace("Inside update ....."); jurorRepository.save(jurorDetails); log.trace("Updating Juror notification as sent ({})... ", jurorDetails.getJuror().getNotifications()); } catch (TransactionSystemException e) { Throwable cause = e.getRootCause(); - // if (poolDetails.getNotifications().equals(EMAIL_NOTIFICATION_SENT)) { - if (jurorDetails.getJuror().getNotifications() == (EMAIL_NOTIFICATION_SENT)) { - log.trace("notifications is : {} - logging error", jurorDetails.getJuror().getNotifications()); - log.error("Failed to update db to {}. Manual update required. {}", - jurorDetails.getJuror().getNotifications(), - cause.toString() - ); - } else { - log.trace("notifications is : {} - throwing excep", jurorDetails.getJuror().getNotifications()); - throw new JurorCommsNotificationServiceException( - "Failed to update db to " - + jurorDetails.getJuror().getNotifications() + ". Manual update required. ", - cause - ); - } + throw new JurorCommsNotificationServiceException( + "Failed to update db to " + + jurorDetails.getJuror().getNotifications() + ". Manual update required. ", + cause + ); } } diff --git a/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsWeeklyInfoServiceImpl.java b/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsWeeklyInfoServiceImpl.java index 6a93fbec2..b8121d96e 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsWeeklyInfoServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorCommsWeeklyInfoServiceImpl.java @@ -3,7 +3,7 @@ import com.google.common.collect.Lists; import com.querydsl.core.types.dsl.BooleanExpression; -import io.jsonwebtoken.lang.Assert; +import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -15,6 +15,7 @@ import uk.gov.hmcts.juror.api.moj.domain.JurorPool; import uk.gov.hmcts.juror.api.moj.repository.JurorPoolQueries; import uk.gov.hmcts.juror.api.moj.repository.JurorPoolRepository; +import uk.gov.hmcts.juror.api.moj.utils.NotifyUtil; import java.text.SimpleDateFormat; import java.util.Date; @@ -26,26 +27,14 @@ */ @Slf4j @Service +@AllArgsConstructor(onConstructor = @__(@Autowired)) public class JurorCommsWeeklyInfoServiceImpl implements BureauProcessService { private static final Integer NOTIFICATION_SENT = 1; private final JurorCommsNotificationService jurorCommsNotificationService; - - private final JurorPoolRepository jurorRepository; - @Autowired - public JurorCommsWeeklyInfoServiceImpl( - final JurorCommsNotificationService jurorCommsNotificationService, - final JurorPoolRepository jurorRepository) { - Assert.notNull(jurorCommsNotificationService, "JurorCommsNotificationService cannot be null."); - Assert.notNull(jurorRepository, "JurorRepository cannot be null."); - this.jurorCommsNotificationService = jurorCommsNotificationService; - this.jurorRepository = jurorRepository; - - } - /** * Implements a specific job execution. * Processes entries in the Juror table and sends the appropriate email notifications to @@ -66,6 +55,7 @@ public SchedulerServiceClient.Result process() { int infoCommsSent = 0; int noEmailAddress = 0; + int invalidEmailAddress = 0; int infoCommsfailed = 0; for (JurorPool jurorDetail : jurordetailList) { @@ -87,15 +77,17 @@ public SchedulerServiceClient.Result process() { update(jurorDetail); } catch (JurorCommsNotificationServiceException e) { - log.error( - "Unable to send Informational comms for " - + jurorDetail.getJurorNumber() - + " : " + e.getMessage() - + " " + e.getCause().toString(), e - ); - infoCommsfailed++; + if (NotifyUtil.isInvalidEmailAddressError(e.getCause())) { + invalidEmailAddress++; + } else { + log.error( + "Unable to send Informational comms for {}", + jurorDetail.getJurorNumber(), e + ); + infoCommsfailed++; + } } catch (Exception e) { - log.error("Informational Comms Processing : Juror Comms failed : " + e.getMessage(), e); + log.error("Informational Comms Processing : Juror Comms failed", e); infoCommsfailed++; } } @@ -108,9 +100,10 @@ public SchedulerServiceClient.Result process() { ? SchedulerServiceClient.Result.Status.SUCCESS : SchedulerServiceClient.Result.Status.PARTIAL_SUCCESS, null, Map.of( - "INFO_COMMS_SENT", "" + infoCommsSent, - "INFO_COMMS_FAILED", "" + infoCommsfailed, - "NO_EMAIL_ADDRESS", "" + noEmailAddress + "INFO_COMMS_SENT", String.valueOf(infoCommsSent), + "INFO_COMMS_FAILED", String.valueOf(infoCommsfailed), + "NO_EMAIL_ADDRESS", String.valueOf(noEmailAddress), + "INVALID_EMAIL_ADDRESS", String.valueOf(invalidEmailAddress) )); } diff --git a/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorDashboardSmartSurveyImportImpl.java b/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorDashboardSmartSurveyImportImpl.java index 2362eef5f..760521fc4 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorDashboardSmartSurveyImportImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/bureau/service/JurorDashboardSmartSurveyImportImpl.java @@ -79,6 +79,7 @@ public SchedulerServiceClient.Result process() { List surveyResponseList; int dbInsertCount = 0; int dbSkipCount = 0; + int errorCount = 0; SmartSurveyConfigurationProperties.Proxy proxyProperties = smartSurveyConfigurationProperties.getProxy(); @@ -86,8 +87,6 @@ public SchedulerServiceClient.Result process() { // these settings are required for the process to continue log.info("Smart Survey config enabled: {}", smartSurveyEnabled); log.info("Smart Survey config exports url: {}", smartSurveyExportsUrl); - //log.info("Smart Survey config token: {}", smartSurveyToken); - //log.info("Smart Survey config secret: {}", smartSurveyTokenSecret); if (!smartSurveyEnabled) { log.info("Smart Survey data import disabled in application settings"); @@ -115,20 +114,16 @@ public SchedulerServiceClient.Result process() { log.info("Smart Survey proxy port: {}", proxyPort); log.info("Smart Survey proxy type: {}", proxyType); - proxy = new Proxy(proxyType, new InetSocketAddress(proxyHost, Integer.valueOf(proxyPort))); + proxy = new Proxy(proxyType, new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort))); } else { - - proxyHost = null; - proxyPort = null; - proxyType = null; proxy = null; - log.info("Smart Survey proxy settings ignored"); } } catch (Exception e) { log.error("Smart Survey unable to create proxy using application settings"); proxy = null; + errorCount++; } // Output settings retrieved from APP_SETTINGS table @@ -149,22 +144,17 @@ public SchedulerServiceClient.Result process() { log.error("Unable to obtain export download url from smart survey api"); throw new IllegalStateException("unable to obtain export download url from smart survey api"); } else { - exportUrl = exportUrl + smartSurveyCredentials; - surveyResponseList = getExportData(exportUrl, vars, startDate, surveyId); } // Add records to table SURVEY_RESPONSE if not existing - if (surveyResponseList.size() > 0) { + if (!surveyResponseList.isEmpty()) { log.info("Smart Survey records parsed (excluding header): {}", surveyResponseList.size()); - for (int i = 0; - i < surveyResponseList.size(); - i++) { + for (SurveyResponse objSurveyResponse : surveyResponseList) { - SurveyResponse objSurveyResponse = surveyResponseList.get(i); SurveyResponseKey objSurveyResponseKey = new SurveyResponseKey(); objSurveyResponseKey.setId(objSurveyResponse.getId()); objSurveyResponseKey.setSurveyId(objSurveyResponse.getSurveyId()); @@ -174,8 +164,8 @@ public SchedulerServiceClient.Result process() { this.surveyResponseRepository.save(objSurveyResponse); dbInsertCount++; } catch (Exception e) { - log.error("Error inserting survey record: {}", e.getMessage()); - log.error("Error inserting survey record: {}", objSurveyResponse); + errorCount++; + log.error("Error inserting survey record: {} - {}", e.getMessage(), objSurveyResponse); } } else { // record already exists @@ -186,6 +176,7 @@ public SchedulerServiceClient.Result process() { log.info("Records inserted: {}", dbInsertCount); log.info("Records skipped: {}", dbSkipCount); + log.info("Records with error: {}", errorCount); } @@ -193,11 +184,16 @@ public SchedulerServiceClient.Result process() { log.info("Smart Survey Processing : FINISHED- {}", dateFormatSurvey.format(new Date())); - return new SchedulerServiceClient.Result(SchedulerServiceClient.Result.Status.SUCCESS, - "Successfully loaded survey records", + return new SchedulerServiceClient.Result(errorCount == 0 + ? SchedulerServiceClient.Result.Status.SUCCESS + : SchedulerServiceClient.Result.Status.PARTIAL_SUCCESS, + errorCount == 0 + ? "Successfully loaded survey records" + : "Error loading some survey records", Map.of( "RECORDS_INSERTED", String.valueOf(dbInsertCount), - "RECORDS_SKIPPED", String.valueOf(dbSkipCount) + "RECORDS_SKIPPED", String.valueOf(dbSkipCount), + "ERROR_COUNT", String.valueOf(errorCount) )); } @@ -211,9 +207,9 @@ private String getExportDownloadUrl(String smartSurveyUrl, Map v // Get the latest survey export URL from the smart survey API final String configExportName = this.appSetting.getSmartSurveySummonsResponseExportName(); - String smartSurveyExportList = null; - RestTemplate restTemplate = null; - HttpHeaders headers = null; + String smartSurveyExportList; + RestTemplate restTemplate; + HttpHeaders headers; log.info("Smart Survey request url: {}", smartSurveyUrl); log.info("Smart Survey config export name: {}", configExportName); @@ -252,9 +248,7 @@ private String getExportDownloadUrl(String smartSurveyUrl, Map v // Find the latest survey export matching the name set in the config List jsonList = new ArrayList(); - for (int i = 0; - i < jsonArr.length(); - i++) { + for (int i = 0; i < jsonArr.length(); i++) { JSONObject obj = jsonArr.getJSONObject(i); String exportName = obj.getString("name"); @@ -265,7 +259,7 @@ private String getExportDownloadUrl(String smartSurveyUrl, Map v } String exportUrl = null; //Get the Url for the latest export record - first item in list - if (jsonList.size() > 0) { + if (!jsonList.isEmpty()) { JSONObject obj = jsonList.get(0); log.debug("Smart Survey export details: {}", obj); exportUrl = obj.getString("href_download"); @@ -283,9 +277,9 @@ private List getExportData(String smartSurveyUrl, Map surveyResponseList = new ArrayList(); - String smartSurveyExportData = null; - RestTemplate restTemplate = null; - HttpHeaders headers = null; + String smartSurveyExportData; + RestTemplate restTemplate; + HttpHeaders headers; // get export data from Smart Survey API log.info("Smart Survey request url: {}", smartSurveyUrl); @@ -331,9 +325,7 @@ private List getExportData(String smartSurveyUrl, Map 1) { - for (int i = 1; - i < arrCsvRows.length; - i++) { + for (int i = 1; i < arrCsvRows.length; i++) { String csvRow = arrCsvRows[i]; String[] csvCols = csvRow.split(","); diff --git a/src/main/java/uk/gov/hmcts/juror/api/config/bureau/BureauJwtPayload.java b/src/main/java/uk/gov/hmcts/juror/api/config/bureau/BureauJwtPayload.java index 5305130da..925bfd487 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/config/bureau/BureauJwtPayload.java +++ b/src/main/java/uk/gov/hmcts/juror/api/config/bureau/BureauJwtPayload.java @@ -11,6 +11,7 @@ import org.springframework.security.core.authority.AuthorityUtils; import org.springframework.util.ObjectUtils; import uk.gov.hmcts.juror.api.juror.domain.CourtLocation; +import uk.gov.hmcts.juror.api.moj.domain.Permission; import uk.gov.hmcts.juror.api.moj.domain.Role; import uk.gov.hmcts.juror.api.moj.domain.User; import uk.gov.hmcts.juror.api.moj.domain.UserType; @@ -44,6 +45,7 @@ public class BureauJwtPayload { private UserType activeUserType; private Collection roles; + private Collection permissions; public BureauJwtPayload(User user, String locCode, List courtLocations) { this(user, user.getUserType(), locCode, courtLocations); @@ -70,6 +72,12 @@ public BureauJwtPayload(User user, UserType activeType, String locCode, List courts = new ArrayList<>(courtLocations.stream() .map(CourtLocation::getLocCode) .sorted() @@ -85,7 +93,7 @@ public BureauJwtPayload(User user, UserType activeType, String locCode, List getGrantedAuthority() { @@ -108,6 +116,7 @@ public Map toClaims() { data.put("userLevel", userLevel); data.put("staff", staff.toClaims()); data.put("roles", roles); + data.put("permissions", permissions); data.put("userType", userType); data.put("activeUserType", activeUserType); return data; @@ -129,6 +138,14 @@ public static BureauJwtPayload fromClaims(Claims claims) { .map(o -> Role.valueOf(String.valueOf(o))) .toList(); + final List permissionString = + claims.containsKey("permissions") ? claims.get("permissions", List.class) : Collections.emptyList(); + + final List permissions = permissionString + .stream() + .map(o -> Permission.valueOf(String.valueOf(o))) + .toList(); + UserType userType = claims.containsKey("userType") ? UserType.valueOf(claims.get("userType", String.class)) : null; @@ -146,6 +163,7 @@ public static BureauJwtPayload fromClaims(Claims claims) { .activeUserType(activeUserType) .staff(staff) .roles(roles) + .permissions(permissions) .userType(userType) .build(); } diff --git a/src/main/java/uk/gov/hmcts/juror/api/juror/notify/NotifyAdapterImpl.java b/src/main/java/uk/gov/hmcts/juror/api/juror/notify/NotifyAdapterImpl.java index 9bf7f74dd..28a6edd92 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/juror/notify/NotifyAdapterImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/juror/notify/NotifyAdapterImpl.java @@ -9,14 +9,12 @@ import uk.gov.service.notify.NotificationClientException; import uk.gov.service.notify.SendEmailResponse; import uk.gov.service.notify.SendSmsResponse; -//import uk.gov.service.notify.NotificationClient; @Component @Slf4j public class NotifyAdapterImpl implements NotifyAdapter { private final NotifyConfigurationProperties notifyProperties; private final NotificationClientApi notifyClient; - // private final NotificationClient notificationClient; private static final String MESSAGE_1 = "Notify send is disabled? {}"; private static final String MESSAGE_2 = "Notify http response code: {}"; @@ -24,15 +22,12 @@ public class NotifyAdapterImpl implements NotifyAdapter { @Autowired public NotifyAdapterImpl(final NotifyConfigurationProperties notifyProperties, - // final NotificationClient notificationClient, final NotificationClientApi notifyClient) { Assert.notNull(notifyProperties, "NotifyConfigurationProperties cannot be null"); Assert.notNull(notifyClient, "NotificationClient cannot be null"); - // Assert.notNull(notificationClient, "NotificationClient cannot be null"); this.notifyProperties = notifyProperties; this.notifyClient = notifyClient; - // this.notificationClient = notificationClient; } @Override @@ -115,7 +110,6 @@ public EmailNotificationReceipt sendCommsEmail(final EmailNotification notificat log.warn("Juror Comms Notify response was null!"); } } catch (NotificationClientException e) { - //log.error("Failed to send via Notify: {}", e); log.trace(MESSAGE_2, e.getHttpResult()); throw new NotifyApiException("Failed to send Juror Comms via Notify: {}", e); } catch (Exception e) { @@ -152,8 +146,6 @@ public SmsNotificationReceipt sendCommsSms(final SmsNotification notification) t notification.getPayload(), notification.getReferenceNumber() ); - //final SendEmailResponse sendEmailResponse = notifyClient.sendEmail(notification.getTemplateId(), - // notification.getRecipientEmail(), notification.getPayload(), notification.getReferenceNumber()); if (log.isTraceEnabled()) { log.trace("Juror Comms SMS Notify responded: {}", sendSmsResponse); } @@ -164,7 +156,6 @@ public SmsNotificationReceipt sendCommsSms(final SmsNotification notification) t log.warn("Juror Comms SMS Notify response was null!"); } } catch (NotificationClientException e) { - //log.error("Failed to send via Notify: {}", e); log.trace(MESSAGE_2, e.getHttpResult()); throw new NotifyApiException("Failed to send Juror Comms SMS via Notify: {}", e); } catch (Exception e) { diff --git a/src/main/java/uk/gov/hmcts/juror/api/juror/service/ExcusedCompletedCourtCommsServiceImpl.java b/src/main/java/uk/gov/hmcts/juror/api/juror/service/ExcusedCompletedCourtCommsServiceImpl.java index 9d815d52a..09309fbcf 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/juror/service/ExcusedCompletedCourtCommsServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/juror/service/ExcusedCompletedCourtCommsServiceImpl.java @@ -2,7 +2,6 @@ import com.google.common.collect.Lists; import com.querydsl.core.types.dsl.BooleanExpression; -import io.jsonwebtoken.lang.Assert; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -21,7 +20,7 @@ import uk.gov.hmcts.juror.api.moj.repository.JurorPoolRepository; import uk.gov.hmcts.juror.api.moj.repository.RegionNotifyTemplateQueriesMod; import uk.gov.hmcts.juror.api.moj.repository.RegionNotifyTemplateRepositoryMod; -import uk.gov.hmcts.juror.api.moj.service.AppSettingService; +import uk.gov.hmcts.juror.api.moj.utils.NotifyUtil; import uk.gov.service.notify.NotificationClient; import uk.gov.service.notify.NotificationClientException; import uk.gov.service.notify.SendEmailResponse; @@ -43,40 +42,27 @@ public class ExcusedCompletedCourtCommsServiceImpl implements BureauProcessService { private final JurorPoolRepository jurorRepository; - private final CourtRegionModRepository courtRegionModRepository; private final RegionNotifyTemplateRepositoryMod regionNotifyTemplateRepositoryMod; - private Proxy proxy; + private final NotifyConfigurationProperties notifyConfigurationProperties; + private final NotifyRegionsConfigurationProperties notifyRegionsConfigurationProperties; private final String messagePlaceHolderJurorNumber = "JURORNUMBER"; private final String messagePlaceHolderlocationCode = "lOCATIONCODE"; private final String updateMessageStatusSent = "SENTNOTIFY"; private final String updateMessageStatusNotSent = "NOTSENT"; - private final NotifyConfigurationProperties notifyConfigurationProperties; - private final NotifyRegionsConfigurationProperties notifyRegionsConfigurationProperties; + private Proxy proxy; @Autowired public ExcusedCompletedCourtCommsServiceImpl( - - final AppSettingService appSetting, - final JurorPoolRepository jurorRepository, final CourtRegionModRepository courtRegionModRepository, final NotifyConfigurationProperties notifyConfigurationProperties, final NotifyRegionsConfigurationProperties notifyRegionsConfigurationProperties, - final RegionNotifyTemplateRepositoryMod regionNotifyTemplateRepositoryMod) { - Assert.notNull(jurorRepository, "JurorPoolRepository cannot be null."); - Assert.notNull(appSetting, "AppSettingService cannot be null."); - Assert.notNull(courtRegionModRepository, "CourtRegionModRepository cannot be null."); - Assert.notNull(notifyConfigurationProperties, "NotifyConfigurationProperties cannot be null."); - Assert.notNull(notifyRegionsConfigurationProperties, "NotifyRegionsConfigurationProperties cannot be null."); - - Assert.notNull(regionNotifyTemplateRepositoryMod, "RegionNotifyTemplateRepositoryMod cannot be null."); this.jurorRepository = jurorRepository; this.courtRegionModRepository = courtRegionModRepository; this.notifyConfigurationProperties = notifyConfigurationProperties; this.notifyRegionsConfigurationProperties = notifyRegionsConfigurationProperties; - this.regionNotifyTemplateRepositoryMod = regionNotifyTemplateRepositoryMod; } @@ -99,8 +85,6 @@ public SchedulerServiceClient.Result process() { Map myRegionMap = new HashMap<>(); - @SuppressWarnings("PMD.VariableDeclarationUsageDistance") - int errorCount = 0; List regionIds = setUpRegionIds(); List notifyRegionIds = setUpNotifyRegionKeys(); for (int i = 0; i < notifyRegionIds.size(); i++) { @@ -108,23 +92,40 @@ public SchedulerServiceClient.Result process() { } log.debug("Display myRegionMap {}", myRegionMap); - errorCount += processExcusalList(gotProxy, myRegionMap); - errorCount += processCompleted(gotProxy, myRegionMap); - + final Metrics excusalMetrics = processExcusalList(gotProxy, myRegionMap); + final Metrics completedMetrics = processCompleted(gotProxy, myRegionMap); log.info("Excused Completed Court Comms Processing : Finished - {}", dateFormat.format(new Date())); return new SchedulerServiceClient.Result( - errorCount == 0 + excusalMetrics.errorCount == 0 && completedMetrics.errorCount == 0 ? SchedulerServiceClient.Result.Status.SUCCESS : SchedulerServiceClient.Result.Status.PARTIAL_SUCCESS, null, - Map.of("ERROR_COUNT", "" + errorCount)); + getMetaData(excusalMetrics, completedMetrics)); + } + + private static Map getMetaData(Metrics excusalMetrics, Metrics completedMetrics) { + Map metaData = new HashMap<>(); + metaData.put("EXCUSAL_IDENTIFIED", String.valueOf(excusalMetrics.jurorPoolsIdentified)); + metaData.put("EXCUSAL_ERROR_COUNT", String.valueOf(excusalMetrics.errorCount)); + metaData.put("EXCUSAL_INVALID_PHONE_COUNT", String.valueOf(excusalMetrics.invalidPhoneCount)); + metaData.put("EXCUSAL_INVALID_EMAIL_COUNT", String.valueOf(excusalMetrics.invalidEmailAddressCount)); + metaData.put("EXCUSAL_SUCCESS_COUNT", String.valueOf(excusalMetrics.successCount)); + metaData.put("EXCUSAL_MISSING_EMAIL_PHONE", String.valueOf(excusalMetrics.missingEmailAndPhone)); + + metaData.put("COMPLETED_IDENTIFIED", String.valueOf(completedMetrics.jurorPoolsIdentified)); + metaData.put("COMPLETED_ERROR_COUNT", String.valueOf(completedMetrics.errorCount)); + metaData.put("COMPLETED_INVALID_PHONE_COUNT", String.valueOf(completedMetrics.invalidPhoneCount)); + metaData.put("COMPLETED_INVALID_EMAIL_COUNT", String.valueOf(completedMetrics.invalidEmailAddressCount)); + metaData.put("COMPLETED_SUCCESS_COUNT", String.valueOf(completedMetrics.successCount)); + metaData.put("COMPLETED_MISSING_EMAIL_PHONE", String.valueOf(completedMetrics.missingEmailAndPhone)); + return metaData; } public Proxy setUpConnection() { final NotifyConfigurationProperties.Proxy setUpProxy = notifyConfigurationProperties.getProxy(); if (setUpProxy != null && setUpProxy.isEnabled()) { String setupHost = setUpProxy.getHost(); - Integer setupPort = Integer.valueOf(setUpProxy.getPort()); + int setupPort = Integer.parseInt(setUpProxy.getPort()); Proxy.Type setupType = setUpProxy.getType(); final InetSocketAddress socketAddress = new InetSocketAddress(setupHost, setupPort); proxy = new Proxy(setupType, socketAddress); @@ -142,14 +143,6 @@ private void updateCommsStatusFlagCompleted(JurorPool poolCourtDetailCompletedLi } catch (TransactionSystemException e) { Throwable cause = e.getRootCause(); if (poolCourtDetailCompletedList.getJuror().getServiceCompCommsStatus() == null) { - log.trace( - "ServiceCompCommsStatus is : {} - logging error", - poolCourtDetailCompletedList.getJuror().getServiceCompCommsStatus() - ); - log.info( - "ServiceCompCommsStatus is : {} - logging error", - poolCourtDetailCompletedList.getJuror().getServiceCompCommsStatus() - ); log.error( "Failed to update db to {}. Manual update required. {}", poolCourtDetailCompletedList.getJuror().getServiceCompCommsStatus(), @@ -178,14 +171,6 @@ private void updateCommsStatusFlagExcusal(JurorPool poolCourtDetailExcusalList) } catch (TransactionSystemException e) { Throwable cause = e.getRootCause(); if (poolCourtDetailExcusalList.getJuror().getServiceCompCommsStatus() == null) { - log.trace( - "ServiceCompCommsStatus is : {} - logging error", - poolCourtDetailExcusalList.getJuror().getServiceCompCommsStatus() - ); - log.info( - "ServiceCompCommsStatus is : {} - logging error", - poolCourtDetailExcusalList.getJuror().getServiceCompCommsStatus() - ); log.error( "Failed to update db to {}. Manual update required. {}", poolCourtDetailExcusalList.getJuror().getServiceCompCommsStatus(), @@ -220,7 +205,6 @@ public List setUpRegionIds() { for (CourtRegionMod courtRegion : courtRegions) { String courtregionIds = courtRegion.getRegionId(); regionIds.add(courtregionIds); - log.info("CourtRegions {}", courtRegion.getRegionId()); } @@ -228,7 +212,7 @@ public List setUpRegionIds() { return regionIds; } - public int processExcusalList(Proxy gotProxy, Map myRegionMap) { + public Metrics processExcusalList(Proxy gotProxy, Map myRegionMap) { final List jurorCourtDetailListExcusal = Lists.newLinkedList(jurorRepository.findAll( JurorPoolQueries.recordsForExcusalComms())); @@ -238,6 +222,12 @@ public int processExcusalList(Proxy gotProxy, Map myRegionMap) { ); int errorCount = 0; + int invalidPhoneCount = 0; + int invalidEmailCount = 0; + int successCount = 0; + int missingEmailAndPhone = 0; + int missingApiKeyCount = 0; + for (JurorPool jurorCourtDetailExcusalList : jurorCourtDetailListExcusal) { log.info("poolCourtDetailExcusalList PART_NO : {}", jurorCourtDetailExcusalList.getJurorNumber()); log.info("Excusal Date: {}", jurorCourtDetailExcusalList.getJuror().getExcusalDate()); @@ -272,12 +262,11 @@ public int processExcusalList(Proxy gotProxy, Map myRegionMap) { if (regionApikey == null || regionApikey.isEmpty()) { - log.error("Missing Notify Api Account key Cannot send notify communication: "); - log.info("Missing Notify Api Account key Cannot send notify communication: "); + log.error("Missing Notify Api Account key Cannot send notify communication"); jurorCourtDetailExcusalList.getJuror().setServiceCompCommsStatus(updateMessageStatusNotSent); updateCommsStatusFlagExcusal(jurorCourtDetailExcusalList); - + missingApiKeyCount++; continue; } @@ -345,13 +334,13 @@ public int processExcusalList(Proxy gotProxy, Map myRegionMap) { } } else { log.info("No Email or phone"); + missingEmailAndPhone++; continue; } for (RegionNotifyTemplateMod regionNotifyTemplateMod : regionNotifyTriggeredExcusalTemplateList) { UUID notificationId; if (hasEmail) { - String emailExcusalTemplateId = regionNotifyTemplateMod.getNotifyTemplateId(); SendEmailResponse emailResponse = notificationClient.sendEmail( emailExcusalTemplateId, @@ -374,26 +363,36 @@ public int processExcusalList(Proxy gotProxy, Map myRegionMap) { if (notificationId != null) { jurorCourtDetailExcusalList.getJuror().setServiceCompCommsStatus(updateMessageStatusSent); updateCommsStatusFlagExcusal(jurorCourtDetailExcusalList); + successCount++; + } else { + errorCount++; } } } catch (NotificationClientException e) { - log.error("Failed to send via Notify: {}", e); - log.trace("Unable to send notify: {}", e.getHttpResult()); - log.info("Unable to send notify: {}", e.getHttpResult()); + log.info("Unable to send notify: {}", e.getMessage()); jurorCourtDetailExcusalList.getJuror().setServiceCompCommsStatus(updateMessageStatusNotSent); updateCommsStatusFlagExcusal(jurorCourtDetailExcusalList); - errorCount++; + if (NotifyUtil.isInvalidPhoneNumberError(e)) { + invalidPhoneCount++; + } else if (NotifyUtil.isInvalidEmailAddressError(e)) { + invalidEmailCount++; + } else { + log.error("Failed to send via Notify: {}", e.getMessage(), e); + errorCount++; + } } catch (Exception e) { - log.info("Unexpected exception: {}", e); + log.error("Unexpected exception: {}", e.getMessage(), e); errorCount++; } } - return errorCount; + return new Metrics(jurorCourtDetailListExcusal.size(), errorCount, successCount, + missingEmailAndPhone, missingApiKeyCount, + invalidPhoneCount, invalidEmailCount); } - private int processCompleted(Proxy gotProxy, Map myRegionMap) { - int errorCount = 0; + private Metrics processCompleted(Proxy gotProxy, Map myRegionMap) { + final List jurorCourtDetailListCompleted = Lists.newLinkedList(jurorRepository.findAll( JurorPoolQueries.recordsForServiceCompletedComms())); @@ -401,7 +400,12 @@ private int processCompleted(Proxy gotProxy, Map myRegionMap) { "jurorCourtDetailListCompleted Number of Completed Records to process {}", jurorCourtDetailListCompleted.size() ); - + int errorCount = 0; + int invalidPhoneCount = 0; + int invalidEmailCount = 0; + int successCount = 0; + int missingEmailAndPhone = 0; + int missingApiKeyCount = 0; for (JurorPool jurorCourtDetailCompletedList : jurorCourtDetailListCompleted) { log.info("jurorCourtDetailListCompleted PART_NO {}", jurorCourtDetailCompletedList.getJurorNumber()); @@ -416,19 +420,13 @@ private int processCompleted(Proxy gotProxy, Map myRegionMap) { final int emailLength = (email != null ? email.length() : 0); if (emailLength == 1) { - jurorCourtDetailCompletedList.getJuror().setEmail(null); - updateCommsStatusFlagCompleted(jurorCourtDetailCompletedList); - } final String locCode = jurorCourtDetailCompletedList.getCourt().getLocCode(); final String jurorNumber = jurorCourtDetailCompletedList.getJurorNumber(); final String reference = jurorCourtDetailCompletedList.getJurorNumber(); - - // String apiKey = (poolCourtDetailCompletedList != null ? poolCourtDetailCompletedList.getCourt() - // .getCourtRegion().getNotifyAccountKey() : null); final String regionId = jurorCourtDetailCompletedList.getCourt().getCourtRegion().getRegionId(); final String regionApikey = myRegionMap.get(regionId); log.debug("regionApikey {} ", regionApikey); @@ -436,10 +434,9 @@ private int processCompleted(Proxy gotProxy, Map myRegionMap) { if (regionApikey == null || regionApikey.isEmpty()) { log.error("Missing Notify Api Account key Cannot send notify communication: "); - log.info("Missing Notify Api Account key Cannot send notify communication: "); jurorCourtDetailCompletedList.getJuror().setServiceCompCommsStatus(updateMessageStatusNotSent); updateCommsStatusFlagCompleted(jurorCourtDetailCompletedList); - + missingApiKeyCount++; continue; } @@ -501,6 +498,8 @@ private int processCompleted(Proxy gotProxy, Map myRegionMap) { regionNotifyTemplateRepositoryMod.findAll(regionNotifyTriggeredCompleteTemplateSmsFilter)); } } else { + log.info("No Email or phone"); + missingEmailAndPhone++; continue; } @@ -534,22 +533,38 @@ private int processCompleted(Proxy gotProxy, Map myRegionMap) { if (notificationId != null) { jurorCourtDetailCompletedList.getJuror().setServiceCompCommsStatus(updateMessageStatusSent); updateCommsStatusFlagCompleted(jurorCourtDetailCompletedList); + successCount++; + } else { + errorCount++; } } } catch (NotificationClientException e) { - - log.error("Failed to send via Notify: {}", e); - log.trace("Unable to send notify: {}", e.getHttpResult()); - log.info("Unable to send notify: {}", e.getHttpResult()); + log.info("Unable to send notify: {}", e.getMessage()); jurorCourtDetailCompletedList.getJuror().setServiceCompCommsStatus(updateMessageStatusNotSent); - updateCommsStatusFlagCompleted(jurorCourtDetailCompletedList); errorCount++; + if (NotifyUtil.isInvalidPhoneNumberError(e)) { + invalidPhoneCount++; + } else if (NotifyUtil.isInvalidEmailAddressError(e)) { + invalidEmailCount++; + } else { + log.error("Failed to send via Notify: {}", e.getMessage(), e); + errorCount++; + } + } catch (Exception e) { - log.info("Unexpected exception: {}", e); + log.error("Unexpected exception:", e); errorCount++; } } - return errorCount; + return new Metrics(jurorCourtDetailListCompleted.size(), errorCount, successCount, + missingEmailAndPhone, missingApiKeyCount, + invalidPhoneCount, invalidEmailCount); + } + + public record Metrics(int jurorPoolsIdentified, int errorCount, int successCount, + int missingEmailAndPhone, int missingApiKeyCount, + int invalidPhoneCount, int invalidEmailAddressCount) { + } } \ No newline at end of file diff --git a/src/main/java/uk/gov/hmcts/juror/api/juror/service/MessagesServiceImpl.java b/src/main/java/uk/gov/hmcts/juror/api/juror/service/MessagesServiceImpl.java index 0dabd8fc3..378424657 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/juror/service/MessagesServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/juror/service/MessagesServiceImpl.java @@ -5,6 +5,7 @@ import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -21,6 +22,7 @@ import uk.gov.hmcts.juror.api.moj.repository.RegionNotifyTemplateQueriesMod; import uk.gov.hmcts.juror.api.moj.repository.RegionNotifyTemplateRepositoryMod; import uk.gov.hmcts.juror.api.moj.service.AppSettingService; +import uk.gov.hmcts.juror.api.moj.utils.NotifyUtil; import uk.gov.service.notify.NotificationClient; import uk.gov.service.notify.NotificationClientException; import uk.gov.service.notify.SendEmailResponse; @@ -45,7 +47,6 @@ public class MessagesServiceImpl implements BureauProcessService { private static final String MESSAGE_PLACEHOLDER_JUROR = "JURORNUMBER"; private static final String MESSAGE_READ = "SN"; private static final String MESSAGE_READ_APP_ERROR = "NS"; - private static final String MESSAGE_NOT_READ = "NR"; private static final int CHECK_NUM = 1; private static final String LOG_ERROR_MESSAGE_TEMPLATE_ID = " Missing templateId. Cannot send notify " @@ -78,14 +79,10 @@ public SchedulerServiceClient.Result process() { // keys as values Map myRegionMap = new HashMap<>(); - @SuppressWarnings("PMD.VariableDeclarationUsageDistance") - int errorCount = 0; List notifyRegionKeys = setUpNotifyRegionKeys(); List regionIds = setUpRegionIds(); - for (int i = 0; - i < notifyRegionKeys.size(); - i++) { + for (int i = 0; i < notifyRegionKeys.size(); i++) { myRegionMap.put(regionIds.get(i), notifyRegionKeys.get(i)); } @@ -102,6 +99,13 @@ public SchedulerServiceClient.Result process() { Map templateDetailsMap = new HashMap<>(); + int errorCount = 0; + int invalidPhoneCount = 0; + int invalidEmailCount = 0; + int missingApiKeyCount = 0; + int missingEmailAndPhone = 0; + int emailSuccess = 0; + int smsSuccess = 0; for (Message messagesDetail : messageDetailList) { log.info("messagesDetail Juror number : {}", messagesDetail.getJurorNumber()); @@ -124,9 +128,6 @@ public SchedulerServiceClient.Result process() { final String textMessage = messagesDetail.getMessageText(); final String reference = (messagesDetail.getJurorNumber()); - - // String apiKey = (messagesDetail != null ? messagesDetail.getLocationCode().getCourtRegion() - // .getNotifyAccountKey() : null); final String regionId = messagesDetail.getLocationCode().getCourtRegion().getRegionId(); final String regionApikey = myRegionMap.get(regionId); log.debug("regionApikey {} ", regionApikey); @@ -137,7 +138,7 @@ public SchedulerServiceClient.Result process() { regionId); messagesDetail.setMessageRead(MESSAGE_READ_APP_ERROR); updateMessageFlag(messagesDetail); - + missingApiKeyCount++; continue; } @@ -146,10 +147,13 @@ public SchedulerServiceClient.Result process() { personalisation.put(MESSAGE_PLACEHOLDER_JUROR, jurorNumber); - final boolean isEmail = messagesDetail.getEmail() != null; - final boolean isPhone = messagesDetail.getPhone() != null; + final boolean isEmail = StringUtils.isNotBlank(email); + final boolean isPhone = StringUtils.isNotBlank(phoneNumber); if (!isEmail && !isPhone) { + messagesDetail.setMessageRead(MESSAGE_READ_APP_ERROR); + updateMessageFlag(messagesDetail); + missingEmailAndPhone++; continue; } @@ -184,11 +188,13 @@ public SchedulerServiceClient.Result process() { smsTemplateId, email, personalisation, reference); response = emailResponse; notificationId = emailResponse.getNotificationId(); + emailSuccess++; } else if (isPhone) { SendSmsResponse smsResponse = notifyClient.sendSms(smsTemplateId, phoneNumber, personalisation, reference); response = smsResponse; notificationId = smsResponse.getNotificationId(); + smsSuccess++; } if (notificationId != null) { @@ -198,10 +204,17 @@ public SchedulerServiceClient.Result process() { log.trace("Court Comms sms messaging Service : response {}", response); } } catch (NotificationClientException e) { - log.error("Failed to send via Notify", e); + log.info("Failed to send via Notify - {}", e.getMessage()); messagesDetail.setMessageRead(MESSAGE_READ_APP_ERROR); updateMessageFlag(messagesDetail); - errorCount++; + if (NotifyUtil.isInvalidPhoneNumberError(e)) { + invalidPhoneCount++; + } else if (NotifyUtil.isInvalidEmailAddressError(e)) { + invalidEmailCount++; + } else { + log.error("Failed to send via Notify", e); + errorCount++; + } } catch (Exception e) { log.error("Unexpected exception when sending details to notify", e); errorCount++; @@ -213,7 +226,17 @@ public SchedulerServiceClient.Result process() { errorCount == 0 ? SchedulerServiceClient.Result.Status.SUCCESS : SchedulerServiceClient.Result.Status.PARTIAL_SUCCESS, null, - Map.of("ERROR_COUNT", "" + errorCount)); + Map.of( + "TOTAL_MESSAGES_TO_SEND", String.valueOf(messageDetailList.size()), + "ERROR_COUNT", String.valueOf(errorCount), + "MISSING_API_KEY_COUNT", String.valueOf(missingApiKeyCount), + "MISSING_EMAIL_AND_PHONE", String.valueOf(missingEmailAndPhone), + "EMAIL_SUCCESS", String.valueOf(emailSuccess), + "SMS_SUCCESS", String.valueOf(smsSuccess), + + "INVALID_PHONE_COUNT", String.valueOf(invalidPhoneCount), + "INVALID_EMAIL_COUNT", String.valueOf(invalidEmailCount) + )); } private TemplateDetails createTemplateDetails(Message messagesDetail) { diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/controller/JurorRecordController.java b/src/main/java/uk/gov/hmcts/juror/api/moj/controller/JurorRecordController.java index b52ff3978..2c166a32e 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/controller/JurorRecordController.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/controller/JurorRecordController.java @@ -9,6 +9,7 @@ import jakarta.validation.constraints.Size; import lombok.NonNull; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -29,6 +30,7 @@ import uk.gov.hmcts.juror.api.bureau.controller.response.BureauJurorDetailDto; import uk.gov.hmcts.juror.api.config.bureau.BureauJwtAuthentication; import uk.gov.hmcts.juror.api.config.bureau.BureauJwtPayload; +import uk.gov.hmcts.juror.api.config.security.IsBureauUser; import uk.gov.hmcts.juror.api.config.security.IsCourtUser; import uk.gov.hmcts.juror.api.config.security.IsSeniorCourtUser; import uk.gov.hmcts.juror.api.moj.controller.request.ConfirmIdentityDto; @@ -36,6 +38,7 @@ import uk.gov.hmcts.juror.api.moj.controller.request.EditJurorRecordRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.FilterableJurorDetailsRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorCreateRequestDto; +import uk.gov.hmcts.juror.api.moj.controller.request.JurorManualCreationRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorNameDetailsDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorNotesRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorNumberAndPoolNumberDto; @@ -62,6 +65,7 @@ import uk.gov.hmcts.juror.api.moj.domain.FilterJurorRecord; import uk.gov.hmcts.juror.api.moj.domain.PaginatedList; import uk.gov.hmcts.juror.api.moj.domain.PendingJurorStatus; +import uk.gov.hmcts.juror.api.moj.domain.Permission; import uk.gov.hmcts.juror.api.moj.enumeration.PendingJurorStatusEnum; import uk.gov.hmcts.juror.api.moj.exception.MojException; import uk.gov.hmcts.juror.api.moj.service.BulkService; @@ -73,6 +77,7 @@ @RestController @Validated +@Slf4j @RequestMapping(value = "/api/v1/moj/juror-record", produces = MediaType.APPLICATION_JSON_VALUE) @Tag(name = "Juror Management") @RequiredArgsConstructor(onConstructor_ = {@Autowired}) @@ -184,6 +189,22 @@ public void createJurorRecord( jurorRecordService.createJurorRecord(payload, jurorCreateRequestDto); } + @PostMapping("/create-juror-manual") + @IsBureauUser + @Operation(summary = "Send a payload to manually create a Juror Record at the Bureau") + public ResponseEntity createJurorRecord( + @Valid @RequestBody JurorManualCreationRequestDto jurorCreationRequestDto) { + log.info("User {} request to manually create juror", SecurityUtil.getActiveLogin()); + if (!SecurityUtil.isBureauManager() || !SecurityUtil.hasPermission(Permission.CREATE_JUROR)) { + log.error("User {} does not have permission to create juror", SecurityUtil.getActiveLogin()); + return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); + } + + jurorRecordService.createJurorManual(jurorCreationRequestDto); + + return ResponseEntity.status(HttpStatus.CREATED).build(); + } + @GetMapping("/pending-jurors/{loc_code}") @Operation(summary = "Get a list of pending jurors for a given location code") @IsCourtUser @@ -502,4 +523,5 @@ public ResponseEntity> searchForJurorRecord( } return ResponseEntity.ok().body(jurorRecords); } + } diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/controller/request/JurorManualCreationRequestDto.java b/src/main/java/uk/gov/hmcts/juror/api/moj/controller/request/JurorManualCreationRequestDto.java new file mode 100644 index 000000000..d1d055b99 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/controller/request/JurorManualCreationRequestDto.java @@ -0,0 +1,92 @@ +package uk.gov.hmcts.juror.api.moj.controller.request; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; +import uk.gov.hmcts.juror.api.validation.LocalDateOfBirth; +import uk.gov.hmcts.juror.api.validation.NumericString; +import uk.gov.hmcts.juror.api.validation.PoolNumber; + +import java.time.LocalDate; + +import static uk.gov.hmcts.juror.api.validation.ValidationConstants.EMAIL_ADDRESS_REGEX; +import static uk.gov.hmcts.juror.api.validation.ValidationConstants.NO_PIPES_REGEX; +import static uk.gov.hmcts.juror.api.validation.ValidationConstants.PHONE_NO_REGEX; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Builder +public class JurorManualCreationRequestDto { + + @JsonProperty("title") + @Length(max = 10) + @Pattern(regexp = NO_PIPES_REGEX) + @Schema(description = "Juror title") + private String title; + + @JsonProperty("first_name") + @NotBlank + @Pattern(regexp = NO_PIPES_REGEX) + @Length(max = 20) + @Schema(description = "Juror first name") + private String firstName; + + @JsonProperty("last_name") + @NotBlank + @Length(max = 20) + @Pattern(regexp = NO_PIPES_REGEX) + @Schema(description = "Juror last name") + private String lastName; + + @JsonProperty("address") + @NotNull + private JurorAddressDto address; + + @JsonProperty("date_of_birth") + @LocalDateOfBirth + @Schema(description = "Juror date of birth") + private LocalDate dateOfBirth; + + @JsonProperty("primary_phone") + @Pattern(regexp = PHONE_NO_REGEX) + @Schema(description = "Juror primary telephone number") + private String primaryPhone; + + @JsonProperty("alternative_phone") + @Pattern(regexp = PHONE_NO_REGEX) + @Schema(description = "Juror alternative telephone number") + private String alternativePhone; + + @JsonProperty("email_address") + @Length(max = 254) + @Pattern(regexp = EMAIL_ADDRESS_REGEX) + @Schema(description = "Juror email address") + private String emailAddress; + + @JsonProperty("notes") + @Length(max = 2000) + @Schema(description = "Notes on the juror") + private String notes; + + @JsonProperty("pool_number") + @PoolNumber + @NotBlank + @Schema(name = "Pool number", description = "The unique number for the existing pool") + private String poolNumber; + + @JsonProperty("court_code") + @NotBlank + @Length(min = 3, max = 3) + @NumericString + @Schema(description = "Unique 3 digit code to identify a court location") + private String locationCode; + +} diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/domain/JurorPool.java b/src/main/java/uk/gov/hmcts/juror/api/moj/domain/JurorPool.java index f2b7be85b..f7931fb30 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/domain/JurorPool.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/domain/JurorPool.java @@ -98,7 +98,7 @@ public class JurorPool implements Serializable { private LocalDate nextDate; @Column(name = "on_call") - private Boolean onCall; + private boolean onCall; @Length(max = 20) @Column(name = "smart_card") diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/domain/Permission.java b/src/main/java/uk/gov/hmcts/juror/api/moj/domain/Permission.java new file mode 100644 index 000000000..61a98c0ea --- /dev/null +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/domain/Permission.java @@ -0,0 +1,5 @@ +package uk.gov.hmcts.juror.api.moj.domain; + +public enum Permission { + CREATE_JUROR +} diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/domain/User.java b/src/main/java/uk/gov/hmcts/juror/api/moj/domain/User.java index ead4acfe2..937852ede 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/domain/User.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/domain/User.java @@ -83,6 +83,12 @@ public class User implements Serializable { @Column(name = "role") private Set roles; + @ElementCollection(fetch = FetchType.LAZY) + @CollectionTable(schema = "juror_mod", name = "user_permissions", joinColumns = @JoinColumn(name = "username", + referencedColumnName = "username")) + @Enumerated(EnumType.STRING) + @Column(name = "permission") + private Set permissions; @JoinTable( schema = "juror_mod", name = "user_courts", @@ -134,6 +140,13 @@ public Set getRoles() { return roles; } + public Set getPermissions() { + if (permissions == null) { + permissions = new HashSet<>(); + } + return permissions; + } + public void addRole(Role role) { this.getRoles().add(role); } diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/report/DataType.java b/src/main/java/uk/gov/hmcts/juror/api/moj/report/DataType.java index d26d8db72..d707871e8 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/report/DataType.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/report/DataType.java @@ -275,7 +275,7 @@ public enum DataType implements IDataType { .otherwise(0L).sum()), - POLICE_CHECK_TIMED_OUT("Checks completed", Long.class, + POLICE_CHECK_TIMED_OUT("Checks timed out", Long.class, new CaseBuilder() .when(QJuror.juror.policeCheck.in(PoliceCheck.UNCHECKED_MAX_RETRIES_EXCEEDED)) .then(1L) diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/repository/IAppearanceRepositoryImpl.java b/src/main/java/uk/gov/hmcts/juror/api/moj/repository/IAppearanceRepositoryImpl.java index e97749033..486915657 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/repository/IAppearanceRepositoryImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/repository/IAppearanceRepositoryImpl.java @@ -93,9 +93,10 @@ public List retrieveAttendanceDetails(RetrieveAttendanceDetailsDto reques || commonData.getTag().equals(RetrieveAttendanceDetailsTag.PANELLED)) { query = query.where(APPEARANCE.appearanceStage.eq(AppearanceStage.CHECKED_IN)); } else if (commonData.getTag().equals(RetrieveAttendanceDetailsTag.CONFIRM_ATTENDANCE)) { - // a confirmed juror can have appStage of CheckedIn or CheckedOut therefore cannot rely on appStage. A - // confirmed juror will always have TimeIn. - query = query.where(APPEARANCE.timeIn.isNotNull()); + query = query.where(APPEARANCE.timeIn.isNotNull()) + .where(APPEARANCE.appearanceStage.in(AppearanceStage.CHECKED_IN, AppearanceStage.CHECKED_OUT)) + .where(APPEARANCE.attendanceAuditNumber.isNull()) + .where(APPEARANCE.appearanceConfirmed.isFalse()); } // execute the query and return the results @@ -294,13 +295,13 @@ public Optional findByJurorNumberAndLocCodeAndAttendanceDateAndVersi try { return Optional.ofNullable((Appearance) AuditReaderFactory.get(entityManager) - .createQuery() - .forRevisionsOfEntity(Appearance.class, true, false) - .add(AuditEntity.property("jurorNumber").eq(jurorNumber)) - .add(AuditEntity.property("locCode").eq(locCode)) - .add(AuditEntity.property("attendanceDate").eq(attendanceDate)) - .add(AuditEntity.property("version").eq(appearanceVersion)) - .getSingleResult()); + .createQuery() + .forRevisionsOfEntity(Appearance.class, true, false) + .add(AuditEntity.property("jurorNumber").eq(jurorNumber)) + .add(AuditEntity.property("locCode").eq(locCode)) + .add(AuditEntity.property("attendanceDate").eq(attendanceDate)) + .add(AuditEntity.property("version").eq(appearanceVersion)) + .getSingleResult()); } catch (NoResultException e) { return Optional.empty(); } @@ -382,5 +383,4 @@ JPAQueryFactory getQueryFactory() { return new JPAQueryFactory(entityManager); } - } diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/repository/JurorRepositoryImpl.java b/src/main/java/uk/gov/hmcts/juror/api/moj/repository/JurorRepositoryImpl.java index 6ca6f5f72..de30738b9 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/repository/JurorRepositoryImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/repository/JurorRepositoryImpl.java @@ -60,6 +60,7 @@ public List findByJurorNumberInAndIsActiveAndPoolNumberAndCourtAndStatusI } @Override + @SuppressWarnings("PMD.CognitiveComplexity") public JPAQuery fetchFilteredJurorRecords(JurorRecordFilterRequestQuery query) { JPAQueryFactory queryFactory = new JPAQueryFactory(entityManager); @@ -89,7 +90,7 @@ public JPAQuery fetchFilteredJurorRecords(JurorRecordFilterRequestQuery q String[] names = jurorName.split(" "); if (names.length == 2) { - partialQuery.where((JUROR.firstName.containsIgnoreCase(names[0])) + partialQuery.where(JUROR.firstName.containsIgnoreCase(names[0]) .and(JUROR.lastName.containsIgnoreCase(names[1])) .or(JUROR.firstName.concat(" ").concat(JUROR.lastName).containsIgnoreCase(jurorName))); } else if (names.length > 2) { diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorPaperResponseServiceImpl.java b/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorPaperResponseServiceImpl.java index d7044db6e..f4027bdbb 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorPaperResponseServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorPaperResponseServiceImpl.java @@ -151,7 +151,13 @@ private JurorPaperResponseDetailDto copyPaperResponseRecordIntoDto(PaperResponse if (jurorPaperResponse.getStaff() != null) { // set the assignee if there is one - jurorPaperResponseDetailDto.setAssignedStaffMember(new UserDetailsDto(jurorPaperResponse.getStaff())); + try { + jurorPaperResponseDetailDto.setAssignedStaffMember(new UserDetailsDto(jurorPaperResponse.getStaff())); + } catch (Exception e) { + log.error("Error setting assigned staff member for response for juror {}", + jurorPaperResponse.getJurorNumber() + " -- " + e.getMessage()); + } + } // set the contact log diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordService.java b/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordService.java index 51ae75257..7cc90b6a8 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordService.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordService.java @@ -8,6 +8,7 @@ import uk.gov.hmcts.juror.api.moj.controller.request.EditJurorRecordRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.FilterableJurorDetailsRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorCreateRequestDto; +import uk.gov.hmcts.juror.api.moj.controller.request.JurorManualCreationRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorNameDetailsDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorOpticRefRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorRecordFilterRequestQuery; @@ -103,4 +104,6 @@ JurorAttendanceDetailsResponseDto getJurorAttendanceDetails(String locCode, void markResponded(String jurorNumber); PaginatedList searchForJurorRecords(JurorRecordFilterRequestQuery query); + + void createJurorManual(JurorManualCreationRequestDto jurorCreateRequestDto); } diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordServiceImpl.java b/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordServiceImpl.java index d4f717687..ce85f119b 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordServiceImpl.java @@ -5,7 +5,6 @@ import lombok.NoArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.text.WordUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.history.Revision; @@ -26,6 +25,7 @@ import uk.gov.hmcts.juror.api.moj.controller.request.FilterableJurorDetailsRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorAddressDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorCreateRequestDto; +import uk.gov.hmcts.juror.api.moj.controller.request.JurorManualCreationRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorNameDetailsDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorOpticRefRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorRecordFilterRequestQuery; @@ -59,6 +59,7 @@ import uk.gov.hmcts.juror.api.moj.domain.Juror; import uk.gov.hmcts.juror.api.moj.domain.JurorHistory; import uk.gov.hmcts.juror.api.moj.domain.JurorPool; +import uk.gov.hmcts.juror.api.moj.domain.JurorStatus; import uk.gov.hmcts.juror.api.moj.domain.ModJurorDetail; import uk.gov.hmcts.juror.api.moj.domain.PaginatedList; import uk.gov.hmcts.juror.api.moj.domain.PendingJuror; @@ -80,6 +81,7 @@ import uk.gov.hmcts.juror.api.moj.enumeration.PendingJurorStatusEnum; import uk.gov.hmcts.juror.api.moj.enumeration.ReplyMethod; import uk.gov.hmcts.juror.api.moj.exception.MojException; +import uk.gov.hmcts.juror.api.moj.exception.PoolCreateException; import uk.gov.hmcts.juror.api.moj.repository.AppearanceRepository; import uk.gov.hmcts.juror.api.moj.repository.ContactCodeRepository; import uk.gov.hmcts.juror.api.moj.repository.ContactLogRepository; @@ -120,12 +122,12 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; import static org.springframework.transaction.annotation.Propagation.REQUIRED; @@ -146,6 +148,7 @@ @RequiredArgsConstructor(onConstructor_ = {@Autowired}) public class JurorRecordServiceImpl implements JurorRecordService { private final ContactCodeRepository contactCodeRepository; + private final PoolMemberSequenceService poolMemberSequenceService; private static final Character NEW_REQUEST_STATE = 'N'; private static final String REPLY_METHOD_ONLINE = "DIGITAL"; @@ -476,7 +479,7 @@ public PendingJurorsResponseDto getPendingJurors(String locCode, PendingJurorSta @Override @IsCourtUser public void createJurorRecord(BureauJwtPayload payload, JurorCreateRequestDto jurorCreateRequestDto) { - log.info("User {} creating a pending Juror record in court location", payload.getLogin(), + log.info("User {} creating a pending Juror record in court location {}", payload.getLogin(), jurorCreateRequestDto.getLocationCode()); String poolNumber = jurorCreateRequestDto.getPoolNumber(); @@ -600,9 +603,95 @@ public void updateAttendance(UpdateAttendanceRequestDto dto) { } + @Override + @Transactional + public void createJurorManual(JurorManualCreationRequestDto jurorCreateRequestDto) { + + String locCode = jurorCreateRequestDto.getLocationCode(); + String poolNumber = jurorCreateRequestDto.getPoolNumber(); + log.info("Creating a manual Juror record in pool {}", jurorCreateRequestDto.getPoolNumber()); + + PoolRequest poolRequest = RepositoryUtils.retrieveFromDatabase(poolNumber, poolRequestRepository); + + // generating juror number as it does not exist in voters table + String jurorNumber = pendingJurorRepository.generatePendingJurorNumber(locCode); + + if (jurorNumber == null || "null".equals(jurorNumber)) { + throw new MojException.InternalServerError("Error generating new Juror Number", null); + } + + Juror juror = createManualJurorRecord(jurorCreateRequestDto, jurorNumber); + + JurorPool jurorPool = createManualJurorPool(poolNumber, poolRequest, juror); + + printSummonsLetter(juror, jurorPool); + + log.info("Created manual juror {} in pool {}", juror.getJurorNumber(), jurorPool.getPoolNumber()); + + } + + private void printSummonsLetter(Juror juror, JurorPool jurorPool) { + printDataService.printSummonsLetter(jurorPool); + + JurorHistory jurorSummonsHistory = JurorHistory.builder() + .jurorNumber(juror.getJurorNumber()) + .poolNumber(jurorPool.getPoolNumber()) + .createdBy(SecurityUtil.getActiveLogin()) + .historyCode(HistoryCodeMod.PRINT_SUMMONS).build(); + jurorHistoryRepository.save(jurorSummonsHistory); + } + + private JurorPool createManualJurorPool(String poolNumber, PoolRequest poolRequest, Juror juror) { + JurorPool jurorPool = new JurorPool(); + jurorPool.setJuror(juror); + jurorPool.setPool(poolRequest); + jurorPool.setIsActive(true); + jurorPool.setNextDate(poolRequest.getReturnDate()); + + Optional jurorStatusOpt = jurorStatusRepository.findById(IJurorStatus.SUMMONED); + JurorStatus jurorStatus = jurorStatusOpt.orElseThrow(PoolCreateException.InvalidPoolStatus::new); + jurorPool.setStatus(jurorStatus); + + jurorPool.setOwner(SecurityUtil.getActiveOwner()); + + int sequenceNumber = poolMemberSequenceService.getPoolMemberSequenceNumber(poolNumber); + jurorPool.setPoolSequence(poolMemberSequenceService.leftPadInteger(sequenceNumber)); + + jurorPool.setUserEdtq(SecurityUtil.getActiveLogin()); + jurorPool.setLastUpdate(LocalDateTime.now()); + + jurorPoolRepository.save(jurorPool); + return jurorPool; + } + + private Juror createManualJurorRecord(JurorManualCreationRequestDto jurorCreateRequestDto, String jurorNumber) { + Juror juror = Juror.builder() + .jurorNumber(jurorNumber) + .title(jurorCreateRequestDto.getTitle()) + .firstName(jurorCreateRequestDto.getFirstName()) + .lastName(jurorCreateRequestDto.getLastName()) + .dateOfBirth(jurorCreateRequestDto.getDateOfBirth()) + .addressLine1(jurorCreateRequestDto.getAddress().getLineOne()) + .addressLine2(jurorCreateRequestDto.getAddress().getLineTwo()) + .addressLine3(jurorCreateRequestDto.getAddress().getLineThree()) + .addressLine4(jurorCreateRequestDto.getAddress().getTown()) + .addressLine5(jurorCreateRequestDto.getAddress().getCounty()) + .postcode(jurorCreateRequestDto.getAddress().getPostcode()) + .phoneNumber(jurorCreateRequestDto.getPrimaryPhone()) + .altPhoneNumber(jurorCreateRequestDto.getAlternativePhone()) + .email(jurorCreateRequestDto.getEmailAddress()) + .notes(jurorCreateRequestDto.getNotes()) + .responded(false) + .contactPreference(null) + .build(); + + jurorRepository.save(juror); + return juror; + } + private void validateOnCall(JurorPool jurorPool) { - if (jurorPool.getOnCall() != null && jurorPool.getOnCall().equals(true)) { + if (jurorPool.isOnCall()) { throw new MojException.BadRequest("Juror status is already on call", null); } } @@ -1197,7 +1286,7 @@ public JurorAttendanceDetailsResponseDto getJurorAttendanceDetails(String locCod responseDto.setNonAttendances((int) jurorAttendanceDetails.stream() .filter(p -> AttendanceType.NON_ATTENDANCE.equals(p.getAttendanceType())).count()); - responseDto.setOnCall(ObjectUtils.defaultIfNull(jurorPool.getOnCall(), false)); + responseDto.setOnCall(jurorPool.isOnCall()); responseDto.setNextDate(jurorPool.getNextDate()); return responseDto; @@ -1264,7 +1353,7 @@ public JurorPaymentsResponseDto getJurorPayments(String jurorNumber) { PaymentSummaryData::add ); - Map> auditDetailsMap = new HashMap<>(); + Map> auditDetailsMap = new ConcurrentHashMap<>(); return JurorPaymentsResponseDto.builder() .attendances(appearances.size() - nonAttendanceCount) .nonAttendances(nonAttendanceCount) diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/service/JwtServiceImpl.java b/src/main/java/uk/gov/hmcts/juror/api/moj/service/JwtServiceImpl.java index b809314ec..02cad032e 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/service/JwtServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/service/JwtServiceImpl.java @@ -106,8 +106,8 @@ private long timeUnitToMilliseconds(String value) { String lastDigit = value.substring(value.length() - 1).toLowerCase(); long number = Long.parseLong(value.substring(0, value.length() - 1)); return switch (lastDigit) { - case "h" -> number * 3600000; - case "m" -> number * 60000; + case "h" -> number * 3_600_000; + case "m" -> number * 60_000; case "s" -> number * 1000; default -> throw new MojException.InternalServerError("Unknown number format: '" + value + "'", null); }; diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/service/PoolCreateServiceImpl.java b/src/main/java/uk/gov/hmcts/juror/api/moj/service/PoolCreateServiceImpl.java index 324e43752..d4fda0a44 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/service/PoolCreateServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/service/PoolCreateServiceImpl.java @@ -351,7 +351,7 @@ private void updateJurorHistory(String userId, List jurorPools) { .createdBy(userId); // check if pool member is disqualified on selection - if (Objects.equals(jurorPool.getStatus(), IJurorStatus.DISQUALIFIED)) { + if (Objects.equals(jurorPool.getStatus().getStatus(), IJurorStatus.DISQUALIFIED)) { jurorHistBuilder.historyCode(HistoryCodeMod.DISQUALIFY_POOL_MEMBER); jurorHistBuilder.otherInformationRef(HistoryCodeMod.DISQUALIFY_POOL_MEMBER.getCode()); } else { diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/service/trial/TrialServiceImpl.java b/src/main/java/uk/gov/hmcts/juror/api/moj/service/trial/TrialServiceImpl.java index 45ba28f1d..2a93fb584 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/service/trial/TrialServiceImpl.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/service/trial/TrialServiceImpl.java @@ -269,13 +269,15 @@ public void returnJury(BureauJwtPayload payload, String trialNumber, String loca appearance.setTimeOut(LocalTime.parse(returnJuryDto.getCheckOut())); log.debug("setting time out for juror %s".formatted(jurorNumber)); } - //Only give them an attendance number if they were checked out via this process - appearance.setAttendanceAuditNumber("J" + attendanceAuditNumber); + if (appearance.getAttendanceAuditNumber() == null) { + //Only give them an attendance number if they were checked out via this process + appearance.setAttendanceAuditNumber("J" + attendanceAuditNumber); + jurorHistoryService.createJuryAttendanceHistory(jurorPool, appearance, panel); + } } appearance.setTrialNumber(trialNumber); appearance.setSatOnJury(true); jurorAppearanceService.realignAttendanceType(appearance); - jurorHistoryService.createJuryAttendanceHistory(jurorPool, appearance, panel); } panel.setResult(PanelResult.RETURNED); diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/utils/NotifyUtil.java b/src/main/java/uk/gov/hmcts/juror/api/moj/utils/NotifyUtil.java new file mode 100644 index 000000000..bc764fcc4 --- /dev/null +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/utils/NotifyUtil.java @@ -0,0 +1,28 @@ +package uk.gov.hmcts.juror.api.moj.utils; + +import uk.gov.service.notify.NotificationClientException; + +public final class NotifyUtil { + + private NotifyUtil() { + + } + + public static boolean isInvalidPhoneNumberError(Throwable e) { + return doesMessageContain(e, "phone_number is a required property") + || doesMessageContain(e, "InvalidPhoneError"); + } + + public static boolean isInvalidEmailAddressError(Throwable e) { + return doesMessageContain(e, "email_address is a required property") + || doesMessageContain(e, "InvalidEmailAddressError"); + } + + public static boolean doesMessageContain(Throwable e, String message) { + if (e instanceof NotificationClientException notificationClientException) { + return notificationClientException.getMessage() != null + && notificationClientException.getMessage().contains(message); + } + return false; + } +} diff --git a/src/main/java/uk/gov/hmcts/juror/api/moj/utils/SecurityUtil.java b/src/main/java/uk/gov/hmcts/juror/api/moj/utils/SecurityUtil.java index ea237bd78..5266c9f04 100644 --- a/src/main/java/uk/gov/hmcts/juror/api/moj/utils/SecurityUtil.java +++ b/src/main/java/uk/gov/hmcts/juror/api/moj/utils/SecurityUtil.java @@ -6,6 +6,7 @@ import uk.gov.hmcts.juror.api.config.bureau.BureauJwtAuthentication; import uk.gov.hmcts.juror.api.config.bureau.BureauJwtPayload; import uk.gov.hmcts.juror.api.config.public1.PublicJwtAuthentication; +import uk.gov.hmcts.juror.api.moj.domain.Permission; import uk.gov.hmcts.juror.api.moj.domain.Role; import uk.gov.hmcts.juror.api.moj.domain.UserType; import uk.gov.hmcts.juror.api.moj.exception.MojException; @@ -160,6 +161,7 @@ public static String getLocCode() { } public static boolean isManager() { + BureauJwtPayload activeUsersBureauPayload = getActiveUsersBureauPayload(); return getActiveUsersBureauPayload().getRoles().contains(Role.MANAGER); } @@ -171,6 +173,10 @@ public static boolean hasRole(Role role) { return getActiveUsersBureauPayload().getRoles().contains(role); } + public static boolean hasPermission(Permission permission) { + return getActiveUsersBureauPayload().getPermissions().contains(permission); + } + public static boolean canEditApprovalLimit() { return isAdministration(); } diff --git a/src/main/resources/db/migrationv2/V2_32__on_call_updates.sql b/src/main/resources/db/migrationv2/V2_32__on_call_updates.sql new file mode 100644 index 000000000..ee1002833 --- /dev/null +++ b/src/main/resources/db/migrationv2/V2_32__on_call_updates.sql @@ -0,0 +1,7 @@ +update juror_mod.juror_pool jp +set on_call = false +where jp.on_call is null; + +alter table juror_mod.juror_pool + ALTER COLUMN on_call SET DEFAULT false, + ALTER COLUMN on_call SET NOT NULL; \ No newline at end of file diff --git a/src/main/resources/db/migrationv2/V2_33__create_user_permission_table.sql b/src/main/resources/db/migrationv2/V2_33__create_user_permission_table.sql new file mode 100644 index 000000000..6f7bf9161 --- /dev/null +++ b/src/main/resources/db/migrationv2/V2_33__create_user_permission_table.sql @@ -0,0 +1,9 @@ + +CREATE TABLE juror_mod.user_permissions ( + username varchar(30) NOT NULL, + "permission" varchar(30) NOT NULL, + CONSTRAINT user_permissions_pkey PRIMARY KEY (username, permission), + CONSTRAINT user_permissions_permission_val CHECK (((permission)::text = ANY (ARRAY[('CREATE_JUROR'::character varying)::text]))) +); + +ALTER TABLE juror_mod.user_permissions ADD CONSTRAINT user_permissions_user_fkey FOREIGN KEY (username) REFERENCES juror_mod.users(username); \ No newline at end of file diff --git a/src/main/resources/db/migrationv2/V2_34__amend_require_pnc_check_view.sql b/src/main/resources/db/migrationv2/V2_34__amend_require_pnc_check_view.sql new file mode 100644 index 000000000..4ad0ac711 --- /dev/null +++ b/src/main/resources/db/migrationv2/V2_34__amend_require_pnc_check_view.sql @@ -0,0 +1,18 @@ +-- JM-8196 - Add a view to get the juror details for the PNC check +-- juror_mod.require_pnc_check_view source + +DROP VIEW juror_mod.require_pnc_check_view; + +CREATE VIEW juror_mod.require_pnc_check_view +AS SELECT j.police_check, + j.juror_number, + regexp_replace(j.first_name::text, '\s.*'::text, ''::text) AS first_name, + NULLIF(regexp_replace(j.first_name::text, '.*?\s'::text, ''::text), j.first_name::text) AS middle_name, + regexp_replace(j.last_name::text, '\s', '', 'g') AS last_name, + j.dob AS date_of_birth, + upper(regexp_replace(j.postcode::text, '\s+'::text, ''::text)) AS post_code + FROM juror_mod.juror j + JOIN juror_mod.juror_pool jp ON jp.juror_number::text = j.juror_number::text + WHERE jp.status = 2 AND (j.police_check IS NULL OR (j.police_check::text <> ALL (ARRAY['UNCHECKED_MAX_RETRIES_EXCEEDED'::character varying::text, 'ELIGIBLE'::character varying::text, 'INELIGIBLE'::character varying::text]))) AND jp.owner::text = '400'::text AND jp.is_active = true + and upper(regexp_replace(j.postcode::text, '\s+'::text, ''::text)) ~ '^[A-Z0-9]{5,8}$' +; diff --git a/src/test/java/uk/gov/hmcts/juror/api/config/BureauJwtPayloadTest.java b/src/test/java/uk/gov/hmcts/juror/api/config/BureauJwtPayloadTest.java index 1bb134a3c..90e08bc24 100644 --- a/src/test/java/uk/gov/hmcts/juror/api/config/BureauJwtPayloadTest.java +++ b/src/test/java/uk/gov/hmcts/juror/api/config/BureauJwtPayloadTest.java @@ -116,12 +116,14 @@ void positiveToClaims() { ), UserType.COURT, UserType.COURT, - Set.of(Role.MANAGER) + Set.of(Role.MANAGER), + Collections.emptyList() ); assertThat(payload.toClaims()) - .hasSize(9) + .hasSize(10) .containsEntry("email", "email@email.com") .containsEntry("owner", "owner") + .containsEntry("permissions", Collections.emptyList()) .containsEntry("locCode", "locCode") .containsEntry("login", "login") .containsEntry("userLevel", "userLevel") @@ -177,7 +179,8 @@ void positiveFromClaims() { ), UserType.COURT, UserType.COURT, - List.of(Role.MANAGER) + List.of(Role.MANAGER), + Collections.emptyList() ) ); } @@ -221,6 +224,7 @@ void positiveFromClaimsMissingKeys() { ), null, null, + Collections.emptyList(), Collections.emptyList() ) ); diff --git a/src/test/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordServiceTest.java b/src/test/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordServiceTest.java index d28840f9c..44fd7bc0d 100644 --- a/src/test/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordServiceTest.java +++ b/src/test/java/uk/gov/hmcts/juror/api/moj/service/JurorRecordServiceTest.java @@ -35,6 +35,7 @@ import uk.gov.hmcts.juror.api.moj.controller.request.JurorAddressDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorCreateRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorCreateRequestDtoTest; +import uk.gov.hmcts.juror.api.moj.controller.request.JurorManualCreationRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.JurorNameDetailsDto; import uk.gov.hmcts.juror.api.moj.controller.request.ProcessNameChangeRequestDto; import uk.gov.hmcts.juror.api.moj.controller.request.ProcessPendingJurorRequestDto; @@ -222,6 +223,8 @@ class JurorRecordServiceTest { private FinancialAuditService financialAuditService; @Mock private JurorThirdPartyService jurorThirdPartyService; + @Mock + private PoolMemberSequenceService poolMemberSequenceService; @Mock private Clock clock; @@ -2276,7 +2279,7 @@ void updateAttendanceHappyPathOnCall() { verify(jurorPoolRepository, times(1)).save(jurorPool); - assertThat(jurorPool.getOnCall()).isTrue(); + assertThat(jurorPool.isOnCall()).isTrue(); assertThat(jurorPool.getNextDate()).isNull(); } @@ -2303,7 +2306,7 @@ void updateAttendanceHappyPathChangeNextDate() { verify(jurorPoolRepository, times(1)).save(jurorPool); assertThat(jurorPool.getNextDate()).isEqualTo(dto.getNextDate()); - assertThat(jurorPool.getOnCall()).isFalse(); + assertThat(jurorPool.isOnCall()).isFalse(); } @@ -3031,6 +3034,193 @@ private void validateMatch(JurorCreateRequestDto dto, PoolRequest poolRequest, S } + @Nested + @DisplayName("public void createJurorManual(JurorManualCreationRequestDto jurorCreationRequestDto)") + class CreateManualJurorRecord { + + @Test + void positiveTypical() { + + String poolNumber = "415220502"; + final JurorManualCreationRequestDto requestDto = JurorManualCreationRequestDto.builder() + .poolNumber(poolNumber) + .locationCode("415") + .title("Mr") + .firstName("John") + .lastName("Smith") + .dateOfBirth(LocalDate.now().minusYears(20)) + .address(JurorAddressDto.builder() + .lineOne("1 High Street") + .lineTwo("Test") + .lineThree("Test") + .town("Chester") + .county("Test") + .postcode("CH1 2AB") + .build()) + .primaryPhone("01234567890") + .emailAddress("test@test.com") + .notes("A manually created juror") + .build(); + + PoolRequest poolRequest = mock(PoolRequest.class); + when(poolRequest.getOwner()).thenReturn("400"); + when(poolRequest.getPoolNumber()).thenReturn(poolNumber); + when(poolRequest.getReturnDate()).thenReturn(LocalDate.now().plusDays(10)); + + when(pendingJurorRepository.generatePendingJurorNumber(requestDto.getLocationCode())) + .thenReturn("041500022"); + + when(poolRequestRepository.findById(requestDto.getPoolNumber())).thenReturn(Optional.of(poolRequest)); + + JurorStatus jurorStatus = new JurorStatus(); + jurorStatus.setStatus(IJurorStatus.SUMMONED); + when(jurorStatusRepository.findById(IJurorStatus.SUMMONED)).thenReturn(Optional.of(jurorStatus)); + + when(poolMemberSequenceService.getPoolMemberSequenceNumber(poolNumber)).thenReturn(22); + + when(poolMemberSequenceService.leftPadInteger(1)).thenReturn("0022"); + + jurorRecordService.createJurorManual(requestDto); + + verify(poolRequestRepository, times(1)) + .findById(requestDto.getPoolNumber()); + + ArgumentCaptor jurorArgumentCaptor = ArgumentCaptor.forClass(Juror.class); + + verify(jurorRepository, times(1)) + .save(jurorArgumentCaptor.capture()); + + Juror juror = jurorArgumentCaptor.getValue(); + assertEquals("041500022", juror.getJurorNumber(), "Juror number must match"); + + assertEquals("Mr", juror.getTitle(), "Title must match"); + assertEquals("John", juror.getFirstName(), "First name must match"); + assertEquals("Smith", juror.getLastName(), "Last name must match"); + assertEquals(LocalDate.now().minusYears(20), juror.getDateOfBirth(), "Date of birth must match"); + + //Validate address + JurorAddressDto expected = requestDto.getAddress(); + assertEquals(expected.getLineOne(), juror.getAddressLine1(), "Address line one must match"); + assertEquals(expected.getLineTwo(), juror.getAddressLine2(), "Address line two must match"); + assertEquals(expected.getLineThree(), juror.getAddressLine3(), "Address line three must match"); + assertEquals(expected.getTown(), juror.getAddressLine4(), "Address town must match"); + assertEquals(expected.getCounty(), juror.getAddressLine5(), "Address county must match"); + assertEquals(expected.getPostcode(), juror.getPostcode(), "Address postcode must match"); + assertEquals(requestDto.getPrimaryPhone(), juror.getPhoneNumber(), "Primary phone must match"); + assertEquals(requestDto.getEmailAddress(), juror.getEmail(), "Email address must match"); + assertEquals(requestDto.getNotes(), juror.getNotes(), "Notes must match"); + + ArgumentCaptor jurorPoolArgumentCaptor = ArgumentCaptor.forClass(JurorPool.class); + + verify(jurorPoolRepository, times(1)) + .save(jurorPoolArgumentCaptor.capture()); + + JurorPool jurorPool = jurorPoolArgumentCaptor.getValue(); + assertEquals("041500022", jurorPool.getJuror().getJurorNumber(), "Juror number must match"); + assertEquals(poolNumber, jurorPool.getPoolNumber(), "Pool number must match"); + assertEquals(IJurorStatus.SUMMONED, jurorPool.getStatus().getStatus(), "Status must match"); + assertEquals(LocalDate.now().plusDays(10), jurorPool.getNextDate(), "Return date must match"); + + verify(jurorStatusRepository, times(1)).findById(IJurorStatus.SUMMONED); + verify(poolMemberSequenceService, times(1)).getPoolMemberSequenceNumber(poolNumber); + verify(poolMemberSequenceService, times(1)).leftPadInteger(22); + + } + + @Test + void invalidPool() { + + String poolNumber = "415220502"; + final JurorManualCreationRequestDto requestDto = JurorManualCreationRequestDto.builder() + .poolNumber(poolNumber) + .locationCode("415") + .title("Mr") + .firstName("John") + .lastName("Smith") + .dateOfBirth(LocalDate.now().minusYears(20)) + .address(JurorAddressDto.builder() + .lineOne("1 High Street") + .lineTwo("Test") + .lineThree("Test") + .town("Chester") + .county("Test") + .postcode("CH1 2AB") + .build()) + .primaryPhone("01234567890") + .emailAddress("test@test.com") + .notes("A manually created juror") + .build(); + + when(poolRequestRepository.findById(requestDto.getPoolNumber())).thenReturn(Optional.empty()); + + MojException.NotFound exception = + assertThrows(MojException.NotFound.class, + () -> jurorRecordService.createJurorManual(requestDto), + "Unable to find a valid Record in the database for 415220502."); + assertEquals("Unable to find a valid Record in the database for 415220502.", + exception.getMessage(), + "Exception message must match"); + + verify(poolRequestRepository, times(1)) + .findById(requestDto.getPoolNumber()); + + verifyNoMoreInteractions(poolRequestRepository); + verifyNoInteractions(jurorRepository, jurorStatusRepository, poolMemberSequenceService, + jurorPoolRepository); + } + + @Test + void errorGeneratingJurorNumber() { + + String poolNumber = "415220502"; + final JurorManualCreationRequestDto requestDto = JurorManualCreationRequestDto.builder() + .poolNumber(poolNumber) + .locationCode("415") + .title("Mr") + .firstName("John") + .lastName("Smith") + .dateOfBirth(LocalDate.now().minusYears(20)) + .address(JurorAddressDto.builder() + .lineOne("1 High Street") + .lineTwo("Test") + .lineThree("Test") + .town("Chester") + .county("Test") + .postcode("CH1 2AB") + .build()) + .primaryPhone("01234567890") + .emailAddress("test@test.com") + .notes("A manually created juror") + .build(); + + PoolRequest poolRequest = mock(PoolRequest.class); + when(poolRequest.getOwner()).thenReturn("400"); + when(poolRequest.getPoolNumber()).thenReturn(poolNumber); + when(poolRequest.getReturnDate()).thenReturn(LocalDate.now().plusDays(10)); + + when(pendingJurorRepository.generatePendingJurorNumber(requestDto.getLocationCode())) + .thenReturn("null"); + + when(poolRequestRepository.findById(requestDto.getPoolNumber())).thenReturn(Optional.of(poolRequest)); + + MojException.InternalServerError exception = + assertThrows(MojException.InternalServerError.class, + () -> jurorRecordService.createJurorManual(requestDto), + "Error generating new Juror Number"); + assertEquals("Error generating new Juror Number", + exception.getMessage(), + "Exception message must match"); + + verify(poolRequestRepository, times(1)) + .findById(requestDto.getPoolNumber()); + verify(pendingJurorRepository, times(1)) + .generatePendingJurorNumber(requestDto.getLocationCode()); + + verifyNoMoreInteractions(poolRequestRepository, poolMemberSequenceService); + verifyNoInteractions(jurorRepository, jurorStatusRepository, jurorPoolRepository); + } + } + @Nested @DisplayName("public JurorAttendanceDetailsResponseDto getJurorAttendanceDetails(String jurorNumber," + " String poolNumber, BureauJWTPayload payload) ") diff --git a/src/test/java/uk/gov/hmcts/juror/api/moj/service/trial/TrialServiceImplTest.java b/src/test/java/uk/gov/hmcts/juror/api/moj/service/trial/TrialServiceImplTest.java index 2a2206550..4d2978c85 100644 --- a/src/test/java/uk/gov/hmcts/juror/api/moj/service/trial/TrialServiceImplTest.java +++ b/src/test/java/uk/gov/hmcts/juror/api/moj/service/trial/TrialServiceImplTest.java @@ -447,7 +447,7 @@ void testReturnJuryNoConfirmAttendanceNullTimes() { verify(panelRepository, times(1)) .findByTrialTrialNumberAndTrialCourtLocationLocCode(trialNumber, "415"); verify(panelRepository, times(panelMembers.size())).saveAndFlush(any()); - verify(jurorHistoryService, times(panelMembers.size())).createJuryAttendanceHistory(any(), any(), any()); + verify(jurorHistoryService, never()).createJuryAttendanceHistory(any(), any(), any()); verify(jurorAppearanceService, times(panelMembers.size())).realignAttendanceType(any(Appearance.class)); }