use of com.odysseusinc.arachne.portal.util.ImportedFile 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.portal.util.ImportedFile in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeMessagingController method saveEntity.
@ApiOperation("Save entity")
@RequestMapping(value = "/api/v1/data-nodes/common-entity/{id}", method = POST)
public void saveEntity(Principal principal, @PathVariable("id") String id, @RequestParam(required = false) MultipartFile[] files) throws PermissionDeniedException, IOException {
LinkedList<ImportedFile> importedFiles = new LinkedList<>();
for (MultipartFile mpf : files) {
importedFiles.add(new ImportedFile(mpf.getOriginalFilename(), mpf.getBytes()));
}
saveCommonEntity(principal, id, importedFiles);
}
Aggregations