2021-03-29 13:25:15 +02:00
|
|
|
from typing import Optional
|
|
|
|
|
2021-08-05 14:21:42 +02:00
|
|
|
from cpl_core.application import ApplicationABC
|
|
|
|
from cpl_core.configuration import ConfigurationABC
|
|
|
|
from cpl_core.console import Console
|
|
|
|
from cpl_core.dependency_injection import ServiceProviderABC
|
|
|
|
from cpl_core.logging import LoggerABC
|
2021-03-29 14:18:58 +02:00
|
|
|
from model.user_repo_abc import UserRepoABC
|
2021-03-29 14:29:17 +02:00
|
|
|
from model.user_repo import UserRepo
|
2021-03-29 13:25:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Application(ApplicationABC):
|
|
|
|
|
|
|
|
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
|
|
|
|
ApplicationABC.__init__(self, config, services)
|
|
|
|
|
|
|
|
self._logger: Optional[LoggerABC] = None
|
|
|
|
|
|
|
|
def configure(self):
|
|
|
|
self._logger = self._services.get_service(LoggerABC)
|
|
|
|
|
|
|
|
def main(self):
|
|
|
|
self._logger.header(f'{self._configuration.environment.application_name}:')
|
|
|
|
self._logger.debug(__name__, f'Host: {self._configuration.environment.host_name}')
|
|
|
|
self._logger.debug(__name__, f'Environment: {self._configuration.environment.environment_name}')
|
|
|
|
self._logger.debug(__name__, f'Customer: {self._configuration.environment.customer}')
|
2021-03-29 14:29:17 +02:00
|
|
|
|
|
|
|
user_repo: UserRepo = self._services.get_service(UserRepoABC)
|
2021-11-30 11:10:36 +01:00
|
|
|
if len(user_repo.get_users()) == 0:
|
|
|
|
user_repo.add_test_user()
|
|
|
|
|
2021-03-29 14:29:17 +02:00
|
|
|
Console.write_line('Users:')
|
|
|
|
for user in user_repo.get_users():
|
2021-11-30 11:10:36 +01:00
|
|
|
Console.write_line(user.UserId, user.Name, user.City)
|
2021-03-29 14:29:17 +02:00
|
|
|
|
|
|
|
Console.write_line('Cities:')
|
|
|
|
for city in user_repo.get_cities():
|
2021-11-29 20:55:43 +01:00
|
|
|
Console.write_line(city.CityId, city.Name, city.ZIP)
|