use of com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisType in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method addCommonEntityToAnalysis.
@ApiOperation("Add common entity to analysis")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/entities", method = POST)
public JsonResult addCommonEntityToAnalysis(@PathVariable("analysisId") Long analysisId, @RequestBody @Valid DataReferenceDTO entityReference, @RequestParam(value = "type", required = false, defaultValue = "COHORT") CommonAnalysisType analysisType, Principal principal) throws NotExistException, JMSException, IOException, PermissionDeniedException, URISyntaxException {
if (!analysisModificationLock.add(analysisId)) {
throw new ValidationRuntimeException("Analysis import rejected", Collections.singletonMap(entityReference.getEntityGuid(), Collections.singletonList("Another import into this analysis is in progress")));
}
try {
LOGGER.debug("Started import into analysis {}", analysisId);
final IUser user = getUser(principal);
final DataNode dataNode = dataNodeService.getById(entityReference.getDataNodeId());
final T analysis = analysisService.getById(analysisId);
final DataReference dataReference = dataReferenceService.addOrUpdate(entityReference.getEntityGuid(), dataNode);
final List<MultipartFile> entityFiles = getEntityFiles(entityReference, dataNode, analysisType);
String description = doAddCommonEntityToAnalysis(analysis, dataReference, user, analysisType, entityFiles);
return new JsonResult(NO_ERROR, description);
} finally {
analysisModificationLock.remove(analysisId);
LOGGER.debug("Completed import into analysis {}", analysisId);
}
}
use of com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisType in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method getEntityFiles.
public List<MultipartFile> getEntityFiles(DataReferenceDTO entityReference, DataNode dataNode, CommonAnalysisType entityType) throws JMSException, IOException, URISyntaxException {
Long waitForResponse = datanodeImportTimeout;
Long messageLifeTime = datanodeImportTimeout;
String baseQueue = MessagingUtils.Entities.getBaseQueue(dataNode);
CommonEntityRequestDTO request = new CommonEntityRequestDTO(entityReference.getEntityGuid(), entityType);
ProducerConsumerTemplate exchangeTpl = new ProducerConsumerTemplate(destinationResolver, request, baseQueue, waitForResponse, messageLifeTime);
final ObjectMessage responseMessage = jmsTemplate.execute(exchangeTpl, true);
if (responseMessage == null) {
String message = String.format(ENTITY_IS_NOT_AVAILABLE, entityType.getTitle(), entityReference.getEntityGuid(), entityReference.getDataNodeId());
throw new ServiceNotAvailableException(message);
}
final List<ImportedFile> importedFiles = (List<ImportedFile>) responseMessage.getObject();
boolean hasAnalysisRunner = hasAnalysisRunner(importedFiles);
if (entityType.equals(CommonAnalysisType.ESTIMATION) && !hasAnalysisRunner) {
return importService.processEstimation(importedFiles);
}
List<MultipartFile> files = importedFiles.stream().map(file -> conversionService.convert(file, MockMultipartFile.class)).collect(Collectors.toList());
if (!hasAnalysisRunner) {
files.addAll(generateAnalysisFiles(entityType));
}
return files;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisType in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeCommonAnalysisController method listCohorts.
/**
* Returns list of cohorts defined in Atlas connected to the Data node
* (for Central's UI)
*/
@ApiOperation("Returns list of cohorts defined in Atlas connected to the Data node")
@RequestMapping(value = "/api/v1/data-nodes/{dataNodeId}/{type}", method = GET)
public List<CommonCohortShortDTO> listCohorts(@PathVariable("dataNodeId") Long dataNodeId, @PathVariable("type") String type) throws JMSException, NotExistException {
DN dataNode = baseDataNodeService.getById(dataNodeId);
CommonAnalysisType analysisType = analysisTypeMap.getOrDefault(type, CommonAnalysisType.COHORT);
return dataNodeMessageService.getDataList(dataNode, analysisType);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisType in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeMessageServiceImpl method getDataList.
@Override
@PreAuthorize("hasPermission(#dataNode, " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).IMPORT_FROM_DATANODE)")
public <T extends CommonEntityDTO> List<T> getDataList(DN dataNode, CommonAnalysisType analysisType) throws JMSException {
Long waitForResponse = messagingTimeout;
Long messageLifeTime = messagingTimeout;
// Get all Atlases available in user's tenant
List<IAtlas> atlasList = atlasService.findAll().stream().filter(a -> a.getVersion() != null).collect(Collectors.toList());
String baseQueue = MessagingUtils.EntitiesList.getBaseQueue(dataNode);
ProducerConsumerTemplate exchangeTpl = new ProducerConsumerTemplate(destinationResolver, new CommonEntityRequestObject(atlasList.stream().map(IAtlas::getId).collect(Collectors.toList()), analysisType), baseQueue, waitForResponse, messageLifeTime);
ObjectMessage responseMessage = jmsTemplate.execute(exchangeTpl, true);
List<T> entityList = (List<T>) responseMessage.getObject();
Map<Long, IAtlas> atlasMap = atlasList.stream().collect(Collectors.toMap(IAtlas::getId, a -> a));
entityList.forEach(e -> e.setName(atlasMap.get(e.getOriginId()).getName() + ": " + e.getName()));
return entityList;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisType in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisCreateDTOToAnalysisConverter method convert.
@Override
public A convert(DTO dto) {
A analysis = newAnalysis();
analysis.setTitle(dto.getTitle());
analysis.setDescription(dto.getDescription());
final CommonAnalysisType analysisType = CommonAnalysisType.valueOf(dto.getTypeId());
analysis.setType(analysisType);
S study = newStudy();
study.setId(dto.getStudyId());
analysis.setStudy(study);
return analysis;
}
Aggregations