Skip to content

Conversation

@fabieu
Copy link
Owner

@fabieu fabieu commented Dec 25, 2025

This pull request refactors the way tracks are represented and accessed throughout the codebase, replacing the old Track enum with a more flexible RaceTrack class and a RaceTracks registry. This change enables support for multiple simulations and improves extensibility. The update also touches several controllers and entity classes to use the new structure, and introduces a new Simulation enum to handle different racing simulations.

Key changes include:

Track Representation and Registry

  • Replaced the old Track enum with a new RaceTrack class and a RaceTracks registry, allowing tracks to be defined with global IDs, display names, coordinates, and simulation-specific IDs. This makes it easier to support multiple simulations and extend the track list in the future. (RaceTrack.java, RaceTracks.java) [1] [2]
  • Removed the obsolete Track enum and its associated methods, consolidating all track-related logic into the new classes. (Track.java)

Simulation Support

  • Added a new Simulation enum to represent different racing simulations (e.g., ACC, LMU), which is now used throughout the codebase for track lookups and associations. (Simulation.java)

Controller and Entity Updates

  • Updated WeatherController to use trackId (global) instead of accTrackId, and to fetch tracks via RaceTracks.getById. Improved error handling for unknown tracks. (WeatherController.java) [1] [2] [3]
  • Modified the Session entity to store a simulationId and use the new RaceTrack structure for track lookups. (Session.java) [1] [2]

Sorting and Comparison

  • Introduced AccBopComparator to sort Bop entities using the new RaceTracks registry and simulation-aware lookups. (AccBopComparator.java)This pull request refactors how tracks are represented and accessed in the codebase, generalizing the concept from Track (specific to ACC) to a more flexible RaceTrack model that supports multiple simulations. It introduces new entities for simulations and racetracks, updates controller and session logic to use these, and removes the legacy Track enum. These changes improve extensibility and maintainability, making it easier to support additional simulations beyond ACC.

