Ejemplo n.º 1
0
def addRepoFollower(repo_id, person_id):
    try:
        RepoManager.addFollower(int(repo_id), int(person_id))
        return makeResponse(message="Collaborator added")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 2
0
def removeRepoFollower(repo_id, person_id):
    try:
        RepoManager.removeFollower(int(repo_id), int(person_id))
        return makeResponse(message="Follower removed")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 3
0
def removeRepoFollower(repo_id, person_id):
    try:
        RepoManager.removeFollower(int(repo_id), int(person_id))
        return makeResponse(message="Follower removed")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 4
0
def addRepoFollower(repo_id, person_id):
    try:
        RepoManager.addFollower(int(repo_id), int(person_id))
        return makeResponse(message="Collaborator added")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 5
0
def deleteRepo():
    repo_id = int(request.form.get('repo_id'))
    try:
        RepoManager.delete(repo_id)
        return makeResponse(payload={"repo_id": repo_id}, message="Repository deleted")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 6
0
def deleteRepo():
    repo_id = int(request.form.get('repo_id'))
    try:
        RepoManager.delete(repo_id)
        return makeResponse(payload={"repo_id": repo_id},
                            message="Repository deleted")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 7
0
def removeRepoCollab():
    repo_id = request.form.get('repo_id')
    person_id = request.form.get('person_id')

    try:
        RepoManager.removeCollaborator(int(repo_id), int(person_id))
        return makeResponse(message="Collaborator removed")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 8
0
def removeRepoCollab():
    repo_id = request.form.get('repo_id')
    person_id = request.form.get('person_id')

    try:
        RepoManager.removeCollaborator(int(repo_id), int(person_id))
        return makeResponse(message="Collaborator removed")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 9
0
def addRepoCollab():
    repo_id = int(request.form.get('repo_id'))
    person_id = int(request.form.get('person_id'))
    access = request.form.get('access')

    try:
        RepoManager.addCollaborator(repo_id, person_id, access)
        return makeResponse(message="Collaborator added")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 10
0
def addRepoCollab():
    repo_id = int(request.form.get('repo_id'))
    person_id = int(request.form.get('person_id'))
    access = request.form.get('access')

    try:
        RepoManager.addCollaborator(repo_id, person_id, access)
        return makeResponse(message="Collaborator added")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 11
0
def listRepoFollowers(repo_id):
    try:
        return makeResponse(payload=RepoManager.getFollowers(int(repo_id)))
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 12
0
def getRepoForPortal(repo_uuid):
    try:
        return makeResponse(payload=RepoManager.getRepoForPortal(repo_uuid))
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 13
0
def setRepoOwner(repo_id):
    # Get person by auth token
    current_token = get_raw_jwt()
    jti = current_token['jti']

    # email address
    identity = current_token['identity']
    ident_str = "p.email = {identity}"

    try:
        RepoManager.setOwner(int(repo_id), identity, ident_str)
        return makeResponse(payload={}, message="Set repository owner")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 14
0
def setRepoOwner(repo_id):
    # Get person by auth token
    current_token = get_raw_jwt()
    jti = current_token['jti']

    # email address
    identity = current_token['identity']
    ident_str = "p.email = {identity}"

    try:
        RepoManager.setOwner(int(repo_id), identity, ident_str)
        return makeResponse(payload={}, message="Set repository owner")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 15
0
def getRepoForPortal(repo_uuid):
  try:
      return makeResponse(payload=RepoManager.getRepoForPortal(repo_uuid))
  except FindError as e:
      return makeResponse(error=e)
  except DbError as e:
      return makeResponse(error=e)
Ejemplo n.º 16
0
def listRepoFollowers(repo_id):
    try:
        return makeResponse(payload=RepoManager.getFollowers(int(repo_id)))
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 17
0
def getRepoOwner(repo_id):
    try:
        owner = RepoManager.getOwner(int(repo_id))
        return makeResponse(payload=owner)
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 18
0
def deleteRepoOwner(repo_id, person_id):
    try:
        rel_deleted = RepoManager.deleteOwner(int(repo_id), int(person_id))
        return makeResponse(payload={}, message="Deleted owner")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 19
