Search in sources :

Example 11 with DataNode

use of com.odysseusinc.arachne.portal.model.DataNode 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 12 with DataNode

use of com.odysseusinc.arachne.portal.model.DataNode in project ArachneCentralAPI by OHDSI.

the class BaseStudyServiceImpl method updateVirtualDataSource.

@Override
@Transactional
@PreAuthorize("hasPermission(#dataSourceId, 'DataSource', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).DELETE_DATASOURCE)")
public DS updateVirtualDataSource(IUser user, Long studyId, Long dataSourceId, String name, List<String> dataOwnerIds) throws IllegalAccessException, IOException, NoSuchFieldException, SolrServerException, ValidationException {
    Study study = studyRepository.findOne(studyId);
    List<IUser> dataOwners = validateVirtualDataSourceOwners(study, dataOwnerIds);
    final DS dataSource = getStudyDataSource(user, studyId, dataSourceId);
    final DataNode dataNode = dataSource.getDataNode();
    updateDataNodeOwners(dataOwners, dataNode);
    dataSource.setName(name);
    final DS update = dataSourceService.updateInAnyTenant(dataSource);
    return dataSource;
}
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) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with DataNode

use of com.odysseusinc.arachne.portal.model.DataNode in project ArachneCentralAPI by OHDSI.

the class BaseArachneSecureServiceImpl method getRolesBySubmission.

@Override
public List<ParticipantRole> getRolesBySubmission(ArachneUser user, Submission submission) {
    List<ParticipantRole> result = new LinkedList<>();
    if (submission != null) {
        Analysis analysis = submission.getSubmissionGroup().getAnalysis();
        result = getRolesByAnalysis(user, analysis);
        final DataNode dataNode = submission.getDataSource().getDataNode();
        if (!DataNodeUtils.isDataNodeOwner(dataNode, user.getId())) {
            // There can be many DATA_SET_OWNER-s in a single study, owning different data sources
            // But in case of Submission, we are interested, whether current user is owner of the submission's DS
            result.removeIf(ParticipantRole.DATA_SET_OWNER::equals);
        }
    }
    return result;
}
Also used : Analysis(com.odysseusinc.arachne.portal.model.Analysis) DataNode(com.odysseusinc.arachne.portal.model.DataNode) LinkedList(java.util.LinkedList) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole)

Example 14 with DataNode

use of com.odysseusinc.arachne.portal.model.DataNode in project ArachneCentralAPI by OHDSI.

the class BaseUserController method linkUserToDataNode.

@ApiOperation("Link U to DataNode")
@RequestMapping(value = "/api/v1/user-management/datanodes/{datanodeSid}/users", method = POST)
public JsonResult linkUserToDataNode(@PathVariable("datanodeSid") Long datanodeId, @RequestBody CommonLinkUserToDataNodeDTO linkUserToDataNode) throws NotExistException, AlreadyExistException {
    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.getByUnverifiedEmailInAnyTenant(linkUserToDataNode.getUserName());
    baseDataNodeService.linkUserToDataNode(dataNode, user);
    return new JsonResult(NO_ERROR);
}
Also used : DataNode(com.odysseusinc.arachne.portal.model.DataNode) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with DataNode

use of com.odysseusinc.arachne.portal.model.DataNode in project ArachneCentralAPI by OHDSI.

the class CommonDataNodeRegisterDTOToDataNodeConverter method convert.

@Override
public DataNode convert(CommonDataNodeRegisterDTO source) {
    DataNode dataNode = new DataNode();
    dataNode.setName(source.getName());
    dataNode.setDescription(source.getDescription());
    dataNode.setVirtual(false);
    dataNode.setPublished(true);
    return dataNode;
}
Also used : DataNode(com.odysseusinc.arachne.portal.model.DataNode)

Aggregations

DataNode (com.odysseusinc.arachne.portal.model.DataNode)16 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ApiOperation (io.swagger.annotations.ApiOperation)5 ObjectMessage (javax.jms.ObjectMessage)4 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)3 IUser (com.odysseusinc.arachne.portal.model.IUser)3 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 CommonEntityDTO (com.odysseusinc.arachne.commons.api.v1.dto.CommonEntityDTO)2 ConsumerTemplate (com.odysseusinc.arachne.commons.service.messaging.ConsumerTemplate)2 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)2 FavouriteStudy (com.odysseusinc.arachne.portal.model.FavouriteStudy)2 Study (com.odysseusinc.arachne.portal.model.Study)2 UserStudy (com.odysseusinc.arachne.portal.model.UserStudy)2 List (java.util.List)2 Transactional (org.springframework.transaction.annotation.Transactional)2 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 JsonReader (com.google.gson.stream.JsonReader)1