use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseDataSourceController method list.
@RequestMapping(value = "/api/v1/data-sources", method = RequestMethod.GET)
public JsonResult<R> list(Principal principal, @ModelAttribute SearchDataCatalogDTO searchDTO) throws IOException, SolrServerException, PermissionDeniedException, NoSuchFieldException {
final IUser user = getUser(principal);
SolrQuery solrQuery = conversionService.convert(searchDTO, SolrQuery.class);
SearchResult<DS> searchResult = dataSourceService.search(solrQuery, user);
return new JsonResult<>(NO_ERROR, conversionService.convert(searchResult, getSearchResultClass()));
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseStudyController method updateFavourite.
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/favourite", method = PUT)
public JsonResult updateFavourite(@PathVariable("studyId") Long studyId, @RequestBody BooleanDTO isFavourite, Principal principal) throws PermissionDeniedException, NotExistException, NotUniqueException, ValidationException {
final IUser user = getUser(principal);
studyService.setFavourite(user.getId(), studyId, isFavourite.isValue());
return new JsonResult<>(NO_ERROR);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseStudyController method updateParticipantRole.
@ApiOperation("Update participant.")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/participants/{userUuid}", method = PUT)
public JsonResult<Boolean> updateParticipantRole(@PathVariable("studyId") Long studyId, @PathVariable("userUuid") String userUuid, @RequestBody @Valid UpdateParticipantDTO participantDTO) throws NotExistException, AlreadyExistException, ValidationException {
if (participantDTO.getRole() != null) {
ParticipantRole newRole = ParticipantRole.valueOf(participantDTO.getRole());
studyService.updateParticipantRole(studyId, UserIdUtils.uuidToId(userUuid), newRole);
}
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 createVirtualDataSource.
@ApiOperation("Create virtual data source linked to study")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/data-sources", method = POST)
public JsonResult<DataSourceDTO> createVirtualDataSource(Principal principal, @PathVariable("studyId") Long studyId, @RequestBody @Valid CreateVirtualDataSourceDTO dataSourceDTO) throws PermissionDeniedException, NotExistException, IllegalAccessException, SolrServerException, IOException, ValidationException, FieldException, AlreadyExistException, NoSuchFieldException {
final IUser createdBy = getUser(principal);
final IDataSource dataSource = studyService.addVirtualDataSource(createdBy, studyId, dataSourceDTO.getName(), dataSourceDTO.getDataOwnersIds());
final DataSourceDTO registeredDataSourceDTO = conversionService.convert(dataSource, DataSourceDTO.class);
return new JsonResult<>(NO_ERROR, registeredDataSourceDTO);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class CommentController method addComment.
@ApiOperation(value = "Add new comment")
@RequestMapping(value = "/api/v1/comments/{topicId}", method = RequestMethod.POST)
public JsonResult<CommentDTO> addComment(@PathVariable("topicId") Long topicId, @Validated @RequestBody CommentDTO commentDTO, Principal principal) throws PermissionDeniedException {
final IUser user = getUser(principal);
final Comment comment = conversionService.convert(commentDTO, Comment.class);
comment.setAuthor(user);
final Comment saved = commentService.addComment(topicId, commentDTO.getParentId(), comment);
JsonResult<CommentDTO> result = new JsonResult<>(NO_ERROR);
result.setResult(conversionService.convert(saved, CommentDTO.class));
return result;
}
Aggregations