Ejemplo n.º 1
0
    def getBodyBeanList(self):
        cursor.execute("SELECT * FROM body")
        bodyList = cursor.fetchall()
        bodyBeanList = list()

        for body in bodyList:
            bodyBean = BodyBean(body.get('id'), body.get('name'))
            bodyBeanList.append(bodyBean)

        return bodyBeanList
Ejemplo n.º 2
0
    def getRoomBeanList(self):
        cursor.execute("SELECT * FROM room")
        roomList = cursor.fetchall()
        roomBeanList = list()

        for room in roomList:
            roomBean = RoomBean(
                room.get('id'),
                room.get('name'),
            )
            roomBeanList.append(roomBean)

        return roomBeanList
Ejemplo n.º 3
0
    def getBadgerBeanList(self):
        cursor.execute("SELECT * FROM badger")
        badgerList = cursor.fetchall()
        badgerBeanList = list()
        bodyModel = BodyModel()

        for badger in badgerList:
            badgerBean = BadgerBean(
                badger.get('id'), badger.get('firstname'),
                badger.get('lastname'), badger.get('qr_id'),
                bodyModel.getBodyBeanById(badger.get('body_id')))
            badgerBeanList.append(badgerBean)

        return badgerBeanList
Ejemplo n.º 4
0
    def getBadgerListByQrId(self, qrId):
        query = ("SELECT * " "FROM badger " "WHERE badger.qr_id = (%s) ")
        cursor.execute(query, (qrId))
        badgerList = cursor.fetchall()
        badgerBeanList = list()
        bodyModel = BodyModel()

        for badger in badgerList:
            badgerBean = BadgerBean(
                badger.get('id'), badger.get('firstname'),
                badger.get('lastname'), badger.get('qr_id'),
                bodyModel.getBodyNameById(badger.get('body_id')))
            badgerBeanList.append(badgerBean)

        return badgerBeanList
Ejemplo n.º 5
0
    def getPlanningBeanList(self):
        cursor.execute("SELECT * FROM planning")
        planningList = cursor.fetchall()
        planningBeanList = list()
        bodyModel = BodyModel()
        roomModel = RoomModel()

        for planning in planningList:
            planningBean = PlanningBean(
                planning.get('date'),
                bodyModel.getBodyBeanById(planning.get('body_id')),
                roomModel.getRoomBeanById(planning.get('room_id')))
            planningBeanList.append(planningBean)

        return planningBeanList
Ejemplo n.º 6
0
    def getPresenceBeanList(self):
        cursor.execute("SELECT * FROM presence")
        presenceList = cursor.fetchall()
        presenceBeanList = list()
        badgerModel = BadgerModel()
        roomModel = RoomModel()

        for presence in presenceList:
            presenceBean = PresenceBean(
                badgerModel.getBadgerBeanById(presence.get('badger_id')),
                roomModel.getRoomBeanById(presence.get('room_id')),
                presence.get('morning_date'), presence.get('afternoon_date'))
            presenceBeanList.append(presenceBean)

        return presenceBeanList
Ejemplo n.º 7
0
    def getPlanningBeanListByBodyIdAndRoomId(self, bodyId, roomId):
        query = ("SELECT * "
                 "FROM planning "
                 "WHERE body_id = (%s) "
                 "AND  room_id = (%s) ")
        cursor.execute(query, (bodyId, roomId))
        planningList = cursor.fetchall()
        planningBeanList = list()
        bodyModel = BodyModel()
        roomModel = RoomModel()

        for planning in planningList:
            planningBean = PlanningBean(
                planning.get('date'),
                bodyModel.getBodyBeanById(planning.get('body_id')),
                roomModel.getRoomBeanById(planning.get('room_id')))
            planningBeanList.append(planningBean)

        return planningBeanList
Ejemplo n.º 8
0
    def getPresenceBeanListByDateAndRoomId(self, date, roomId):
        query = ("SELECT * "
                 "FROM presence "
                 "WHERE room_id = (%s) "
                 "AND (CAST(morning_date AS DATE) = (%s) "
                 "OR CAST(afternoon_date AS DATE) = (%s)) ")
        cursor.execute(query, (roomId, date, date))
        presenceList = cursor.fetchall()
        presenceBeanList = list()
        badgerModel = BadgerModel()
        roomModel = RoomModel()

        for presence in presenceList:
            presenceBean = PresenceBean(
                badgerModel.getBadgerBeanById(presence.get('badger_id')),
                roomModel.getRoomBeanById(presence.get('room_id')),
                presence.get('morning_date'), presence.get('afternoon_date'))
            presenceBeanList.append(presenceBean)

        return presenceBeanList
Ejemplo n.º 9
0
 def getPresenceByBadgerId(self, badgerId):
     query = ("SELECT * " "FROM presence " "WHERE badger_id = (%s) ")
     cursor.execute(query, (badgerId))
     presence = cursor.fetchall()
     return presence