Exemplo n.º 1
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()
Exemplo n.º 2
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()
Exemplo n.º 3
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()
Exemplo n.º 4
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()
Exemplo n.º 5
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()
Exemplo n.º 6
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()
Exemplo n.º 7
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()
Exemplo n.º 8
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()
Exemplo n.º 9
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()
Exemplo n.º 10
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()
Exemplo n.º 11
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()
Exemplo n.º 12
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()