Search in sources :

Example 81 with JsonResult

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult 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);
}
Also used : IUser(com.odysseusinc.arachne.portal.model.IUser) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 82 with JsonResult

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult 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);
}
Also used : JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 83 with JsonResult

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult 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);
}
Also used : DataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO) CreateVirtualDataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO) IUser(com.odysseusinc.arachne.portal.model.IUser) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) IDataSource(com.odysseusinc.arachne.portal.model.IDataSource) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 84 with JsonResult

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult 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;
}
Also used : Comment(com.odysseusinc.arachne.portal.model.Comment) IUser(com.odysseusinc.arachne.portal.model.IUser) CommentDTO(com.odysseusinc.arachne.portal.api.v1.dto.CommentDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)77 ApiOperation (io.swagger.annotations.ApiOperation)59 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)44 IUser (com.odysseusinc.arachne.portal.model.IUser)22 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)21 ResponseEntity (org.springframework.http.ResponseEntity)20 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)17 GET (org.springframework.web.bind.annotation.RequestMethod.GET)8 POST (org.springframework.web.bind.annotation.RequestMethod.POST)8 PUT (org.springframework.web.bind.annotation.RequestMethod.PUT)8 FileDTO (com.odysseusinc.arachne.portal.api.v1.dto.FileDTO)6 SubmissionFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO)6 UploadFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO)6 NotUniqueException (com.odysseusinc.arachne.portal.exception.NotUniqueException)6 FieldError (org.springframework.validation.FieldError)6 GetMapping (org.springframework.web.bind.annotation.GetMapping)6 ResultFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO)5 PermissionDeniedException (com.odysseusinc.arachne.portal.exception.PermissionDeniedException)5 ValidationException (com.odysseusinc.arachne.portal.exception.ValidationException)5 AnalysisFile (com.odysseusinc.arachne.portal.model.AnalysisFile)5