use of com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO in project ArachneCentralAPI by OHDSI.
the class BaseStudyController method suggest.
@ApiOperation("Suggest study.")
@RequestMapping(value = "/api/v1/study-management/studies/search", method = GET)
public JsonResult<List<StudyDTO>> suggest(Principal principal, @RequestParam("id") String requestId, @RequestParam("query") String query, @RequestParam("region") SuggestSearchRegion region) throws PermissionDeniedException {
JsonResult<List<StudyDTO>> result;
IUser owner = getUser(principal);
Long id;
switch(region) {
case DATASOURCE:
id = Long.valueOf(requestId);
break;
case PARTICIPANT:
IUser participant = Optional.ofNullable(userService.getByUuid(requestId)).orElseThrow(() -> new NotExistException(EX_USER_NOT_EXISTS, User.class));
id = participant.getId();
break;
default:
id = 0L;
break;
}
Iterable<T> studies = studyService.suggestStudy(query, owner, id, region);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
List<StudyDTO> studiesDTOs = new LinkedList<>();
for (Study study : studies) {
studiesDTOs.add(conversionService.convert(study, StudyDTO.class));
}
result.setResult(studiesDTOs);
return result;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO in project ArachneCentralAPI by OHDSI.
the class StudyToStudyShortDTOConverter method convert.
@Override
public StudyShortDTO convert(Study source) {
final StudyShortDTO studyDTO = new StudyShortDTO();
studyDTO.setId(source.getId());
studyDTO.setTitle(source.getTitle());
studyDTO.setKind(source.getKind());
return studyDTO;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO in project ArachneCentralAPI by OHDSI.
the class StudyToStudyMediumDTOConverter method convert.
@Override
public StudyMediumDTO convert(Study source) {
final StudyMediumDTO studyDTO = new StudyMediumDTO();
studyDTO.setId(source.getId());
studyDTO.setTitle(source.getTitle());
studyDTO.setDescription(source.getDescription());
studyDTO.setCreated(source.getCreated());
studyDTO.setStartDate(source.getStartDate());
studyDTO.setEndDate(source.getEndDate());
studyDTO.setStatus(conversionService.convert(source.getStatus(), StudyStatusDTO.class));
final Map<ParticipantRole, List<UserStudyExtended>> studyParticipants = source.getParticipants().stream().collect(Collectors.groupingBy(link -> link.getRole() == ParticipantRole.LEAD_INVESTIGATOR ? LEAD_INVESTIGATOR : CONTRIBUTOR));
final List<UserStudyExtended> studyLeads = studyParticipants.get(LEAD_INVESTIGATOR);
if (!CollectionUtils.isEmpty(studyLeads)) {
studyDTO.setStudyLeads(studyLeads.stream().filter(distinctByKey(p -> p.getUser().getId())).map(studyParticipant -> conversionService.convert(studyParticipant, ParticipantDTO.class)).collect(Collectors.toList()));
}
final List<UserStudyExtended> studyContributors = studyParticipants.get(CONTRIBUTOR);
if (!CollectionUtils.isEmpty(studyContributors)) {
studyDTO.setStudyParticipants(studyContributors.stream().filter(distinctByKey(p -> p.getUser().getId())).map(studyParticipant -> conversionService.convert(studyParticipant, ParticipantExtendedDTO.class)).collect(Collectors.toList()));
}
final List<StudyDataSourceLink> studyDataSources = source.getDataSources();
studyDTO.setStudyDataSources(studyDataSources.stream().map(studyDataSource -> conversionService.convert(studyDataSource.getDataSource(), DataSourceDTO.class)).collect(Collectors.toList()));
return studyDTO;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO in project ArachneCentralAPI by OHDSI.
the class BaseStudyToStudyListDTOConverter method convert.
@Override
public DTO convert(S userStudyExtendedLink) {
DTO studyDTO = createResultObject();
Study source = userStudyExtendedLink.getStudy();
List<IUser> studyLeadList = studyService.findLeads(source);
studyDTO.setStatus(conversionService.convert(source.getStatus(), StudyStatusDTO.class));
studyDTO.setTitle(source.getTitle());
studyDTO.setType(conversionService.convert(source.getType(), StudyTypeDTO.class));
studyDTO.setEndDate(source.getEndDate());
studyDTO.setStartDate(source.getStartDate());
studyDTO.setDescription(source.getDescription());
studyDTO.setCreated(source.getCreated());
studyDTO.setUpdated(source.getUpdated());
studyDTO.setId(source.getId());
StringBuilder stringBuilder = new StringBuilder();
for (String participantRole : userStudyExtendedLink.getRole() != null ? userStudyExtendedLink.getRole().split(",") : new String[] {}) {
stringBuilder.append(ParticipantRole.valueOf(participantRole).toString()).append(", ");
}
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.length());
studyDTO.setRole(stringBuilder.toString());
studyDTO.setPermissions(conversionService.convert(source, PermissionsDTO.class));
studyDTO.setFavourite(userStudyExtendedLink.getFavourite());
studyDTO.setLeadList(studyLeadList.stream().map(studyLead -> conversionService.convert(studyLead, ShortUserDTO.class)).collect(Collectors.toList()));
studyDTO.setPrivacy(source.getPrivacy());
proceedAdditionalFields(studyDTO, userStudyExtendedLink);
return studyDTO;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO in project ArachneCentralAPI by OHDSI.
the class BaseUserStudyItemToStudyDTOConverter method convert.
@Override
public S convert(AbstractUserStudyListItem source) {
final Study study = source.getStudy();
S studyDto = createResultObject();
StudyDTO baseObject = conversionService.convert(study, getDtoClass());
baseObject.setFavourite(source.getFavourite());
List<StudyDataSourceLink> links = study.getDataSources().stream().filter(ds -> DataSourceStatus.DELETED.equals(ds.getStatus())).collect(Collectors.toList());
// this list won't be empty only in case when we intentionally get all (include those with deleted_at != NULL) StudyDataSourceLinks from repository
if (!links.isEmpty()) {
List<DataSourceDTO> dataSourceDTOS = converterUtils.convertList(links, DataSourceDTO.class);
baseObject.getDataSources().addAll(dataSourceDTOS);
}
converterUtils.shallowCopy(studyDto, baseObject);
studyDto.setPrivacy(study.getPrivacy());
proceedAdditionalFields(studyDto, source);
return studyDto;
}
Aggregations