From 69e984a126163bbbdc471f4b1c471c17861b3136 Mon Sep 17 00:00:00 2001 From: hamz2a Date: Wed, 17 Apr 2024 11:43:42 +0200 Subject: [PATCH 1/3] editoast: move SpeedSection to editoast_schemas --- editoast/editoast_schemas/src/infra.rs | 3 +++ .../src/infra}/speed_section.rs | 14 +++++++------- editoast/src/converters/utils.rs | 2 ++ .../src/generated_data/error/speed_sections.rs | 2 +- editoast/src/infra_cache/mod.rs | 3 ++- .../object_cache/speed_section_cache.rs | 2 +- editoast/src/infra_cache/operation/create.rs | 4 ++-- editoast/src/modelsv2/infra.rs | 1 + editoast/src/modelsv2/infra_objects.rs | 2 +- editoast/src/schema/mod.rs | 3 --- editoast/src/schema/railjson.rs | 2 +- editoast/src/views/infra/auto_fixes/mod.rs | 2 +- .../src/views/infra/auto_fixes/speed_section.rs | 4 ++-- editoast/src/views/infra/mod.rs | 2 +- 14 files changed, 25 insertions(+), 21 deletions(-) rename editoast/{src/schema => editoast_schemas/src/infra}/speed_section.rs (94%) diff --git a/editoast/editoast_schemas/src/infra.rs b/editoast/editoast_schemas/src/infra.rs index cbb3e303bd8..c3b6079bc7e 100644 --- a/editoast/editoast_schemas/src/infra.rs +++ b/editoast/editoast_schemas/src/infra.rs @@ -11,6 +11,7 @@ mod neutral_section; mod side; mod sign; mod signal; +mod speed_section; mod switch; mod switch_type; mod track_endpoint; @@ -38,6 +39,8 @@ pub use signal::LogicalSignal; pub use signal::Signal; pub use signal::SignalExtensions; pub use signal::SignalSncfExtension; +pub use speed_section::Speed; +pub use speed_section::SpeedSection; pub use switch::Switch; pub use switch_type::builtin_node_types_list; pub use switch_type::Crossing; diff --git a/editoast/src/schema/speed_section.rs b/editoast/editoast_schemas/src/infra/speed_section.rs similarity index 94% rename from editoast/src/schema/speed_section.rs rename to editoast/editoast_schemas/src/infra/speed_section.rs index 6482c1627c5..bf136e7ccc8 100644 --- a/editoast/src/schema/speed_section.rs +++ b/editoast/editoast_schemas/src/infra/speed_section.rs @@ -1,16 +1,16 @@ use std::collections::HashMap; use derivative::Derivative; +use editoast_common::Identifier; +use editoast_common::NonBlankString; use serde::Deserialize; use serde::Serialize; -use super::OSRDIdentified; -use super::ObjectType; -use editoast_common::Identifier; -use editoast_common::NonBlankString; -use editoast_schemas::infra::ApplicableDirectionsTrackRange; -use editoast_schemas::infra::Sign; -use editoast_schemas::primitives::OSRDTyped; +use super::ApplicableDirectionsTrackRange; +use super::Sign; +use crate::primitives::OSRDIdentified; +use crate::primitives::OSRDTyped; +use crate::primitives::ObjectType; #[derive(Debug, Derivative, Clone, Serialize, PartialEq, Copy)] pub struct Speed(pub f64); diff --git a/editoast/src/converters/utils.rs b/editoast/src/converters/utils.rs index 982ed117a04..47dac6074ce 100644 --- a/editoast/src/converters/utils.rs +++ b/editoast/src/converters/utils.rs @@ -8,6 +8,8 @@ use editoast_schemas::infra::LogicalSignal; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SignalExtensions; use editoast_schemas::infra::SignalSncfExtension; +use editoast_schemas::infra::Speed; +use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; use std::collections::HashMap; use std::str::FromStr; diff --git a/editoast/src/generated_data/error/speed_sections.rs b/editoast/src/generated_data/error/speed_sections.rs index 943d69d2eb3..ddb991f14e4 100644 --- a/editoast/src/generated_data/error/speed_sections.rs +++ b/editoast/src/generated_data/error/speed_sections.rs @@ -150,7 +150,7 @@ mod tests { use crate::infra_cache::tests::create_small_infra_cache; use crate::infra_cache::tests::create_speed_section_cache; use crate::infra_cache::Graph; - use crate::schema::Speed; + use editoast_schemas::infra::Speed; use editoast_schemas::primitives::ObjectRef; use editoast_schemas::primitives::ObjectType; diff --git a/editoast/src/infra_cache/mod.rs b/editoast/src/infra_cache/mod.rs index bfa17838185..fbf448ceb2f 100644 --- a/editoast/src/infra_cache/mod.rs +++ b/editoast/src/infra_cache/mod.rs @@ -28,6 +28,7 @@ use editoast_schemas::infra::Endpoint; use editoast_schemas::infra::Link; use editoast_schemas::infra::PointSwitch; use editoast_schemas::infra::SingleSlipSwitch; +use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::SwitchType; use editoast_schemas::infra::TrackEndpoint; use editoast_schemas::infra::Waypoint; @@ -862,7 +863,6 @@ pub mod tests { use crate::modelsv2::infra::tests::test_infra_transaction; use crate::schema::OperationalPoint; use crate::schema::Route; - use crate::schema::SpeedSection; use editoast_common::Identifier; use editoast_common::NonBlankString; use editoast_schemas::infra::ApplicableDirections; @@ -870,6 +870,7 @@ pub mod tests { use editoast_schemas::infra::Direction; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::Endpoint; + use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; use editoast_schemas::infra::SwitchPortConnection; use editoast_schemas::infra::SwitchType; diff --git a/editoast/src/infra_cache/object_cache/speed_section_cache.rs b/editoast/src/infra_cache/object_cache/speed_section_cache.rs index a518018366a..cebec18a626 100644 --- a/editoast/src/infra_cache/object_cache/speed_section_cache.rs +++ b/editoast/src/infra_cache/object_cache/speed_section_cache.rs @@ -1,6 +1,6 @@ use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; -use crate::schema::SpeedSection; +use editoast_schemas::infra::SpeedSection; impl Cache for SpeedSection { fn get_track_referenced_id(&self) -> Vec<&String> { diff --git a/editoast/src/infra_cache/operation/create.rs b/editoast/src/infra_cache/operation/create.rs index 1b1c6f8f040..26e5a76c99a 100644 --- a/editoast/src/infra_cache/operation/create.rs +++ b/editoast/src/infra_cache/operation/create.rs @@ -14,13 +14,13 @@ use crate::error::Result; use crate::modelsv2::get_table; use crate::schema::OperationalPoint; use crate::schema::Route; -use crate::schema::SpeedSection; use crate::schema::TrackSection; use editoast_schemas::infra::BufferStop; use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::NeutralSection; use editoast_schemas::infra::Signal; +use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; use editoast_schemas::infra::SwitchType; use editoast_schemas::primitives::OSRDIdentified; @@ -252,12 +252,12 @@ pub mod tests { use crate::modelsv2::infra::tests::test_infra_transaction; use crate::schema::OperationalPoint; use crate::schema::Route; - use crate::schema::SpeedSection; use crate::schema::TrackSection; use editoast_schemas::infra::BufferStop; use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::Signal; + use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; use editoast_schemas::infra::SwitchType; diff --git a/editoast/src/modelsv2/infra.rs b/editoast/src/modelsv2/infra.rs index b01992078b9..fc779a23f6f 100644 --- a/editoast/src/modelsv2/infra.rs +++ b/editoast/src/modelsv2/infra.rs @@ -251,6 +251,7 @@ pub mod tests { use editoast_schemas::infra::Electrification; use editoast_schemas::infra::NeutralSection; use editoast_schemas::infra::Signal; + use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; use editoast_schemas::infra::SwitchType; use editoast_schemas::primitives::OSRDIdentified; diff --git a/editoast/src/modelsv2/infra_objects.rs b/editoast/src/modelsv2/infra_objects.rs index 309fe37731b..d75a58c9264 100644 --- a/editoast/src/modelsv2/infra_objects.rs +++ b/editoast/src/modelsv2/infra_objects.rs @@ -189,7 +189,7 @@ infra_model!( SpeedSectionModel, infra_object_speed_section, infra_layer_speed_section, - schema::SpeedSection + editoast_schemas::infra::SpeedSection ); infra_model!( diff --git a/editoast/src/schema/mod.rs b/editoast/src/schema/mod.rs index 4864ac0fd2b..6729a4a3c57 100644 --- a/editoast/src/schema/mod.rs +++ b/editoast/src/schema/mod.rs @@ -2,7 +2,6 @@ mod errors; pub mod operational_point; mod railjson; mod route; -mod speed_section; pub mod track_section; pub mod utils; pub mod v2; @@ -19,8 +18,6 @@ pub use railjson::RailJson; pub use railjson::RAILJSON_VERSION; pub use route::Route; pub use route::RoutePath; -pub use speed_section::Speed; -pub use speed_section::SpeedSection; pub use track_section::TrackSection; cfg_if! { diff --git a/editoast/src/schema/railjson.rs b/editoast/src/schema/railjson.rs index cebece71fba..596408f5bd1 100644 --- a/editoast/src/schema/railjson.rs +++ b/editoast/src/schema/railjson.rs @@ -4,13 +4,13 @@ use serde::Serialize; use super::OperationalPoint; use super::Route; -use super::SpeedSection; use super::TrackSection; use editoast_schemas::infra::BufferStop; use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::NeutralSection; use editoast_schemas::infra::Signal; +use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; use editoast_schemas::infra::SwitchType; diff --git a/editoast/src/views/infra/auto_fixes/mod.rs b/editoast/src/views/infra/auto_fixes/mod.rs index 556cc9f6862..987fb5f99bd 100644 --- a/editoast/src/views/infra/auto_fixes/mod.rs +++ b/editoast/src/views/infra/auto_fixes/mod.rs @@ -342,7 +342,6 @@ mod tests { use crate::schema::OperationalPointPart; use crate::schema::Route; use crate::schema::Slope; - use crate::schema::SpeedSection; use crate::schema::TrackSection; use crate::views::pagination::PaginatedResponse; use crate::views::tests::create_test_service; @@ -352,6 +351,7 @@ mod tests { use editoast_schemas::infra::Electrification; use editoast_schemas::infra::Endpoint; use editoast_schemas::infra::Signal; + use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; use editoast_schemas::infra::TrackEndpoint; use editoast_schemas::infra::Waypoint; diff --git a/editoast/src/views/infra/auto_fixes/speed_section.rs b/editoast/src/views/infra/auto_fixes/speed_section.rs index 4cd40514199..985527cded0 100644 --- a/editoast/src/views/infra/auto_fixes/speed_section.rs +++ b/editoast/src/views/infra/auto_fixes/speed_section.rs @@ -16,7 +16,7 @@ use crate::infra_cache::operation::RailjsonObject; use crate::infra_cache::operation::UpdateOperation; use crate::schema::InfraError; use crate::schema::InfraErrorType; -use crate::schema::SpeedSection; +use editoast_schemas::infra::SpeedSection; use editoast_schemas::primitives::OSRDIdentified as _; use editoast_schemas::primitives::OSRDObject as _; use editoast_schemas::primitives::ObjectRef; @@ -95,10 +95,10 @@ mod tests { use crate::infra_cache::operation::Operation; use crate::infra_cache::ObjectCache; use crate::schema::InfraError; - use crate::schema::SpeedSection; use editoast_common::Identifier; use editoast_schemas::infra::ApplicableDirections; use editoast_schemas::infra::ApplicableDirectionsTrackRange; + use editoast_schemas::infra::SpeedSection; use editoast_schemas::primitives::OSRDObject as _; use editoast_schemas::primitives::ObjectRef; use editoast_schemas::primitives::ObjectType; diff --git a/editoast/src/views/infra/mod.rs b/editoast/src/views/infra/mod.rs index 77474312e17..b65a7a113bf 100644 --- a/editoast/src/views/infra/mod.rs +++ b/editoast/src/views/infra/mod.rs @@ -571,11 +571,11 @@ pub mod tests { use crate::modelsv2::get_geometry_layer_table; use crate::modelsv2::get_table; use crate::modelsv2::infra::DEFAULT_INFRA_VERSION; - use crate::schema::SpeedSection; use crate::schema::RAILJSON_VERSION; use crate::views::tests::create_test_service; use crate::views::tests::create_test_service_with_core_client; use editoast_schemas::infra::Electrification; + use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::SwitchType; use editoast_schemas::primitives::ObjectType; From 85ef5e8e7b2ce619cf2335e0911ac296596b7608 Mon Sep 17 00:00:00 2001 From: hamz2a Date: Wed, 17 Apr 2024 12:10:14 +0200 Subject: [PATCH 2/3] editoast: move Route to editoast_schemas --- editoast/editoast_schemas/src/infra.rs | 3 +++ .../schema => editoast_schemas/src/infra}/route.rs | 14 +++++++------- editoast/src/converters/generate_routes.rs | 1 + editoast/src/infra_cache/mod.rs | 4 +++- .../src/infra_cache/object_cache/route_cache.rs | 2 +- editoast/src/infra_cache/operation/create.rs | 4 ++-- editoast/src/modelsv2/infra.rs | 1 + editoast/src/modelsv2/infra_objects.rs | 6 +++++- editoast/src/schema/mod.rs | 3 --- editoast/src/schema/railjson.rs | 2 +- editoast/src/views/infra/auto_fixes/mod.rs | 2 +- editoast/src/views/infra/auto_fixes/route.rs | 2 +- editoast/src/views/infra/routes.rs | 2 +- 13 files changed, 27 insertions(+), 19 deletions(-) rename editoast/{src/schema => editoast_schemas/src/infra}/route.rs (80%) diff --git a/editoast/editoast_schemas/src/infra.rs b/editoast/editoast_schemas/src/infra.rs index c3b6079bc7e..9bc251829b0 100644 --- a/editoast/editoast_schemas/src/infra.rs +++ b/editoast/editoast_schemas/src/infra.rs @@ -8,6 +8,7 @@ mod electrical_profiles; mod electrification; mod endpoint; mod neutral_section; +mod route; mod side; mod sign; mod signal; @@ -33,6 +34,8 @@ pub use electrical_profiles::LevelValues; pub use electrification::Electrification; pub use endpoint::Endpoint; pub use neutral_section::NeutralSection; +pub use route::Route; +pub use route::RoutePath; pub use side::Side; pub use sign::Sign; pub use signal::LogicalSignal; diff --git a/editoast/src/schema/route.rs b/editoast/editoast_schemas/src/infra/route.rs similarity index 80% rename from editoast/src/schema/route.rs rename to editoast/editoast_schemas/src/infra/route.rs index 358e8abe65f..990a71a66d2 100644 --- a/editoast/src/schema/route.rs +++ b/editoast/editoast_schemas/src/infra/route.rs @@ -1,16 +1,16 @@ use std::collections::HashMap; use derivative::Derivative; +use editoast_common::Identifier; use serde::Deserialize; use serde::Serialize; -use super::OSRDIdentified; -use super::ObjectType; -use editoast_common::Identifier; -use editoast_schemas::infra::Direction; -use editoast_schemas::infra::DirectionalTrackRange; -use editoast_schemas::infra::Waypoint; -use editoast_schemas::primitives::OSRDTyped; +use super::Direction; +use super::DirectionalTrackRange; +use super::Waypoint; +use crate::primitives::OSRDIdentified; +use crate::primitives::OSRDTyped; +use crate::primitives::ObjectType; #[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq)] #[serde(deny_unknown_fields)] diff --git a/editoast/src/converters/generate_routes.rs b/editoast/src/converters/generate_routes.rs index 36308839274..9b4f89cec5d 100644 --- a/editoast/src/converters/generate_routes.rs +++ b/editoast/src/converters/generate_routes.rs @@ -11,6 +11,7 @@ use editoast_common::Identifier; use editoast_schemas::infra::builtin_node_types_list; use editoast_schemas::infra::Direction; use editoast_schemas::infra::Endpoint; +use editoast_schemas::infra::Route; use editoast_schemas::infra::TrackEndpoint; use editoast_schemas::infra::Waypoint; use editoast_schemas::primitives::OSRDIdentified; diff --git a/editoast/src/infra_cache/mod.rs b/editoast/src/infra_cache/mod.rs index fbf448ceb2f..732391ca84d 100644 --- a/editoast/src/infra_cache/mod.rs +++ b/editoast/src/infra_cache/mod.rs @@ -27,6 +27,8 @@ use editoast_schemas::infra::Electrification; use editoast_schemas::infra::Endpoint; use editoast_schemas::infra::Link; use editoast_schemas::infra::PointSwitch; +use editoast_schemas::infra::Route; +use editoast_schemas::infra::RoutePath; use editoast_schemas::infra::SingleSlipSwitch; use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::SwitchType; @@ -862,7 +864,6 @@ pub mod tests { use crate::map::BoundingBox; use crate::modelsv2::infra::tests::test_infra_transaction; use crate::schema::OperationalPoint; - use crate::schema::Route; use editoast_common::Identifier; use editoast_common::NonBlankString; use editoast_schemas::infra::ApplicableDirections; @@ -870,6 +871,7 @@ pub mod tests { use editoast_schemas::infra::Direction; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::Endpoint; + use editoast_schemas::infra::Route; use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; use editoast_schemas::infra::SwitchPortConnection; diff --git a/editoast/src/infra_cache/object_cache/route_cache.rs b/editoast/src/infra_cache/object_cache/route_cache.rs index 1426b047437..acfa1b1a19a 100644 --- a/editoast/src/infra_cache/object_cache/route_cache.rs +++ b/editoast/src/infra_cache/object_cache/route_cache.rs @@ -1,6 +1,6 @@ use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; -use crate::schema::Route; +use editoast_schemas::infra::Route; impl Cache for Route { fn get_track_referenced_id(&self) -> Vec<&String> { diff --git a/editoast/src/infra_cache/operation/create.rs b/editoast/src/infra_cache/operation/create.rs index 26e5a76c99a..2aaeaa5347d 100644 --- a/editoast/src/infra_cache/operation/create.rs +++ b/editoast/src/infra_cache/operation/create.rs @@ -13,12 +13,12 @@ use super::OperationError; use crate::error::Result; use crate::modelsv2::get_table; use crate::schema::OperationalPoint; -use crate::schema::Route; use crate::schema::TrackSection; use editoast_schemas::infra::BufferStop; use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::NeutralSection; +use editoast_schemas::infra::Route; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; @@ -251,11 +251,11 @@ pub mod tests { use crate::infra_cache::operation::create::RailjsonObject; use crate::modelsv2::infra::tests::test_infra_transaction; use crate::schema::OperationalPoint; - use crate::schema::Route; use crate::schema::TrackSection; use editoast_schemas::infra::BufferStop; use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; + use editoast_schemas::infra::Route; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; diff --git a/editoast/src/modelsv2/infra.rs b/editoast/src/modelsv2/infra.rs index fc779a23f6f..91c4184b6bd 100644 --- a/editoast/src/modelsv2/infra.rs +++ b/editoast/src/modelsv2/infra.rs @@ -250,6 +250,7 @@ pub mod tests { use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::NeutralSection; + use editoast_schemas::infra::Route; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; diff --git a/editoast/src/modelsv2/infra_objects.rs b/editoast/src/modelsv2/infra_objects.rs index d75a58c9264..206a8aaedd7 100644 --- a/editoast/src/modelsv2/infra_objects.rs +++ b/editoast/src/modelsv2/infra_objects.rs @@ -169,7 +169,11 @@ infra_model!( schema::OperationalPoint ); -infra_model!(RouteModel, infra_object_route, schema::Route); +infra_model!( + RouteModel, + infra_object_route, + editoast_schemas::infra::Route +); infra_model!( SignalModel, diff --git a/editoast/src/schema/mod.rs b/editoast/src/schema/mod.rs index 6729a4a3c57..eeeb10b3b0e 100644 --- a/editoast/src/schema/mod.rs +++ b/editoast/src/schema/mod.rs @@ -1,7 +1,6 @@ mod errors; pub mod operational_point; mod railjson; -mod route; pub mod track_section; pub mod utils; pub mod v2; @@ -16,8 +15,6 @@ pub use operational_point::OperationalPointIdentifierExtension; pub use operational_point::OperationalPointPart; pub use railjson::RailJson; pub use railjson::RAILJSON_VERSION; -pub use route::Route; -pub use route::RoutePath; pub use track_section::TrackSection; cfg_if! { diff --git a/editoast/src/schema/railjson.rs b/editoast/src/schema/railjson.rs index 596408f5bd1..f11ae1fea42 100644 --- a/editoast/src/schema/railjson.rs +++ b/editoast/src/schema/railjson.rs @@ -3,12 +3,12 @@ use serde::Deserialize; use serde::Serialize; use super::OperationalPoint; -use super::Route; use super::TrackSection; use editoast_schemas::infra::BufferStop; use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::NeutralSection; +use editoast_schemas::infra::Route; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; diff --git a/editoast/src/views/infra/auto_fixes/mod.rs b/editoast/src/views/infra/auto_fixes/mod.rs index 987fb5f99bd..dc1771ea839 100644 --- a/editoast/src/views/infra/auto_fixes/mod.rs +++ b/editoast/src/views/infra/auto_fixes/mod.rs @@ -340,7 +340,6 @@ mod tests { use crate::infra_cache::InfraCacheEditoastError; use crate::schema::OperationalPoint; use crate::schema::OperationalPointPart; - use crate::schema::Route; use crate::schema::Slope; use crate::schema::TrackSection; use crate::views::pagination::PaginatedResponse; @@ -350,6 +349,7 @@ mod tests { use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::Endpoint; + use editoast_schemas::infra::Route; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; diff --git a/editoast/src/views/infra/auto_fixes/route.rs b/editoast/src/views/infra/auto_fixes/route.rs index 91c9860d4df..d35f993187b 100644 --- a/editoast/src/views/infra/auto_fixes/route.rs +++ b/editoast/src/views/infra/auto_fixes/route.rs @@ -6,7 +6,7 @@ use super::new_ref_fix_delete_pair; use super::Fix; use crate::schema::InfraError; use crate::schema::InfraErrorType; -use crate::schema::Route; +use editoast_schemas::infra::Route; use editoast_schemas::primitives::OSRDIdentified as _; use editoast_schemas::primitives::OSRDObject as _; use editoast_schemas::primitives::ObjectRef; diff --git a/editoast/src/views/infra/routes.rs b/editoast/src/views/infra/routes.rs index 5521ddd7305..b350bfcbb15 100644 --- a/editoast/src/views/infra/routes.rs +++ b/editoast/src/views/infra/routes.rs @@ -237,13 +237,13 @@ mod tests { use crate::fixtures::tests::empty_infra; use crate::fixtures::tests::small_infra; use crate::infra_cache::operation::Operation; - use crate::schema::Route; use crate::schema::TrackSection; use crate::views::infra::routes::RoutesResponse; use crate::views::infra::routes::WaypointType; use crate::views::tests::create_test_service; use editoast_schemas::infra::BufferStop; use editoast_schemas::infra::Detector; + use editoast_schemas::infra::Route; use editoast_schemas::infra::Waypoint; #[rstest] From 21d1a5d8b3a713b2f38903730294d8faecd0f651 Mon Sep 17 00:00:00 2001 From: hamz2a Date: Wed, 17 Apr 2024 15:42:43 +0200 Subject: [PATCH 3/3] editoast: move OperationalPoint to editoast_schemas --- editoast/editoast_schemas/src/infra.rs | 5 +++++ .../src/infra}/operational_point.rs | 12 ++++++------ editoast/src/converters/utils.rs | 8 +++++--- editoast/src/infra_cache/mod.rs | 4 ++-- .../object_cache/operational_point_cache.rs | 4 ++-- editoast/src/infra_cache/operation/create.rs | 4 ++-- editoast/src/modelsv2/infra.rs | 1 + editoast/src/modelsv2/infra_objects.rs | 2 +- editoast/src/schema/mod.rs | 5 ----- editoast/src/schema/railjson.rs | 2 +- editoast/src/views/infra/auto_fixes/mod.rs | 4 ++-- editoast/src/views/pathfinding/mod.rs | 2 +- editoast/src/views/timetable/import.rs | 2 +- editoast/src/views/v2/path/pathfinding.rs | 2 +- editoast/src/views/v2/path/properties.rs | 4 ++-- 15 files changed, 32 insertions(+), 29 deletions(-) rename editoast/{src/schema => editoast_schemas/src/infra}/operational_point.rs (95%) diff --git a/editoast/editoast_schemas/src/infra.rs b/editoast/editoast_schemas/src/infra.rs index 9bc251829b0..355c13c2bd4 100644 --- a/editoast/editoast_schemas/src/infra.rs +++ b/editoast/editoast_schemas/src/infra.rs @@ -8,6 +8,7 @@ mod electrical_profiles; mod electrification; mod endpoint; mod neutral_section; +mod operational_point; mod route; mod side; mod sign; @@ -34,6 +35,10 @@ pub use electrical_profiles::LevelValues; pub use electrification::Electrification; pub use endpoint::Endpoint; pub use neutral_section::NeutralSection; +pub use operational_point::OperationalPoint; +pub use operational_point::OperationalPointExtensions; +pub use operational_point::OperationalPointIdentifierExtension; +pub use operational_point::OperationalPointPart; pub use route::Route; pub use route::RoutePath; pub use side::Side; diff --git a/editoast/src/schema/operational_point.rs b/editoast/editoast_schemas/src/infra/operational_point.rs similarity index 95% rename from editoast/src/schema/operational_point.rs rename to editoast/editoast_schemas/src/infra/operational_point.rs index b97b2df6477..912189f8315 100644 --- a/editoast/src/schema/operational_point.rs +++ b/editoast/editoast_schemas/src/infra/operational_point.rs @@ -1,14 +1,14 @@ use derivative::Derivative; -use editoast_schemas::infra::TrackOffset; +use editoast_common::Identifier; +use editoast_common::NonBlankString; use serde::Deserialize; use serde::Serialize; use utoipa::ToSchema; -use super::OSRDIdentified; -use super::ObjectType; -use editoast_common::Identifier; -use editoast_common::NonBlankString; -use editoast_schemas::primitives::OSRDTyped; +use super::TrackOffset; +use crate::primitives::OSRDIdentified; +use crate::primitives::OSRDTyped; +use crate::primitives::ObjectType; #[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] diff --git a/editoast/src/converters/utils.rs b/editoast/src/converters/utils.rs index 47dac6074ce..76fd6867712 100644 --- a/editoast/src/converters/utils.rs +++ b/editoast/src/converters/utils.rs @@ -5,6 +5,10 @@ use editoast_schemas::infra::Detector; use editoast_schemas::infra::Direction; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::LogicalSignal; +use editoast_schemas::infra::OperationalPoint; +use editoast_schemas::infra::OperationalPointExtensions; +use editoast_schemas::infra::OperationalPointIdentifierExtension; +use editoast_schemas::infra::OperationalPointPart; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SignalExtensions; use editoast_schemas::infra::SignalSncfExtension; @@ -14,6 +18,7 @@ use editoast_schemas::infra::Switch; use std::collections::HashMap; use std::str::FromStr; +use editoast_common::Identifier; use editoast_schemas::infra::Endpoint; use editoast_schemas::infra::Side; use editoast_schemas::infra::TrackEndpoint; @@ -24,9 +29,6 @@ use osmpbfreader::Node; use tracing::error; use tracing::warn; -use crate::schema::*; -use editoast_common::Identifier; - // Given an edge and a coordinate, returns the coordinates used to compute the angle // It uses the nearest OpenStreetMap node, and the other as the the rails might do a loop // that would result in a bad angle diff --git a/editoast/src/infra_cache/mod.rs b/editoast/src/infra_cache/mod.rs index 732391ca84d..57d52e89a04 100644 --- a/editoast/src/infra_cache/mod.rs +++ b/editoast/src/infra_cache/mod.rs @@ -26,6 +26,7 @@ use editoast_schemas::infra::DoubleSlipSwitch; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::Endpoint; use editoast_schemas::infra::Link; +use editoast_schemas::infra::OperationalPointPart; use editoast_schemas::infra::PointSwitch; use editoast_schemas::infra::Route; use editoast_schemas::infra::RoutePath; @@ -56,7 +57,6 @@ use crate::infra_cache::operation::RailjsonObject; use crate::map::BoundingBox; use crate::modelsv2::railjson::find_all_schemas; use crate::modelsv2::Infra; -use crate::schema::*; /// Contains infra cached data used to generate layers and errors #[derive(Debug, Default, Clone)] @@ -863,7 +863,6 @@ pub mod tests { use crate::infra_cache::SwitchCache; use crate::map::BoundingBox; use crate::modelsv2::infra::tests::test_infra_transaction; - use crate::schema::OperationalPoint; use editoast_common::Identifier; use editoast_common::NonBlankString; use editoast_schemas::infra::ApplicableDirections; @@ -871,6 +870,7 @@ pub mod tests { use editoast_schemas::infra::Direction; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::Endpoint; + use editoast_schemas::infra::OperationalPoint; use editoast_schemas::infra::Route; use editoast_schemas::infra::SpeedSection; use editoast_schemas::infra::Switch; diff --git a/editoast/src/infra_cache/object_cache/operational_point_cache.rs b/editoast/src/infra_cache/object_cache/operational_point_cache.rs index 006b9c5b764..adda0b324a2 100644 --- a/editoast/src/infra_cache/object_cache/operational_point_cache.rs +++ b/editoast/src/infra_cache/object_cache/operational_point_cache.rs @@ -8,8 +8,8 @@ use serde::Serialize; use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; -use crate::schema::OperationalPoint; -use crate::schema::OperationalPointPart; +use editoast_schemas::infra::OperationalPoint; +use editoast_schemas::infra::OperationalPointPart; #[derive(Debug, Clone, Derivative)] #[derivative(Hash, PartialEq)] diff --git a/editoast/src/infra_cache/operation/create.rs b/editoast/src/infra_cache/operation/create.rs index 2aaeaa5347d..d423807f510 100644 --- a/editoast/src/infra_cache/operation/create.rs +++ b/editoast/src/infra_cache/operation/create.rs @@ -12,12 +12,12 @@ use serde_json::Value; use super::OperationError; use crate::error::Result; use crate::modelsv2::get_table; -use crate::schema::OperationalPoint; use crate::schema::TrackSection; use editoast_schemas::infra::BufferStop; use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::NeutralSection; +use editoast_schemas::infra::OperationalPoint; use editoast_schemas::infra::Route; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SpeedSection; @@ -250,11 +250,11 @@ pub mod tests { use crate::infra_cache::operation::create::apply_create_operation; use crate::infra_cache::operation::create::RailjsonObject; use crate::modelsv2::infra::tests::test_infra_transaction; - use crate::schema::OperationalPoint; use crate::schema::TrackSection; use editoast_schemas::infra::BufferStop; use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; + use editoast_schemas::infra::OperationalPoint; use editoast_schemas::infra::Route; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SpeedSection; diff --git a/editoast/src/modelsv2/infra.rs b/editoast/src/modelsv2/infra.rs index 91c4184b6bd..272a27640aa 100644 --- a/editoast/src/modelsv2/infra.rs +++ b/editoast/src/modelsv2/infra.rs @@ -250,6 +250,7 @@ pub mod tests { use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::NeutralSection; + use editoast_schemas::infra::OperationalPoint; use editoast_schemas::infra::Route; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SpeedSection; diff --git a/editoast/src/modelsv2/infra_objects.rs b/editoast/src/modelsv2/infra_objects.rs index 206a8aaedd7..bc4102cbf91 100644 --- a/editoast/src/modelsv2/infra_objects.rs +++ b/editoast/src/modelsv2/infra_objects.rs @@ -166,7 +166,7 @@ infra_model!( OperationalPointModel, infra_object_operational_point, infra_layer_operational_point, - schema::OperationalPoint + editoast_schemas::infra::OperationalPoint ); infra_model!( diff --git a/editoast/src/schema/mod.rs b/editoast/src/schema/mod.rs index eeeb10b3b0e..74fb1f5d5f0 100644 --- a/editoast/src/schema/mod.rs +++ b/editoast/src/schema/mod.rs @@ -1,5 +1,4 @@ mod errors; -pub mod operational_point; mod railjson; pub mod track_section; pub mod utils; @@ -9,10 +8,6 @@ use editoast_schemas::primitives::OSRDIdentified; use editoast_schemas::primitives::ObjectType; pub use errors::InfraError; pub use errors::InfraErrorType; -pub use operational_point::OperationalPoint; -pub use operational_point::OperationalPointExtensions; -pub use operational_point::OperationalPointIdentifierExtension; -pub use operational_point::OperationalPointPart; pub use railjson::RailJson; pub use railjson::RAILJSON_VERSION; pub use track_section::TrackSection; diff --git a/editoast/src/schema/railjson.rs b/editoast/src/schema/railjson.rs index f11ae1fea42..9f4eea12ca3 100644 --- a/editoast/src/schema/railjson.rs +++ b/editoast/src/schema/railjson.rs @@ -2,12 +2,12 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; -use super::OperationalPoint; use super::TrackSection; use editoast_schemas::infra::BufferStop; use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::NeutralSection; +use editoast_schemas::infra::OperationalPoint; use editoast_schemas::infra::Route; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SpeedSection; diff --git a/editoast/src/views/infra/auto_fixes/mod.rs b/editoast/src/views/infra/auto_fixes/mod.rs index dc1771ea839..f8eed83ce78 100644 --- a/editoast/src/views/infra/auto_fixes/mod.rs +++ b/editoast/src/views/infra/auto_fixes/mod.rs @@ -338,8 +338,6 @@ mod tests { use crate::infra_cache::operation::Operation; use crate::infra_cache::operation::RailjsonObject; use crate::infra_cache::InfraCacheEditoastError; - use crate::schema::OperationalPoint; - use crate::schema::OperationalPointPart; use crate::schema::Slope; use crate::schema::TrackSection; use crate::views::pagination::PaginatedResponse; @@ -349,6 +347,8 @@ mod tests { use editoast_schemas::infra::Detector; use editoast_schemas::infra::Electrification; use editoast_schemas::infra::Endpoint; + use editoast_schemas::infra::OperationalPoint; + use editoast_schemas::infra::OperationalPointPart; use editoast_schemas::infra::Route; use editoast_schemas::infra::Signal; use editoast_schemas::infra::SpeedSection; diff --git a/editoast/src/views/pathfinding/mod.rs b/editoast/src/views/pathfinding/mod.rs index 899650dcb1c..4bb8b530d03 100644 --- a/editoast/src/views/pathfinding/mod.rs +++ b/editoast/src/views/pathfinding/mod.rs @@ -53,10 +53,10 @@ use crate::modelsv2::Infra; use crate::modelsv2::OperationalPointModel; use crate::modelsv2::Retrieve as RetrieveV2; use crate::modelsv2::RollingStockModel; -use crate::schema::OperationalPoint; use crate::schema::TrackSection; use crate::DbPool; use editoast_schemas::infra::ApplicableDirectionsTrackRange; +use editoast_schemas::infra::OperationalPoint; crate::routes! { "/pathfinding" => { diff --git a/editoast/src/views/timetable/import.rs b/editoast/src/views/timetable/import.rs index 2f19ff8065c..d89524bda56 100644 --- a/editoast/src/views/timetable/import.rs +++ b/editoast/src/views/timetable/import.rs @@ -34,7 +34,6 @@ use crate::modelsv2::Infra; use crate::modelsv2::OperationalPointModel; use crate::modelsv2::RetrieveBatch; use crate::modelsv2::RollingStockModel; -use crate::schema::OperationalPointPart; use crate::views::infra::call_core_infra_state; use crate::views::infra::InfraApiError; use crate::views::infra::InfraState; @@ -43,6 +42,7 @@ use crate::views::timetable::Path; use crate::views::timetable::TimetableError; use crate::views::train_schedule::process_simulation_response; use crate::DbPool; +use editoast_schemas::infra::OperationalPointPart; crate::routes! { post_timetable, diff --git a/editoast/src/views/v2/path/pathfinding.rs b/editoast/src/views/v2/path/pathfinding.rs index 2ced21f4ab2..94d9840260a 100644 --- a/editoast/src/views/v2/path/pathfinding.rs +++ b/editoast/src/views/v2/path/pathfinding.rs @@ -28,11 +28,11 @@ use crate::modelsv2::RollingStockModel; use crate::modelsv2::TrackSectionModel; use crate::redis_utils::RedisClient; use crate::redis_utils::RedisConnection; -use crate::schema::operational_point::OperationalPoint; use crate::views::get_app_version; use crate::views::v2::path::PathfindingError; use crate::views::v2::path::TrackRange; use crate::DbPool; +use editoast_schemas::infra::OperationalPoint; type TrackOffsetResult = std::result::Result>, PathfindingResult>; diff --git a/editoast/src/views/v2/path/properties.rs b/editoast/src/views/v2/path/properties.rs index 01f3276ec08..d09d9924f74 100644 --- a/editoast/src/views/v2/path/properties.rs +++ b/editoast/src/views/v2/path/properties.rs @@ -25,8 +25,6 @@ use utoipa::ToSchema; use super::CACHE_PATH_EXPIRATION; use crate::client::get_app_version; use crate::error::Result; -use crate::schema::OperationalPointExtensions; -use crate::schema::OperationalPointPart; use crate::views::v2::path::retrieve_infra_version; use crate::views::v2::path::TrackRange; use crate::DbPool; @@ -34,6 +32,8 @@ use crate::RedisClient; use crate::RedisConnection; use editoast_common::geometry::GeoJsonLineString; use editoast_common::Identifier; +use editoast_schemas::infra::OperationalPointExtensions; +use editoast_schemas::infra::OperationalPointPart; crate::routes! { "/v2/infra/{infra_id}/path_properties" => {post},