use of com.odysseusinc.arachne.portal.model.DataNodeUser in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeServiceImpl method linkUserToDataNodeUnsafe.
@Transactional
@Override
public void linkUserToDataNodeUnsafe(DN dataNode, IUser user) throws NotExistException {
LOGGER.info(LINKING_USER_LOG, user.getId(), dataNode.getId());
final DataNodeUser dataNodeUser = new DataNodeUser();
dataNodeUser.setDataNode(dataNode);
dataNodeUser.setUser(user);
saveOrUpdateDataNodeUser(dataNode, dataNodeUser);
}
use of com.odysseusinc.arachne.portal.model.DataNodeUser in project ArachneCentralAPI by OHDSI.
the class BaseStudyServiceImpl method addVirtualDataSource.
@Override
@Transactional
@PreAuthorize("hasPermission(#studyId, 'Study', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).INVITE_DATANODE)")
public DS addVirtualDataSource(IUser createdBy, Long studyId, String dataSourceName, List<String> dataOwnerIds) throws NotExistException, AlreadyExistException, NoSuchFieldException, IOException, ValidationException, FieldException, IllegalAccessException, SolrServerException {
Study study = studyRepository.findOne(studyId);
List<IUser> dataNodeOwners = validateVirtualDataSourceOwners(study, dataOwnerIds);
final DataNode dataNode = studyHelper.getVirtualDataNode(study.getTitle(), dataSourceName);
final DataNode registeredDataNode = baseDataNodeService.create(dataNode);
final Set<DataNodeUser> dataNodeUsers = updateDataNodeOwners(dataNodeOwners, registeredDataNode);
registeredDataNode.setDataNodeUsers(dataNodeUsers);
final DS dataSource = studyHelper.getVirtualDataSource(registeredDataNode, dataSourceName);
dataSource.setHealthStatus(CommonHealthStatus.GREEN);
dataSource.setHealthStatusDescription("Virtual DataSources are always GREEN");
dataSource.getTenants().add(study.getTenant());
final DS registeredDataSource = dataSourceService.createOrRestoreDataSource(dataSource);
addDataSource(createdBy, studyId, registeredDataSource.getId());
return registeredDataSource;
}
use of com.odysseusinc.arachne.portal.model.DataNodeUser in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeServiceImpl method unlinkUserToDataNode.
@Transactional
@Override
@PreAuthorize("#dataNode == authentication.principal")
public void unlinkUserToDataNode(DN dataNode, IUser user) throws NotExistException {
LOGGER.info(UNLINKING_USER_LOG, user.getId(), dataNode.getId());
final DataNodeUser existDataNodeUser = dataNodeUserRepository.findByDataNodeAndUserId(dataNode, user.getId()).orElseThrow(() -> {
final String message = String.format(USER_IS_NOT_LINKED_EXC, user.getId(), dataNode.getId());
return new NotExistException(message, User.class);
});
dataNodeUserRepository.delete(existDataNodeUser);
}
use of com.odysseusinc.arachne.portal.model.DataNodeUser in project ArachneCentralAPI by OHDSI.
the class BaseStudyServiceImpl method updateDataNodeOwners.
private Set<DataNodeUser> updateDataNodeOwners(List<IUser> dataOwners, DataNode dataNode) {
final Set<DataNodeUser> dataNodeUsers = studyHelper.createDataNodeUsers(dataOwners, dataNode);
final Authentication savedAuth = studyHelper.loginByNode(dataNode);
baseDataNodeService.relinkAllUsersToDataNode(dataNode, dataNodeUsers);
SecurityContextHolder.getContext().setAuthentication(savedAuth);
return dataNodeUsers;
}
Aggregations