예제 #1
0
    def add_byonic_user(self, byonic_user: COByonicUser):
        dbsession = None
        try:

            if not isinstance(byonic_user, COByonicUser):
                message = COMLByonicUser.MSG_BYONIC_USER_NOT_VALID + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    byonic_user.identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_400_BAD_REQUEST)

            dbsession = DBConnection().getsession()
            byonic_user.password = hashlib.sha512(byonic_user.password.encode("utf-8")).hexdigest()
            dbsession.add(byonic_user)
            dbsession.commit()

            self.get_logger().info(
                COMLByonicUser.MSG_BYONIC_USER_INSERT_SUCCESS + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    byonic_user.identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLByonicUser.MSG_BYONIC_USER_INSERT_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                byonic_user.identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
예제 #2
0
    def update_intent_topics(self, intent_topics: COTopic):
        dbsession = None
        try:

            if not isinstance(intent_topics, COTopic):
                message = COMLTopic.MSG_TOPIC_NOT_VALID + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    intent_topics.identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message),
                                  message,
                                  status_code=CFException.HTTP_400_BAD_REQUEST)

            dbsession = DBConnection().getsession()
            db_intent_topics: COTopic = dbsession.query(COTopic).get(
                intent_topics.identifier)
            db_intent_topics.identifier = intent_topics.identifier
            db_intent_topics.name = intent_topics.name

            dbsession.commit()

            self.get_logger().info(COMLTopic.MSG_TOPIC_UPDATE_SUCCESS +
                                   COStringLiteral.STR_SEPARATOR_PIPE +
                                   str(intent_topics.identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLTopic.MSG_TOPIC_UPDATE_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                intent_topics.identifier)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
예제 #3
0
    def load_byonic_user(self, identifier: int):
        dbsession = None
        try:
            dbsession = DBConnection().getsession()
            byonic_user: COByonicUser = dbsession.query(COByonicUser).get(identifier)

            if byonic_user is None:
                message = COMLByonicUser.MSG_BYONIC_USER_NOT_FOUND + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_404_NOT_FOUND)

            self.get_logger().info(
                COMLByonicUser.MSG_BYONIC_USER_LOAD_SUCCESS + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    byonic_user.identifier))

        except CFException:
            raise
        except Exception:
            message = COMLByonicUser.MSG_BYONIC_USER_LOAD_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return byonic_user
예제 #4
0
    def add_revenue_range(self, revenue_range: CORevenue):
        dbsession = None
        try:

            if not isinstance(revenue_range, CORevenue):
                message = COMLRevenue.MSG_REVENUE_RANGE_NOT_VALID + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    revenue_range.identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message),
                                  message,
                                  status_code=CFException.HTTP_400_BAD_REQUEST)

            dbsession = DBConnection().getsession()
            dbsession.add(revenue_range)
            dbsession.commit()

            self.get_logger().info(
                COMLRevenue.MSG_REVENUE_RANGE_INSERT_SUCCESS +
                COStringLiteral.STR_SEPARATOR_PIPE +
                str(revenue_range.identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLRevenue.MSG_REVENUE_RANGE_INSERT_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                revenue_range.identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
예제 #5
0
    def load_all(self):
        dbsession = None
        employee_size = dict()
        try:
            dbsession = DBConnection().getsession()
            employee_size_list = dbsession.query(COEmployee).all()

            if employee_size_list is None:
                message = COMLEmployee.MSG_EMPLOYEE_VALUES_NOT_FOUND
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_404_NOT_FOUND)

            for ct in employee_size_list:
                employee_size[ct.get_key()] = ct

            self.get_logger().info(COMLEmployee.MSG_EMPLOYEE_VALUES_LOAD_SUCCESS)

        except CFException:
            raise
        except Exception:
            message = COMLEmployee.MSG_EMPLOYEE_VALUES_LOAD_FAILED
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return employee_size
예제 #6
0
    def load_all(self):
        dbsession = None
        byonic_users = dict()
        try:
            dbsession = DBConnection().getsession()
            byonic_user_list = dbsession.query(COByonicUser).all()
            if byonic_user_list is None:
                message = COMLByonicUser.MSG_BYONIC_USERS_NOT_FOUND
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_404_NOT_FOUND)

            for ct in byonic_user_list:
                byonic_users[ct.get_key()] = ct

            self.get_logger().info(COMLByonicUser.MSG_BYONIC_USERS_LOAD_SUCCESS)

        except CFException:
            raise
        except Exception:
            message = COMLByonicUser.MSG_BYONIC_USERS_LOAD_FAILED
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return byonic_users
예제 #7
0
    def load_revenue_range(self, identifier: int):
        dbsession = None
        try:
            dbsession = DBConnection().getsession()
            revenue_range: CORevenue = dbsession.query(CORevenue).get(
                identifier)

            if revenue_range is None:
                message = COMLRevenue.MSG_REVENUE_RANGE_NOT_FOUND + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message),
                                  message,
                                  status_code=CFException.HTTP_404_NOT_FOUND)

            self.get_logger().info(COMLRevenue.MSG_REVENUE_RANGE_LOAD_SUCCESS +
                                   COStringLiteral.STR_SEPARATOR_PIPE +
                                   str(revenue_range.identifier))

        except CFException:
            raise
        except Exception:
            message = COMLRevenue.MSG_REVENUE_RANGE_LOAD_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return revenue_range