0
def getRepoInfo(repo_id):
    try:
        repo = RepoManager.getInfo(int(repo_id))
        return makeResponse(payload=repo)
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 20
0
def getRepoInfo(repo_id):
    try:
        repo = RepoManager.getInfo(int(repo_id))
        return makeResponse(payload=repo)
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 21
0
def deleteRepoOwner(repo_id, person_id):
    try:
        rel_deleted = RepoManager.deleteOwner(int(repo_id), int(person_id))
        return makeResponse(payload={}, message="Deleted owner")
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 22
0
def getRepoOwner(repo_id):
    try:
        owner = RepoManager.getOwner(int(repo_id))
        return makeResponse(payload=owner)
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 23
0
def listRepoUsers():
    repo_id = int(request.form.get('repo_id'))

    try:
        return makeResponse(payload=RepoManager.getUsers(repo_id))
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 24
0
def listRepoUsers():
    repo_id = int(request.form.get('repo_id'))

    try:
        return makeResponse(payload=RepoManager.getUsers(repo_id))
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 25
0
def getRepoDataCounts():
  repo_id = int(request.form.get('repo_id'))

  try:
      return makeResponse(payload=RepoManager.getDataCounts(repo_id))
  except FindError as e:
      return makeResponse(error=e)
  except DbError as e:
      return makeResponse(error=e)
Ejemplo n.º 26
0
def getRepoDataCounts():
    repo_id = int(request.form.get('repo_id'))

    try:
        return makeResponse(payload=RepoManager.getDataCounts(repo_id))
    except FindError as e:
        return makeResponse(error=e)
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 27
0
    def getDataForType(repo_id, type_code, start=0, limit=None):
        repo_id = int(repo_id)
        RepoManager.validate_repo_id(repo_id)
        type_info = SchemaManager.getInfoForType(repo_id, type_code)

        nodes = []
        cols = [] #list(map(lambda  x: x['code'], type_info['fields']))

        colNames = {}
        for f in type_info['fields']:
            if f['type'] == 'MediaDataType':
                colNames[f['code'] + "_preview_path"] = {"name": f['name'], "type": "MediaDataType" }
                cols.append(f['code'] + "_preview_path")
            else:
                colNames[f['code']] = {"name": f['name'], "type": f['type'] }
                cols.append(f['code'])

        c = 0

        try:
            # TODO: implement start/limit rather than fixed limit
            q = "MATCH (r:Repository)--(t:SchemaType)--(n:Data) WHERE ID(r)={repo_id} AND ID(t)={type_id} RETURN n SKIP {start}"
            q_values = {"repo_id": repo_id, "type_id": type_info["type_id"],  "start": start}
            if limit is not None:
                q = q + " LIMIT {limit}"
                q_values['limit'] = limit

            result = db.run(q, q_values)
            if result is not None:
                for data in result:
                    d = data.items()[0][1].properties

                    for x in d:
                        if (x + '_preview_path') in d:
                            d[x + '_preview_path'] = '<img src="/' + str(d[x + '_preview_path']) + '"/>'
                    nodes.append(d)
                    c = c + 1

            return {"data": nodes, "columns": cols, "columnNames": colNames,  "type_id": type_info["type_id"], "repo_id": repo_id, "start": start, "limit": limit, "count": c}
        except Exception as e:
            return {"data": [], "columns": [], "type_id": type_info["type_id"], "repo_id": repo_id, "start": start,
                    "limit": limit, "count": 0}
Ejemplo n.º 28
0
def editRepo(repo_id):
    url = request.form.get('url')
    name = request.form.get('name')
    readme = request.form.get('readme')
    license = request.form.get('license')
    published = request.form.get('published')
    featured = request.form.get('featured')

    try:
        return makeResponse(payload=RepoManager.edit(repo_id, name, url, readme, license, published, featured), message="Edited repository")
    except FindError as e:
        return makeResponse(error=e)
    except ValidationError as e:
        return makeResponse(error=e)