Track and Simulation Model Refactoring

  • Added new RaceTrack, RaceTracks, and Simulation entities to provide a unified and extensible way to represent tracks across different simulations, replacing the previous ACC-specific Track enum. ([[1]](https://github.com/fabieu/simdesk/pull/278/files#diff-ed15fb117d3100a4d39ab91ae6070cfe1c02608b8113dc4b5971e7eeac73e432R1-R26), [[2]](https://github.com/fabieu/simdesk/pull/278/files#diff-a40c315d9e8fab989c3d5c52466939a931b5839a95d69c50a2842b665762bf57R1-R343), [[3]](https://github.com/fabieu/simdesk/pull/278/files#diff-96e23c50eda6b3c11be7b5e5a380186cf4cbfccfc143f74c79da016f04a98ebeR1-R24))
  • Removed the legacy Track enum and its associated methods, migrating all track-related logic to use RaceTrack and RaceTracks. ([simdesk-web/src/main/java/de/sustineo/simdesk/entities/Track.javaL1-L76](https://github.com/fabieu/simdesk/pull/278/files#diff-61262593194a6130c10e6426737ff9896aec4a0b494a74cab78a8a18668e134fL1-L76))

Controller and API Changes

  • Updated WeatherController endpoints to accept both simulationId and trackId parameters instead of just accTrackId, and refactored logic to fetch tracks using the new RaceTracks.getById method. ([[1]](https://github.com/fabieu/simdesk/pull/278/files#diff-76b68d37f58020c648b7a24c4e560c651e6e82454a99b22b2b4e50c7c96720f5L61-R70), [[2]](https://github.com/fabieu/simdesk/pull/278/files#diff-76b68d37f58020c648b7a24c4e560c651e6e82454a99b22b2b4e50c7c96720f5L85-R108), [[3]](https://github.com/fabieu/simdesk/pull/278/files#diff-76b68d37f58020c648b7a24c4e560c651e6e82454a99b22b2b4e50c7c96720f5L4-R6))

Entity Updates

  • Updated the Session entity to include a simulationId field and use RaceTrack instead of Track for track lookups. ([[1]](https://github.com/fabieu/simdesk/pull/278/files#diff-3e91b5502c7571fa88ad325fa5cc9bed50c37976896de67e5c8c9661e3363c92R16), [[2]](https://github.com/fabieu/simdesk/pull/278/files#diff-3e91b5502c7571fa88ad325fa5cc9bed50c37976896de67e5c8c9661e3363c92L26-R28))

Comparator Improvements

  • Refactored BopComparator to use the new RaceTracks and Simulation entities for sorting by track display name, improving sorting logic and consistency. ([simdesk-web/src/main/java/de/sustineo/simdesk/entities/comparator/BopComparator.javaR3-R17](https://github.com/fabieu/simdesk/pull/278/files#diff-7bdd09b00697c017adfb91eb3ed7c5192c4224f5a34aee6f10cbc985c6502b02R3-R17))This pull request refactors the way tracks are represented and accessed throughout the codebase, replacing the previous Track enum with a new, more flexible RaceTrack class and associated utilities. It introduces support for multiple simulations (such as ACC and LMU) and enables querying tracks by simulation and track ID. The changes also update controller, entity, and comparator logic to use the new track system.

Track Representation Refactor:

  • Removed the old Track enum and related static methods, replacing it with the new RaceTrack class and the RaceTracks registry, which supports multiple simulations and provides flexible lookup and registration of tracks. (simdesk-web/src/main/java/de/sustineo/simdesk/entities/Track.java, simdesk-web/src/main/java/de/sustineo/simdesk/entities/RaceTrack.java, simdesk-web/src/main/java/de/sustineo/simdesk/entities/RaceTracks.java) [1] [2] [3]
  • Added the Simulation enum to represent supported simulation platforms and enable track lookup per simulation. (simdesk-web/src/main/java/de/sustineo/simdesk/entities/Simulation.java)

Controller and Entity Updates:

  • Updated the WeatherController to accept simulationId and trackId parameters instead of just accTrackId, and to use the new track lookup logic, improving error handling and flexibility for future simulation support. (simdesk-web/src/main/java/de/sustineo/simdesk/controller/WeatherController.java) [1] [2] [3]
  • Refactored the Session entity to store simulationId and use the new RaceTrack lookup instead of the old Track enum. (simdesk-web/src/main/java/de/sustineo/simdesk/entities/Session.java) [1] [2]

Comparator Update:

  • Simplified and improved the BopComparator to use the new RaceTrack display name for sorting, ensuring consistent ordering across simulations. (simdesk-web/src/main/java/de/sustineo/simdesk/entities/comparator/BopComparator.java)

@fabieu fabieu requested a review from Copilot December 25, 2025 04:45
@fabieu fabieu self-assigned this Dec 25, 2025
@fabieu fabieu added the enhancement New feature or request label Dec 25, 2025
@fabieu fabieu linked an issue Dec 25, 2025 that may be closed by this pull request
3 tasks
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors track-related entities from a single Track enum to a more flexible RaceTrack class with simulation-specific support. The refactoring introduces a Simulation enum (ACC, LMU) and a RaceTracks registry pattern to enable support for multiple racing simulations.

Key changes:

  • Replaced Track enum with RaceTrack class and RaceTracks static registry
  • Introduced Simulation enum to support multiple racing simulations (ACC and LMU)
  • Updated all track references throughout views, services, filters, and entities to use the new RaceTrack API

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
entities/Track.java Removed enum - replaced by RaceTrack class
entities/Simulation.java New enum defining supported simulations (ACC, LMU)
entities/RaceTrack.java New class representing a race track with simulation-specific IDs
entities/RaceTracks.java Static registry providing access to all race tracks
entities/Session.java Updated to use RaceTrack instead of Track enum
entities/json/kunos/acc/AccBop.java Renamed getTrack() to getRaceTrack()
entities/comparator/BopComparator.java Simplified to use fluent comparator API with RaceTrack
entities/record/LapByTrack.java Updated to use RaceTrack, removed factory method
entities/record/LapsByTrack.java Updated to use RaceTrack, removed factory method
entities/record/LapsByAccCar.java Removed factory method (unrelated cleanup)
views/filter/grid/SessionFilter.java Renamed track field to raceTrack
views/filter/grid/OverallLapTimesFilter.java Updated to use RaceTracks.getById()
views/filter/grid/BopManagementFilter.java Updated to use RaceTracks.getById()
views/filter/grid/GridFilter.java Removed generic type constraint from createComboBoxHeader
views/SessionComponentFactory.java Updated to use RaceTracks.getById() for display
views/MapView.java Updated variable names and iteration over RaceTracks
views/LeaderboardSessionsView.java Updated grid column and filter to use RaceTrack
views/LeaderboardOverallLapTimesView.java Updated grid column and filter to use RaceTrack
views/LeaderboardOverallLapTimesDifferentiatedView.java Updated to use RaceTrack with simulation support
views/LeaderboardDriverDetailView.java Updated lap grouping and grid to use RaceTrack
views/EntrylistEditorView.java Updated grid column to use RaceTrack display name
views/BopManagementView.java Comprehensive update to use RaceTrack throughout
views/BopEditorView.java Updated ComboBox and validation to use RaceTrack
views/BopDisplayView.java Added simulation parameter support, updated to use RaceTrack
views/BaseView.java Added QUERY_PARAMETER_SIMULATION_ID constant, removed unused constant
services/weather/WeatherService.java Updated to use RaceTrack for weather data storage
services/bop/BopService.java Updated initialization to use RaceTracks registry
controller/WeatherController.java Updated API to accept simulationId and trackId parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 32 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 33 out of 33 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fabieu and others added 2 commits December 25, 2025 11:14
@fabieu fabieu merged commit da90e37 into main Dec 25, 2025
1 check passed
@fabieu fabieu deleted the 277-refactor-track-entity branch December 25, 2025 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor track entity and make independent of game (simulation)

2 participants