use of com.odysseusinc.arachne.commons.api.v1.dto.CommonEntityDTO in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeMessagingController method saveListResponse.
/**
* Posts responses for for CommonEntity list requests
* (for pushing by Node's back)
*/
@RequestMapping(value = "/api/v1/data-nodes/entity-lists/responses", method = POST)
public void saveListResponse(@RequestBody @Valid CommonListEntityResponseDTO commonListEntityResponseDTO, Principal principal) throws PermissionDeniedException {
DataNode dataNode = getDatanode(principal);
String responseQueue = getResponseQueueName(MessagingUtils.EntitiesList.getBaseQueue(dataNode));
List<CommonEntityDTO> response = (List<CommonEntityDTO>) commonListEntityResponseDTO.getEntities();
for (String correlationId : commonListEntityResponseDTO.getRequestIds()) {
jmsTemplate.send(responseQueue, session -> {
ObjectMessage message = session.createObjectMessage((Serializable) response);
message.setJMSCorrelationID(correlationId);
return message;
});
}
}
use of com.odysseusinc.arachne.commons.api.v1.dto.CommonEntityDTO 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;
}
Aggregations