VSN-1998 : Integrating api call to prepared passenger associated establishment & dynamising the invocation based on form context.
Merge Request Description
Title
Dynamic Retrieval of Associated Establishment Schedules Based on Form Context
Overview
This merge request introduces a new feature that enables dynamic retrieval of establishment schedules associated with prepared passengers. The implementation adapts the API behavior based on the current form context (prepared vs final), ensuring that the correct data source and endpoint are used transparently. This enhancement improves data consistency, reduces duplication, and aligns schedule extraction logic with the actual lifecycle of prepared passengers.
Scope of Changes
The changes span across API definition, service layer, and integration logic to fully support context-aware schedule retrieval.
Detailed Changes
1. Endpoint Definition
- Added a new REST endpoint dedicated to fetching establishment schedules linked to prepared passengers.
- The endpoint is designed to be context-aware, allowing differentiation between:
- Prepared (draft) passenger context
- Final (validated) passenger context
- This ensures that schedule data is retrieved from the appropriate backend source without requiring duplicated endpoints.
2. Service Layer Enhancements
- Introduced a new method signature in the service layer responsible for fetching establishment schedules.
- The service method abstracts the decision logic related to:
- Which repository or external call to use
- How to map results based on the current form context
- This keeps controllers lightweight and maintains a clean separation of concerns.
3. Method Implementation
- Implemented the service method to handle:
- Retrieval of establishment schedules associated with prepared passengers
- Conditional logic that adapts behavior depending on whether the form is in preparation or final mode
- The implementation ensures:
- Correct parameter propagation (establishment identifiers, context flags)
- Consistent mapping of schedule data into response DTOs
- Safe handling of missing or incomplete data scenarios
4. Dynamic API Call Based on Form Context
- Enhanced the integration layer to dynamically select the appropriate API call depending on the form context.
- When the form is in:
- Prepared mode: schedules are fetched from prepared passenger associations
- Final mode: schedules are fetched from finalized passenger associations
- This dynamic behavior eliminates hardcoded assumptions and makes the feature reusable across multiple views and workflows.
Benefits
- Improves flexibility by supporting multiple passenger lifecycle states
- Prevents data inconsistency between prepared and final forms
- Reduces technical debt by centralizing context-based logic in the service layer
- Enhances maintainability and future extensibility of schedule-related features
Impacted Areas
- REST API (new endpoint)
- Service layer (new method signature and implementation)
- Integration logic (context-aware API invocation)
Backward Compatibility
- Existing endpoints and functionalities remain unchanged
- The new feature is additive and does not introduce breaking changes
Conclusion
This merge request provides a robust and scalable solution for retrieving establishment schedules associated with prepared passengers. By dynamically adapting to the form context, the implementation ensures correctness, reduces duplication, and aligns with best practices in API and service design.
Closes VSN-1998