Search in sources :

Example 1 with WorkspaceDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.WorkspaceDTO in project ArachneCentralAPI by OHDSI.

the class BaseStudyToWorkspaceDTOConverter method convert.

@Override
public DTO convert(S source) {
    final DTO workspaceDTO = super.convert(source);
    if (!source.getParticipants().isEmpty()) {
        Optional<UserStudyExtended> leadOptional = source.getParticipants().stream().filter(participant -> participant.getRole().equals(ParticipantRole.LEAD_INVESTIGATOR)).findFirst();
        workspaceDTO.setLeadParticipant(conversionService.convert(leadOptional.orElseThrow(() -> {
            final String message = "Lead investigator for workspace id = " + workspaceDTO.getId() + " doesn't exist";
            return new NotExistException(message, UserStudyExtended.class);
        }), ParticipantDTO.class));
    }
    return workspaceDTO;
}
Also used : NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) AnalysisService(com.odysseusinc.arachne.portal.service.analysis.AnalysisService) ParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO) UserStudyExtended(com.odysseusinc.arachne.portal.model.UserStudyExtended) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole) ArachneConverterUtils(com.odysseusinc.arachne.portal.util.ArachneConverterUtils) Optional(java.util.Optional) Autowired(org.springframework.beans.factory.annotation.Autowired) BaseStudyService(com.odysseusinc.arachne.portal.service.BaseStudyService) WorkspaceDTO(com.odysseusinc.arachne.portal.api.v1.dto.WorkspaceDTO) Study(com.odysseusinc.arachne.portal.model.Study) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) ParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO) UserStudyExtended(com.odysseusinc.arachne.portal.model.UserStudyExtended) ParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO) WorkspaceDTO(com.odysseusinc.arachne.portal.api.v1.dto.WorkspaceDTO)

Aggregations

ParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO)1 WorkspaceDTO (com.odysseusinc.arachne.portal.api.v1.dto.WorkspaceDTO)1 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)1 ParticipantRole (com.odysseusinc.arachne.portal.model.ParticipantRole)1 Study (com.odysseusinc.arachne.portal.model.Study)1 UserStudyExtended (com.odysseusinc.arachne.portal.model.UserStudyExtended)1 BaseStudyService (com.odysseusinc.arachne.portal.service.BaseStudyService)1 AnalysisService (com.odysseusinc.arachne.portal.service.analysis.AnalysisService)1 ArachneConverterUtils (com.odysseusinc.arachne.portal.util.ArachneConverterUtils)1 Optional (java.util.Optional)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1