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