예제 #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)
예제 #2
0
def getPermissionsForStudy(studyId):
    validateUser(studyId)
    userPermissionList = permission_db_access.getPermissionsForStudy(studyId)
    return toJson(userPermissionList)
예제 #3
0
def getFacilitiesForStudy(studyId):
    validateUser(studyId)
    facilityList = facility_db_access.getFacilitiesForStudy(studyId)
    return toJson(facilityList)
예제 #4
0
def getStudy(studyId):
    validateUser(studyId)
    study = study_db_access.getStudy(studyId)
    return toJson(study)
예제 #5
0
def updateStudy(studyId):
    validateUser(studyId)
    studyData = request.get_json()
    study = study_db_access.updateStudy(studyId, studyData)
    return toJson(study)
예제 #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})
예제 #7
0
def getStudiesForUser():
    validateUser()
    studyList = permission_db_access.getStudiesForUser(getUserId())
    return toJson(studyList)
예제 #8
0
def getFacility(facilityId):
    facility = facility_db_access.getFacility(facilityId)
    return toJson(facility)
예제 #9
0
def getAllFacilities():
    facilityList = facility_db_access.getAllFacilities()
    return toJson(facilityList)
예제 #10
0
def getEquipment(equipmentId):
    equipment = equipment_db_access.getEquipment(equipmentId)
    return toJson(equipment)
예제 #11
0
def getAllEquipment():
    equipmentList = equipment_db_access.getAllEquipment()
    return toJson(equipmentList)
예제 #12
0
def handleAPIError(e):
    return toJson({"error":type(e).__name__, "status":e.getStatusCode(), "message":str(e)}), e.getStatusCode()
예제 #13
0
def handleInternalServerError(e):
    return toJson({"error":type(e).__name__, "status":500, "message":"Internal Server Error"}), 500
예제 #14
0
def handleNotFoundEror(e):
    return toJson({"error":type(e).__name__, "status":404, "message":str(e)}), 404
예제 #15
0
def getAllDeploymentsForStudy(studyId):
    validateUser(studyId)
    deploymentList = deployment_db_access.getAllDeployments(studyId)
    return toJson(deploymentList)
예제 #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)
예제 #17
0
def createDeploymentForStudy(studyId):
    validateUser(studyId)
    deploymentData = request.get_json()
    deployment = deployment_db_access.createDeployment(studyId, deploymentData)
    return toJson(deployment)
예제 #18
0
def getDeploymentForStudy(studyId, deploymentId):
    validateUser(studyId)
    deployment = deployment_db_access.getDeployment(studyId, deploymentId)
    return toJson(deployment)