예제 #8
0
    def add_job_level(self, job_level: COJobLevel):
        dbsession = None
        try:

            if not isinstance(job_level, COJobLevel):
                message = COMLJobLevel.MSG_JOB_LEVEL_NOT_VALID + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    job_level.identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message),
                                  message,
                                  status_code=CFException.HTTP_400_BAD_REQUEST)

            dbsession = DBConnection().getsession()
            dbsession.add(job_level)
            dbsession.commit()

            self.get_logger().info(COMLJobLevel.MSG_JOB_LEVEL_INSERT_SUCCESS +
                                   COStringLiteral.STR_SEPARATOR_PIPE +
                                   str(job_level.identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLJobLevel.MSG_JOB_LEVEL_INSERT_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                job_level.identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
예제 #9
0
    def load_all(self):
        dbsession = None
        industry_dict = dict()
        try:
            dbsession = DBConnection().getsession()

            industry_list = dbsession.query(COIndustry).all()

            if industry_list is None:
                message = COMLIndustry.MSG_INDUSTRIES_NOT_FOUND
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_404_NOT_FOUND)

            try:
                for ct in industry_list:
                    for cts in ct:
                        industry_dict[cts.get_key()] = cts
            except TypeError:
                for ct in industry_list:
                    industry_dict[ct.get_key()] = ct

            self.get_logger().info(COMLIndustry.MSG_INDUSTRIES_LOAD_SUCCESS)

        except CFException:
            raise
        except Exception:
            message = COMLIndustry.MSG_INDUSTRIES_LOAD_FAILED
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return industry_dict
예제 #10
0
    def load_all(self):
        dbsession = None
        job_level = dict()
        try:
            dbsession = DBConnection().getsession()
            job_level_list = dbsession.query(COJobLevel).all()

            if job_level_list is None:
                message = COMLJobLevel.MSG_JOB_LEVELS_NOT_FOUND
                self.get_logger().error(message)
                raise CFException(ValueError(message),
                                  message,
                                  status_code=CFException.HTTP_404_NOT_FOUND)

            for ct in job_level_list:
                job_level[ct.get_key()] = ct

            self.get_logger().info(COMLJobLevel.MSG_JOB_LEVELS_LOAD_SUCCESS)

        except CFException:
            raise
        except Exception:
            message = COMLJobLevel.MSG_JOB_LEVELS_LOAD_FAILED
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return job_level
예제 #11
0
    def load_job_level(self, identifier: int):
        dbsession = None
        try:
            dbsession = DBConnection().getsession()
            job_level: COJobLevel = dbsession.query(COJobLevel).get(identifier)

            if job_level is None:
                message = COMLJobLevel.MSG_JOB_LEVEL_NOT_FOUND + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message),
                                  message,
                                  status_code=CFException.HTTP_404_NOT_FOUND)

            self.get_logger().info(COMLJobLevel.MSG_JOB_LEVEL_LOAD_SUCCESS +
                                   COStringLiteral.STR_SEPARATOR_PIPE +
                                   str(job_level.identifier))

        except CFException:
            raise
        except Exception:
            message = COMLJobLevel.MSG_JOB_LEVEL_LOAD_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return job_level
