Search in sources :

Example 26 with AnalysisFile

use of com.odysseusinc.arachne.portal.model.AnalysisFile in project ArachneCentralAPI by OHDSI.

the class BaseAnalysisController method updateCommonEntityInAnalysis.

@ApiOperation("update common entity in analysis")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/entities/{fileUuid}", method = PUT)
public JsonResult updateCommonEntityInAnalysis(@PathVariable("analysisId") Long analysisId, @PathVariable("fileUuid") String fileUuid, @RequestParam(value = "type", required = false, defaultValue = "COHORT") CommonAnalysisType analysisType, Principal principal) throws IOException, JMSException, PermissionDeniedException, URISyntaxException {
    final IUser user = getUser(principal);
    final AnalysisFile analysisFile = analysisService.getAnalysisFile(analysisId, fileUuid);
    T analysis = (T) analysisFile.getAnalysis();
    final DataReference dataReference = analysisFile.getDataReference();
    final DataReferenceDTO entityReference = new DataReferenceDTO(dataReference.getDataNode().getId(), dataReference.getGuid());
    final List<MultipartFile> entityFiles = getEntityFiles(entityReference, dataReference.getDataNode(), analysisType);
    analysisService.findAnalysisFilesByDataReference(analysis, dataReference).forEach(existingAnalysisFile -> {
        analysisService.deleteAnalysisFile(analysis, existingAnalysisFile);
        analysis.getFiles().remove(existingAnalysisFile);
    });
    final String description = doAddCommonEntityToAnalysis(analysis, dataReference, user, analysisType, entityFiles);
    return new JsonResult(NO_ERROR, description);
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MultipartFile(org.springframework.web.multipart.MultipartFile) DataReferenceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataReferenceDTO) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) GET(org.springframework.web.bind.annotation.RequestMethod.GET) POST(org.springframework.web.bind.annotation.RequestMethod.POST) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) IUser(com.odysseusinc.arachne.portal.model.IUser) DataReference(com.odysseusinc.arachne.portal.model.DataReference) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AnalysisFile (com.odysseusinc.arachne.portal.model.AnalysisFile)26 Path (java.nio.file.Path)11 IOException (java.io.IOException)9 Date (java.util.Date)8 IORuntimeException (com.odysseusinc.arachne.portal.exception.IORuntimeException)6 Analysis (com.odysseusinc.arachne.portal.model.Analysis)6 ApiOperation (io.swagger.annotations.ApiOperation)6 IUser (com.odysseusinc.arachne.portal.model.IUser)5 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)4 AnalysisFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.AnalysisFileDTO)4 AntivirusJob (com.odysseusinc.arachne.portal.service.impl.antivirus.events.AntivirusJob)4 AntivirusJobEvent (com.odysseusinc.arachne.portal.service.impl.antivirus.events.AntivirusJobEvent)4 FileInputStream (java.io.FileInputStream)4 AlreadyExistException (com.odysseusinc.arachne.portal.exception.AlreadyExistException)3 ValidationRuntimeException (com.odysseusinc.arachne.portal.exception.ValidationRuntimeException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)3 MultipartFile (org.springframework.web.multipart.MultipartFile)3