Beispiel #1
0
def createPermissionForStudy(studyId):
    validateUser(studyId)
    permissionData = request.get_json()
    if not ("userId" in permissionData and type(permissionData["userId"])==str and len(permissionData["userId"])>0):
        raise errors.BadRequestError("Permission must have attribute 'userId' (type=str and length>0)")
    userId = permissionData["userId"]
    userPermission = permission_db_access.createAdminForStudy(userId, studyId)
    return toJson(userPermission)
Beispiel #2
0
def getPermissionsForStudy(studyId):
    validateUser(studyId)
    userPermissionList = permission_db_access.getPermissionsForStudy(studyId)
    return toJson(userPermissionList)
Beispiel #3
0
def getFacilitiesForStudy(studyId):
    validateUser(studyId)
    facilityList = facility_db_access.getFacilitiesForStudy(studyId)
    return toJson(facilityList)
Beispiel #4
0
def getStudy(studyId):
    validateUser(studyId)
    study = study_db_access.getStudy(studyId)
    return toJson(study)
Beispiel #5
0
def updateStudy(studyId):
    validateUser(studyId)
    studyData = request.get_json()
    study = study_db_access.updateStudy(studyId, studyData)
    return toJson(study)
Beispiel #6
0
def createResourceForStudy(studyId):
    validateUser(studyId)
    file = request.files['user_file']
    fileName = s3_access.uploadFile(studyId, file)
    return toJson({"message": "file uploaded successfully", "fileName":fileName})
Beispiel #7
0
def getStudiesForUser():
    validateUser()
    studyList = permission_db_access.getStudiesForUser(getUserId())
    return toJson(studyList)
Beispiel #8
0
def getFacility(facilityId):
    facility = facility_db_access.getFacility(facilityId)
    return toJson(facility)
Beispiel #9
0
def getAllFacilities():
    facilityList = facility_db_access.getAllFacilities()
    return toJson(facilityList)
Beispiel #10
0
def getEquipment(equipmentId):
    equipment = equipment_db_access.getEquipment(equipmentId)
    return toJson(equipment)
Beispiel #11
0
def getAllEquipment():
    equipmentList = equipment_db_access.getAllEquipment()
    return toJson(equipmentList)
Beispiel #12
0
def handleAPIError(e):
    return toJson({"error":type(e).__name__, "status":e.getStatusCode(), "message":str(e)}), e.getStatusCode()
Beispiel #13
0
def handleInternalServerError(e):
    return toJson({"error":type(e).__name__, "status":500, "message":"Internal Server Error"}), 500
Beispiel #14
0
def handleNotFoundEror(e):
    return toJson({"error":type(e).__name__, "status":404, "message":str(e)}), 404
Beispiel #15
0
def getAllDeploymentsForStudy(studyId):
    validateUser(studyId)
    deploymentList = deployment_db_access.getAllDeployments(studyId)
    return toJson(deploymentList)
Beispiel #16
0
def createStudy():
    validateUser()
    studyData = request.get_json()
    study = study_db_access.createStudy(studyData)
    permission_db_access.createOwnerForStudy(getUserId(), study.studyId)
    return toJson(study)
Beispiel #17
0
def createDeploymentForStudy(studyId):
    validateUser(studyId)
    deploymentData = request.get_json()
    deployment = deployment_db_access.createDeployment(studyId, deploymentData)
    return toJson(deployment)
Beispiel #18
0
def getDeploymentForStudy(studyId, deploymentId):
    validateUser(studyId)
    deployment = deployment_db_access.getDeployment(studyId, deploymentId)
    return toJson(deployment)