diff --git a/.github/.DS_Store b/.github/.DS_Store deleted file mode 100644 index f74d0bca..00000000 Binary files a/.github/.DS_Store and /dev/null differ diff --git a/das_client/.gitignore b/das_client/.gitignore index d67b010a..306a60d4 100644 --- a/das_client/.gitignore +++ b/das_client/.gitignore @@ -19,7 +19,6 @@ migrate_working_dir/ .idea/ coverage/ - # The .vscode folder contains launch configuration and tasks you configure in # VS Code which you may wish to be included in version control, so this line # is commented out by default. @@ -52,3 +51,6 @@ app.*.map.json *.gr.dart *.freezed.dart *.mocks.dart + +# FVM Version Cache +.fvm/ \ No newline at end of file diff --git a/das_client/README.md b/das_client/README.md index da4c82fa..f4ebab91 100644 --- a/das_client/README.md +++ b/das_client/README.md @@ -76,6 +76,8 @@ This application uses the code style defined in the [Flutter Wiki][2]. The recommendations are mandatory and should always be followed unless there is a good reason not to do so. However, this must be approved by all developers. +Notable difference: Line length is set to 120 characters. Please adapt your IDE configuration accordingly. + ## Flutter SDK version This app uses [FVM][1] to configure the Flutter SDK version. diff --git a/das_client/integration_test/app_test.dart b/das_client/integration_test/app_test.dart index 0339804c..79db99df 100644 --- a/das_client/integration_test/app_test.dart +++ b/das_client/integration_test/app_test.dart @@ -1,5 +1,5 @@ import 'package:das_client/flavor.dart'; -import 'package:das_client/i18n/i18n.dart'; +import 'package:das_client/app/i18n/i18n.dart'; import 'package:das_client/main.dart'; import 'package:fimber/fimber.dart'; import 'package:flutter_gen/gen_l10n/app_localizations_de.dart'; diff --git a/das_client/integration_test/auth/integrationtest_authenticator.dart b/das_client/integration_test/auth/integrationtest_authenticator.dart index 7991d5da..c9b7c4fd 100644 --- a/das_client/integration_test/auth/integrationtest_authenticator.dart +++ b/das_client/integration_test/auth/integrationtest_authenticator.dart @@ -1,4 +1,4 @@ -import 'package:das_client/auth/authenticator.dart'; +import 'package:das_client/auth/authentication_component.dart'; import 'package:flutter/foundation.dart'; import 'package:sbb_oidc/sbb_oidc.dart'; diff --git a/das_client/integration_test/auth/mqtt_client_user_connector.dart b/das_client/integration_test/auth/mqtt_client_user_connector.dart index 7b700783..918937e7 100644 --- a/das_client/integration_test/auth/mqtt_client_user_connector.dart +++ b/das_client/integration_test/auth/mqtt_client_user_connector.dart @@ -1,4 +1,4 @@ -import 'package:das_client/service/mqtt/mqtt_client_connector.dart'; +import 'package:das_client/mqtt/mqtt_component.dart'; import 'package:fimber/fimber.dart'; import 'package:mqtt_client/mqtt_client.dart'; diff --git a/das_client/integration_test/di.dart b/das_client/integration_test/di.dart index 37cfdb0f..41626da8 100644 --- a/das_client/integration_test/di.dart +++ b/das_client/integration_test/di.dart @@ -1,7 +1,7 @@ -import 'package:das_client/auth/authenticator.dart'; +import 'package:das_client/auth/authentication_component.dart'; import 'package:das_client/di.dart'; import 'package:das_client/flavor.dart'; -import 'package:das_client/service/mqtt/mqtt_client_connector.dart'; +import 'package:das_client/mqtt/mqtt_component.dart'; import 'package:fimber/fimber.dart'; import 'package:get_it/get_it.dart'; @@ -10,6 +10,7 @@ import 'auth/mqtt_client_user_connector.dart'; class IntegrationTestDI { const IntegrationTestDI._(); + static bool _initialized = false; static Future init(Flavor flavor) { @@ -21,11 +22,12 @@ class IntegrationTestDI { GetIt.I.registerTokenSpecProvider(); GetIt.I.registerOidcClient(); _registerIntegrationTestAuthenticator(); - GetIt.I.registerSferaAuthService(); + GetIt.I.registerSferaComponents(); + GetIt.I.registerMqttComponent(); + + GetIt.I.unregister(); _registerMqttClientConnector(); - GetIt.I.registerMqttService(); - GetIt.I.registerRepositories(); - GetIt.I.registerSferaService(); + _initialized = true; } return GetIt.I.allReady(); diff --git a/das_client/integration_test/test/navigation_test.dart b/das_client/integration_test/test/navigation_test.dart index d638eedd..37a69ef9 100644 --- a/das_client/integration_test/test/navigation_test.dart +++ b/das_client/integration_test/test/navigation_test.dart @@ -1,7 +1,7 @@ -import 'package:das_client/pages/journey/journey_page.dart'; -import 'package:das_client/pages/links/links_page.dart'; -import 'package:das_client/pages/profile/profile_page.dart'; -import 'package:das_client/pages/settings/settings_page.dart'; +import 'package:das_client/app/pages/journey/journey_page.dart'; +import 'package:das_client/app/pages/links/links_page.dart'; +import 'package:das_client/app/pages/profile/profile_page.dart'; +import 'package:das_client/app/pages/settings/settings_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/das_client/lib/app.dart b/das_client/lib/app.dart index b33b724f..8c0724bd 100644 --- a/das_client/lib/app.dart +++ b/das_client/lib/app.dart @@ -1,5 +1,5 @@ -import 'package:das_client/i18n/i18n.dart'; -import 'package:das_client/nav/app_router.dart'; +import 'package:das_client/app/i18n/i18n.dart'; +import 'package:das_client/app/nav/app_router.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/bloc/train_journey_cubit.dart b/das_client/lib/app/bloc/train_journey_cubit.dart similarity index 89% rename from das_client/lib/bloc/train_journey_cubit.dart rename to das_client/lib/app/bloc/train_journey_cubit.dart index 506cdd97..2d0f8c93 100644 --- a/das_client/lib/bloc/train_journey_cubit.dart +++ b/das_client/lib/app/bloc/train_journey_cubit.dart @@ -1,10 +1,6 @@ import 'dart:async'; -import 'package:das_client/model/sfera/journey_profile.dart'; -import 'package:das_client/model/sfera/otn_id.dart'; -import 'package:das_client/model/sfera/segment_profile.dart'; -import 'package:das_client/service/sfera/sfera_service.dart'; -import 'package:das_client/service/sfera/sfera_service_state.dart'; +import 'package:das_client/sfera/sfera_component.dart'; import 'package:das_client/util/error_code.dart'; import 'package:fimber/fimber.dart'; import 'package:flutter/material.dart'; @@ -83,7 +79,8 @@ class TrainJourneyCubit extends Cubit { if (state is BaseTrainJourneyState) { Fimber.i('Reseting TrainJourney cubit in state $state'); emit(SelectingTrainJourneyState( - trainNumber: (state as BaseTrainJourneyState).trainNumber, company: (state as BaseTrainJourneyState).company)); + trainNumber: (state as BaseTrainJourneyState).trainNumber, + company: (state as BaseTrainJourneyState).company)); } } } diff --git a/das_client/lib/bloc/train_journey_state.dart b/das_client/lib/app/bloc/train_journey_state.dart similarity index 100% rename from das_client/lib/bloc/train_journey_state.dart rename to das_client/lib/app/bloc/train_journey_state.dart diff --git a/das_client/lib/i18n/i18n.dart b/das_client/lib/app/i18n/i18n.dart similarity index 88% rename from das_client/lib/i18n/i18n.dart rename to das_client/lib/app/i18n/i18n.dart index 1f9b9af7..2f8f0f63 100644 --- a/das_client/lib/i18n/i18n.dart +++ b/das_client/lib/app/i18n/i18n.dart @@ -3,7 +3,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; export 'package:flutter_gen/gen_l10n/app_localizations.dart'; -export 'package:das_client/i18n/src/build_context_x.dart'; +export 'package:das_client/app/i18n/src/build_context_x.dart'; const localizationDelegates = >[ AppLocalizations.delegate, diff --git a/das_client/lib/i18n/src/build_context_x.dart b/das_client/lib/app/i18n/src/build_context_x.dart similarity index 79% rename from das_client/lib/i18n/src/build_context_x.dart rename to das_client/lib/app/i18n/src/build_context_x.dart index af50c86b..c5f7655f 100644 --- a/das_client/lib/i18n/src/build_context_x.dart +++ b/das_client/lib/app/i18n/src/build_context_x.dart @@ -1,4 +1,4 @@ -import 'package:das_client/i18n/i18n.dart'; +import 'package:das_client/app/i18n/i18n.dart'; import 'package:flutter/widgets.dart'; extension BuildContextX on BuildContext { diff --git a/das_client/lib/nav/app_router.dart b/das_client/lib/app/nav/app_router.dart similarity index 69% rename from das_client/lib/nav/app_router.dart rename to das_client/lib/app/nav/app_router.dart index c38a0756..47892072 100644 --- a/das_client/lib/nav/app_router.dart +++ b/das_client/lib/app/nav/app_router.dart @@ -1,10 +1,10 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/pages/links/links_page.dart'; -import 'package:das_client/pages/profile/profile_page.dart'; -import 'package:das_client/pages/login/login_page.dart'; -import 'package:das_client/pages/login/splash_page.dart'; -import 'package:das_client/pages/settings/settings_page.dart'; -import 'package:das_client/pages/journey/journey_page.dart'; +import 'package:das_client/app/pages/links/links_page.dart'; +import 'package:das_client/app/pages/profile/profile_page.dart'; +import 'package:das_client/app/pages/login/login_page.dart'; +import 'package:das_client/app/pages/login/splash_page.dart'; +import 'package:das_client/app/pages/settings/settings_page.dart'; +import 'package:das_client/app/pages/journey/journey_page.dart'; part 'app_router.gr.dart'; diff --git a/das_client/lib/nav/das_navigation_drawer.dart b/das_client/lib/app/nav/das_navigation_drawer.dart similarity index 92% rename from das_client/lib/nav/das_navigation_drawer.dart rename to das_client/lib/app/nav/das_navigation_drawer.dart index 699bd477..dbdc3832 100644 --- a/das_client/lib/nav/das_navigation_drawer.dart +++ b/das_client/lib/app/nav/das_navigation_drawer.dart @@ -1,8 +1,8 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/i18n/i18n.dart'; -import 'package:das_client/nav/app_router.dart'; -import 'package:das_client/widgets/app_version_text.dart'; -import 'package:das_client/widgets/device_id_text.dart'; +import 'package:das_client/app/i18n/i18n.dart'; +import 'package:das_client/app/nav/app_router.dart'; +import 'package:das_client/app/widgets/app_version_text.dart'; +import 'package:das_client/app/widgets/device_id_text.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/pages/journey/journey_page.dart b/das_client/lib/app/pages/journey/journey_page.dart similarity index 80% rename from das_client/lib/pages/journey/journey_page.dart rename to das_client/lib/app/pages/journey/journey_page.dart index 9785e920..e8c5ecc5 100644 --- a/das_client/lib/pages/journey/journey_page.dart +++ b/das_client/lib/app/pages/journey/journey_page.dart @@ -1,12 +1,12 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/auth/auth_cubit.dart'; -import 'package:das_client/bloc/train_journey_cubit.dart'; +import 'package:das_client/auth/authentication_component.dart'; +import 'package:das_client/app/bloc/train_journey_cubit.dart'; import 'package:das_client/di.dart'; -import 'package:das_client/i18n/i18n.dart'; -import 'package:das_client/nav/app_router.dart'; -import 'package:das_client/nav/das_navigation_drawer.dart'; -import 'package:das_client/pages/journey/train_journey/train_journey_overview.dart'; -import 'package:das_client/pages/journey/train_selection/train_selection.dart'; +import 'package:das_client/app/i18n/i18n.dart'; +import 'package:das_client/app/nav/app_router.dart'; +import 'package:das_client/app/nav/das_navigation_drawer.dart'; +import 'package:das_client/app/pages/journey/train_journey/train_journey_overview.dart'; +import 'package:das_client/app/pages/journey/train_selection/train_selection.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/das_client/lib/pages/journey/train_journey/train_journey_overview.dart b/das_client/lib/app/pages/journey/train_journey/train_journey_overview.dart similarity index 66% rename from das_client/lib/pages/journey/train_journey/train_journey_overview.dart rename to das_client/lib/app/pages/journey/train_journey/train_journey_overview.dart index 6c2d63cd..9427d507 100644 --- a/das_client/lib/pages/journey/train_journey/train_journey_overview.dart +++ b/das_client/lib/app/pages/journey/train_journey/train_journey_overview.dart @@ -1,6 +1,6 @@ -import 'package:das_client/pages/journey/train_journey/widgets/header/adl_notification.dart'; -import 'package:das_client/pages/journey/train_journey/widgets/header/header.dart'; -import 'package:das_client/pages/journey/train_journey/widgets/train_journey.dart'; +import 'package:das_client/app/pages/journey/train_journey/widgets/header/adl_notification.dart'; +import 'package:das_client/app/pages/journey/train_journey/widgets/header/header.dart'; +import 'package:das_client/app/pages/journey/train_journey/widgets/train_journey.dart'; import 'package:flutter/material.dart'; // TODO: handle extraLarge font sizes (diff to figma) globally. diff --git a/das_client/lib/pages/journey/train_journey/widgets/header/adl_notification.dart b/das_client/lib/app/pages/journey/train_journey/widgets/header/adl_notification.dart similarity index 95% rename from das_client/lib/pages/journey/train_journey/widgets/header/adl_notification.dart rename to das_client/lib/app/pages/journey/train_journey/widgets/header/adl_notification.dart index f16b01e8..1eaf9ce9 100644 --- a/das_client/lib/pages/journey/train_journey/widgets/header/adl_notification.dart +++ b/das_client/lib/app/pages/journey/train_journey/widgets/header/adl_notification.dart @@ -1,4 +1,4 @@ -import 'package:das_client/i18n/i18n.dart'; +import 'package:das_client/app/i18n/i18n.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/pages/journey/train_journey/widgets/header/departure_authorization.dart b/das_client/lib/app/pages/journey/train_journey/widgets/header/departure_authorization.dart similarity index 100% rename from das_client/lib/pages/journey/train_journey/widgets/header/departure_authorization.dart rename to das_client/lib/app/pages/journey/train_journey/widgets/header/departure_authorization.dart diff --git a/das_client/lib/pages/journey/train_journey/widgets/header/header.dart b/das_client/lib/app/pages/journey/train_journey/widgets/header/header.dart similarity index 78% rename from das_client/lib/pages/journey/train_journey/widgets/header/header.dart rename to das_client/lib/app/pages/journey/train_journey/widgets/header/header.dart index 1b219bbd..b1629fcb 100644 --- a/das_client/lib/pages/journey/train_journey/widgets/header/header.dart +++ b/das_client/lib/app/pages/journey/train_journey/widgets/header/header.dart @@ -1,5 +1,5 @@ -import 'package:das_client/pages/journey/train_journey/widgets/header/main_container.dart'; -import 'package:das_client/pages/journey/train_journey/widgets/header/time_container.dart'; +import 'package:das_client/app/pages/journey/train_journey/widgets/header/main_container.dart'; +import 'package:das_client/app/pages/journey/train_journey/widgets/header/time_container.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/pages/journey/train_journey/widgets/header/main_container.dart b/das_client/lib/app/pages/journey/train_journey/widgets/header/main_container.dart similarity index 89% rename from das_client/lib/pages/journey/train_journey/widgets/header/main_container.dart rename to das_client/lib/app/pages/journey/train_journey/widgets/header/main_container.dart index e2d71e74..9017efbf 100644 --- a/das_client/lib/pages/journey/train_journey/widgets/header/main_container.dart +++ b/das_client/lib/app/pages/journey/train_journey/widgets/header/main_container.dart @@ -1,6 +1,6 @@ -import 'package:das_client/pages/journey/train_journey/widgets/header/departure_authorization.dart'; -import 'package:das_client/pages/journey/train_journey/widgets/header/radio_channel.dart'; -import 'package:das_client/util/widget_extensions.dart'; +import 'package:das_client/app/pages/journey/train_journey/widgets/header/departure_authorization.dart'; +import 'package:das_client/app/pages/journey/train_journey/widgets/header/radio_channel.dart'; +import 'package:das_client/app/widgets/widget_extensions.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/pages/journey/train_journey/widgets/header/radio_channel.dart b/das_client/lib/app/pages/journey/train_journey/widgets/header/radio_channel.dart similarity index 100% rename from das_client/lib/pages/journey/train_journey/widgets/header/radio_channel.dart rename to das_client/lib/app/pages/journey/train_journey/widgets/header/radio_channel.dart diff --git a/das_client/lib/pages/journey/train_journey/widgets/header/time_container.dart b/das_client/lib/app/pages/journey/train_journey/widgets/header/time_container.dart similarity index 100% rename from das_client/lib/pages/journey/train_journey/widgets/header/time_container.dart rename to das_client/lib/app/pages/journey/train_journey/widgets/header/time_container.dart diff --git a/das_client/lib/pages/journey/train_journey/widgets/train_journey.dart b/das_client/lib/app/pages/journey/train_journey/widgets/train_journey.dart similarity index 65% rename from das_client/lib/pages/journey/train_journey/widgets/train_journey.dart rename to das_client/lib/app/pages/journey/train_journey/widgets/train_journey.dart index 88b454d8..37daff19 100644 --- a/das_client/lib/pages/journey/train_journey/widgets/train_journey.dart +++ b/das_client/lib/app/pages/journey/train_journey/widgets/train_journey.dart @@ -1,9 +1,5 @@ -import 'package:das_client/bloc/train_journey_cubit.dart'; -import 'package:das_client/model/sfera/journey_profile.dart'; -import 'package:das_client/model/sfera/segment_profile.dart'; -import 'package:das_client/model/sfera/timing_point.dart'; -import 'package:das_client/model/sfera/timing_point_constraints.dart'; -import 'package:das_client/model/sfera/tp_id_reference.dart'; +import 'package:das_client/app/bloc/train_journey_cubit.dart'; +import 'package:das_client/sfera/sfera_component.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; import 'package:rxdart/rxdart.dart'; @@ -16,8 +12,7 @@ class TrainJourney extends StatelessWidget { final bloc = context.trainJourneyCubit; return StreamBuilder>( - stream: - CombineLatestStream.list([bloc.journeyStream, bloc.segmentStream]), + stream: CombineLatestStream.list([bloc.journeyStream, bloc.segmentStream]), builder: (context, snapshot) { JourneyProfile? journeyProfile = snapshot.data?[0]; List segmentProfiles = snapshot.data?[1] ?? []; @@ -34,23 +29,17 @@ class TrainJourney extends StatelessWidget { List segmentProfiles, ) { final timingPoints = journeyProfile.segmentProfilesLists - .expand((it) => it.timingPoints - .toList() - .sublist(it == journeyProfile.segmentProfilesLists.first ? 0 : 1)) + .expand((it) => it.timingPoints.toList().sublist(it == journeyProfile.segmentProfilesLists.first ? 0 : 1)) .toList(); - final points = segmentProfiles - .expand((it) => it.points?.timingPoints.toList() ?? []); + final points = segmentProfiles.expand((it) => it.points?.timingPoints.toList() ?? []); return SingleChildScrollView( child: Column( children: [ ...List.generate(timingPoints.length, (index) { var timingPoint = timingPoints[index]; - var tpId = timingPoint.timingPointReference.children - .whereType() - .firstOrNull - ?.tpId; + var tpId = timingPoint.timingPointReference.children.whereType().firstOrNull?.tpId; var tp = points.where((point) => point.id == tpId).firstOrNull; return Padding( padding: const EdgeInsets.all(sbbDefaultSpacing * 0.5), @@ -68,8 +57,7 @@ class TrainJourney extends StatelessWidget { ); } - Widget _servicePointName(TimingPoint? tp) => - Text(tp?.names.first.name ?? 'Unknown'); + Widget _servicePointName(TimingPoint? tp) => Text(tp?.names.first.name ?? 'Unknown'); Widget _arrivalTime(TimingPointConstraints timingPoint) { return Text(timingPoint.attributes['TP_PlannedLatestArrivalTime'] ?? ''); diff --git a/das_client/lib/pages/journey/train_selection/train_selection.dart b/das_client/lib/app/pages/journey/train_selection/train_selection.dart similarity index 97% rename from das_client/lib/pages/journey/train_selection/train_selection.dart rename to das_client/lib/app/pages/journey/train_selection/train_selection.dart index b4a52366..3fdafabc 100644 --- a/das_client/lib/pages/journey/train_selection/train_selection.dart +++ b/das_client/lib/app/pages/journey/train_selection/train_selection.dart @@ -1,5 +1,5 @@ -import 'package:das_client/bloc/train_journey_cubit.dart'; -import 'package:das_client/i18n/i18n.dart'; +import 'package:das_client/app/bloc/train_journey_cubit.dart'; +import 'package:das_client/app/i18n/i18n.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; diff --git a/das_client/lib/pages/links/links_page.dart b/das_client/lib/app/pages/links/links_page.dart similarity index 85% rename from das_client/lib/pages/links/links_page.dart rename to das_client/lib/app/pages/links/links_page.dart index 16cffdcf..dc678125 100644 --- a/das_client/lib/pages/links/links_page.dart +++ b/das_client/lib/app/pages/links/links_page.dart @@ -1,6 +1,6 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/i18n/i18n.dart'; -import 'package:das_client/nav/das_navigation_drawer.dart'; +import 'package:das_client/app/i18n/i18n.dart'; +import 'package:das_client/app/nav/das_navigation_drawer.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/pages/login/login_page.dart b/das_client/lib/app/pages/login/login_page.dart similarity index 95% rename from das_client/lib/pages/login/login_page.dart rename to das_client/lib/app/pages/login/login_page.dart index 624b90e7..87de7aca 100644 --- a/das_client/lib/pages/login/login_page.dart +++ b/das_client/lib/app/pages/login/login_page.dart @@ -1,9 +1,9 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/auth/authenticator.dart'; +import 'package:das_client/auth/authentication_component.dart'; import 'package:das_client/di.dart'; import 'package:das_client/flavor.dart'; -import 'package:das_client/i18n/i18n.dart'; -import 'package:das_client/nav/app_router.dart'; +import 'package:das_client/app/i18n/i18n.dart'; +import 'package:das_client/app/nav/app_router.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:fimber/fimber.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/pages/login/splash_page.dart b/das_client/lib/app/pages/login/splash_page.dart similarity index 88% rename from das_client/lib/pages/login/splash_page.dart rename to das_client/lib/app/pages/login/splash_page.dart index ec4905a9..7065cf29 100644 --- a/das_client/lib/pages/login/splash_page.dart +++ b/das_client/lib/app/pages/login/splash_page.dart @@ -1,8 +1,7 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/auth/auth_cubit.dart'; -import 'package:das_client/auth/authenticator.dart'; +import 'package:das_client/app/nav/app_router.dart'; +import 'package:das_client/auth/authentication_component.dart'; import 'package:das_client/di.dart'; -import 'package:das_client/nav/app_router.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/das_client/lib/pages/profile/profile_page.dart b/das_client/lib/app/pages/profile/profile_page.dart similarity index 85% rename from das_client/lib/pages/profile/profile_page.dart rename to das_client/lib/app/pages/profile/profile_page.dart index 1776eb70..c1e1e668 100644 --- a/das_client/lib/pages/profile/profile_page.dart +++ b/das_client/lib/app/pages/profile/profile_page.dart @@ -1,6 +1,6 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/i18n/i18n.dart'; -import 'package:das_client/nav/das_navigation_drawer.dart'; +import 'package:das_client/app/i18n/i18n.dart'; +import 'package:das_client/app/nav/das_navigation_drawer.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/pages/settings/settings_page.dart b/das_client/lib/app/pages/settings/settings_page.dart similarity index 85% rename from das_client/lib/pages/settings/settings_page.dart rename to das_client/lib/app/pages/settings/settings_page.dart index 366098f5..6e3b6438 100644 --- a/das_client/lib/pages/settings/settings_page.dart +++ b/das_client/lib/app/pages/settings/settings_page.dart @@ -1,6 +1,6 @@ import 'package:auto_route/auto_route.dart'; -import 'package:das_client/i18n/i18n.dart'; -import 'package:das_client/nav/das_navigation_drawer.dart'; +import 'package:das_client/app/i18n/i18n.dart'; +import 'package:das_client/app/nav/das_navigation_drawer.dart'; import 'package:design_system_flutter/design_system_flutter.dart'; import 'package:flutter/material.dart'; diff --git a/das_client/lib/widgets/app_version_text.dart b/das_client/lib/app/widgets/app_version_text.dart similarity index 100% rename from das_client/lib/widgets/app_version_text.dart rename to das_client/lib/app/widgets/app_version_text.dart diff --git a/das_client/lib/widgets/device_id_text.dart b/das_client/lib/app/widgets/device_id_text.dart similarity index 100% rename from das_client/lib/widgets/device_id_text.dart rename to das_client/lib/app/widgets/device_id_text.dart diff --git a/das_client/lib/util/widget_extensions.dart b/das_client/lib/app/widgets/widget_extensions.dart similarity index 100% rename from das_client/lib/util/widget_extensions.dart rename to das_client/lib/app/widgets/widget_extensions.dart diff --git a/das_client/lib/auth/authentication_component.dart b/das_client/lib/auth/authentication_component.dart new file mode 100644 index 00000000..3c30d820 --- /dev/null +++ b/das_client/lib/auth/authentication_component.dart @@ -0,0 +1,19 @@ +import 'package:das_client/auth/src/authenticator.dart'; +import 'package:das_client/auth/src/azure_authenticator.dart'; +import 'package:das_client/auth/src/token_spec_provider.dart'; +import 'package:sbb_oidc/sbb_oidc.dart'; + +export 'package:das_client/auth/src/auth_cubit.dart'; +export 'package:das_client/auth/src/authenticator.dart'; +export 'package:das_client/auth/src/authenticator_config.dart'; +export 'package:das_client/auth/src/token_spec_provider.dart'; +export 'package:das_client/auth/src/token_spec.dart'; + +class AuthenticationComponent { + const AuthenticationComponent._(); + + static Authenticator createAzureAuthenticator( + {required OidcClient oidcClient, required TokenSpecProvider tokenSpecs}) { + return AzureAuthenticator(oidcClient: oidcClient, tokenSpecs: tokenSpecs); + } +} diff --git a/das_client/lib/auth/auth_cubit.dart b/das_client/lib/auth/src/auth_cubit.dart similarity index 94% rename from das_client/lib/auth/auth_cubit.dart rename to das_client/lib/auth/src/auth_cubit.dart index 977b1f5e..dbcde50e 100644 --- a/das_client/lib/auth/auth_cubit.dart +++ b/das_client/lib/auth/src/auth_cubit.dart @@ -1,4 +1,4 @@ -import 'package:das_client/auth/authenticator.dart'; +import 'package:das_client/auth/src/authenticator.dart'; import 'package:das_client/di.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/das_client/lib/auth/auth_state.dart b/das_client/lib/auth/src/auth_state.dart similarity index 100% rename from das_client/lib/auth/auth_state.dart rename to das_client/lib/auth/src/auth_state.dart diff --git a/das_client/lib/auth/authenticator.dart b/das_client/lib/auth/src/authenticator.dart similarity index 100% rename from das_client/lib/auth/authenticator.dart rename to das_client/lib/auth/src/authenticator.dart diff --git a/das_client/lib/auth/authenticator_config.dart b/das_client/lib/auth/src/authenticator_config.dart similarity index 93% rename from das_client/lib/auth/authenticator_config.dart rename to das_client/lib/auth/src/authenticator_config.dart index 485b909a..84ace9cd 100644 --- a/das_client/lib/auth/authenticator_config.dart +++ b/das_client/lib/auth/src/authenticator_config.dart @@ -1,4 +1,4 @@ -import 'package:das_client/auth/token_spec_provider.dart'; +import 'package:das_client/auth/src/token_spec_provider.dart'; import 'package:meta/meta.dart'; @sealed diff --git a/das_client/lib/auth/azure_authenticator.dart b/das_client/lib/auth/src/azure_authenticator.dart similarity index 89% rename from das_client/lib/auth/azure_authenticator.dart rename to das_client/lib/auth/src/azure_authenticator.dart index 460f58dd..3a10116c 100644 --- a/das_client/lib/auth/azure_authenticator.dart +++ b/das_client/lib/auth/src/azure_authenticator.dart @@ -1,8 +1,8 @@ import 'dart:async'; -import 'package:das_client/auth/authenticator.dart'; -import 'package:das_client/auth/token_spec.dart'; -import 'package:das_client/auth/token_spec_provider.dart'; +import 'package:das_client/auth/src/authenticator.dart'; +import 'package:das_client/auth/src/token_spec.dart'; +import 'package:das_client/auth/src/token_spec_provider.dart'; import 'package:sbb_oidc/sbb_oidc.dart'; class AzureAuthenticator implements Authenticator { diff --git a/das_client/lib/auth/token_spec.dart b/das_client/lib/auth/src/token_spec.dart similarity index 100% rename from das_client/lib/auth/token_spec.dart rename to das_client/lib/auth/src/token_spec.dart diff --git a/das_client/lib/auth/token_spec_provider.dart b/das_client/lib/auth/src/token_spec_provider.dart similarity index 93% rename from das_client/lib/auth/token_spec_provider.dart rename to das_client/lib/auth/src/token_spec_provider.dart index 5fca3cb4..63d97aa6 100644 --- a/das_client/lib/auth/token_spec_provider.dart +++ b/das_client/lib/auth/src/token_spec_provider.dart @@ -1,5 +1,5 @@ import 'package:collection/collection.dart'; -import 'package:das_client/auth/token_spec.dart'; +import 'package:das_client/auth/src/token_spec.dart'; class TokenSpecProvider { const TokenSpecProvider(this._specs); diff --git a/das_client/lib/auth/user.dart b/das_client/lib/auth/src/user.dart similarity index 100% rename from das_client/lib/auth/user.dart rename to das_client/lib/auth/src/user.dart diff --git a/das_client/lib/di.dart b/das_client/lib/di.dart index 408747a2..2224994c 100644 --- a/das_client/lib/di.dart +++ b/das_client/lib/di.dart @@ -1,15 +1,8 @@ -import 'package:das_client/auth/authenticator.dart'; -import 'package:das_client/auth/azure_authenticator.dart'; -import 'package:das_client/auth/token_spec_provider.dart'; +import 'package:das_client/auth/authentication_component.dart'; import 'package:das_client/flavor.dart'; -import 'package:das_client/repo/sfera_repository.dart'; +import 'package:das_client/mqtt/mqtt_component.dart'; import 'package:das_client/service/backend_service.dart'; -import 'package:das_client/service/mqtt/mqtt_client_connector.dart'; -import 'package:das_client/service/mqtt/mqtt_client_oauth_connector.dart'; -import 'package:das_client/service/mqtt/mqtt_client_tms_oauth_connector.dart'; -import 'package:das_client/service/mqtt/mqtt_service.dart'; -import 'package:das_client/service/sfera/sfera_service.dart'; -import 'package:das_client/service/sfera_auth_service.dart'; +import 'package:das_client/sfera/sfera_component.dart'; import 'package:fimber/fimber.dart'; import 'package:get_it/get_it.dart'; import 'package:sbb_oidc/sbb_oidc.dart'; @@ -52,11 +45,8 @@ extension GetItX on GetIt { registerTokenSpecProvider(useTms: useTms); registerOidcClient(useTms: useTms); registerAzureAuthenticator(); - registerSferaAuthService(useTms: useTms); - registerMqttClientConnector(useTms: useTms); - registerMqttService(useTms: useTms); - registerRepositories(); - registerSferaService(); + registerMqttComponent(useTms: useTms); + registerSferaComponents(useTms: useTms); registerBackendService(); await allReady(); } @@ -89,28 +79,22 @@ extension GetItX on GetIt { registerSingletonAsync(factoryFunc); } - void registerMqttService({bool useTms = false}) { + void registerMqttComponent({bool useTms = false}) { final flavor = get(); - registerSingletonWithDependencies( - () => MqttService( - mqttUrl: useTms ? flavor.tmsMqttUrl! : flavor.mqttUrl, - mqttClientConnector: get(), - prefix: flavor.mqttTopicPrefix), - dependsOn: [MqttClientConnector]); - } - void registerSferaAuthService({bool useTms = false}) { - final flavor = get(); - registerSingletonWithDependencies( - () => SferaAuthService( - authenticator: get(), tokenExchangeUrl: useTms ? flavor.tmsTokenExchangeUrl! : flavor.tokenExchangeUrl), - dependsOn: [Authenticator]); + registerLazySingleton( + () => MqttComponent.createMqttClientConnector(sfereAuthService: get(), authenticator: get(), useTms: useTms)); + + registerLazySingleton(() => MqttComponent.createMqttService( + mqttUrl: useTms ? flavor.tmsMqttUrl! : flavor.mqttUrl, + mqttClientConnector: get(), + prefix: flavor.mqttTopicPrefix)); } /// Azure Authenticator. void registerAzureAuthenticator() { factoryFunc() { - return AzureAuthenticator( + return AuthenticationComponent.createAzureAuthenticator( oidcClient: get(), tokenSpecs: get(), ); @@ -122,29 +106,21 @@ extension GetItX on GetIt { ); } - void registerMqttClientConnector({bool useTms = false}) { - if (useTms) { - registerSingletonWithDependencies(() => MqttClientTMSOauthConnector(sferaAuthService: get()), - dependsOn: [SferaAuthService]); - } else { - registerSingletonWithDependencies( - () => MqttClientOauthConnector(sferaAuthService: get(), authenticator: get()), - dependsOn: [Authenticator, SferaAuthService]); - } - } + void registerSferaComponents({bool useTms = false}) { + final flavor = get(); - void registerRepositories() { - registerSingletonAsync(() async => SferaRepository()); - } + registerLazySingleton(() => SferaComponent.createRepository()); + registerLazySingleton(() => SferaComponent.createSferaAuthService( + authenticator: get(), tokenExchangeUrl: useTms ? flavor.tmsTokenExchangeUrl! : flavor.tokenExchangeUrl)); - void registerSferaService() { - registerSingletonWithDependencies(() => SferaService(mqttService: get(), sferaRepository: get()), - dependsOn: [MqttService, SferaRepository]); + registerLazySingleton( + () => SferaComponent.createSferaService(mqttService: get(), sferaRepository: get())); } void registerBackendService() { final flavor = get(); - registerSingletonWithDependencies(() => BackendService(authenticator: DI.get(), baseUrl: flavor.backendUrl), + registerSingletonWithDependencies( + () => BackendService(authenticator: DI.get(), baseUrl: flavor.backendUrl), dependsOn: [Authenticator]); } } diff --git a/das_client/lib/flavor.dart b/das_client/lib/flavor.dart index 0791f06c..bd08b93c 100644 --- a/das_client/lib/flavor.dart +++ b/das_client/lib/flavor.dart @@ -1,6 +1,4 @@ -import 'package:das_client/auth/authenticator_config.dart'; -import 'package:das_client/auth/token_spec.dart'; -import 'package:das_client/auth/token_spec_provider.dart'; +import 'package:das_client/auth/authentication_component.dart'; enum Flavor { dev( diff --git a/das_client/lib/main.dart b/das_client/lib/main.dart index 51a3b8fe..0b367958 100644 --- a/das_client/lib/main.dart +++ b/das_client/lib/main.dart @@ -1,5 +1,5 @@ import 'package:das_client/app.dart'; -import 'package:das_client/auth/auth_cubit.dart'; +import 'package:das_client/auth/authentication_component.dart'; import 'package:das_client/di.dart'; import 'package:das_client/flavor.dart'; import 'package:das_client/logging/logging_component.dart'; diff --git a/das_client/lib/mqtt/mqtt_component.dart b/das_client/lib/mqtt/mqtt_component.dart new file mode 100644 index 00000000..3907aa81 --- /dev/null +++ b/das_client/lib/mqtt/mqtt_component.dart @@ -0,0 +1,28 @@ +import 'package:das_client/auth/authentication_component.dart'; +import 'package:das_client/mqtt/src/mqtt_client_connector.dart'; +import 'package:das_client/mqtt/src/mqtt_client_oauth_connector.dart'; +import 'package:das_client/mqtt/src/mqtt_client_tms_oauth_connector.dart'; +import 'package:das_client/mqtt/src/mqtt_service.dart'; +import 'package:das_client/mqtt/src/mqtt_service_impl.dart'; +import 'package:das_client/sfera/sfera_component.dart'; + +export 'package:das_client/mqtt/src/mqtt_client_connector.dart'; +export 'package:das_client/mqtt/src/mqtt_service.dart'; + +class MqttComponent { + const MqttComponent._(); + + static MqttClientConnector createMqttClientConnector( + {required SferaAuthService sfereAuthService, required Authenticator authenticator, bool useTms = false}) { + if (useTms) { + return MqttClientTMSOauthConnector(sferaAuthService: sfereAuthService); + } else { + return MqttClientOauthConnector(sferaAuthService: sfereAuthService, authenticator: authenticator); + } + } + + static MqttService createMqttService( + {required String mqttUrl, required MqttClientConnector mqttClientConnector, required String prefix}) { + return MqttServiceImpl(mqttUrl: mqttUrl, mqttClientConnector: mqttClientConnector, prefix: prefix); + } +} diff --git a/das_client/lib/service/mqtt/mqtt_client_connector.dart b/das_client/lib/mqtt/src/mqtt_client_connector.dart similarity index 100% rename from das_client/lib/service/mqtt/mqtt_client_connector.dart rename to das_client/lib/mqtt/src/mqtt_client_connector.dart diff --git a/das_client/lib/service/mqtt/mqtt_client_oauth_connector.dart b/das_client/lib/mqtt/src/mqtt_client_oauth_connector.dart similarity index 89% rename from das_client/lib/service/mqtt/mqtt_client_oauth_connector.dart rename to das_client/lib/mqtt/src/mqtt_client_oauth_connector.dart index 6358c71c..6d7ec458 100644 --- a/das_client/lib/service/mqtt/mqtt_client_oauth_connector.dart +++ b/das_client/lib/mqtt/src/mqtt_client_oauth_connector.dart @@ -1,6 +1,6 @@ -import 'package:das_client/auth/authenticator.dart'; -import 'package:das_client/service/sfera_auth_service.dart'; -import 'package:das_client/service/mqtt/mqtt_client_connector.dart'; +import 'package:das_client/auth/authentication_component.dart'; +import 'package:das_client/mqtt/src/mqtt_client_connector.dart'; +import 'package:das_client/sfera/sfera_component.dart'; import 'package:fimber/fimber.dart'; import 'package:mqtt_client/mqtt_client.dart'; diff --git a/das_client/lib/service/mqtt/mqtt_client_tms_oauth_connector.dart b/das_client/lib/mqtt/src/mqtt_client_tms_oauth_connector.dart similarity index 90% rename from das_client/lib/service/mqtt/mqtt_client_tms_oauth_connector.dart rename to das_client/lib/mqtt/src/mqtt_client_tms_oauth_connector.dart index 43de1505..ba96bd72 100644 --- a/das_client/lib/service/mqtt/mqtt_client_tms_oauth_connector.dart +++ b/das_client/lib/mqtt/src/mqtt_client_tms_oauth_connector.dart @@ -1,5 +1,5 @@ -import 'package:das_client/service/mqtt/mqtt_client_connector.dart'; -import 'package:das_client/service/sfera_auth_service.dart'; +import 'package:das_client/mqtt/src/mqtt_client_connector.dart'; +import 'package:das_client/sfera/sfera_component.dart'; import 'package:fimber/fimber.dart'; import 'package:mqtt_client/mqtt_client.dart'; diff --git a/das_client/lib/mqtt/src/mqtt_service.dart b/das_client/lib/mqtt/src/mqtt_service.dart new file mode 100644 index 00000000..1609d908 --- /dev/null +++ b/das_client/lib/mqtt/src/mqtt_service.dart @@ -0,0 +1,13 @@ +import 'dart:core'; + +abstract class MqttService { + MqttService._(); + + Stream get messageStream; + + void disconnect(); + + Future connect(String company, String train); + + bool publishMessage(String company, String train, String message); +} diff --git a/das_client/lib/service/mqtt/mqtt_service.dart b/das_client/lib/mqtt/src/mqtt_service_impl.dart similarity index 90% rename from das_client/lib/service/mqtt/mqtt_service.dart rename to das_client/lib/mqtt/src/mqtt_service_impl.dart index 61a4cf45..79fa3578 100644 --- a/das_client/lib/service/mqtt/mqtt_service.dart +++ b/das_client/lib/mqtt/src/mqtt_service_impl.dart @@ -2,14 +2,15 @@ import 'dart:async'; import 'dart:convert'; import 'dart:core'; -import 'package:das_client/service/mqtt/mqtt_client_connector.dart'; +import 'package:das_client/mqtt/src/mqtt_client_connector.dart'; +import 'package:das_client/mqtt/src/mqtt_service.dart'; import 'package:das_client/util/device_id_info.dart'; import 'package:fimber/fimber.dart'; import 'package:mqtt_client/mqtt_client.dart'; import 'package:mqtt_client/mqtt_server_client.dart'; import 'package:rxdart/rxdart.dart'; -class MqttService { +class MqttServiceImpl implements MqttService { final String _mqttUrl; final MqttClientConnector _mqttClientConnector; final String prefix; @@ -21,9 +22,10 @@ class MqttService { final _messageSubject = BehaviorSubject(); + @override Stream get messageStream => _messageSubject.stream; - MqttService({required String mqttUrl, required MqttClientConnector mqttClientConnector, required this.prefix}) + MqttServiceImpl({required String mqttUrl, required MqttClientConnector mqttClientConnector, required this.prefix}) : _mqttUrl = mqttUrl, _mqttClientConnector = mqttClientConnector { _init(); @@ -35,11 +37,13 @@ class MqttService { _client.useWebSocket = true; } + @override void disconnect() { Fimber.i('Disconnecting from MQTT broker'); _client.disconnect(); } + @override Future connect(String company, String train) async { if (_client.connectionStatus?.state != MqttConnectionState.disconnected) { _client.disconnect(); @@ -55,6 +59,7 @@ class MqttService { return false; } + @override bool publishMessage(String company, String train, String message) { if (_client.connectionStatus?.state == MqttConnectionState.connected) { final topic = '${prefix}90940/2/B2G/$company/$train/$_deviceId'; diff --git a/das_client/lib/service/backend_service.dart b/das_client/lib/service/backend_service.dart index c4a5b542..8d13600a 100644 --- a/das_client/lib/service/backend_service.dart +++ b/das_client/lib/service/backend_service.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'dart:core'; -import 'package:das_client/auth/authenticator.dart'; +import 'package:das_client/auth/authentication_component.dart'; import 'package:das_client/logging/logging_component.dart'; import 'package:fimber/fimber.dart'; import 'package:http/http.dart' as http; diff --git a/das_client/lib/sfera/sfera_component.dart b/das_client/lib/sfera/sfera_component.dart new file mode 100644 index 00000000..7343d46f --- /dev/null +++ b/das_client/lib/sfera/sfera_component.dart @@ -0,0 +1,60 @@ +import 'package:das_client/auth/authentication_component.dart'; +import 'package:das_client/mqtt/mqtt_component.dart'; +import 'package:das_client/sfera/src/repo/sfera_repository.dart'; +import 'package:das_client/sfera/src/repo/sfera_repository_impl.dart'; +import 'package:das_client/sfera/src/service/sfera_auth_service.dart'; +import 'package:das_client/sfera/src/service/sfera_service.dart'; +import 'package:das_client/sfera/src/service/sfera_service_impl.dart'; + +export 'package:das_client/sfera/src/model/b2g_request.dart'; +export 'package:das_client/sfera/src/model/das_operating_modes_selected.dart'; +export 'package:das_client/sfera/src/model/das_operating_modes_supported.dart'; +export 'package:das_client/sfera/src/model/g2b_reply_payload.dart'; +export 'package:das_client/sfera/src/model/handshake_acknowledgement.dart'; +export 'package:das_client/sfera/src/model/handshake_reject.dart'; +export 'package:das_client/sfera/src/model/handshake_request.dart'; +export 'package:das_client/sfera/src/model/journey_profile.dart'; +export 'package:das_client/sfera/src/model/jp_request.dart'; +export 'package:das_client/sfera/src/model/message_header.dart'; +export 'package:das_client/sfera/src/model/otn_id.dart'; +export 'package:das_client/sfera/src/model/segment_profile.dart'; +export 'package:das_client/sfera/src/model/segment_profile_list.dart'; +export 'package:das_client/sfera/src/model/sfera_b2g_request_message.dart'; +export 'package:das_client/sfera/src/model/sfera_g2b_reply_message.dart'; +export 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +export 'package:das_client/sfera/src/model/signal.dart'; +export 'package:das_client/sfera/src/model/signal_id.dart'; +export 'package:das_client/sfera/src/model/sp_points.dart'; +export 'package:das_client/sfera/src/model/sp_request.dart'; +export 'package:das_client/sfera/src/model/sp_zone.dart'; +export 'package:das_client/sfera/src/model/stopping_point_information.dart'; +export 'package:das_client/sfera/src/model/timing_point.dart'; +export 'package:das_client/sfera/src/model/timing_point_constraints.dart'; +export 'package:das_client/sfera/src/model/timing_point_reference.dart'; +export 'package:das_client/sfera/src/model/tp_id_reference.dart'; +export 'package:das_client/sfera/src/model/tp_name.dart'; +export 'package:das_client/sfera/src/model/train_identification.dart'; +export 'package:das_client/sfera/src/model/virtual_balise.dart'; +export 'package:das_client/sfera/src/model/virtual_balise_position.dart'; +export 'package:das_client/sfera/src/repo/sfera_repository.dart'; +export 'package:das_client/sfera/src/service/sfera_auth_service.dart'; +export 'package:das_client/sfera/src/service/sfera_service.dart'; +export 'package:das_client/sfera/src/service/sfera_service_state.dart'; +export 'package:das_client/sfera/src/sfera_reply_parser.dart'; + +class SferaComponent { + const SferaComponent._(); + + static SferaRepository createRepository() { + return SferaRepositoryImpl(); + } + + static SferaAuthService createSferaAuthService( + {required Authenticator authenticator, required String tokenExchangeUrl}) { + return SferaAuthService(authenticator: authenticator, tokenExchangeUrl: tokenExchangeUrl); + } + + static SferaService createSferaService({required MqttService mqttService, required SferaRepository sferaRepository}) { + return SferaServiceImpl(mqttService: mqttService, sferaRepository: sferaRepository); + } +} diff --git a/das_client/lib/model/db/journey_profile_entity.dart b/das_client/lib/sfera/src/db/journey_profile_entity.dart similarity index 89% rename from das_client/lib/model/db/journey_profile_entity.dart rename to das_client/lib/sfera/src/db/journey_profile_entity.dart index e7e6e524..397c9e74 100644 --- a/das_client/lib/model/db/journey_profile_entity.dart +++ b/das_client/lib/sfera/src/db/journey_profile_entity.dart @@ -1,5 +1,5 @@ -import 'package:das_client/model/sfera/journey_profile.dart'; -import 'package:das_client/model/sfera/sfera_reply_parser.dart'; +import 'package:das_client/sfera/src/model/journey_profile.dart'; +import 'package:das_client/sfera/src/sfera_reply_parser.dart'; import 'package:isar/isar.dart'; part 'journey_profile_entity.g.dart'; diff --git a/das_client/lib/model/db/segment_profile_entity.dart b/das_client/lib/sfera/src/db/segment_profile_entity.dart similarity index 86% rename from das_client/lib/model/db/segment_profile_entity.dart rename to das_client/lib/sfera/src/db/segment_profile_entity.dart index c33088e2..455e0588 100644 --- a/das_client/lib/model/db/segment_profile_entity.dart +++ b/das_client/lib/sfera/src/db/segment_profile_entity.dart @@ -1,5 +1,5 @@ -import 'package:das_client/model/sfera/segment_profile.dart'; -import 'package:das_client/model/sfera/sfera_reply_parser.dart'; +import 'package:das_client/sfera/src/model/segment_profile.dart'; +import 'package:das_client/sfera/src/sfera_reply_parser.dart'; import 'package:isar/isar.dart'; part 'segment_profile_entity.g.dart'; diff --git a/das_client/lib/model/sfera/b2g_request.dart b/das_client/lib/sfera/src/model/b2g_request.dart similarity index 74% rename from das_client/lib/model/sfera/b2g_request.dart rename to das_client/lib/sfera/src/model/b2g_request.dart index 766ae47b..4b9e348a 100644 --- a/das_client/lib/model/sfera/b2g_request.dart +++ b/das_client/lib/sfera/src/model/b2g_request.dart @@ -1,6 +1,6 @@ -import 'package:das_client/model/sfera/jp_request.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/sp_request.dart'; +import 'package:das_client/sfera/src/model/jp_request.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sp_request.dart'; class B2gRequest extends SferaXmlElement { static const String elementType = 'B2G_Request'; diff --git a/das_client/lib/model/sfera/das_operating_modes_selected.dart b/das_client/lib/sfera/src/model/das_operating_modes_selected.dart similarity index 71% rename from das_client/lib/model/sfera/das_operating_modes_selected.dart rename to das_client/lib/sfera/src/model/das_operating_modes_selected.dart index 452ebba7..33b6fd3b 100644 --- a/das_client/lib/model/sfera/das_operating_modes_selected.dart +++ b/das_client/lib/sfera/src/model/das_operating_modes_selected.dart @@ -1,7 +1,7 @@ -import 'package:das_client/model/sfera/enums/das_architecture.dart'; -import 'package:das_client/model/sfera/enums/das_connectivity.dart'; -import 'package:das_client/model/sfera/enums/xml_enum.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/enums/das_architecture.dart'; +import 'package:das_client/sfera/src/model/enums/das_connectivity.dart'; +import 'package:das_client/sfera/src/model/enums/xml_enum.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class DasOperatingModesSelected extends SferaXmlElement { static const String elementType = 'DAS_OperatingModeSelected'; diff --git a/das_client/lib/model/sfera/das_operating_modes_supported.dart b/das_client/lib/sfera/src/model/das_operating_modes_supported.dart similarity index 75% rename from das_client/lib/model/sfera/das_operating_modes_supported.dart rename to das_client/lib/sfera/src/model/das_operating_modes_supported.dart index 0117526e..6140892a 100644 --- a/das_client/lib/model/sfera/das_operating_modes_supported.dart +++ b/das_client/lib/sfera/src/model/das_operating_modes_supported.dart @@ -1,7 +1,7 @@ -import 'package:das_client/model/sfera/enums/das_architecture.dart'; -import 'package:das_client/model/sfera/enums/das_connectivity.dart'; -import 'package:das_client/model/sfera/enums/das_driving_mode.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/enums/das_architecture.dart'; +import 'package:das_client/sfera/src/model/enums/das_connectivity.dart'; +import 'package:das_client/sfera/src/model/enums/das_driving_mode.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class DasOperatingModesSupported extends SferaXmlElement { static const String elementType = 'DAS_OperatingModesSupported'; diff --git a/das_client/lib/model/sfera/enums/das_architecture.dart b/das_client/lib/sfera/src/model/enums/das_architecture.dart similarity index 80% rename from das_client/lib/model/sfera/enums/das_architecture.dart rename to das_client/lib/sfera/src/model/enums/das_architecture.dart index b2a28eab..3bf12f86 100644 --- a/das_client/lib/model/sfera/enums/das_architecture.dart +++ b/das_client/lib/sfera/src/model/enums/das_architecture.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/enums/xml_enum.dart'; +import 'package:das_client/sfera/src/model/enums/xml_enum.dart'; enum DasArchitecture implements XmlEnum { groundAdviceCalculation(xmlValue: 'GroundAdviceCalculation'), diff --git a/das_client/lib/model/sfera/enums/das_connectivity.dart b/das_client/lib/sfera/src/model/enums/das_connectivity.dart similarity index 77% rename from das_client/lib/model/sfera/enums/das_connectivity.dart rename to das_client/lib/sfera/src/model/enums/das_connectivity.dart index 90d9662a..8904628e 100644 --- a/das_client/lib/model/sfera/enums/das_connectivity.dart +++ b/das_client/lib/sfera/src/model/enums/das_connectivity.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/enums/xml_enum.dart'; +import 'package:das_client/sfera/src/model/enums/xml_enum.dart'; enum DasConnectivity implements XmlEnum { standalone(xmlValue: 'Standalone'), diff --git a/das_client/lib/model/sfera/enums/das_driving_mode.dart b/das_client/lib/sfera/src/model/enums/das_driving_mode.dart similarity index 86% rename from das_client/lib/model/sfera/enums/das_driving_mode.dart rename to das_client/lib/sfera/src/model/enums/das_driving_mode.dart index b37a9495..4b6b9218 100644 --- a/das_client/lib/model/sfera/enums/das_driving_mode.dart +++ b/das_client/lib/sfera/src/model/enums/das_driving_mode.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/enums/xml_enum.dart'; +import 'package:das_client/sfera/src/model/enums/xml_enum.dart'; enum DasDrivingMode implements XmlEnum { inactive(xmlValue: 'Inactive'), diff --git a/das_client/lib/model/sfera/enums/handshake_reject_reason.dart b/das_client/lib/sfera/src/model/enums/handshake_reject_reason.dart similarity index 90% rename from das_client/lib/model/sfera/enums/handshake_reject_reason.dart rename to das_client/lib/sfera/src/model/enums/handshake_reject_reason.dart index 9e2848e0..9c6d5eac 100644 --- a/das_client/lib/model/sfera/enums/handshake_reject_reason.dart +++ b/das_client/lib/sfera/src/model/enums/handshake_reject_reason.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/enums/xml_enum.dart'; +import 'package:das_client/sfera/src/model/enums/xml_enum.dart'; enum HandshakeRejectReason implements XmlEnum { atoVersionIncompatible(xmlValue: 'ATO system version incompatible'), diff --git a/das_client/lib/model/sfera/enums/related_train_request_type.dart b/das_client/lib/sfera/src/model/enums/related_train_request_type.dart similarity index 86% rename from das_client/lib/model/sfera/enums/related_train_request_type.dart rename to das_client/lib/sfera/src/model/enums/related_train_request_type.dart index e3029f54..ee7f5b1a 100644 --- a/das_client/lib/model/sfera/enums/related_train_request_type.dart +++ b/das_client/lib/sfera/src/model/enums/related_train_request_type.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/enums/xml_enum.dart'; +import 'package:das_client/sfera/src/model/enums/xml_enum.dart'; enum RelatedTrainRequestType implements XmlEnum { none(xmlValue: 'None'), diff --git a/das_client/lib/model/sfera/enums/xml_enum.dart b/das_client/lib/sfera/src/model/enums/xml_enum.dart similarity index 100% rename from das_client/lib/model/sfera/enums/xml_enum.dart rename to das_client/lib/sfera/src/model/enums/xml_enum.dart diff --git a/das_client/lib/model/sfera/g2b_reply_payload.dart b/das_client/lib/sfera/src/model/g2b_reply_payload.dart similarity index 65% rename from das_client/lib/model/sfera/g2b_reply_payload.dart rename to das_client/lib/sfera/src/model/g2b_reply_payload.dart index fd84c44d..1d7ecdc9 100644 --- a/das_client/lib/model/sfera/g2b_reply_payload.dart +++ b/das_client/lib/sfera/src/model/g2b_reply_payload.dart @@ -1,6 +1,6 @@ -import 'package:das_client/model/sfera/journey_profile.dart'; -import 'package:das_client/model/sfera/segment_profile.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/journey_profile.dart'; +import 'package:das_client/sfera/src/model/segment_profile.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class G2bReplyPayload extends SferaXmlElement { static const String elementType = 'G2B_ReplyPayload'; diff --git a/das_client/lib/model/sfera/handshake_acknowledgement.dart b/das_client/lib/sfera/src/model/handshake_acknowledgement.dart similarity index 75% rename from das_client/lib/model/sfera/handshake_acknowledgement.dart rename to das_client/lib/sfera/src/model/handshake_acknowledgement.dart index 6654c287..a4708357 100644 --- a/das_client/lib/model/sfera/handshake_acknowledgement.dart +++ b/das_client/lib/sfera/src/model/handshake_acknowledgement.dart @@ -1,5 +1,5 @@ -import 'package:das_client/model/sfera/das_operating_modes_selected.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/das_operating_modes_selected.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class HandshakeAcknowledgement extends SferaXmlElement { static const String elementType = 'HandshakeAcknowledgement'; diff --git a/das_client/lib/model/sfera/handshake_reject.dart b/das_client/lib/sfera/src/model/handshake_reject.dart similarity index 63% rename from das_client/lib/model/sfera/handshake_reject.dart rename to das_client/lib/sfera/src/model/handshake_reject.dart index 054cbeb1..f9557ccd 100644 --- a/das_client/lib/model/sfera/handshake_reject.dart +++ b/das_client/lib/sfera/src/model/handshake_reject.dart @@ -1,7 +1,7 @@ -import 'package:das_client/model/sfera/enums/handshake_reject_reason.dart'; -import 'package:das_client/model/sfera/enums/xml_enum.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/sp_zone.dart'; +import 'package:das_client/sfera/src/model/enums/handshake_reject_reason.dart'; +import 'package:das_client/sfera/src/model/enums/xml_enum.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sp_zone.dart'; class HandshakeReject extends SferaXmlElement { static const String elementType = 'HandshakeReject'; diff --git a/das_client/lib/model/sfera/handshake_request.dart b/das_client/lib/sfera/src/model/handshake_request.dart similarity index 79% rename from das_client/lib/model/sfera/handshake_request.dart rename to das_client/lib/sfera/src/model/handshake_request.dart index d41e0abd..e6de99d2 100644 --- a/das_client/lib/model/sfera/handshake_request.dart +++ b/das_client/lib/sfera/src/model/handshake_request.dart @@ -1,6 +1,6 @@ -import 'package:das_client/model/sfera/das_operating_modes_supported.dart'; -import 'package:das_client/model/sfera/enums/related_train_request_type.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/das_operating_modes_supported.dart'; +import 'package:das_client/sfera/src/model/enums/related_train_request_type.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class HandshakeRequest extends SferaXmlElement { static const String elementType = 'HandshakeRequest'; diff --git a/das_client/lib/model/sfera/journey_profile.dart b/das_client/lib/sfera/src/model/journey_profile.dart similarity index 70% rename from das_client/lib/model/sfera/journey_profile.dart rename to das_client/lib/sfera/src/model/journey_profile.dart index ae26832e..96323e20 100644 --- a/das_client/lib/model/sfera/journey_profile.dart +++ b/das_client/lib/sfera/src/model/journey_profile.dart @@ -1,6 +1,6 @@ -import 'package:das_client/model/sfera/segment_profile_list.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/train_identification.dart'; +import 'package:das_client/sfera/src/model/segment_profile_list.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/train_identification.dart'; class JourneyProfile extends SferaXmlElement { static const String elementType = 'JourneyProfile'; diff --git a/das_client/lib/model/sfera/jp_request.dart b/das_client/lib/sfera/src/model/jp_request.dart similarity index 72% rename from das_client/lib/model/sfera/jp_request.dart rename to das_client/lib/sfera/src/model/jp_request.dart index a705d211..2b5ebf05 100644 --- a/das_client/lib/model/sfera/jp_request.dart +++ b/das_client/lib/sfera/src/model/jp_request.dart @@ -1,5 +1,5 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/train_identification.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/train_identification.dart'; class JpRequest extends SferaXmlElement { static const String elementType = 'JP_Request'; diff --git a/das_client/lib/model/sfera/message_header.dart b/das_client/lib/sfera/src/model/message_header.dart similarity index 92% rename from das_client/lib/model/sfera/message_header.dart rename to das_client/lib/sfera/src/model/message_header.dart index b233146a..738a1575 100644 --- a/das_client/lib/model/sfera/message_header.dart +++ b/das_client/lib/sfera/src/model/message_header.dart @@ -1,5 +1,5 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/train_identification.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/train_identification.dart'; class MessageHeader extends SferaXmlElement { static const String elementType = 'MessageHeader'; diff --git a/das_client/lib/model/sfera/otn_id.dart b/das_client/lib/sfera/src/model/otn_id.dart similarity index 95% rename from das_client/lib/model/sfera/otn_id.dart rename to das_client/lib/sfera/src/model/otn_id.dart index c6b3989d..37099161 100644 --- a/das_client/lib/model/sfera/otn_id.dart +++ b/das_client/lib/sfera/src/model/otn_id.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; import 'package:das_client/util/format.dart'; class OtnId extends SferaXmlElement { diff --git a/das_client/lib/model/sfera/segment_profile.dart b/das_client/lib/sfera/src/model/segment_profile.dart similarity index 80% rename from das_client/lib/model/sfera/segment_profile.dart rename to das_client/lib/sfera/src/model/segment_profile.dart index 83b2f487..0a69d63f 100644 --- a/das_client/lib/model/sfera/segment_profile.dart +++ b/das_client/lib/sfera/src/model/segment_profile.dart @@ -1,6 +1,6 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/sp_points.dart'; -import 'package:das_client/model/sfera/sp_zone.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sp_points.dart'; +import 'package:das_client/sfera/src/model/sp_zone.dart'; class SegmentProfile extends SferaXmlElement { static const String elementType = 'SegmentProfile'; @@ -8,8 +8,11 @@ class SegmentProfile extends SferaXmlElement { SegmentProfile({super.type = elementType, super.attributes, super.children, super.value}); String get versionMajor => attributes['SP_VersionMajor']!; + String get versionMinor => attributes['SP_VersionMinor']!; + String get length => attributes['SP_Length']!; + String get id => attributes['SP_ID']!; SpZone? get zone => children.whereType().firstOrNull; diff --git a/das_client/lib/model/sfera/segment_profile_list.dart b/das_client/lib/sfera/src/model/segment_profile_list.dart similarity index 79% rename from das_client/lib/model/sfera/segment_profile_list.dart rename to das_client/lib/sfera/src/model/segment_profile_list.dart index 27a01af5..9152756a 100644 --- a/das_client/lib/model/sfera/segment_profile_list.dart +++ b/das_client/lib/sfera/src/model/segment_profile_list.dart @@ -1,6 +1,6 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/sp_zone.dart'; -import 'package:das_client/model/sfera/timing_point_constraints.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sp_zone.dart'; +import 'package:das_client/sfera/src/model/timing_point_constraints.dart'; class SegmentProfileList extends SferaXmlElement { static const String elementType = 'SegmentProfileList'; diff --git a/das_client/lib/model/sfera/sfera_b2g_request_message.dart b/das_client/lib/sfera/src/model/sfera_b2g_request_message.dart similarity index 81% rename from das_client/lib/model/sfera/sfera_b2g_request_message.dart rename to das_client/lib/sfera/src/model/sfera_b2g_request_message.dart index 08496800..b96708d2 100644 --- a/das_client/lib/model/sfera/sfera_b2g_request_message.dart +++ b/das_client/lib/sfera/src/model/sfera_b2g_request_message.dart @@ -1,7 +1,7 @@ -import 'package:das_client/model/sfera/b2g_request.dart'; -import 'package:das_client/model/sfera/handshake_request.dart'; -import 'package:das_client/model/sfera/message_header.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/b2g_request.dart'; +import 'package:das_client/sfera/src/model/handshake_request.dart'; +import 'package:das_client/sfera/src/model/message_header.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class SferaB2gRequestMessage extends SferaXmlElement { static const String elementType = 'SFERA_B2G_RequestMessage'; diff --git a/das_client/lib/model/sfera/sfera_g2b_reply_message.dart b/das_client/lib/sfera/src/model/sfera_g2b_reply_message.dart similarity index 71% rename from das_client/lib/model/sfera/sfera_g2b_reply_message.dart rename to das_client/lib/sfera/src/model/sfera_g2b_reply_message.dart index 3d91d917..0fc49615 100644 --- a/das_client/lib/model/sfera/sfera_g2b_reply_message.dart +++ b/das_client/lib/sfera/src/model/sfera_g2b_reply_message.dart @@ -1,8 +1,8 @@ -import 'package:das_client/model/sfera/g2b_reply_payload.dart'; -import 'package:das_client/model/sfera/handshake_acknowledgement.dart'; -import 'package:das_client/model/sfera/handshake_reject.dart'; -import 'package:das_client/model/sfera/message_header.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/g2b_reply_payload.dart'; +import 'package:das_client/sfera/src/model/handshake_acknowledgement.dart'; +import 'package:das_client/sfera/src/model/handshake_reject.dart'; +import 'package:das_client/sfera/src/model/message_header.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class SferaG2bReplyMessage extends SferaXmlElement { static const String elementType = 'SFERA_G2B_ReplyMessage'; diff --git a/das_client/lib/model/sfera/sfera_xml_element.dart b/das_client/lib/sfera/src/model/sfera_xml_element.dart similarity index 97% rename from das_client/lib/model/sfera/sfera_xml_element.dart rename to das_client/lib/sfera/src/model/sfera_xml_element.dart index 4de53d7f..f971b1b4 100644 --- a/das_client/lib/model/sfera/sfera_xml_element.dart +++ b/das_client/lib/sfera/src/model/sfera_xml_element.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/enums/xml_enum.dart'; +import 'package:das_client/sfera/src/model/enums/xml_enum.dart'; import 'package:fimber/fimber.dart'; import 'package:xml/xml.dart'; diff --git a/das_client/lib/model/sfera/signal.dart b/das_client/lib/sfera/src/model/signal.dart similarity index 72% rename from das_client/lib/model/sfera/signal.dart rename to das_client/lib/sfera/src/model/signal.dart index 933c5411..d0eaa9ee 100644 --- a/das_client/lib/model/sfera/signal.dart +++ b/das_client/lib/sfera/src/model/signal.dart @@ -1,5 +1,5 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/signal_id.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/signal_id.dart'; class Signal extends SferaXmlElement { static const String elementType = 'Signal'; diff --git a/das_client/lib/model/sfera/signal_id.dart b/das_client/lib/sfera/src/model/signal_id.dart similarity index 86% rename from das_client/lib/model/sfera/signal_id.dart rename to das_client/lib/sfera/src/model/signal_id.dart index aa0622c4..d0279d34 100644 --- a/das_client/lib/model/sfera/signal_id.dart +++ b/das_client/lib/sfera/src/model/signal_id.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class SignalId extends SferaXmlElement { static const String elementType = 'Signal_ID'; diff --git a/das_client/lib/model/sfera/sp_points.dart b/das_client/lib/sfera/src/model/sp_points.dart similarity index 61% rename from das_client/lib/model/sfera/sp_points.dart rename to das_client/lib/sfera/src/model/sp_points.dart index e3f19d45..bcdba12c 100644 --- a/das_client/lib/model/sfera/sp_points.dart +++ b/das_client/lib/sfera/src/model/sp_points.dart @@ -1,7 +1,7 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/signal.dart'; -import 'package:das_client/model/sfera/timing_point.dart'; -import 'package:das_client/model/sfera/virtual_balise.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/signal.dart'; +import 'package:das_client/sfera/src/model/timing_point.dart'; +import 'package:das_client/sfera/src/model/virtual_balise.dart'; class SpPoints extends SferaXmlElement { static const String elementType = 'SP_Points'; diff --git a/das_client/lib/model/sfera/sp_request.dart b/das_client/lib/sfera/src/model/sp_request.dart similarity index 81% rename from das_client/lib/model/sfera/sp_request.dart rename to das_client/lib/sfera/src/model/sp_request.dart index b398a30e..f2a29a73 100644 --- a/das_client/lib/model/sfera/sp_request.dart +++ b/das_client/lib/sfera/src/model/sp_request.dart @@ -1,5 +1,5 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/sp_zone.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sp_zone.dart'; class SpRequest extends SferaXmlElement { static const String elementType = 'SP_Request'; diff --git a/das_client/lib/model/sfera/sp_zone.dart b/das_client/lib/sfera/src/model/sp_zone.dart similarity index 85% rename from das_client/lib/model/sfera/sp_zone.dart rename to das_client/lib/sfera/src/model/sp_zone.dart index 72ea40db..70dd8298 100644 --- a/das_client/lib/model/sfera/sp_zone.dart +++ b/das_client/lib/sfera/src/model/sp_zone.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class SpZone extends SferaXmlElement { static const String elementType = 'SP_Zone'; diff --git a/das_client/lib/model/sfera/stopping_point_information.dart b/das_client/lib/sfera/src/model/stopping_point_information.dart similarity index 85% rename from das_client/lib/model/sfera/stopping_point_information.dart rename to das_client/lib/sfera/src/model/stopping_point_information.dart index a73b21af..8e671d77 100644 --- a/das_client/lib/model/sfera/stopping_point_information.dart +++ b/das_client/lib/sfera/src/model/stopping_point_information.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class StoppingPointInformation extends SferaXmlElement { static const String elementType = 'StoppingPointInformation'; diff --git a/das_client/lib/model/sfera/timing_point.dart b/das_client/lib/sfera/src/model/timing_point.dart similarity index 79% rename from das_client/lib/model/sfera/timing_point.dart rename to das_client/lib/sfera/src/model/timing_point.dart index 914db755..4d63e09b 100644 --- a/das_client/lib/model/sfera/timing_point.dart +++ b/das_client/lib/sfera/src/model/timing_point.dart @@ -1,5 +1,5 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/tp_name.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/tp_name.dart'; class TimingPoint extends SferaXmlElement { static const String elementType = 'TimingPoint'; diff --git a/das_client/lib/model/sfera/timing_point_constraints.dart b/das_client/lib/sfera/src/model/timing_point_constraints.dart similarity index 75% rename from das_client/lib/model/sfera/timing_point_constraints.dart rename to das_client/lib/sfera/src/model/timing_point_constraints.dart index 7f3ec9ba..db99abe6 100644 --- a/das_client/lib/model/sfera/timing_point_constraints.dart +++ b/das_client/lib/sfera/src/model/timing_point_constraints.dart @@ -1,5 +1,5 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/timing_point_reference.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/timing_point_reference.dart'; class TimingPointConstraints extends SferaXmlElement { static const String elementType = 'TimingPointConstraints'; diff --git a/das_client/lib/model/sfera/timing_point_reference.dart b/das_client/lib/sfera/src/model/timing_point_reference.dart similarity index 76% rename from das_client/lib/model/sfera/timing_point_reference.dart rename to das_client/lib/sfera/src/model/timing_point_reference.dart index dde84adb..db670a2c 100644 --- a/das_client/lib/model/sfera/timing_point_reference.dart +++ b/das_client/lib/sfera/src/model/timing_point_reference.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class TimingPointReference extends SferaXmlElement { static const String elementType = 'TimingPointReference'; diff --git a/das_client/lib/model/sfera/tp_id_reference.dart b/das_client/lib/sfera/src/model/tp_id_reference.dart similarity index 83% rename from das_client/lib/model/sfera/tp_id_reference.dart rename to das_client/lib/sfera/src/model/tp_id_reference.dart index 54687b1d..627788fb 100644 --- a/das_client/lib/model/sfera/tp_id_reference.dart +++ b/das_client/lib/sfera/src/model/tp_id_reference.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class TpIdReference extends SferaXmlElement { static const String elementType = 'TP_ID_Reference'; diff --git a/das_client/lib/model/sfera/tp_name.dart b/das_client/lib/sfera/src/model/tp_name.dart similarity index 82% rename from das_client/lib/model/sfera/tp_name.dart rename to das_client/lib/sfera/src/model/tp_name.dart index ae355015..2d625d7c 100644 --- a/das_client/lib/model/sfera/tp_name.dart +++ b/das_client/lib/sfera/src/model/tp_name.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class TpName extends SferaXmlElement { static const String elementType = 'TP_Name'; diff --git a/das_client/lib/model/sfera/train_identification.dart b/das_client/lib/sfera/src/model/train_identification.dart similarity index 82% rename from das_client/lib/model/sfera/train_identification.dart rename to das_client/lib/sfera/src/model/train_identification.dart index f3276486..34baa5e4 100644 --- a/das_client/lib/model/sfera/train_identification.dart +++ b/das_client/lib/sfera/src/model/train_identification.dart @@ -1,5 +1,5 @@ -import 'package:das_client/model/sfera/otn_id.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/otn_id.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class TrainIdentification extends SferaXmlElement { static const String elementType = 'TrainIdentification'; diff --git a/das_client/lib/model/sfera/virtual_balise.dart b/das_client/lib/sfera/src/model/virtual_balise.dart similarity index 77% rename from das_client/lib/model/sfera/virtual_balise.dart rename to das_client/lib/sfera/src/model/virtual_balise.dart index 0cc65003..0dff76e4 100644 --- a/das_client/lib/model/sfera/virtual_balise.dart +++ b/das_client/lib/sfera/src/model/virtual_balise.dart @@ -1,5 +1,5 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/virtual_balise_position.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/virtual_balise_position.dart'; class VirtualBalise extends SferaXmlElement { static const String elementType = 'VirtualBalise'; diff --git a/das_client/lib/model/sfera/virtual_balise_position.dart b/das_client/lib/sfera/src/model/virtual_balise_position.dart similarity index 88% rename from das_client/lib/model/sfera/virtual_balise_position.dart rename to das_client/lib/sfera/src/model/virtual_balise_position.dart index a5e00104..5320ff21 100644 --- a/das_client/lib/model/sfera/virtual_balise_position.dart +++ b/das_client/lib/sfera/src/model/virtual_balise_position.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; class VirtualBalisePosition extends SferaXmlElement { static const String elementType = 'VirtualBalisePosition'; diff --git a/das_client/lib/sfera/src/repo/sfera_repository.dart b/das_client/lib/sfera/src/repo/sfera_repository.dart new file mode 100644 index 00000000..050c211a --- /dev/null +++ b/das_client/lib/sfera/src/repo/sfera_repository.dart @@ -0,0 +1,19 @@ +import 'package:das_client/sfera/src/db/journey_profile_entity.dart'; +import 'package:das_client/sfera/src/db/segment_profile_entity.dart'; +import 'package:das_client/sfera/src/model/journey_profile.dart'; +import 'package:das_client/sfera/src/model/segment_profile.dart'; + +abstract class SferaRepository { + const SferaRepository._(); + + Future saveJourneyProfile(JourneyProfile journeyProfile); + + Future saveSegmentProfile(SegmentProfile segmentProfile); + + Future findJourneyProfile(String company, String operationalTrainNumber, DateTime startDate); + + Future findSegmentProfile(String spId, String majorVersion, String minorVersion); + + Stream> observeJourneyProfile( + String company, String operationalTrainNumber, DateTime startDate); +} diff --git a/das_client/lib/repo/sfera_repository.dart b/das_client/lib/sfera/src/repo/sfera_repository_impl.dart similarity index 88% rename from das_client/lib/repo/sfera_repository.dart rename to das_client/lib/sfera/src/repo/sfera_repository_impl.dart index cdcfa16f..e09dd69a 100644 --- a/das_client/lib/repo/sfera_repository.dart +++ b/das_client/lib/sfera/src/repo/sfera_repository_impl.dart @@ -1,16 +1,15 @@ -import 'package:das_client/model/db/journey_profile_entity.dart'; -import 'package:das_client/model/db/segment_profile_entity.dart'; -import 'package:das_client/model/sfera/journey_profile.dart'; -import 'package:das_client/model/sfera/segment_profile.dart'; +import 'package:das_client/sfera/sfera_component.dart'; +import 'package:das_client/sfera/src/db/journey_profile_entity.dart'; +import 'package:das_client/sfera/src/db/segment_profile_entity.dart'; import 'package:fimber/fimber.dart'; import 'package:isar/isar.dart'; import 'package:path_provider/path_provider.dart'; -class SferaRepository { +class SferaRepositoryImpl implements SferaRepository { late final Future _initialized; late final Isar _db; - SferaRepository() { + SferaRepositoryImpl() { _initialized = _init(); } @@ -18,12 +17,10 @@ class SferaRepository { Fimber.i('Initializing SferaStore...'); final dir = await getApplicationDocumentsDirectory(); _db = await Isar.openAsync( - schemas: [JourneyProfileEntitySchema, SegmentProfileEntitySchema], - directory: dir.path, - name: 'das' - ); + schemas: [JourneyProfileEntitySchema, SegmentProfileEntitySchema], directory: dir.path, name: 'das'); } + @override Future saveJourneyProfile(JourneyProfile journeyProfile) async { await _initialized; @@ -45,6 +42,7 @@ class SferaRepository { }); } + @override Future saveSegmentProfile(SegmentProfile segmentProfile) async { await _initialized; @@ -63,6 +61,7 @@ class SferaRepository { } } + @override Future findJourneyProfile( String company, String operationalTrainNumber, DateTime startDate) async { await _initialized; @@ -74,6 +73,7 @@ class SferaRepository { .findFirst(); } + @override Future findSegmentProfile(String spId, String majorVersion, String minorVersion) async { await _initialized; return _db.segmentProfile @@ -84,6 +84,7 @@ class SferaRepository { .findFirst(); } + @override Stream> observeJourneyProfile( String company, String operationalTrainNumber, DateTime startDate) { return _db.journeyProfile diff --git a/das_client/lib/service/sfera/handler/journey_profile_reply_handler.dart b/das_client/lib/sfera/src/service/handler/journey_profile_reply_handler.dart similarity index 72% rename from das_client/lib/service/sfera/handler/journey_profile_reply_handler.dart rename to das_client/lib/sfera/src/service/handler/journey_profile_reply_handler.dart index 99b9f4e6..7ef93a55 100644 --- a/das_client/lib/service/sfera/handler/journey_profile_reply_handler.dart +++ b/das_client/lib/sfera/src/service/handler/journey_profile_reply_handler.dart @@ -1,6 +1,6 @@ -import 'package:das_client/model/sfera/sfera_g2b_reply_message.dart'; -import 'package:das_client/repo/sfera_repository.dart'; -import 'package:das_client/service/sfera/handler/sfera_message_handler.dart'; +import 'package:das_client/sfera/src/model/sfera_g2b_reply_message.dart'; +import 'package:das_client/sfera/src/repo/sfera_repository.dart'; +import 'package:das_client/sfera/src/service/handler/sfera_message_handler.dart'; import 'package:fimber/fimber.dart'; class JourneyProfileReplyHandler implements SferaMessageHandler { diff --git a/das_client/lib/service/sfera/handler/segment_profile_reply_handler.dart b/das_client/lib/sfera/src/service/handler/segment_profile_reply_handler.dart similarity index 72% rename from das_client/lib/service/sfera/handler/segment_profile_reply_handler.dart rename to das_client/lib/sfera/src/service/handler/segment_profile_reply_handler.dart index ea334af2..554d8b80 100644 --- a/das_client/lib/service/sfera/handler/segment_profile_reply_handler.dart +++ b/das_client/lib/sfera/src/service/handler/segment_profile_reply_handler.dart @@ -1,6 +1,6 @@ -import 'package:das_client/model/sfera/sfera_g2b_reply_message.dart'; -import 'package:das_client/repo/sfera_repository.dart'; -import 'package:das_client/service/sfera/handler/sfera_message_handler.dart'; +import 'package:das_client/sfera/src/model/sfera_g2b_reply_message.dart'; +import 'package:das_client/sfera/src/repo/sfera_repository.dart'; +import 'package:das_client/sfera/src/service/handler/sfera_message_handler.dart'; import 'package:fimber/fimber.dart'; class SegmentProfileReplyHandler implements SferaMessageHandler { diff --git a/das_client/lib/service/sfera/handler/sfera_message_handler.dart b/das_client/lib/sfera/src/service/handler/sfera_message_handler.dart similarity index 58% rename from das_client/lib/service/sfera/handler/sfera_message_handler.dart rename to das_client/lib/sfera/src/service/handler/sfera_message_handler.dart index 9dc2ca7d..afc26a56 100644 --- a/das_client/lib/service/sfera/handler/sfera_message_handler.dart +++ b/das_client/lib/sfera/src/service/handler/sfera_message_handler.dart @@ -1,4 +1,4 @@ -import 'package:das_client/model/sfera/sfera_g2b_reply_message.dart'; +import 'package:das_client/sfera/src/model/sfera_g2b_reply_message.dart'; abstract class SferaMessageHandler { Future handleMessage(SferaG2bReplyMessage replyMessage); diff --git a/das_client/lib/service/sfera_auth_service.dart b/das_client/lib/sfera/src/service/sfera_auth_service.dart similarity index 94% rename from das_client/lib/service/sfera_auth_service.dart rename to das_client/lib/sfera/src/service/sfera_auth_service.dart index fffdb152..27c07f9a 100644 --- a/das_client/lib/service/sfera_auth_service.dart +++ b/das_client/lib/sfera/src/service/sfera_auth_service.dart @@ -1,6 +1,6 @@ import 'dart:core'; -import 'package:das_client/auth/authenticator.dart'; +import 'package:das_client/auth/authentication_component.dart'; import 'package:fimber/fimber.dart'; import 'package:http/http.dart' as http; @@ -13,7 +13,6 @@ class SferaAuthService { _tokenExchangeUrl = tokenExchangeUrl; Future retrieveSferaAuthToken(String ru, String train, String role) async { - Fimber.i('Trying to fetch sfera auth token for ru=$ru train=$train role=$role...'); final url = Uri.parse('$_tokenExchangeUrl?ru=$ru&train=$train&role=$role'); diff --git a/das_client/lib/sfera/src/service/sfera_service.dart b/das_client/lib/sfera/src/service/sfera_service.dart new file mode 100644 index 00000000..dd52b84f --- /dev/null +++ b/das_client/lib/sfera/src/service/sfera_service.dart @@ -0,0 +1,33 @@ +import 'dart:core'; + +import 'package:das_client/sfera/sfera_component.dart'; +import 'package:das_client/util/device_id_info.dart'; +import 'package:das_client/util/error_code.dart'; +import 'package:das_client/util/format.dart'; +import 'package:uuid/uuid.dart'; + +abstract class SferaService { + const SferaService._(); + + Stream get stateStream; + + Stream get journeyStream; + + Stream> get segmentStream; + + ErrorCode? get lastErrorCode; + + Future connect(OtnId otnId); + + void disconnect(); + + static Future messageHeader({TrainIdentification? trainIdentification}) async { + return MessageHeader.create(const Uuid().v4(), Format.sferaTimestamp(DateTime.now()), + await DeviceIdInfo.getDeviceId(), 'TMS', '1085', '0085', + trainIdentification: trainIdentification); + } + + static String sferaTrain(String trainNumber, DateTime date) { + return '${trainNumber}_${Format.sferaDate(date)}'; + } +} diff --git a/das_client/lib/service/sfera/sfera_service.dart b/das_client/lib/sfera/src/service/sfera_service_impl.dart similarity index 70% rename from das_client/lib/service/sfera/sfera_service.dart rename to das_client/lib/sfera/src/service/sfera_service_impl.dart index 259210e4..25c46aaa 100644 --- a/das_client/lib/service/sfera/sfera_service.dart +++ b/das_client/lib/sfera/src/service/sfera_service_impl.dart @@ -1,31 +1,20 @@ import 'dart:async'; import 'dart:core'; -import 'package:das_client/model/sfera/journey_profile.dart'; -import 'package:das_client/model/sfera/message_header.dart'; -import 'package:das_client/model/sfera/otn_id.dart'; -import 'package:das_client/model/sfera/segment_profile.dart'; -import 'package:das_client/model/sfera/sfera_g2b_reply_message.dart'; -import 'package:das_client/model/sfera/sfera_reply_parser.dart'; -import 'package:das_client/model/sfera/train_identification.dart'; -import 'package:das_client/repo/sfera_repository.dart'; -import 'package:das_client/service/mqtt/mqtt_service.dart'; -import 'package:das_client/service/sfera/handler/journey_profile_reply_handler.dart'; -import 'package:das_client/service/sfera/handler/segment_profile_reply_handler.dart'; -import 'package:das_client/service/sfera/handler/sfera_message_handler.dart'; -import 'package:das_client/service/sfera/sfera_service_state.dart'; -import 'package:das_client/service/sfera/task/handshake_task.dart'; -import 'package:das_client/service/sfera/task/request_journey_profile_task.dart'; -import 'package:das_client/service/sfera/task/request_segment_profiles_task.dart'; -import 'package:das_client/service/sfera/task/sfera_task.dart'; -import 'package:das_client/util/device_id_info.dart'; +import 'package:das_client/mqtt/mqtt_component.dart'; +import 'package:das_client/sfera/sfera_component.dart'; +import 'package:das_client/sfera/src/service/handler/journey_profile_reply_handler.dart'; +import 'package:das_client/sfera/src/service/handler/segment_profile_reply_handler.dart'; +import 'package:das_client/sfera/src/service/handler/sfera_message_handler.dart'; +import 'package:das_client/sfera/src/service/task/handshake_task.dart'; +import 'package:das_client/sfera/src/service/task/request_journey_profile_task.dart'; +import 'package:das_client/sfera/src/service/task/request_segment_profiles_task.dart'; +import 'package:das_client/sfera/src/service/task/sfera_task.dart'; import 'package:das_client/util/error_code.dart'; -import 'package:das_client/util/format.dart'; import 'package:fimber/fimber.dart'; import 'package:rxdart/rxdart.dart'; -import 'package:uuid/uuid.dart'; -class SferaService { +class SferaServiceImpl implements SferaService { final MqttService _mqttService; final SferaRepository _sferaRepository; @@ -34,20 +23,25 @@ class SferaService { final _stateSubject = BehaviorSubject.seeded(SferaServiceState.disconnected); + @override Stream get stateStream => _stateSubject.stream; final _journeyProfileSubject = BehaviorSubject.seeded(null); + @override Stream get journeyStream => _journeyProfileSubject.stream; final _segmentProfilesSubject = BehaviorSubject>(); + @override Stream> get segmentStream => _segmentProfilesSubject.stream; OtnId? otnId; + + @override ErrorCode? lastErrorCode; - SferaService({required MqttService mqttService, required SferaRepository sferaRepository}) + SferaServiceImpl({required MqttService mqttService, required SferaRepository sferaRepository}) : _mqttService = mqttService, _sferaRepository = sferaRepository { _init(); @@ -71,6 +65,7 @@ class SferaService { }); } + @override Future connect(OtnId otnId) async { Fimber.i('Starting new connection for $otnId'); this.otnId = otnId; @@ -78,7 +73,8 @@ class SferaService { lastErrorCode = null; _stateSubject.add(SferaServiceState.connecting); - if (await _mqttService.connect(otnId.company, sferaTrain(otnId.operationalTrainNumber, otnId.startDate))) { + if (await _mqttService.connect( + otnId.company, SferaService.sferaTrain(otnId.operationalTrainNumber, otnId.startDate))) { _stateSubject.add(SferaServiceState.handshaking); var handshakeTask = HandshakeTask(mqttService: _mqttService, otnId: otnId); _messageHandlers.add(handshakeTask); @@ -144,21 +140,12 @@ class SferaService { } } + @override void disconnect() { _mqttService.disconnect(); _stateSubject.add(SferaServiceState.disconnected); } - static Future messageHeader({TrainIdentification? trainIdentification}) async { - return MessageHeader.create(const Uuid().v4(), Format.sferaTimestamp(DateTime.now()), - await DeviceIdInfo.getDeviceId(), 'TMS', '1085', '0085', - trainIdentification: trainIdentification); - } - - static String sferaTrain(String trainNumber, DateTime date) { - return '${trainNumber}_${Format.sferaDate(date)}'; - } - void dispose() { _mqttStreamSubscription?.cancel(); _mqttStreamSubscription = null; diff --git a/das_client/lib/service/sfera/sfera_service_state.dart b/das_client/lib/sfera/src/service/sfera_service_state.dart similarity index 100% rename from das_client/lib/service/sfera/sfera_service_state.dart rename to das_client/lib/sfera/src/service/sfera_service_state.dart diff --git a/das_client/lib/service/sfera/task/handshake_task.dart b/das_client/lib/sfera/src/service/task/handshake_task.dart similarity index 70% rename from das_client/lib/service/sfera/task/handshake_task.dart rename to das_client/lib/sfera/src/service/task/handshake_task.dart index 14b8ea25..29826f02 100644 --- a/das_client/lib/service/sfera/task/handshake_task.dart +++ b/das_client/lib/sfera/src/service/task/handshake_task.dart @@ -1,21 +1,20 @@ -import 'package:das_client/model/sfera/das_operating_modes_supported.dart'; -import 'package:das_client/model/sfera/enums/das_architecture.dart'; -import 'package:das_client/model/sfera/enums/das_connectivity.dart'; -import 'package:das_client/model/sfera/enums/das_driving_mode.dart'; -import 'package:das_client/model/sfera/enums/related_train_request_type.dart'; -import 'package:das_client/model/sfera/handshake_request.dart'; -import 'package:das_client/model/sfera/otn_id.dart'; -import 'package:das_client/model/sfera/sfera_b2g_request_message.dart'; -import 'package:das_client/model/sfera/sfera_g2b_reply_message.dart'; -import 'package:das_client/service/mqtt/mqtt_service.dart'; -import 'package:das_client/service/sfera/sfera_service.dart'; -import 'package:das_client/service/sfera/task/sfera_task.dart'; +import 'package:das_client/mqtt/mqtt_component.dart'; +import 'package:das_client/sfera/src/model/das_operating_modes_supported.dart'; +import 'package:das_client/sfera/src/model/enums/das_architecture.dart'; +import 'package:das_client/sfera/src/model/enums/das_connectivity.dart'; +import 'package:das_client/sfera/src/model/enums/das_driving_mode.dart'; +import 'package:das_client/sfera/src/model/enums/related_train_request_type.dart'; +import 'package:das_client/sfera/src/model/handshake_request.dart'; +import 'package:das_client/sfera/src/model/otn_id.dart'; +import 'package:das_client/sfera/src/model/sfera_b2g_request_message.dart'; +import 'package:das_client/sfera/src/model/sfera_g2b_reply_message.dart'; +import 'package:das_client/sfera/src/service/sfera_service.dart'; +import 'package:das_client/sfera/src/service/task/sfera_task.dart'; import 'package:das_client/util/error_code.dart'; import 'package:fimber/fimber.dart'; class HandshakeTask extends SferaTask { - HandshakeTask({required MqttService mqttService, required this.otnId, super.timeout}) - : _mqttService = mqttService; + HandshakeTask({required MqttService mqttService, required this.otnId, super.timeout}) : _mqttService = mqttService; final MqttService _mqttService; final OtnId otnId; diff --git a/das_client/lib/service/sfera/task/request_journey_profile_task.dart b/das_client/lib/sfera/src/service/task/request_journey_profile_task.dart similarity index 71% rename from das_client/lib/service/sfera/task/request_journey_profile_task.dart rename to das_client/lib/sfera/src/service/task/request_journey_profile_task.dart index 0ce369c2..5e71295a 100644 --- a/das_client/lib/service/sfera/task/request_journey_profile_task.dart +++ b/das_client/lib/sfera/src/service/task/request_journey_profile_task.dart @@ -1,22 +1,19 @@ -import 'package:das_client/model/sfera/b2g_request.dart'; -import 'package:das_client/model/sfera/journey_profile.dart'; -import 'package:das_client/model/sfera/jp_request.dart'; -import 'package:das_client/model/sfera/otn_id.dart'; -import 'package:das_client/model/sfera/sfera_b2g_request_message.dart'; -import 'package:das_client/model/sfera/sfera_g2b_reply_message.dart'; -import 'package:das_client/model/sfera/train_identification.dart'; -import 'package:das_client/repo/sfera_repository.dart'; -import 'package:das_client/service/mqtt/mqtt_service.dart'; -import 'package:das_client/service/sfera/sfera_service.dart'; -import 'package:das_client/service/sfera/task/sfera_task.dart'; +import 'package:das_client/mqtt/mqtt_component.dart'; +import 'package:das_client/sfera/src/model/b2g_request.dart'; +import 'package:das_client/sfera/src/model/journey_profile.dart'; +import 'package:das_client/sfera/src/model/jp_request.dart'; +import 'package:das_client/sfera/src/model/otn_id.dart'; +import 'package:das_client/sfera/src/model/sfera_b2g_request_message.dart'; +import 'package:das_client/sfera/src/model/sfera_g2b_reply_message.dart'; +import 'package:das_client/sfera/src/model/train_identification.dart'; +import 'package:das_client/sfera/src/repo/sfera_repository.dart'; +import 'package:das_client/sfera/src/service/sfera_service.dart'; +import 'package:das_client/sfera/src/service/task/sfera_task.dart'; import 'package:fimber/fimber.dart'; class RequestJourneyProfileTask extends SferaTask { RequestJourneyProfileTask( - {required MqttService mqttService, - required SferaRepository sferaRepository, - required this.otnId, - super.timeout}) + {required MqttService mqttService, required SferaRepository sferaRepository, required this.otnId, super.timeout}) : _mqttService = mqttService, _sferaRepository = sferaRepository; diff --git a/das_client/lib/service/sfera/task/request_segment_profiles_task.dart b/das_client/lib/sfera/src/service/task/request_segment_profiles_task.dart similarity index 64% rename from das_client/lib/service/sfera/task/request_segment_profiles_task.dart rename to das_client/lib/sfera/src/service/task/request_segment_profiles_task.dart index d046f36e..3c66dfca 100644 --- a/das_client/lib/service/sfera/task/request_segment_profiles_task.dart +++ b/das_client/lib/sfera/src/service/task/request_segment_profiles_task.dart @@ -1,24 +1,25 @@ -import 'package:das_client/model/sfera/b2g_request.dart'; -import 'package:das_client/model/sfera/journey_profile.dart'; -import 'package:das_client/model/sfera/otn_id.dart'; -import 'package:das_client/model/sfera/segment_profile.dart'; -import 'package:das_client/model/sfera/segment_profile_list.dart'; -import 'package:das_client/model/sfera/sfera_b2g_request_message.dart'; -import 'package:das_client/model/sfera/sfera_g2b_reply_message.dart'; -import 'package:das_client/model/sfera/sp_request.dart'; -import 'package:das_client/model/sfera/train_identification.dart'; -import 'package:das_client/repo/sfera_repository.dart'; -import 'package:das_client/service/mqtt/mqtt_service.dart'; -import 'package:das_client/service/sfera/sfera_service.dart'; -import 'package:das_client/service/sfera/task/sfera_task.dart'; +import 'package:das_client/mqtt/mqtt_component.dart'; +import 'package:das_client/sfera/src/model/b2g_request.dart'; +import 'package:das_client/sfera/src/model/journey_profile.dart'; +import 'package:das_client/sfera/src/model/otn_id.dart'; +import 'package:das_client/sfera/src/model/segment_profile.dart'; +import 'package:das_client/sfera/src/model/segment_profile_list.dart'; +import 'package:das_client/sfera/src/model/sfera_b2g_request_message.dart'; +import 'package:das_client/sfera/src/model/sfera_g2b_reply_message.dart'; +import 'package:das_client/sfera/src/model/sp_request.dart'; +import 'package:das_client/sfera/src/model/train_identification.dart'; +import 'package:das_client/sfera/src/repo/sfera_repository.dart'; +import 'package:das_client/sfera/src/service/sfera_service.dart'; +import 'package:das_client/sfera/src/service/task/sfera_task.dart'; import 'package:fimber/fimber.dart'; class RequestSegmentProfilesTask extends SferaTask> { - RequestSegmentProfilesTask({required MqttService mqttService, - required SferaRepository sferaRepository, - required this.otnId, - required this.journeyProfile, - super.timeout}) + RequestSegmentProfilesTask( + {required MqttService mqttService, + required SferaRepository sferaRepository, + required this.otnId, + required this.journeyProfile, + super.timeout}) : _mqttService = mqttService, _sferaRepository = sferaRepository; @@ -39,7 +40,6 @@ class RequestSegmentProfilesTask extends SferaTask> { } Future _requestSegmentProfiles() async { - var missingSp = await findMissingSegmentProfiles(); if (missingSp.isEmpty) { Fimber.i('No missing SegmentProfiles found...'); @@ -49,7 +49,8 @@ class RequestSegmentProfilesTask extends SferaTask> { List spRequests = []; for (var sp in missingSp) { - spRequests.add(SpRequest.create(id: sp.spId, versionMajor: sp.versionMajor, versionMinor: sp.versionMinor, spZone: sp.spZone)); + spRequests.add(SpRequest.create( + id: sp.spId, versionMajor: sp.versionMajor, versionMinor: sp.versionMinor, spZone: sp.spZone)); } var trainIdentification = TrainIdentification.create(otnId: otnId); @@ -67,8 +68,8 @@ class RequestSegmentProfilesTask extends SferaTask> { var missingSps = []; for (var segment in journeyProfile.segmentProfilesLists) { - var existingProfile = await _sferaRepository.findSegmentProfile( - segment.spId, segment.versionMajor, segment.versionMinor); + var existingProfile = + await _sferaRepository.findSegmentProfile(segment.spId, segment.versionMajor, segment.versionMinor); if (existingProfile == null) { missingSps.add(segment); } diff --git a/das_client/lib/service/sfera/task/sfera_task.dart b/das_client/lib/sfera/src/service/task/sfera_task.dart similarity index 91% rename from das_client/lib/service/sfera/task/sfera_task.dart rename to das_client/lib/sfera/src/service/task/sfera_task.dart index 7716c70c..ede1d366 100644 --- a/das_client/lib/service/sfera/task/sfera_task.dart +++ b/das_client/lib/sfera/src/service/task/sfera_task.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'package:das_client/service/sfera/handler/sfera_message_handler.dart'; +import 'package:das_client/sfera/src/service/handler/sfera_message_handler.dart'; import 'package:das_client/util/error_code.dart'; import 'package:fimber/fimber.dart'; diff --git a/das_client/lib/model/sfera/sfera_reply_parser.dart b/das_client/lib/sfera/src/sfera_reply_parser.dart similarity index 73% rename from das_client/lib/model/sfera/sfera_reply_parser.dart rename to das_client/lib/sfera/src/sfera_reply_parser.dart index 048c3931..8cda0dd1 100644 --- a/das_client/lib/model/sfera/sfera_reply_parser.dart +++ b/das_client/lib/sfera/src/sfera_reply_parser.dart @@ -1,27 +1,27 @@ -import 'package:das_client/model/sfera/das_operating_modes_selected.dart'; -import 'package:das_client/model/sfera/g2b_reply_payload.dart'; -import 'package:das_client/model/sfera/handshake_acknowledgement.dart'; -import 'package:das_client/model/sfera/handshake_reject.dart'; -import 'package:das_client/model/sfera/journey_profile.dart'; -import 'package:das_client/model/sfera/message_header.dart'; -import 'package:das_client/model/sfera/otn_id.dart'; -import 'package:das_client/model/sfera/segment_profile.dart'; -import 'package:das_client/model/sfera/segment_profile_list.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; -import 'package:das_client/model/sfera/sfera_g2b_reply_message.dart'; -import 'package:das_client/model/sfera/signal.dart'; -import 'package:das_client/model/sfera/signal_id.dart'; -import 'package:das_client/model/sfera/sp_points.dart'; -import 'package:das_client/model/sfera/sp_zone.dart'; -import 'package:das_client/model/sfera/stopping_point_information.dart'; -import 'package:das_client/model/sfera/timing_point.dart'; -import 'package:das_client/model/sfera/timing_point_constraints.dart'; -import 'package:das_client/model/sfera/timing_point_reference.dart'; -import 'package:das_client/model/sfera/tp_id_reference.dart'; -import 'package:das_client/model/sfera/tp_name.dart'; -import 'package:das_client/model/sfera/train_identification.dart'; -import 'package:das_client/model/sfera/virtual_balise.dart'; -import 'package:das_client/model/sfera/virtual_balise_position.dart'; +import 'package:das_client/sfera/src/model/das_operating_modes_selected.dart'; +import 'package:das_client/sfera/src/model/g2b_reply_payload.dart'; +import 'package:das_client/sfera/src/model/handshake_acknowledgement.dart'; +import 'package:das_client/sfera/src/model/handshake_reject.dart'; +import 'package:das_client/sfera/src/model/journey_profile.dart'; +import 'package:das_client/sfera/src/model/message_header.dart'; +import 'package:das_client/sfera/src/model/otn_id.dart'; +import 'package:das_client/sfera/src/model/segment_profile.dart'; +import 'package:das_client/sfera/src/model/segment_profile_list.dart'; +import 'package:das_client/sfera/src/model/sfera_g2b_reply_message.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/signal.dart'; +import 'package:das_client/sfera/src/model/signal_id.dart'; +import 'package:das_client/sfera/src/model/sp_points.dart'; +import 'package:das_client/sfera/src/model/sp_zone.dart'; +import 'package:das_client/sfera/src/model/stopping_point_information.dart'; +import 'package:das_client/sfera/src/model/timing_point.dart'; +import 'package:das_client/sfera/src/model/timing_point_constraints.dart'; +import 'package:das_client/sfera/src/model/timing_point_reference.dart'; +import 'package:das_client/sfera/src/model/tp_id_reference.dart'; +import 'package:das_client/sfera/src/model/tp_name.dart'; +import 'package:das_client/sfera/src/model/train_identification.dart'; +import 'package:das_client/sfera/src/model/virtual_balise.dart'; +import 'package:das_client/sfera/src/model/virtual_balise_position.dart'; import 'package:xml/xml.dart'; class SferaReplyParser { diff --git a/das_client/test/model/sfera/sfera_document_test.dart b/das_client/test/sfera/model/sfera_document_test.dart similarity index 83% rename from das_client/test/model/sfera/sfera_document_test.dart rename to das_client/test/sfera/model/sfera_document_test.dart index c67851cc..72fd22b3 100644 --- a/das_client/test/model/sfera/sfera_document_test.dart +++ b/das_client/test/sfera/model/sfera_document_test.dart @@ -1,17 +1,17 @@ import 'dart:io'; -import 'package:das_client/model/sfera/das_operating_modes_supported.dart'; -import 'package:das_client/model/sfera/enums/das_architecture.dart'; -import 'package:das_client/model/sfera/enums/das_connectivity.dart'; -import 'package:das_client/model/sfera/enums/das_driving_mode.dart'; -import 'package:das_client/model/sfera/enums/handshake_reject_reason.dart'; -import 'package:das_client/model/sfera/enums/related_train_request_type.dart'; -import 'package:das_client/model/sfera/handshake_request.dart'; -import 'package:das_client/model/sfera/message_header.dart'; -import 'package:das_client/model/sfera/sfera_b2g_request_message.dart'; -import 'package:das_client/model/sfera/sfera_g2b_reply_message.dart'; -import 'package:das_client/model/sfera/sfera_reply_parser.dart'; -import 'package:das_client/model/sfera/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/model/das_operating_modes_supported.dart'; +import 'package:das_client/sfera/src/model/enums/das_architecture.dart'; +import 'package:das_client/sfera/src/model/enums/das_connectivity.dart'; +import 'package:das_client/sfera/src/model/enums/das_driving_mode.dart'; +import 'package:das_client/sfera/src/model/enums/handshake_reject_reason.dart'; +import 'package:das_client/sfera/src/model/enums/related_train_request_type.dart'; +import 'package:das_client/sfera/src/model/handshake_request.dart'; +import 'package:das_client/sfera/src/model/message_header.dart'; +import 'package:das_client/sfera/src/model/sfera_b2g_request_message.dart'; +import 'package:das_client/sfera/src/model/sfera_g2b_reply_message.dart'; +import 'package:das_client/sfera/src/model/sfera_xml_element.dart'; +import 'package:das_client/sfera/src/sfera_reply_parser.dart'; import 'package:fimber/fimber.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -59,8 +59,7 @@ void main() { expect(payload.segmentProfiles.first.points!.timingPoints, hasLength(3)); expect(payload.segmentProfiles.first.points!.timingPoints.first.id, '1837'); expect(payload.segmentProfiles.first.points!.timingPoints.first.location, '0'); - expect( - payload.segmentProfiles.first.points!.timingPoints.first.names.first.name, 'MEER-GRENS'); + expect(payload.segmentProfiles.first.points!.timingPoints.first.names.first.name, 'MEER-GRENS'); expect(payload.segmentProfiles.first.points!.signals, hasLength(9)); expect(payload.segmentProfiles.first.points!.signals.first.id.physicalId, '102346'); @@ -80,7 +79,8 @@ void main() { DasDrivingMode.goa1, DasArchitecture.boardAdviceCalculation, DasConnectivity.standalone) ], relatedTrainRequestType: RelatedTrainRequestType.ownTrainAndOrRelatedTrains, statusReportsEnabled: true); - var messageHeader = MessageHeader.create('a24e63c3-ab2e-4102-9a10-ba058dec5efe', '2019-09-26T20:07:36Z', 'DAS', 'TMS', '1084', '0084'); + var messageHeader = MessageHeader.create( + 'a24e63c3-ab2e-4102-9a10-ba058dec5efe', '2019-09-26T20:07:36Z', 'DAS', 'TMS', '1084', '0084'); var sferaB2gRequestMessage = SferaB2gRequestMessage.create(messageHeader, handshakeRequest: handshakeRequest); expect(sferaB2gRequestMessage.validate(), true); diff --git a/das_client/test/service/sfera/sfera_handshake_task_test.dart b/das_client/test/sfera/service/sfera_handshake_task_test.dart similarity index 89% rename from das_client/test/service/sfera/sfera_handshake_task_test.dart rename to das_client/test/sfera/service/sfera_handshake_task_test.dart index 98006850..57156b96 100644 --- a/das_client/test/service/sfera/sfera_handshake_task_test.dart +++ b/das_client/test/sfera/service/sfera_handshake_task_test.dart @@ -1,10 +1,8 @@ import 'dart:io'; -import 'package:das_client/model/sfera/otn_id.dart'; -import 'package:das_client/model/sfera/sfera_g2b_reply_message.dart'; -import 'package:das_client/model/sfera/sfera_reply_parser.dart'; -import 'package:das_client/service/mqtt/mqtt_service.dart'; -import 'package:das_client/service/sfera/task/handshake_task.dart'; +import 'package:das_client/mqtt/mqtt_component.dart'; +import 'package:das_client/sfera/sfera_component.dart'; +import 'package:das_client/sfera/src/service/task/handshake_task.dart'; import 'package:das_client/util/error_code.dart'; import 'package:fimber/fimber.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -34,7 +32,7 @@ void main() { await handshakeTask.execute((task, data) { expect(task, handshakeTask); expect(data, isNull); - },(task, errorCode) { + }, (task, errorCode) { fail('Task failed with error code $errorCode'); }); @@ -54,7 +52,7 @@ void main() { await handshakeTask.execute((task, data) { fail('Task should not be sucessful'); - },(task, errorCode) { + }, (task, errorCode) { expect(errorCode, ErrorCode.sferaHandshakeRejected); }); @@ -74,7 +72,7 @@ void main() { await handshakeTask.execute((task, data) { fail('Test should not call success'); - },(task, errorCode) { + }, (task, errorCode) { fail('Test should not call error'); }); diff --git a/das_client/test/service/sfera/sfera_request_journey_profile_task_test.dart b/das_client/test/sfera/service/sfera_request_journey_profile_task_test.dart similarity index 91% rename from das_client/test/service/sfera/sfera_request_journey_profile_task_test.dart rename to das_client/test/sfera/service/sfera_request_journey_profile_task_test.dart index b17909b2..3dcf2779 100644 --- a/das_client/test/service/sfera/sfera_request_journey_profile_task_test.dart +++ b/das_client/test/sfera/service/sfera_request_journey_profile_task_test.dart @@ -1,11 +1,8 @@ import 'dart:io'; -import 'package:das_client/model/sfera/otn_id.dart'; -import 'package:das_client/model/sfera/sfera_g2b_reply_message.dart'; -import 'package:das_client/model/sfera/sfera_reply_parser.dart'; -import 'package:das_client/repo/sfera_repository.dart'; -import 'package:das_client/service/mqtt/mqtt_service.dart'; -import 'package:das_client/service/sfera/task/request_journey_profile_task.dart'; +import 'package:das_client/mqtt/mqtt_component.dart'; +import 'package:das_client/sfera/sfera_component.dart'; +import 'package:das_client/sfera/src/service/task/request_journey_profile_task.dart'; import 'package:das_client/util/error_code.dart'; import 'package:fimber/fimber.dart'; import 'package:flutter_test/flutter_test.dart';