Exemplo n.º 1
0
 def addMember(self, gID, pID):
     dao = GroupDAO()
     pid, gid = dao.addMember(pID, gID)
     result = {}
     result['pid'] = pid
     result['gid'] = gid
     dao.closeDB()
     return jsonify(Addition=result), 201
Exemplo n.º 2
0
 def getMessagesByGroupID(self, gID):
     dao = GroupDAO()
     if not dao.getGroupById(gID):
         dao.closeDB()
         return jsonify(Error="Group NOT FOUND"), 404
     message_list = dao.getMessagesByGroupID(gID)
     if not message_list:
         dao.closeDB()
         return jsonify(Error="Message NOT FOUND"), 404
     results = []
     for row in message_list:
         result = mapMessageInfoToDict(row)
         results.append(result)
     dao.closeDB()
     return jsonify(Message=results)
Exemplo n.º 3
0
 def getPeopleByGroupID(self, gID):
     dao = GroupDAO()
     if not dao.getGroupById(gID):
         dao.closeDB()
         return jsonify(Error="Group NOT FOUND"), 404
     person_list = dao.getPeopleByGroupID(gID)
     results = []
     for row in person_list:
         result = mapPersonToDict(row)
         results.append(result)
     dao.closeDB()
     return jsonify(Person=results)
Exemplo n.º 4
0
 def getGroupById(self, gid):
     dao = GroupDAO()
     result = dao.getGroupById(gid)
     if result is None:
         dao.closeDB()
         return jsonify(Error="Group NOT FOUND"), 404
     else:
         mapped = mapGroupToDict(result)
         dao.closeDB()
         return jsonify(Group=mapped)
Exemplo n.º 5
0
 def getAllGroups(self):
     dao = GroupDAO()
     group_list = dao.getAllGroups()
     if not group_list:
         dao.closeDB()
         return jsonify(Error="Group NOT FOUND"), 404
     result_list = []
     for row in group_list:
         result = mapGroupToDict(row)
         result_list.append(result)
     dao.closeDB()
     return jsonify(Group=result_list)
Exemplo n.º 6
0
 def getMessagesPostedByPersoninGroupID(self, mID, gID):
     dao = MessageDAO()
     dao1 = GroupDAO()
     results = []
     if not dao.getMessageById(mID):
         dao.closeDB()
         dao1.closeDB()
         return jsonify(Error="Message NOT FOUND"), 404
     if not dao1.getGroupById(gID):
         dao.closeDB()
         dao1.closeDB()
         return jsonify(Error="Group NOT FOUND"), 404
     message_list = dao.getMessagesPostedByPersoninGroupID(mID, gID)
     for row in message_list:
         result = mapMessageToDict(row)
         results.append(result)
     dao.closeDB()
     dao1.closeDB()
     return jsonify(Messages=results)
Exemplo n.º 7
0
    def getOwnerByGroupId(self, gID):
        dao = GroupDAO()
        result = dao.getOwnerByGroupId(gID)
        if result is None:
            dao.closeDB()
            return jsonify(Error="Group NOT FOUND"), 404

        mapperResult = {}
        mapperResult['pID'] = result[0]
        mapperResult['username'] = result[1]
        mapperResult['pFirstName'] = result[2]
        mapperResult['pLastName'] = result[3]
        mapperResult['pPhone'] = result[4]
        mapperResult['pEmail'] = result[5]
        dao.closeDB()
        return jsonify(Person=mapperResult)
Exemplo n.º 8
0
 def getMessagesWithHashtagInGroupID(self, ht, gID):
     dao = MessageDAO()
     dao1 = GroupDAO()
     dao2 = HashTagDAO()
     results = []
     if not dao1.getGroupById(gID):
         dao.closeDB()
         dao1.closeDB()
         dao2.closeDB()
         return jsonify(Error="Group NOT FOUND"), 404
     if not dao2.getMessageByHashTag(ht):
         dao.closeDB()
         dao1.closeDB()
         dao2.closeDB()
         return jsonify(Error="HashTag NOT FOUND"), 404
     message_list = dao.getMessagesWithHashtagInGroupID(ht, gID)
     for row in message_list:
         result = mapMessageInfoToDict(row)
         results.append(result)
     dao.closeDB()
     dao1.closeDB()
     dao2.closeDB()
     return jsonify(Messages=results)
Exemplo n.º 9
0
 def getAllOwners(self):
     dao = GroupDAO()
     ownerList = dao.getAllOwners()
     if not ownerList:
         dao.closeDB()
         return jsonify(Error="Owner NOT FOUND"), 404
     result = []
     for r in ownerList:
         mappedResult = {}
         mappedResult['pID'] = r[0]
         mappedResult['username'] = r[1]
         mappedResult['pFirstName'] = r[2]
         mappedResult['pLastName'] = r[3]
         mappedResult['pPhone'] = r[4]
         mappedResult['pEmail'] = r[5]
         result.append(mappedResult)
     dao.closeDB()
     return jsonify(Owner=result)