diff --git a/src/main/java/cz/cvut/kbss/study/persistence/dao/PatientRecordDao.java b/src/main/java/cz/cvut/kbss/study/persistence/dao/PatientRecordDao.java index 2a9ffb93..a61e42e5 100644 --- a/src/main/java/cz/cvut/kbss/study/persistence/dao/PatientRecordDao.java +++ b/src/main/java/cz/cvut/kbss/study/persistence/dao/PatientRecordDao.java @@ -236,7 +236,7 @@ private Page findRecords(RecordFilterParams filters, Pageable pageSpec, C return new PageImpl<>(records, pageSpec, totalCount); } - public Set findUsedRecordsPhases(){ + public Set findUsedRecordPhases(){ return em.createNativeQuery("SELECT ?phase WHERE { ?record ?hasPhase ?phase } ", String.class) .setParameter("hasPhase", URI.create(Vocabulary.s_p_has_phase)) .getResultList() diff --git a/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java b/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java index 7d4f6a55..343fe184 100644 --- a/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java +++ b/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java @@ -83,9 +83,9 @@ public List getRecords( } @PreAuthorize("hasRole('" + SecurityConstants.ROLE_ADMIN + "') or @securityUtils.isMemberOfInstitution(#institutionKey)") - @GetMapping(value="availablePhases", produces = MediaType.APPLICATION_JSON_VALUE) - public Set getUsedRecordsPhases(@RequestParam(value = "institution", required = false) String institutionKey){ - return recordService.findUsedRecordsPhases(); + @GetMapping(value="used-record-phases", produces = MediaType.APPLICATION_JSON_VALUE) + public Set getUsedRecordPhases(@RequestParam(value = "institution", required = false) String institutionKey){ + return recordService.findUsedRecordPhases(); } diff --git a/src/main/java/cz/cvut/kbss/study/service/PatientRecordService.java b/src/main/java/cz/cvut/kbss/study/service/PatientRecordService.java index 11499b21..220fe617 100644 --- a/src/main/java/cz/cvut/kbss/study/service/PatientRecordService.java +++ b/src/main/java/cz/cvut/kbss/study/service/PatientRecordService.java @@ -100,7 +100,7 @@ public interface PatientRecordService extends BaseService { * * @return Set of all available record phases */ - Set findUsedRecordsPhases(); + Set findUsedRecordPhases(); } diff --git a/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryPatientRecordService.java b/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryPatientRecordService.java index 3d188aae..5c4600d0 100644 --- a/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryPatientRecordService.java +++ b/src/main/java/cz/cvut/kbss/study/service/repository/RepositoryPatientRecordService.java @@ -134,7 +134,7 @@ public Page exportRecords(RecordFilterParams filters, Pageable pageSp @Transactional(readOnly = true) @Override - public Set findUsedRecordsPhases() { - return recordDao.findUsedRecordsPhases(); + public Set findUsedRecordPhases() { + return recordDao.findUsedRecordPhases(); } } diff --git a/src/test/java/cz/cvut/kbss/study/rest/PatientRecordControllerTest.java b/src/test/java/cz/cvut/kbss/study/rest/PatientRecordControllerTest.java index 80595c99..fb965998 100644 --- a/src/test/java/cz/cvut/kbss/study/rest/PatientRecordControllerTest.java +++ b/src/test/java/cz/cvut/kbss/study/rest/PatientRecordControllerTest.java @@ -96,13 +96,13 @@ public void getRecordThrowsNotFoundWhenReportIsNotFound() throws Exception { } @Test - public void testGetUsedRecordsPhases() throws Exception{ + public void testGetUsedRecordPhases() throws Exception{ Set phases = new HashSet<>(Arrays.asList(RecordPhase.completed, RecordPhase.valid)); - when(patientRecordServiceMock.findUsedRecordsPhases()).thenReturn(phases); + when(patientRecordServiceMock.findUsedRecordPhases()).thenReturn(phases); - final MvcResult result = mockMvc.perform(get("/records/availablePhases")) + final MvcResult result = mockMvc.perform(get("/records/used-record-phases")) .andReturn(); assertEquals(HttpStatus.OK, HttpStatus.valueOf(result.getResponse().getStatus())); final Set body = objectMapper.readValue(result.getResponse().getContentAsString(), new TypeReference<>() {});