use of com.odysseusinc.arachne.portal.exception.ServiceNotAvailableException in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method getEntityFiles.
protected 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);
}
List<MultipartFile> files = new LinkedList<>();
final List<ImportedFile> importedFiles = (List<ImportedFile>) responseMessage.getObject();
if (entityType.equals(CommonAnalysisType.ESTIMATION)) {
files.addAll(importService.processEstimation(importedFiles));
} else {
files = importedFiles.stream().map(file -> conversionService.convert(file, MockMultipartFile.class)).collect(Collectors.toList());
}
if (entityType.equals(CommonAnalysisType.PREDICTION)) {
attachPredictionFiles(files);
}
if (entityType.equals(CommonAnalysisType.COHORT_CHARACTERIZATION)) {
attachCohortCharacterizationFiles(files);
}
if (entityType.equals(CommonAnalysisType.INCIDENCE)) {
attachIncidenceRatesFiles(files);
}
return files;
}
Aggregations