예제 #12
0
    def load_industry(self, identifier: int):
        dbsession = None
        try:
            dbsession = DBConnection().getsession()
            industry: COIndustry = dbsession.query(COIndustry).get(identifier)

            if industry is None:
                message = COMLIndustry.MSG_INDUSTRY_NOT_FOUND + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_404_NOT_FOUND)

            self.get_logger().info(
                COMLIndustry.MSG_INDUSTRY_LOAD_SUCCESS + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    industry.identifier))

        except CFException:
            raise
        except Exception:
            message = COMLIndustry.MSG_INDUSTRY_LOAD_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return industry
예제 #13
0
    def add_employee_size(self, employee_size: COEmployee):
        dbsession = None
        try:

            if not isinstance(employee_size, COEmployee):
                message = COMLEmployee.MSG_EMPLOYEE_VALUE_NOT_VALID + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    employee_size.identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_400_BAD_REQUEST)

            dbsession = DBConnection().getsession()
            dbsession.add(employee_size)
            dbsession.commit()

            self.get_logger().info(
                COMLEmployee.MSG_EMPLOYEE_VALUE_INSERT_SUCCESS + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    employee_size.identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLEmployee.MSG_EMPLOYEE_VALUE_INSERT_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                employee_size.identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
예제 #14
0
    def load_employee_size(self, identifier: int):
        dbsession = None
        try:
            dbsession = DBConnection().getsession()
            employee_size: COEmployee = dbsession.query(COEmployee).get(identifier)

            if employee_size is None:
                message = COMLEmployee.MSG_EMPLOYEE_VALUE_NOT_FOUND + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_404_NOT_FOUND)

            self.get_logger().info(
                COMLEmployee.MSG_EMPLOYEE_VALUE_LOAD_SUCCESS + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    employee_size.identifier))

        except CFException:
            raise
        except Exception:
            message = COMLEmployee.MSG_EMPLOYEE_VALUE_LOAD_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return employee_size
