Skip to content

Commit

Permalink
[kbss-cvut/record-manager-ui#203] Change method name to findUsedRecor…
Browse files Browse the repository at this point in the history
…dPhases. Change endpoint url to used-record-phases
  • Loading branch information
palagdan committed Aug 9, 2024
1 parent 3a223e3 commit d3e6eda
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private <T> Page<T> findRecords(RecordFilterParams filters, Pageable pageSpec, C
return new PageImpl<>(records, pageSpec, totalCount);
}

public Set<RecordPhase> findUsedRecordsPhases(){
public Set<RecordPhase> findUsedRecordPhases(){
return em.createNativeQuery("SELECT ?phase WHERE { ?record ?hasPhase ?phase } ", String.class)
.setParameter("hasPhase", URI.create(Vocabulary.s_p_has_phase))
.getResultList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public List<PatientRecordDto> getRecords(
}

@PreAuthorize("hasRole('" + SecurityConstants.ROLE_ADMIN + "') or @securityUtils.isMemberOfInstitution(#institutionKey)")
@GetMapping(value="availablePhases", produces = MediaType.APPLICATION_JSON_VALUE)
public Set<RecordPhase> getUsedRecordsPhases(@RequestParam(value = "institution", required = false) String institutionKey){
return recordService.findUsedRecordsPhases();
@GetMapping(value="used-record-phases", produces = MediaType.APPLICATION_JSON_VALUE)
public Set<RecordPhase> getUsedRecordPhases(@RequestParam(value = "institution", required = false) String institutionKey){
return recordService.findUsedRecordPhases();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public interface PatientRecordService extends BaseService<PatientRecord> {
*
* @return Set of all available record phases
*/
Set<RecordPhase> findUsedRecordsPhases();
Set<RecordPhase> findUsedRecordPhases();


}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public Page<RawRecord> exportRecords(RecordFilterParams filters, Pageable pageSp

@Transactional(readOnly = true)
@Override
public Set<RecordPhase> findUsedRecordsPhases() {
return recordDao.findUsedRecordsPhases();
public Set<RecordPhase> findUsedRecordPhases() {
return recordDao.findUsedRecordPhases();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public void getRecordThrowsNotFoundWhenReportIsNotFound() throws Exception {
}

@Test
public void testGetUsedRecordsPhases() throws Exception{
public void testGetUsedRecordPhases() throws Exception{

Set<RecordPhase> 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<RecordPhase> body = objectMapper.readValue(result.getResponse().getContentAsString(), new TypeReference<>() {});
Expand Down

0 comments on commit d3e6eda

Please sign in to comment.