Esempio n. 1
0
    def get_configuration():
        isConfigurationNull = GlobalConfiguration.configuration is not None
        configurationLength = GlobalConfiguration.configuration.__len__()

        if isConfigurationNull and configurationLength > 0:
            return GlobalConfiguration.configuration

        customerServiceUrl = os.environ.get(CUSTOMER_SERVICE_URL, None)

        if customerServiceUrl is None:
            raise ErrorProvider.get_error(ERRORS, 1)

        mongoServer = os.environ.get(MONGO_SERVER, None)

        if mongoServer is None:
            raise ErrorProvider.get_error(ERRORS, 2)

        mongoPort = os.environ.get(MONGO_PORT, None)

        if mongoPort is None:
            raise ErrorProvider.get_error(ERRORS, 3)

        mongoDB = os.environ.get(MONGO_DB, None)

        if mongoDB is None:
            raise ErrorProvider.get_error(ERRORS, 4)

        GlobalConfiguration.configuration[CUSTOMER_SERVICE_URL] = customerServiceUrl
        GlobalConfiguration.configuration[MONGO_SERVER] = mongoServer
        GlobalConfiguration.configuration[MONGO_PORT] = mongoPort
        GlobalConfiguration.configuration[MONGO_DB] = mongoDB

        return GlobalConfiguration.configuration
Esempio n. 2
0
    def __init__(self, callback):
        threading.Thread.__init__(self)

        if callback is None:
            raise ErrorProvider.get_error(ERRORS, 4)

        self.callback = callback

        configuration = GlobalConfiguration.get_configuration()
        mongoServer = configuration[MONGO_SERVER]

        if mongoServer is None:
            raise ErrorProvider.get_error(ERRORS, 1)

        mongoPort = configuration[MONGO_PORT]

        if mongoPort is None:
            raise ErrorProvider.get_error(ERRORS, 2)

        mongoDB = configuration[MONGO_DB]

        if mongoDB is None:
            raise ErrorProvider.get_error(ERRORS, 3)

        self.mongoServer = mongoServer
        self.mongoPort = mongoPort
        self.mongoDB = mongoDB
    def __init__(self, customerService: CustomerService, orderService: OrderService):
        if customerService is None:
            raise ErrorProvider.get_error(ERRORS, 2)

        self.customerService = customerService

        if orderService is None:
            raise ErrorProvider.get_error(ERRORS, 3)

        self.orderService = orderService
Esempio n. 4
0
    def __init__(self, callback):
        threading.Thread.__init__(self)

        if callback is None:
            raise ErrorProvider.get_error(ERRORS, 1)

        self.callback = callback

        configuration = GlobalConfiguration.get_configuration()
        customerServiceUrl = configuration[CUSTOMER_SERVICE_URL]

        if customerServiceUrl is None:
            raise ErrorProvider.get_error(ERRORS, 2)

        self.customerServiceUrl = customerServiceUrl
Esempio n. 5
0
    def transform(dictionary):
        if dictionary is None:
            raise ErrorProvider.get_error(ERRORS, 1)

        order = Order(dictionary["orderId"], dictionary["orderDate"],
                      dictionary["customer"], dictionary["billingAddress"], dictionary["amount"])

        return order
    def transform(dictionary):
        if dictionary is None:
            raise ErrorProvider.get_error(ERRORS, 1)

        customer = Customer(dictionary["id"], dictionary["name"],
                            dictionary["address"], dictionary["credit"],
                            dictionary["status"], dictionary["remarks"])

        return customer
    def __init__(self):
        configuration = GlobalConfiguration.get_configuration()
        customerServiceUrl = configuration[
            GlobalConstants.CUSTOMER_SERVICE_URL]

        if customerServiceUrl is None:
            raise ErrorProvider.get_error(ERRORS, 2)

        self.customerServiceUrl = customerServiceUrl
    def __init__(self, customerService: CustomerService,
                 orderService: OrderService):
        serviceStatus = customerService is not None and \
            orderService is not None

        if not (serviceStatus):
            raise ErrorProvider.get_error(ERRORS, 2)

        self.customerService = customerService
        self.orderService = orderService
    def process(self, callback):
        if callback is None:
            raise ErrorProvider.get_error(ERRORS, 1)

        self.customerService.start()
        self.customerService.join()

        self.orderService.start()
        self.orderService.join()

        callback()
Esempio n. 10
0
    def get_customer_table(customers):
        if customers is None:
            raise ErrorProvider.get_error(1)

        table = PrettyTable(["Id", "Name", "Address", "Credit", "Status"])

        for customer in customers:
            table.add_row([
                customer.id, customer.name, customer.address, customer.credit,
                customer.status
            ])

        return table
    def __init__(self, callback):
        threading.Thread.__init__(self)

        if callback is None:
            raise ErrorProvider.get_error(ERRORS, 1)

        self.callback = callback

        configuration = GlobalConfiguration.get_configuration()
        mongoServer = configuration[GlobalConstants.MONGO_SERVER]
        mongoPort = configuration[GlobalConstants.MONGO_PORT]
        mongoDB = configuration[GlobalConstants.MONGO_DB]

        isMongoConfigurationValid = mongoServer is not None and \
            mongoPort is not None and mongoDB is not None

        if not(isMongoConfigurationValid):
            raise ErrorProvider.get_error(ERRORS, 2)

        self.mongoServer = mongoServer
        self.mongoPort = int(mongoPort)
        self.mongoDB = mongoDB
Esempio n. 12
0
    def get_orders_table(orders):
        if orders is None:
            raise ErrorProvider.get_error(ERRORS, 2)

        table = PrettyTable(
            ["Order #", "Order Date", "Customer", "Address", "Amount"])

        for order in orders:
            table.add_row([
                order.orderId, order.orderDate, order.customer,
                order.billingAddress, order.amount
            ])

        return table
Esempio n. 13
0
    def __init__(self):
        configuration = GlobalConfiguration.get_configuration()
        mongoServer = configuration[GlobalConstants.MONGO_SERVER]
        mongoPort = configuration[GlobalConstants.MONGO_PORT]
        mongoDB = configuration[GlobalConstants.MONGO_DB]

        isMongoConfigurationValid = mongoServer is not None and \
            mongoPort is not None and mongoDB is not None

        if not(isMongoConfigurationValid):
            raise ErrorProvider.get_error(ERRORS, 2)

        self.mongoServer = mongoServer
        self.mongoPort = int(mongoPort)
        self.mongoDB = mongoDB