예제 #15
0
    def filter_user(self, org_id: int):
        dbsession = None
        global user_list
        byonic_users = dict()
        try:
            dbsession = DBConnection().getsession()
            byonic_user_list = dbsession.query(COByonicUser)
            print(type(org_id))
            if org_id == str(1):
                byonic_user_list = byonic_user_list

            else:
                byonic_user_list = byonic_user_list.filter(COByonicUser.col_org_id == org_id)

            byonic_user_list = byonic_user_list.all()

            if byonic_user_list is None:
                message = COMLByonicUser.MSG_BYONIC_USERS_NOT_FOUND
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_404_NOT_FOUND)
            print(byonic_user_list)
            for ct in byonic_user_list:
                byonic_users[ct.get_key()] = ct

            self.get_logger().info(COMLByonicUser.MSG_BYONIC_USERS_LOAD_SUCCESS)

        except CFException:
            raise
        except Exception:
            message = COMLByonicUser.MSG_BYONIC_USERS_LOAD_FAILED
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return byonic_users
예제 #16
0
    def load_all(self):
        dbsession = None
        revenue_range_dict = dict()
        try:
            dbsession = DBConnection().getsession()

            revenue_range_list = dbsession.query(CORevenue).all()

            if revenue_range_list is None:
                message = COMLRevenue.MSG_REVENUE_RANGES_NOT_FOUND
                self.get_logger().error(message)
                raise CFException(ValueError(message),
                                  message,
                                  status_code=CFException.HTTP_404_NOT_FOUND)

            try:
                for ct in revenue_range_list:
                    for cts in ct:
                        revenue_range_dict[cts.get_key()] = cts

            except TypeError:
                for ct in revenue_range_list:
                    revenue_range_dict[ct.get_key()] = ct

            self.get_logger().info(COMLRevenue.MSG_REVENUE_RANGES_LOAD_SUCCESS)

        except CFException:
            raise
        except Exception:
            message = COMLRevenue.MSG_REVENUE_RANGES_LOAD_FAILED
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return revenue_range_dict
예제 #17
0
    def login_user(self, mail: str, password: str):
        dbsession = None
        byonic_users = dict()
        try:
            dbsession = DBConnection().getsession()
            password = hashlib.sha512(password.encode("utf-8")).hexdigest()
            byonic_user_list = dbsession.query(COByonicUser).filter(COByonicUser.col_mail
                                                                    == mail). \
                filter(COByonicUser.col_password == password).all()

            if byonic_user_list is None:
                message = COMLByonicUser.MSG_BYONIC_USERS_NOT_FOUND
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_404_NOT_FOUND)

            for ct in byonic_user_list:
                byonic_users[ct.get_key()] = ct

            self.get_logger().info(COMLByonicUser.MSG_BYONIC_USERS_LOAD_SUCCESS)

        except CFException:
            raise
        except Exception:
            message = COMLByonicUser.MSG_BYONIC_USERS_LOAD_FAILED
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
        return byonic_users
예제 #18
0
    def add_industry(self, industry: COIndustry):
        dbsession = None
        try:

            if not isinstance(industry, COIndustry):
                message = COMLIndustry.MSG_INDUSTRY_NOT_VALID + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    industry.identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_400_BAD_REQUEST)

            dbsession = DBConnection().getsession()
            dbsession.add(industry)
            dbsession.commit()

            self.get_logger().info(
                COMLIndustry.MSG_INDUSTRY_INSERT_SUCCESS + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    industry.identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLIndustry.MSG_INDUSTRY_INSERT_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    industry.identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
예제 #19
0
    def UPDATE_NEW_PASSWORD(self):
        id = self.id
        conn = DBConnection().getEngine()
        metadata = DBConnection().metadata()
        byonic_user = Table('tbl_byonic_user', metadata, autoload=True, autoload_with=conn)
        query = select([byonic_user.columns.user_role_id, byonic_user.columns.user_first_name]).where(byonic_user.columns.user_role_id==1)
        ResultProxy = conn.execute(query).fetchall()
        # ResultSet = pd.read_sql(query, con=conn).to_json(orient='records')
        conn.close()
        # print(ResultProxy.fetchall())

        values = ['user_role_id', 'user_first_name']
        dictionary = []
        print(ResultProxy)
        for i in range(len(ResultProxy)):
            files = dict(zip(values, ResultProxy[i]))
            dictionary.append(files)

        campaign_view = {'campaign_view': dictionary}
        print(campaign_view)
        return
예제 #20
0
    def update_byonic_user(self, byonic_user: COByonicUser):
        dbsession = None
        try:

            if not isinstance(byonic_user, COByonicUser):
                message = COMLByonicUser.MSG_BYONIC_USER_NOT_VALID + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    byonic_user.identifier)
                self.get_logger().error(message)
                raise CFException(ValueError(message), message, status_code=CFException.HTTP_400_BAD_REQUEST)

            dbsession = DBConnection().getsession()
            db_byonic_user: COByonicUser = dbsession.query(COByonicUser).get(byonic_user.identifier)
            db_byonic_user.identifier = byonic_user.identifier
            db_byonic_user.reset = byonic_user.reset
            db_byonic_user.user_first_name = byonic_user.user_first_name
            db_byonic_user.user_last_name = byonic_user.user_last_name
            db_byonic_user.email = byonic_user.email
            db_byonic_user.password = hashlib.sha512(byonic_user.password.encode("utf-8")).hexdigest()
            db_byonic_user.organisation_id = byonic_user.organisation_id
            db_byonic_user.role_id = byonic_user.role_id
            db_byonic_user.status = byonic_user.status

            dbsession.commit()

            self.get_logger().info(
                COMLByonicUser.MSG_BYONIC_USER_UPDATE_SUCCESS + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    byonic_user.identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLByonicUser.MSG_BYONIC_USER_UPDATE_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                byonic_user.identifier)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
