init method

Future<void> init()

Implementation

Future<void> init() async {
  initialized = true;
  this.urlTools = UrlTools(userTools, smd, transaction);
  waterLineDao = WaterLineDao.sep(smdSys, transaction);
  await waterLineDao.init();
  waterLine = WaterLine(waterLineDao, smd, transaction);

  UserDto? currentUserDto;
  try {
    currentUserDto = await userTools.getCurrentUserDto(smd, transaction);
  } on SqlException catch (e) {
    if (e.sqlExceptionEnum == SqlExceptionEnum.ENTRY_NOT_FOUND)
      print("WS $e");
  }
  SimpleEntry writeServerUrl = await urlTools.getServerUrl(WardenType.WRITE_SERVER);
  SimpleEntry readServerUrl;
  if (currentUserDto == null ||
      currentUserDto.warden ==
          WardenType.USER) // Only users use a different server
    readServerUrl = await urlTools.getServerUrl(WardenType.READ_SERVER);
  else
    readServerUrl = writeServerUrl;
  userRowsLimit = await userTools.getConfigurationInteger(
      smd, transaction, ConfigurationNameEnum.ROWS_LIMIT);

  writeClient = Client(writeServerUrl.stringValue, writeServerUrl.intValue,
      UrlTools.C_REST_BASE_URL);
  readClient = Client(readServerUrl.stringValue, readServerUrl.intValue,
      UrlTools.C_REST_BASE_URL);
}