use of com.odysseusinc.arachne.portal.model.DataNode in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeMessagingController method saveCommonEntity.
private void saveCommonEntity(Principal principal, String id, Serializable object) throws PermissionDeniedException {
DataNode dataNode = getDatanode(principal);
String queueBase = MessagingUtils.Entities.getBaseQueue(dataNode);
String responseQueue = getResponseQueueName(queueBase);
jmsTemplate.send(responseQueue, session -> {
ObjectMessage message = session.createObjectMessage(object);
message.setJMSCorrelationID(id);
return message;
});
}
use of com.odysseusinc.arachne.portal.model.DataNode 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.portal.model.DataNode in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeMessagingController method getEntityRequests.
@RequestMapping(value = "/api/v1/data-nodes/entities", method = GET)
public List<CommonEntityRequestDTO> getEntityRequests(Principal principal) throws PermissionDeniedException, JMSException {
DataNode dataNode = getDatanode(principal);
final String requestQueue = getRequestQueueName(MessagingUtils.Entities.getBaseQueue(dataNode));
ConsumerTemplate consumerTpl = new ConsumerTemplate(destinationResolver, requestQueue, // Give some time for case when new connection to a broker is established
1000L);
List<CommonEntityRequestDTO> cohortRequests = new ArrayList<>();
while (true) {
ObjectMessage requestMessage = jmsTemplate.execute(consumerTpl, true);
if (requestMessage == null) {
break;
}
final CommonEntityRequestDTO cohortRequest = (CommonEntityRequestDTO) requestMessage.getObject();
cohortRequest.setId(requestMessage.getJMSCorrelationID());
cohortRequests.add(cohortRequest);
}
return cohortRequests;
}
use of com.odysseusinc.arachne.portal.model.DataNode 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 {
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);
doAddCommonEntityToAnalysis(analysis, dataReference, user, analysisType, entityFiles);
return new JsonResult(NO_ERROR);
}
use of com.odysseusinc.arachne.portal.model.DataNode in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeController method createDataSource.
@ApiOperation("Create new data source of datanode.")
@RequestMapping(value = "/api/v1/data-nodes/{dataNodeId}/data-sources", method = RequestMethod.POST)
public JsonResult createDataSource(@PathVariable("dataNodeId") Long id, @RequestBody C_DS_DTO commonDataSourceDTO) throws FieldException, NotExistException, ValidationException, IOException, SolrServerException, NoSuchFieldException, IllegalAccessException, BindException {
// we validate only two fields, because we don't want to validate another fields, because they always are null
validate(commonDataSourceDTO);
JsonResult<CommonDataSourceDTO> result;
DataNode dataNode = baseDataNodeService.getById(id);
if (dataNode == null) {
throw new IllegalArgumentException("Unable to find datanode by ID " + id);
}
DS dataSource = convertCommonDataSourceDtoToDataSource(commonDataSourceDTO);
dataSource.setDataNode(dataNode);
dataSource = dataSourceService.createOrRestoreDataSource(dataSource);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(genericConversionService.convert(dataSource, CommonDataSourceDTO.class));
return result;
}
Aggregations