Search in sources :

Example 1 with DataNodeUser

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);
}
Also used : DataNodeUser(com.odysseusinc.arachne.portal.model.DataNodeUser) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with 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;
}
Also used : UserStudy(com.odysseusinc.arachne.portal.model.UserStudy) Study(com.odysseusinc.arachne.portal.model.Study) FavouriteStudy(com.odysseusinc.arachne.portal.model.FavouriteStudy) DataNode(com.odysseusinc.arachne.portal.model.DataNode) IUser(com.odysseusinc.arachne.portal.model.IUser) DataNodeUser(com.odysseusinc.arachne.portal.model.DataNodeUser) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with DataNodeUser

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);
}
Also used : NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) DataNodeUser(com.odysseusinc.arachne.portal.model.DataNodeUser) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with DataNodeUser

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;
}
Also used : Authentication(org.springframework.security.core.Authentication) DataNodeUser(com.odysseusinc.arachne.portal.model.DataNodeUser)

Aggregations

DataNodeUser (com.odysseusinc.arachne.portal.model.DataNodeUser)4 Transactional (org.springframework.transaction.annotation.Transactional)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)1 DataNode (com.odysseusinc.arachne.portal.model.DataNode)1 FavouriteStudy (com.odysseusinc.arachne.portal.model.FavouriteStudy)1 IUser (com.odysseusinc.arachne.portal.model.IUser)1 Study (com.odysseusinc.arachne.portal.model.Study)1 UserStudy (com.odysseusinc.arachne.portal.model.UserStudy)1 Authentication (org.springframework.security.core.Authentication)1