Ejemplo n.º 1
0
    def delete(content_item_id):
        """
        Delete's a Content item with id

        :param content_item_id: The content item id to remove [String, Required]
        :return: True if deleted.
        :return: False if not deleted.
        """

        db_object.query(FacadeContent.REQUEST_DELETE_CONTENT_ITEM,
                        (int(content_item_id), ))
Ejemplo n.º 2
0
    def add(entity):

        # Make sure all pending values are initialized
        entity.replace_all_none_by_empty()

        db_object.query(FacadeContent.REQUEST_INSERT_CONTENT_LIST, (
            entity['title'],
            entity['popularity'],
            entity['director'],
            json.dumps(entity['genre']),
            entity['imdb_score'],
        ))
        db_object.commit_query()
Ejemplo n.º 3
0
    def get_by_login(login):
        """
        Load the user information for the requested login

        :param login: The login of the user wanted [String, Required]
        :return: None if the user has not been found
        :return: Entity of user values if the user has been found
                    user_id: The uuid of the user [String]
                    password: The password associated to this user [String]
                    email: The email associated to this user [String]
                    firstname: The first name of the user [String]
                    lastname: The last name of the user [String]
        """

        cursor = db_object.query(FacadeUser.REQUEST_GET_USER_BY_LOGIN,
                                 (login, ))
        result_set = cursor.fetchall()

        if result_set:
            return Entity({
                'login': result_set[0][0],
                'password': result_set[0][1],
                'uuid': result_set[0][2],
                'firstname': result_set[0][3],
                'lastname': result_set[0][4],
                'email': result_set[0][5]
            })

        return None
Ejemplo n.º 4
0
    def update(content_item_id, entity):
        """
        Update a Content item with id

        :param content_item_id: The content item id to update [String, Required]
        :param entity: The content data to update [String, Required]
        :return: True if deleted.
        :return: False if not deleted.
        """

        db_object.query(FacadeContent.REQUEST_UPDATE_CONTENT_ITEM, (
            entity['title'],
            entity['popularity'],
            entity['director'],
            json.dumps(entity['genre']),
            entity['imdb_score'],
            int(content_item_id),
        ))
Ejemplo n.º 5
0
    def add(entity):
        print("In Dal | FacadeAdmin | add method ..." )

        # Make sure all the optional values are initialized
        entity.add_member_if_not_exist('firstname', None)
        entity.add_member_if_not_exist('lastname', None)
        entity.add_member_if_not_exist('created_on', datetime.now())

        # Make sure all pending values are initialized
        entity.replace_all_none_by_empty()

        db_object.query(FacadeAdmin.REQUEST_INSERT_ADMIN_USER_AUTH, (entity['uuid'],
                                                                     entity['login'],
                                                                     entity['password'],))
        db_object.query(FacadeAdmin.REQUEST_INSERT_ADMIN_USER_INFO, (entity['uuid'],
                                                                     entity['firstname'],
                                                                     entity['lastname'],
                                                                     entity['email'],))
        db_object.commit_query()
Ejemplo n.º 6
0
    def get_content_by_id(content_item_id):
        """
        Verify is a content item with the requested id exist in the database

        :param content_item_id: The content_item_id on which we have to perform the verification [String, Required]
        :return: True if found.
        :return: False if not found.
        """

        cursor = db_object.query(FacadeContent.REQUEST_EXIST_CONTENT_ITEM,
                                 (int(content_item_id), ))
        result_set = cursor.fetchall()
        return result_set
Ejemplo n.º 7
0
    def is_exist_by_login(login):
        """
        Verify is a admin user with the requested login exist in the database

        :param login: The login on which we have to perform the verification [String, Required]
        :return: True if found.
        :return: False if not found.
        """

        cursor = db_object.query(FacadeAdmin.REQUEST_EXIST_ADMIN_USER_BY_LOGIN, (login,))

        result_set = cursor.fetchall()
        db_object.commit_query()
        return result_set
Ejemplo n.º 8
0
    def get_list(search=None):

        query = FacadeContent.REQUEST_CONTENT_LIST

        if search is not None:
            query += " WHERE MATCH(title, genre, director) AGAINST('" + search + "*' IN BOOLEAN MODE ) "

        cursor = db_object.query(query)
        my_list = {}

        result_set = cursor.fetchall()

        for content in result_set:

            my_list[content[0]] = {}
            my_list[content[0]]['title'] = content[1]
            my_list[content[0]]['popularity'] = content[2]
            my_list[content[0]]['director'] = content[3]
            my_list[content[0]]['genre'] = content[4]
            my_list[content[0]]['imdb_score'] = content[5]

        return my_list
Ejemplo n.º 9
0
    def get_content_info_by_id(content_item_id):
        """
        Fetch a Content item with id

        :param content_item_id: The content item id to update [String, Required]
        :return: Entity of content item information.
        """

        cursor = db_object.query(FacadeContent.REQUEST_GET_CONTENT_ITEM,
                                 (content_item_id, ))

        result_set = cursor.fetchall()

        if result_set:
            return Entity({
                'title': result_set[0][0],
                'popularity': float(result_set[0][1]),
                'director': result_set[0][2],
                'genre': result_set[0][3],
                'imdb_score': float(result_set[0][4])
            })
        return None