use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method uploadFile.
@ApiOperation("Upload file to attach to analysis.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/upload", method = POST)
public JsonResult<List<AnalysisFileDTO>> uploadFile(Principal principal, @Valid UploadFileDTO uploadFileDTO, @PathVariable("analysisId") Long id) throws PermissionDeniedException, NotExistException, IOException {
IUser user = getUser(principal);
T analysis = analysisService.getById(id);
JsonResult<List<AnalysisFileDTO>> result = new JsonResult<>(NO_ERROR);
List<AnalysisFileDTO> createdFiles = new ArrayList<>();
if (uploadFileDTO.getFile() != null) {
AnalysisFile createdFile = analysisService.saveFile(uploadFileDTO.getFile(), user, analysis, uploadFileDTO.getLabel(), uploadFileDTO.getExecutable(), null);
createdFiles.add(conversionService.convert(createdFile, AnalysisFileDTO.class));
} else {
if (StringUtils.hasText(uploadFileDTO.getLink())) {
AnalysisFile createdFile = analysisService.saveFile(uploadFileDTO.getLink(), user, analysis, uploadFileDTO.getLabel(), uploadFileDTO.getExecutable());
createdFiles.add(conversionService.convert(createdFile, AnalysisFileDTO.class));
} else {
result.setErrorCode(VALIDATION_ERROR.getCode());
}
}
result.setResult(createdFiles);
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseDataSourceController method updateDataSource.
private JsonResult<DTO> updateDataSource(Principal principal, Long dataSourceId, DTO commonDataSourceDTO, BindingResult bindingResult) throws PermissionDeniedException, IllegalAccessException, IOException, NoSuchFieldException, SolrServerException, ValidationException {
JsonResult result;
if (bindingResult.hasErrors()) {
result = setValidationErrors(bindingResult);
} else {
IUser user = getUser(principal);
final DS exist = dataSourceService.getNotDeletedByIdInAnyTenant(dataSourceId);
DS dataSource = convertDTOToDataSource(commonDataSourceDTO);
dataSource.setId(dataSourceId);
dataSource.setDataNode(exist.getDataNode());
dataSource.setPublished(true);
dataSource = dataSourceService.updateInAnyTenant(dataSource);
result = new JsonResult<>(NO_ERROR);
result.setResult(convertDataSourceToDTO(dataSource));
}
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseStudyController method addParticipant.
@ApiOperation("Add participant to the study.")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/participants", method = POST)
public JsonResult<Boolean> addParticipant(Principal principal, @PathVariable("studyId") Long studyId, @RequestBody @Valid AddStudyParticipantDTO addParticipantDTO, BindingResult binding) throws PermissionDeniedException, NotExistException, AlreadyExistException {
JsonResult<Boolean> result;
if (binding.hasErrors()) {
return setValidationErrors(binding);
}
final IUser createdBy = getUser(principal);
IUser participant = Optional.ofNullable(userService.getByUuid(addParticipantDTO.getUserId())).orElseThrow(() -> new NotExistException(EX_USER_NOT_EXISTS, User.class));
UserStudy userStudy = studyService.addParticipant(createdBy, studyId, participant.getId(), addParticipantDTO.getRole());
wsTemplate.convertAndSendToUser(userStudy.getUser().getUsername(), "/topic/invitations", new UpdateNotificationDTO());
return new JsonResult<>(NO_ERROR, Boolean.TRUE);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseStudyController method list.
@ApiOperation("List studies.")
@RequestMapping(value = "/api/v1/study-management/studies", method = GET)
public JsonResult<Page<SL>> list(Principal principal, SS studySearch) throws PermissionDeniedException {
handleInputSearchParams(studySearch);
final IUser user = getUser(principal);
studySearch.setUserId(user.getId());
Page<SL> converted = studyService.findStudies(studySearch).map(this::convertListItem);
return new JsonResult<>(NO_ERROR, converted);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseStudyController method updateDataSource.
@ApiOperation("Update data source linked to study")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/data-sources/{dataSourceId}", method = PUT)
public JsonResult<DataSourceDTO> updateDataSource(Principal principal, @PathVariable("studyId") Long studyId, @PathVariable("dataSourceId") Long dataSourceId, @RequestBody @Valid CreateVirtualDataSourceDTO dataSourceDTO) throws PermissionDeniedException, ValidationException, IOException, NoSuchFieldException, SolrServerException, IllegalAccessException {
final IUser user = getUser(principal);
IDataSource dataSource = studyService.updateVirtualDataSource(user, studyId, dataSourceId, dataSourceDTO.getName(), dataSourceDTO.getDataOwnersIds());
return new JsonResult<>(NO_ERROR, conversionService.convert(dataSource, DataSourceDTO.class));
}
Aggregations