use of com.odysseusinc.arachne.portal.model.DataNode in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeController method buildEmptyDataNode.
protected DataNode buildEmptyDataNode() {
DataNode dataNode = new DataNode();
dataNode.setVirtual(false);
dataNode.setName(null);
dataNode.setPublished(false);
return dataNode;
}
use of com.odysseusinc.arachne.portal.model.DataNode in project ArachneCentralAPI by OHDSI.
the class BaseUserController method unlinkUserToDataNode.
@ApiOperation("Unlink User to DataNode")
@RequestMapping(value = "/api/v1/user-management/datanodes/{datanodeId}/users", method = RequestMethod.DELETE)
public JsonResult unlinkUserToDataNode(@PathVariable("datanodeId") Long datanodeId, @RequestBody CommonLinkUserToDataNodeDTO linkUserToDataNode) throws NotExistException {
final DN datanode = Optional.ofNullable(baseDataNodeService.getById(datanodeId)).orElseThrow(() -> new NotExistException(String.format(DATA_NODE_NOT_FOUND_EXCEPTION, datanodeId), DataNode.class));
final U user = userService.getByUsernameInAnyTenant(linkUserToDataNode.getUserName());
baseDataNodeService.unlinkUserToDataNode(datanode, user);
return new JsonResult(NO_ERROR);
}
use of com.odysseusinc.arachne.portal.model.DataNode 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;
}
use of com.odysseusinc.arachne.portal.model.DataNode in project ArachneCentralAPI by OHDSI.
the class AuthenticationSystemTokenFilter method doFilter.
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest;
String token = request.getHeader(tokenHeader);
if (token != null) {
DataNode dataNode = baseDataNodeService.findByToken(token).orElseThrow(() -> new BadCredentialsException("dataNode not found"));
if (SecurityContextHolder.getContext().getAuthentication() == null) {
GrantedAuthority dataNodeAuthority = new SimpleGrantedAuthority("ROLE_" + Roles.ROLE_DATA_NODE);
Collection<GrantedAuthority> authorityCollection = new ArrayList<>();
authorityCollection.add(dataNodeAuthority);
DataNodeAuthenticationToken authentication = new DataNodeAuthenticationToken(token, dataNode, authorityCollection);
SecurityContextHolder.getContext().setAuthentication(authentication);
}
}
filterChain.doFilter(servletRequest, servletResponse);
}
use of com.odysseusinc.arachne.portal.model.DataNode in project ArachneCentralAPI by OHDSI.
the class AchillesImportServiceImpl method importData.
@Override
@Async(value = "importAchillesReportsExecutor")
@Transactional
public void importData(IDataSource dataSource, File archivedData) throws IOException {
Characterization characterization = new Characterization();
characterization.setDataSource(dataSource);
final Long dataSourceId = dataSource.getId();
final String dataSourceName = dataSource.getName();
final DataNode dataNode = dataSource.getDataNode();
final Long dataNodeId = dataNode.getId();
final String dataNodeName = dataNode.getName();
LOGGER.info(IMPORT_ACHILLES_RESULT_LOG, "Started", dataSourceId, dataSourceName, dataNodeId, dataNodeName);
Timestamp now = new Timestamp(new Date().getTime());
characterization.setDate(now);
Path tempDir = Files.createTempDirectory("achilles_");
entityManager.setFlushMode(FlushModeType.COMMIT);
batch.set(new ArrayList<>());
try {
unzipData(archivedData, tempDir);
List<AchillesFile> files = new LinkedList<>();
JsonParser parser = new JsonParser();
final Characterization result = characterizationRepository.save(characterization);
Files.walkFileTree(tempDir, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
AchillesFile achillesFile = new AchillesFile();
achillesFile.setFilePath(tempDir.relativize(file).toString());
try (JsonReader reader = new JsonReader(new InputStreamReader(Files.newInputStream(file, READ)))) {
JsonObject jsonObject = parser.parse(reader).getAsJsonObject();
achillesFile.setData(jsonObject);
}
achillesFile.setCharacterization(result);
saveAsBatch(achillesFile);
return CONTINUE;
}
});
flush();
LOGGER.info(IMPORT_ACHILLES_RESULT_LOG, "Finished", dataSourceId, dataSourceName, dataNodeId, dataNodeName);
} finally {
FileUtils.deleteQuietly(tempDir.toFile());
}
}
Aggregations