Search in sources :

Example 1 with IAtlas

use of com.odysseusinc.arachne.portal.model.IAtlas 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;
}
Also used : CommonListEntityRequest(com.odysseusinc.arachne.commons.api.v1.dto.CommonListEntityRequest) AtlasService(com.odysseusinc.arachne.portal.service.AtlasService) ConsumerTemplate(com.odysseusinc.arachne.commons.service.messaging.ConsumerTemplate) IAtlas(com.odysseusinc.arachne.portal.model.IAtlas) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ObjectMessage(javax.jms.ObjectMessage) CommonAnalysisType(com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisType) Collectors(java.util.stream.Collectors) JMSException(javax.jms.JMSException) CommonEntityDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonEntityDTO) LinkedHashMap(java.util.LinkedHashMap) Value(org.springframework.beans.factory.annotation.Value) CommonEntityRequestObject(com.odysseusinc.arachne.commons.api.v1.dto.CommonEntityRequestObject) List(java.util.List) DataNode(com.odysseusinc.arachne.portal.model.DataNode) Map(java.util.Map) JmsTemplate(org.springframework.jms.core.JmsTemplate) ProducerConsumerTemplate(com.odysseusinc.arachne.commons.service.messaging.ProducerConsumerTemplate) MessagingUtils.getRequestQueueName(com.odysseusinc.arachne.commons.service.messaging.MessagingUtils.getRequestQueueName) DestinationResolver(org.springframework.jms.support.destination.DestinationResolver) CommonEntityRequestObject(com.odysseusinc.arachne.commons.api.v1.dto.CommonEntityRequestObject) ObjectMessage(javax.jms.ObjectMessage) List(java.util.List) ProducerConsumerTemplate(com.odysseusinc.arachne.commons.service.messaging.ProducerConsumerTemplate) IAtlas(com.odysseusinc.arachne.portal.model.IAtlas) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

CommonAnalysisType (com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisType)1 CommonEntityDTO (com.odysseusinc.arachne.commons.api.v1.dto.CommonEntityDTO)1 CommonEntityRequestObject (com.odysseusinc.arachne.commons.api.v1.dto.CommonEntityRequestObject)1 CommonListEntityRequest (com.odysseusinc.arachne.commons.api.v1.dto.CommonListEntityRequest)1 ConsumerTemplate (com.odysseusinc.arachne.commons.service.messaging.ConsumerTemplate)1 MessagingUtils.getRequestQueueName (com.odysseusinc.arachne.commons.service.messaging.MessagingUtils.getRequestQueueName)1 ProducerConsumerTemplate (com.odysseusinc.arachne.commons.service.messaging.ProducerConsumerTemplate)1 DataNode (com.odysseusinc.arachne.portal.model.DataNode)1 IAtlas (com.odysseusinc.arachne.portal.model.IAtlas)1 AtlasService (com.odysseusinc.arachne.portal.service.AtlasService)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 JMSException (javax.jms.JMSException)1 ObjectMessage (javax.jms.ObjectMessage)1 Value (org.springframework.beans.factory.annotation.Value)1 JmsTemplate (org.springframework.jms.core.JmsTemplate)1 DestinationResolver (org.springframework.jms.support.destination.DestinationResolver)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1