Skip to content

Commit

Permalink
Fix for missing protocol files for studies in challenges teaser (MSSEG)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkain committed Jul 29, 2024
1 parent 83845bc commit 12a8388
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public ResponseEntity<List<StudyLightDTO>> findPublicStudiesData() {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
for (Study study : studies) {
studiesDTO.add(studyMapper.studyToStudyLightDTO(study));
studiesDTO.add(studyMapper.studyToStudyLightDTONoFilePaths(study));
}
return new ResponseEntity<>(studiesDTO, HttpStatus.OK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public class StudyLightDTO {

private List<StudyTagDTO> studyTags;

private List<String> protocolFilePaths;

private List<String> dataUserAgreementPaths;

/**
* Default constructor.
*/
Expand Down Expand Up @@ -232,4 +236,20 @@ public void setStudyTags(List<StudyTagDTO> studyTags) {
this.studyTags = studyTags;
}

public List<String> getProtocolFilePaths() {
return protocolFilePaths;
}

public void setProtocolFilePaths(List<String> protocolFilePaths) {
this.protocolFilePaths = protocolFilePaths;
}

public List<String> getDataUserAgreementPaths() {
return dataUserAgreementPaths;
}

public void setDataUserAgreementPaths(List<String> dataUserAgreementPaths) {
this.dataUserAgreementPaths = dataUserAgreementPaths;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,22 @@ public interface StudyMapper {
@Named("study.detailed")
StudyDTO studyToStudyDTODetailed(Study study);

@Named("studies.light")
@IterableMapping(qualifiedByName = "study.light")
List<StudyLightDTO> studiesToStudyLightDTOs(List<Study> studies);

@Named("study.light")
@Mapping(target = "studyTags", ignore = true)
StudyLightDTO studyToStudyLightDTO(Study study);

@Named("study.light.no.paths")
@Mappings({
@Mapping(target = "studyTags", ignore = true),
@Mapping(target = "protocolFilePaths", ignore = true),
@Mapping(target = "dataUserAgreementPaths", ignore = true)
})
StudyLightDTO studyToStudyLightDTONoFilePaths(Study study);

@Named("studies.idname")
@IterableMapping(qualifiedByName = "study.idname")
List<IdNameCenterStudyDTO> studiesToSimpleStudyDTOs(List<Study> studies);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ public interface StudyRepository extends CrudRepository<Study, Long>, StudyRepos
@Query("SELECT s FROM Study s WHERE s.id = :studyId")
Study findStudyWithTagsById(@Param("studyId") Long studyId);

@Query("SELECT s.protocolFilePaths FROM Study s WHERE s.id = :studyId")
List<String> findProtocolFilePathsByStudyId(Long studyId);

@Query("SELECT s.dataUserAgreementPaths FROM Study s WHERE s.id = :studyId")
List<String> findDataUserAgreementPathsByStudyId(Long studyId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ public List<Study> findAll() {
s.getStudyUserList().stream().forEach(ss -> ss.setCenters(studyUserRepository.findDistinctCentersByStudyId(ss.getStudyId())));
});
setNumberOfSubjectsAndExaminations(studies);
setFilePaths(studies);
// Utils.copyList is used to prevent a bug with @PostFilter
return Utils.copyList(studies);
}
Expand Down Expand Up @@ -539,6 +540,13 @@ private void setNumberOfSubjectsAndExaminations(List<Study> studies) {
});
}

private void setFilePaths(List<Study> studies) {
studies.stream().forEach(s -> {
s.setProtocolFilePaths(studyRepository.findProtocolFilePathsByStudyId(s.getId()));
s.setDataUserAgreementPaths(studyRepository.findDataUserAgreementPathsByStudyId(s.getId()));
});
}

@Transactional
protected void updateStudyUsers(Study studyDb, Study study) {
if (study.getStudyUserList() == null) {
Expand Down

0 comments on commit 12a8388

Please sign in to comment.