Ejemplo n.º 29
0
def editRepo(repo_id):
    url = request.form.get('url')
    name = request.form.get('name')
    readme = request.form.get('readme')
    license = request.form.get('license')
    published = request.form.get('published')
    featured = request.form.get('featured')

    try:
        return makeResponse(payload=RepoManager.edit(repo_id, name, url,
                                                     readme, license,
                                                     published, featured),
                            message="Edited repository")
    except FindError as e:
        return makeResponse(error=e)
    except ValidationError as e:
        return makeResponse(error=e)
Ejemplo n.º 30
0
def addRepo():
    url = request.form.get('url')
    name = request.form.get('name')
    readme = request.form.get('readme')
    license = request.form.get('license')
    published = request.form.get('published')

    # Get person by auth token
    current_token = get_raw_jwt()
    jti = current_token['jti']

    # email address
    identity = current_token['identity']
    ident_str = "p.email = {identity}"

    try:
        return makeResponse(payload=RepoManager.create(url, name, readme, license, published, identity, ident_str), message="Created repository")
    except ValidationError as e:
        return makeResponse(error=e)
Ejemplo n.º 31
0
def addRepo():
    url = request.form.get('url')
    name = request.form.get('name')
    readme = request.form.get('readme')
    license = request.form.get('license')
    published = request.form.get('published')

    # Get person by auth token
    current_token = get_raw_jwt()
    jti = current_token['jti']

    # email address
    identity = current_token['identity']
    ident_str = "p.email = {identity}"

    try:
        return makeResponse(payload=RepoManager.create(url, name, readme,
                                                       license, published,
                                                       identity, ident_str),
                            message="Created repository")
    except ValidationError as e:
        return makeResponse(error=e)
Ejemplo n.º 32
0
    def getDataForType(repo_id, type_code, start=0, limit=None):
        repo_id = int(repo_id)
        RepoManager.validate_repo_id(repo_id)
        type_info = SchemaManager.getInfoForType(repo_id, type_code)

        nodes = []
        cols = []  #list(map(lambda  x: x['code'], type_info['fields']))

        colNames = {}
        for f in type_info['fields']:
            if f['type'] == 'MediaDataType':
                colNames[f['code'] + "_preview_path"] = {
                    "name": f['name'],
                    "type": "MediaDataType"
                }
                cols.append(f['code'] + "_preview_path")
            else:
                colNames[f['code']] = {"name": f['name'], "type": f['type']}
                cols.append(f['code'])

        c = 0

        try:
            # TODO: implement start/limit rather than fixed limit
            q = "MATCH (r:Repository)--(t:SchemaType)--(n:Data) WHERE ID(r)={repo_id} AND ID(t)={type_id} RETURN n SKIP {start}"
            q_values = {
                "repo_id": repo_id,
                "type_id": type_info["type_id"],
                "start": start
            }
            if limit is not None:
                q = q + " LIMIT {limit}"
                q_values['limit'] = limit

            result = db.run(q, q_values)
            if result is not None:
                for data in result:
                    d = data.items()[0][1].properties

                    for x in d:
                        if (x + '_preview_path') in d:
                            d[x + '_preview_path'] = '<img src="/' + str(
                                d[x + '_preview_path']) + '"/>'
                    nodes.append(d)
                    c = c + 1

            return {
                "data": nodes,
                "columns": cols,
                "columnNames": colNames,
                "type_id": type_info["type_id"],
                "repo_id": repo_id,
                "start": start,
                "limit": limit,
                "count": c
            }
        except Exception as e:
            return {
                "data": [],
                "columns": [],
                "type_id": type_info["type_id"],
                "repo_id": repo_id,
                "start": start,
                "limit": limit,
                "count": 0
            }
Ejemplo n.º 33
0
def repoList():
    try:
        return makeResponse(payload=RepoManager.getAll())
    except DbError as e:
        return makeResponse(error=e)
Ejemplo n.º 34
0
def repoList():
    try:
        return makeResponse(payload=RepoManager.getAll())
    except DbError as e:
        return makeResponse(error=e)