예제 #21
0
    def delete_employee_size(self, identifier: int):
        dbsession = None
        try:
            dbsession = DBConnection().getsession()
            db_employee_size: COEmployee = dbsession.query(COEmployee).get(identifier)
            dbsession.delete(db_employee_size)
            dbsession.commit()

            self.get_logger().info(
                COMLEmployee.MSG_EMPLOYEE_VALUE_DELETE_SUCCESS + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLEmployee.MSG_EMPLOYEE_VALUE_DELETE_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
예제 #22
0
    def delete_industry(self, identifier: int):
        dbsession = None
        try:
            dbsession = DBConnection().getsession()
            db_industry: COIndustry = dbsession.query(COIndustry).get(identifier)
            dbsession.delete(db_industry)
            dbsession.commit()

            self.get_logger().info(
                COMLIndustry.MSG_INDUSTRY_DELETE_SUCCESS + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLIndustry.MSG_INDUSTRY_DELETE_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
예제 #23
0
    def delete_byonic_user(self, identifier: int):
        dbsession = None
        try:
            dbsession = DBConnection().getsession()
            db_byonic_user: COByonicUser = dbsession.query(COByonicUser).get(identifier)
            dbsession.delete(db_byonic_user)
            dbsession.commit()

            self.get_logger().info(
                COMLByonicUser.MSG_BYONIC_USER_DELETE_SUCCESS + COStringLiteral.STR_SEPARATOR_PIPE + str(
                    identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLByonicUser.MSG_BYONIC_USER_DELETE_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
예제 #24
0
    def delete_job_level(self, identifier: int):
        dbsession = None
        try:
            dbsession = DBConnection().getsession()
            db_job_level: COJobLevel = dbsession.query(COJobLevel).get(
                identifier)
            dbsession.delete(db_job_level)
            dbsession.commit()

            self.get_logger().info(COMLJobLevel.MSG_JOB_LEVEL_DELETE_SUCCESS +
                                   COStringLiteral.STR_SEPARATOR_PIPE +
                                   str(identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLJobLevel.MSG_JOB_LEVEL_DELETE_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()
예제 #25
0
    def delete_revenue_range(self, identifier: int):
        dbsession = None
        try:
            dbsession = DBConnection().getsession()
            db_revenue_range: CORevenue = dbsession.query(CORevenue).get(
                identifier)
            dbsession.delete(db_revenue_range)
            dbsession.commit()

            self.get_logger().info(
                COMLRevenue.MSG_REVENUE_RANGE_DELETE_SUCCESS +
                COStringLiteral.STR_SEPARATOR_PIPE + str(identifier))

        except CFException:
            dbsession.rollback()
            raise
        except Exception:
            dbsession.rollback()
            message = COMLRevenue.MSG_REVENUE_RANGE_DELETE_FAILED + COStringLiteral.STR_SEPARATOR_PIPE + str(
                identifier)
            self.get_logger().error(message)
            raise CFException(Exception(message), message)
        finally:
            dbsession.close()