From 940d62b66a7385d3bfe88d6e7b731d4cf1e6bb6d Mon Sep 17 00:00:00 2001 From: hamz2a Date: Mon, 8 Apr 2024 11:59:32 +0200 Subject: [PATCH] editoast: move identifier to editoast_common --- editoast/Cargo.lock | 2 ++ editoast/Cargo.toml | 6 ++++-- editoast/editoast_common/Cargo.toml | 2 ++ .../{src/schema/utils => editoast_common/src}/identifier.rs | 0 editoast/editoast_common/src/lib.rs | 2 ++ editoast/src/converters/generate_routes.rs | 2 +- editoast/src/converters/osm_to_railjson.rs | 2 +- editoast/src/converters/utils.rs | 2 +- editoast/src/core/v2/simulation.rs | 2 +- editoast/src/infra_cache/graph.rs | 4 ++-- editoast/src/infra_cache/mod.rs | 4 ++-- editoast/src/schema/buffer_stop.rs | 2 +- editoast/src/schema/detector.rs | 2 +- editoast/src/schema/electrification.rs | 2 +- editoast/src/schema/mod.rs | 2 +- editoast/src/schema/neutral_section.rs | 2 +- editoast/src/schema/operational_point.rs | 2 +- editoast/src/schema/route.rs | 2 +- editoast/src/schema/signal.rs | 2 +- editoast/src/schema/speed_section.rs | 2 +- editoast/src/schema/switch.rs | 2 +- editoast/src/schema/switch_type.rs | 2 +- editoast/src/schema/track_section.rs | 2 +- editoast/src/schema/utils/mod.rs | 2 -- editoast/src/schema/v2/trainschedule.rs | 2 +- editoast/src/views/infra/auto_fixes/electrifications.rs | 2 +- editoast/src/views/infra/auto_fixes/mod.rs | 2 +- editoast/src/views/infra/auto_fixes/speed_section.rs | 2 +- editoast/src/views/infra/auto_fixes/track_section.rs | 2 +- editoast/src/views/infra/pathfinding.rs | 4 ++-- editoast/src/views/timetable/import.rs | 2 +- editoast/src/views/train_schedule/projection.rs | 2 +- editoast/src/views/train_schedule/simulation_report.rs | 2 +- editoast/src/views/v2/path.rs | 2 +- editoast/src/views/v2/path/pathfinding.rs | 2 +- editoast/src/views/v2/path/properties.rs | 2 +- editoast/src/views/v2/train_schedule.rs | 2 +- 37 files changed, 44 insertions(+), 38 deletions(-) rename editoast/{src/schema/utils => editoast_common/src}/identifier.rs (100%) diff --git a/editoast/Cargo.lock b/editoast/Cargo.lock index 200e1a75f14..ce32021b246 100644 --- a/editoast/Cargo.lock +++ b/editoast/Cargo.lock @@ -1444,12 +1444,14 @@ dependencies = [ "iso8601", "mvt", "postgis_diesel", + "rand 0.8.5", "rangemap", "serde", "serde_derive", "serde_json", "thiserror", "utoipa", + "uuid", ] [[package]] diff --git a/editoast/Cargo.toml b/editoast/Cargo.toml index 2b6189e6ca4..a06eb7d23bf 100644 --- a/editoast/Cargo.toml +++ b/editoast/Cargo.toml @@ -14,6 +14,7 @@ editoast_common = { path = "./editoast_common" } geos = { version = "8.3.1", features = ["json"] } mvt = "0.9.0" postgis_diesel = { version = "2.3.0", features = ["serde"] } +rand = "0.8.5" rangemap = "1.5.1" serde = "1.0.195" serde_derive = "1.0.195" @@ -21,6 +22,7 @@ serde_json = "1.0.115" strum = { version = "0.26.2", features = ["derive"] } thiserror = "1.0.58" utoipa = { version = "4.2.0", features = ["actix_extras", "chrono", "uuid"] } +uuid = { version = "1.8.0", features = ["v4"] } [dependencies] # For batch dependcy updates see https://osrd.fr/en/docs/guides/contribute/batch-updating-dependencies/ @@ -72,7 +74,7 @@ paste = "1.0.14" pathfinding = "4.9.1" postgis_diesel.workspace = true postgres-openssl = "0.5.0" -rand = "0.8.5" +rand.workspace = true rangemap.workspace = true redis = { version = "0.25.3", features = [ "cluster-async", @@ -98,7 +100,7 @@ tracing-opentelemetry = "0.23.0" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } url = "2.5.0" utoipa.workspace = true -uuid = { version = "1.8.0", features = ["v4"] } +uuid.workspace = true validator = { version = "0.17.0", features = ["derive"] } [dev-dependencies] diff --git a/editoast/editoast_common/Cargo.toml b/editoast/editoast_common/Cargo.toml index 163263566f3..b6048602646 100644 --- a/editoast/editoast_common/Cargo.toml +++ b/editoast/editoast_common/Cargo.toml @@ -11,9 +11,11 @@ geos.workspace = true iso8601 = "0.6.1" mvt.workspace = true postgis_diesel.workspace = true +rand.workspace = true rangemap.workspace = true serde.workspace = true serde_derive.workspace = true serde_json.workspace = true thiserror.workspace = true utoipa.workspace = true +uuid.workspace = true diff --git a/editoast/src/schema/utils/identifier.rs b/editoast/editoast_common/src/identifier.rs similarity index 100% rename from editoast/src/schema/utils/identifier.rs rename to editoast/editoast_common/src/identifier.rs diff --git a/editoast/editoast_common/src/lib.rs b/editoast/editoast_common/src/lib.rs index c434ddaccf9..550a89af720 100644 --- a/editoast/editoast_common/src/lib.rs +++ b/editoast/editoast_common/src/lib.rs @@ -2,9 +2,11 @@ pub mod duration; pub mod geo_json; pub mod geometry; mod hash_rounded_float; +mod identifier; pub mod rangemap_utils; pub mod schemas; pub use duration::PositiveDuration; pub use hash_rounded_float::hash_float; pub use hash_rounded_float::hash_float_slice; +pub use identifier::Identifier; diff --git a/editoast/src/converters/generate_routes.rs b/editoast/src/converters/generate_routes.rs index 8d2a5c86acb..7fe06f27878 100644 --- a/editoast/src/converters/generate_routes.rs +++ b/editoast/src/converters/generate_routes.rs @@ -6,8 +6,8 @@ use std::collections::HashMap; -use crate::schema::utils::Identifier; use crate::schema::*; +use editoast_common::Identifier; /* Part 1: type definitions */ // When building the graph, a node can be a trackEndPoint, a detector or a buffer stop diff --git a/editoast/src/converters/osm_to_railjson.rs b/editoast/src/converters/osm_to_railjson.rs index 0c2e320e2a6..f2695a1087b 100644 --- a/editoast/src/converters/osm_to_railjson.rs +++ b/editoast/src/converters/osm_to_railjson.rs @@ -131,8 +131,8 @@ mod tests { use super::parse_osm; use crate::converters::*; - use crate::schema::utils::Identifier; use crate::schema::*; + use editoast_common::Identifier; #[test] fn convert_osm_to_railjson() { let output = tempfile::NamedTempFile::new().unwrap(); diff --git a/editoast/src/converters/utils.rs b/editoast/src/converters/utils.rs index dfec2ee5449..0d67d4a1df4 100644 --- a/editoast/src/converters/utils.rs +++ b/editoast/src/converters/utils.rs @@ -8,8 +8,8 @@ use osmpbfreader::Node; use tracing::error; use tracing::warn; -use crate::schema::utils::Identifier; 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 diff --git a/editoast/src/core/v2/simulation.rs b/editoast/src/core/v2/simulation.rs index d78c576f714..8138ba47e42 100644 --- a/editoast/src/core/v2/simulation.rs +++ b/editoast/src/core/v2/simulation.rs @@ -9,7 +9,6 @@ use serde::Deserialize; use serde::Serialize; use crate::core::{AsCoreRequest, Json}; -use crate::schema::utils::Identifier; use crate::schema::v2::trainschedule::MarginValue; use crate::schema::v2::trainschedule::TrainScheduleOptions; use crate::schema::v2::trainschedule::{Comfort, Distribution}; @@ -19,6 +18,7 @@ use crate::views::v2::train_schedule::Mrsp; use crate::views::v2::train_schedule::ReportTrain; use crate::RollingStockModel; use derivative::Derivative; +use editoast_common::Identifier; use std::hash::Hash; #[derive(Debug, Serialize, Derivative)] diff --git a/editoast/src/infra_cache/graph.rs b/editoast/src/infra_cache/graph.rs index f69538bf15d..3e495eb9d13 100644 --- a/editoast/src/infra_cache/graph.rs +++ b/editoast/src/infra_cache/graph.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; use crate::infra_cache::InfraCache; -use crate::schema::utils::Identifier; use crate::schema::SwitchCache; use crate::schema::TrackEndpoint; +use editoast_common::Identifier; #[derive(Default, Clone, Debug)] pub struct Graph<'a> { @@ -92,8 +92,8 @@ mod tests { use crate::infra_cache::tests::create_small_infra_cache; use crate::infra_cache::tests::create_track_endpoint; use crate::infra_cache::InfraCache; - use crate::schema::utils::Identifier; use crate::schema::Endpoint; + use editoast_common::Identifier; #[test] fn create_empty_graph() { diff --git a/editoast/src/infra_cache/mod.rs b/editoast/src/infra_cache/mod.rs index f8b851a112f..6d3a20369a6 100644 --- a/editoast/src/infra_cache/mod.rs +++ b/editoast/src/infra_cache/mod.rs @@ -744,7 +744,6 @@ pub mod tests { use crate::infra_cache::SwitchCache; use crate::map::BoundingBox; use crate::modelsv2::infra::tests::test_infra_transaction; - use crate::schema::utils::Identifier; use crate::schema::utils::NonBlankString; use crate::schema::ApplicableDirections; use crate::schema::ApplicableDirectionsTrackRange; @@ -761,6 +760,7 @@ pub mod tests { use crate::schema::SwitchType; use crate::schema::TrackEndpoint; use crate::schema::Waypoint; + use editoast_common::Identifier; #[actix_test] async fn load_track_section() { @@ -1283,11 +1283,11 @@ pub mod tests { use crate::infra_cache::tests::create_switch_type_cache; use crate::infra_cache::InfraCache; use crate::infra_cache::InfraCacheEditoastError; - use crate::schema::utils::Identifier; use crate::schema::Direction::StartToStop; use crate::schema::ObjectType; use crate::schema::TrackEndpoint; use crate::schema::Waypoint::BufferStop; + use editoast_common::Identifier; #[test] fn track_section() { diff --git a/editoast/src/schema/buffer_stop.rs b/editoast/src/schema/buffer_stop.rs index 4849a789548..0b1eca9d0ed 100644 --- a/editoast/src/schema/buffer_stop.rs +++ b/editoast/src/schema/buffer_stop.rs @@ -4,12 +4,12 @@ use diesel::sql_types::Text; use serde::Deserialize; use serde::Serialize; -use super::utils::Identifier; use super::OSRDIdentified; use super::OSRDTyped; use super::ObjectType; use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; +use editoast_common::Identifier; #[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] #[serde(deny_unknown_fields)] diff --git a/editoast/src/schema/detector.rs b/editoast/src/schema/detector.rs index 0cef0c849df..3a4f5c1d516 100644 --- a/editoast/src/schema/detector.rs +++ b/editoast/src/schema/detector.rs @@ -4,12 +4,12 @@ use diesel::sql_types::Text; use serde::Deserialize; use serde::Serialize; -use super::utils::Identifier; use super::OSRDIdentified; use super::OSRDTyped; use super::ObjectType; use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; +use editoast_common::Identifier; #[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] #[serde(deny_unknown_fields)] diff --git a/editoast/src/schema/electrification.rs b/editoast/src/schema/electrification.rs index 042a36e8410..d0b3e6b2b4c 100644 --- a/editoast/src/schema/electrification.rs +++ b/editoast/src/schema/electrification.rs @@ -2,7 +2,6 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; -use super::utils::Identifier; use super::utils::NonBlankString; use super::ApplicableDirectionsTrackRange; use super::OSRDIdentified; @@ -10,6 +9,7 @@ use super::OSRDTyped; use super::ObjectType; use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; +use editoast_common::Identifier; #[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] #[serde(deny_unknown_fields)] #[derivative(Default)] diff --git a/editoast/src/schema/mod.rs b/editoast/src/schema/mod.rs index 16034922a24..24637e14cdc 100644 --- a/editoast/src/schema/mod.rs +++ b/editoast/src/schema/mod.rs @@ -69,8 +69,8 @@ use strum::Display; use strum::EnumIter; use utoipa::ToSchema; -use self::utils::Identifier; use self::utils::NonBlankString; +use editoast_common::Identifier; editoast_common::schemas! { ObjectType, diff --git a/editoast/src/schema/neutral_section.rs b/editoast/src/schema/neutral_section.rs index 5a794901900..e5ec197f117 100644 --- a/editoast/src/schema/neutral_section.rs +++ b/editoast/src/schema/neutral_section.rs @@ -2,12 +2,12 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; -use super::utils::Identifier; use super::DirectionalTrackRange; use super::OSRDIdentified; use super::OSRDTyped; use super::ObjectType; use super::Sign; +use editoast_common::Identifier; /// Neutral sections are portions of track where trains aren't allowed to pull power from electrifications. They have to rely on inertia to cross such sections. /// diff --git a/editoast/src/schema/operational_point.rs b/editoast/src/schema/operational_point.rs index 43726e88efd..033791dd46c 100644 --- a/editoast/src/schema/operational_point.rs +++ b/editoast/src/schema/operational_point.rs @@ -3,7 +3,6 @@ use serde::Deserialize; use serde::Serialize; use utoipa::ToSchema; -use super::utils::Identifier; use super::utils::NonBlankString; use super::OSRDIdentified; use super::OSRDTyped; @@ -12,6 +11,7 @@ use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; use crate::modelsv2::OperationalPointModel; use crate::schema::TrackOffset; +use editoast_common::Identifier; #[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, ToSchema)] #[serde(deny_unknown_fields)] diff --git a/editoast/src/schema/route.rs b/editoast/src/schema/route.rs index 125e4b4f6fa..132b9521f98 100644 --- a/editoast/src/schema/route.rs +++ b/editoast/src/schema/route.rs @@ -7,7 +7,6 @@ use serde::Serialize; use super::Direction; use super::DirectionalTrackRange; use super::Endpoint; -use super::Identifier; use super::OSRDIdentified; use super::OSRDTyped; use super::ObjectType; @@ -17,6 +16,7 @@ use crate::infra_cache::Cache; use crate::infra_cache::Graph; use crate::infra_cache::InfraCache; use crate::infra_cache::ObjectCache; +use editoast_common::Identifier; #[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq, Eq)] #[serde(deny_unknown_fields)] diff --git a/editoast/src/schema/signal.rs b/editoast/src/schema/signal.rs index a39494eb4f7..e53c7c58782 100644 --- a/editoast/src/schema/signal.rs +++ b/editoast/src/schema/signal.rs @@ -8,7 +8,6 @@ use diesel_json::Json as DieselJson; use serde::Deserialize; use serde::Serialize; -use super::utils::Identifier; use super::utils::NonBlankString; use super::Direction; use super::OSRDIdentified; @@ -17,6 +16,7 @@ use super::ObjectType; use super::Side; use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; +use editoast_common::Identifier; #[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] #[serde(deny_unknown_fields)] diff --git a/editoast/src/schema/speed_section.rs b/editoast/src/schema/speed_section.rs index dacd3de08c9..604134bd58f 100644 --- a/editoast/src/schema/speed_section.rs +++ b/editoast/src/schema/speed_section.rs @@ -4,7 +4,6 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; -use super::utils::Identifier; use super::utils::NonBlankString; use super::ApplicableDirectionsTrackRange; use super::OSRDIdentified; @@ -13,6 +12,7 @@ use super::ObjectType; use super::Sign; use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; +use editoast_common::Identifier; #[derive(Debug, Derivative, Clone, Serialize, PartialEq, Copy)] pub struct Speed(pub f64); diff --git a/editoast/src/schema/switch.rs b/editoast/src/schema/switch.rs index a9eaebccd63..0fa01828371 100644 --- a/editoast/src/schema/switch.rs +++ b/editoast/src/schema/switch.rs @@ -4,7 +4,6 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; -use super::utils::Identifier; use super::utils::NonBlankString; use super::OSRDIdentified; use super::OSRDTyped; @@ -12,6 +11,7 @@ use super::ObjectType; use super::TrackEndpoint; use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; +use editoast_common::Identifier; #[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] #[serde(deny_unknown_fields)] diff --git a/editoast/src/schema/switch_type.rs b/editoast/src/schema/switch_type.rs index b12dbbb0112..a9c78d4f036 100644 --- a/editoast/src/schema/switch_type.rs +++ b/editoast/src/schema/switch_type.rs @@ -4,12 +4,12 @@ use derivative::Derivative; use serde::Deserialize; use serde::Serialize; -use super::utils::Identifier; use super::OSRDIdentified; use super::OSRDTyped; use super::ObjectType; use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; +use editoast_common::Identifier; type StaticPortConnection = (&'static str, &'static str); type StaticMap = (&'static str, &'static [StaticPortConnection]); diff --git a/editoast/src/schema/track_section.rs b/editoast/src/schema/track_section.rs index b58e9cfeaae..6e63d6611e9 100644 --- a/editoast/src/schema/track_section.rs +++ b/editoast/src/schema/track_section.rs @@ -5,7 +5,6 @@ use geos::geojson::Value::LineString; use serde::Deserialize; use serde::Serialize; -use super::utils::Identifier; use super::utils::NonBlankString; use super::Endpoint; use super::OSRDIdentified; @@ -15,6 +14,7 @@ use super::TrackEndpoint; use crate::infra_cache::Cache; use crate::infra_cache::ObjectCache; use crate::map::BoundingBox; +use editoast_common::Identifier; #[derive(Debug, Derivative, Clone, Deserialize, Serialize, PartialEq)] #[serde(deny_unknown_fields)] diff --git a/editoast/src/schema/utils/mod.rs b/editoast/src/schema/utils/mod.rs index 22509f3bc8e..28f39a560f2 100644 --- a/editoast/src/schema/utils/mod.rs +++ b/editoast/src/schema/utils/mod.rs @@ -1,8 +1,6 @@ -mod identifier; mod non_blank_string; use editoast_common::geometry; -pub use identifier::Identifier; pub use non_blank_string::NonBlankString; editoast_common::schemas! { diff --git a/editoast/src/schema/v2/trainschedule.rs b/editoast/src/schema/v2/trainschedule.rs index fca23e91891..55d6984ee94 100644 --- a/editoast/src/schema/v2/trainschedule.rs +++ b/editoast/src/schema/v2/trainschedule.rs @@ -12,9 +12,9 @@ use serde::Serialize; use strum::FromRepr; use utoipa::ToSchema; -use crate::schema::utils::Identifier; use crate::schema::utils::NonBlankString; use crate::schema::TrackOffset; +use editoast_common::Identifier; use editoast_common::PositiveDuration; #[derive(Debug, Default, Clone, Serialize, ToSchema)] diff --git a/editoast/src/views/infra/auto_fixes/electrifications.rs b/editoast/src/views/infra/auto_fixes/electrifications.rs index fb609f2ddaa..278f04856f1 100644 --- a/editoast/src/views/infra/auto_fixes/electrifications.rs +++ b/editoast/src/views/infra/auto_fixes/electrifications.rs @@ -94,7 +94,6 @@ mod tests { use crate::infra_cache::operation::CacheOperation; use crate::infra_cache::operation::Operation; use crate::infra_cache::ObjectCache; - use crate::schema::utils::Identifier; use crate::schema::ApplicableDirections; use crate::schema::ApplicableDirectionsTrackRange; use crate::schema::Electrification; @@ -102,6 +101,7 @@ mod tests { use crate::schema::OSRDObject as _; use crate::schema::ObjectRef; use crate::schema::ObjectType; + use editoast_common::Identifier; #[test] fn invalid_refs_ordered_electrification() { diff --git a/editoast/src/views/infra/auto_fixes/mod.rs b/editoast/src/views/infra/auto_fixes/mod.rs index 2320a2e28e2..1be905c0064 100644 --- a/editoast/src/views/infra/auto_fixes/mod.rs +++ b/editoast/src/views/infra/auto_fixes/mod.rs @@ -333,7 +333,6 @@ mod tests { use crate::infra_cache::operation::Operation; use crate::infra_cache::operation::RailjsonObject; use crate::infra_cache::InfraCacheEditoastError; - use crate::schema::utils::Identifier; use crate::schema::ApplicableDirectionsTrackRange; use crate::schema::BufferStop; use crate::schema::BufferStopCache; @@ -357,6 +356,7 @@ mod tests { use crate::schema::Waypoint; use crate::views::pagination::PaginatedResponse; use crate::views::tests::create_test_service; + use editoast_common::Identifier; async fn get_infra_cache(infra: &Infra) -> InfraCache { InfraCache::load(&mut db_pool().get().await.unwrap(), infra) diff --git a/editoast/src/views/infra/auto_fixes/speed_section.rs b/editoast/src/views/infra/auto_fixes/speed_section.rs index 5780f818f27..3f9bbeeb39b 100644 --- a/editoast/src/views/infra/auto_fixes/speed_section.rs +++ b/editoast/src/views/infra/auto_fixes/speed_section.rs @@ -94,7 +94,6 @@ mod tests { use crate::infra_cache::operation::CacheOperation; use crate::infra_cache::operation::Operation; use crate::infra_cache::ObjectCache; - use crate::schema::utils::Identifier; use crate::schema::ApplicableDirections; use crate::schema::ApplicableDirectionsTrackRange; use crate::schema::InfraError; @@ -102,6 +101,7 @@ mod tests { use crate::schema::ObjectRef; use crate::schema::ObjectType; use crate::schema::SpeedSection; + use editoast_common::Identifier; #[test] fn invalid_refs_ordered_speed_section() { diff --git a/editoast/src/views/infra/auto_fixes/track_section.rs b/editoast/src/views/infra/auto_fixes/track_section.rs index e4cf1fd1416..ce6e462a3f1 100644 --- a/editoast/src/views/infra/auto_fixes/track_section.rs +++ b/editoast/src/views/infra/auto_fixes/track_section.rs @@ -6,7 +6,6 @@ use uuid::Uuid; use super::new_ref_fix_create_pair; use super::Fix; use crate::infra_cache::operation::RailjsonObject; -use crate::schema::utils::Identifier; use crate::schema::BufferStop; use crate::schema::Endpoint; use crate::schema::InfraError; @@ -15,6 +14,7 @@ use crate::schema::OSRDIdentified as _; use crate::schema::OSRDObject as _; use crate::schema::ObjectRef; use crate::schema::TrackSectionCache; +use editoast_common::Identifier; pub fn fix_track_section( track_section: &TrackSectionCache, diff --git a/editoast/src/views/infra/pathfinding.rs b/editoast/src/views/infra/pathfinding.rs index 5cbed8037f5..8eeb5c961ea 100644 --- a/editoast/src/views/infra/pathfinding.rs +++ b/editoast/src/views/infra/pathfinding.rs @@ -20,7 +20,6 @@ use crate::infra_cache::Graph; use crate::infra_cache::InfraCache; use crate::modelsv2::prelude::*; use crate::modelsv2::Infra; -use crate::schema::utils::Identifier; use crate::schema::Direction; use crate::schema::DirectionalTrackRange; use crate::schema::Endpoint; @@ -29,6 +28,7 @@ use crate::schema::TrackEndpoint; use crate::views::infra::InfraApiError; use crate::views::infra::InfraIdParam; use crate::DbPool; +use editoast_common::Identifier; crate::routes! { "/pathfinding" => { @@ -411,11 +411,11 @@ mod tests { use super::compute_path; use crate::infra_cache::tests::create_small_infra_cache; use crate::infra_cache::Graph; - use crate::schema::utils::Identifier; use crate::schema::Direction; use crate::schema::DirectionalTrackRange; use crate::views::infra::pathfinding::PathfindingInput; use crate::views::infra::pathfinding::PathfindingTrackLocationInput; + use editoast_common::Identifier; fn expected_path() -> Vec { vec![ diff --git a/editoast/src/views/timetable/import.rs b/editoast/src/views/timetable/import.rs index 7d3e57f4e26..2c6ac42c32b 100644 --- a/editoast/src/views/timetable/import.rs +++ b/editoast/src/views/timetable/import.rs @@ -580,7 +580,7 @@ fn build_simulation_request( #[cfg(test)] mod tests { use super::*; - use crate::schema::utils::Identifier; + use editoast_common::Identifier; #[test] fn test_waypoints_from_steps() { diff --git a/editoast/src/views/train_schedule/projection.rs b/editoast/src/views/train_schedule/projection.rs index 857166ca66b..e0776bcaca8 100644 --- a/editoast/src/views/train_schedule/projection.rs +++ b/editoast/src/views/train_schedule/projection.rs @@ -4,8 +4,8 @@ use serde::Deserialize; use serde::Serialize; use crate::models::PathfindingPayload; -use crate::schema::utils::Identifier; use crate::schema::DirectionalTrackRange; +use editoast_common::Identifier; #[derive(Debug, Serialize, Deserialize)] pub struct Projection { diff --git a/editoast/src/views/train_schedule/simulation_report.rs b/editoast/src/views/train_schedule/simulation_report.rs index fb586bdd88d..b3df5643363 100644 --- a/editoast/src/views/train_schedule/simulation_report.rs +++ b/editoast/src/views/train_schedule/simulation_report.rs @@ -30,11 +30,11 @@ use crate::models::SimulationOutputChangeset; use crate::models::Slope; use crate::models::TrainSchedule; use crate::modelsv2::RollingStockModel; -use crate::schema::utils::Identifier; use crate::views::pathfinding::make_track_map; use crate::views::train_schedule::projection::Projection; use crate::views::train_schedule::TrainScheduleError::UnsimulatedTrainSchedule; use crate::DbPool; +use editoast_common::Identifier; editoast_common::schemas! { SimulationReport, diff --git a/editoast/src/views/v2/path.rs b/editoast/src/views/v2/path.rs index 3f093f13254..29514ea0238 100644 --- a/editoast/src/views/v2/path.rs +++ b/editoast/src/views/v2/path.rs @@ -14,8 +14,8 @@ use utoipa::ToSchema; use crate::error::Result; use crate::modelsv2::prelude::*; use crate::modelsv2::Infra; -use crate::schema::utils::Identifier; use crate::schema::Direction; +use editoast_common::Identifier; /// Expiration time for the cache of the pathfinding and path properties. /// Note: 604800 seconds = 1 week diff --git a/editoast/src/views/v2/path/pathfinding.rs b/editoast/src/views/v2/path/pathfinding.rs index ae22fede675..60f19f81151 100644 --- a/editoast/src/views/v2/path/pathfinding.rs +++ b/editoast/src/views/v2/path/pathfinding.rs @@ -26,13 +26,13 @@ use crate::modelsv2::TrackSectionModel; use crate::redis_utils::RedisClient; use crate::redis_utils::RedisConnection; use crate::schema::operational_point::OperationalPoint; -use crate::schema::utils::Identifier; use crate::schema::v2::trainschedule::PathItemLocation; use crate::schema::TrackOffset; use crate::views::get_app_version; use crate::views::v2::path::PathfindingError; use crate::views::v2::path::TrackRange; use crate::DbPool; +use editoast_common::Identifier; 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 8d4dee9d8de..e89ad6a2897 100644 --- a/editoast/src/views/v2/path/properties.rs +++ b/editoast/src/views/v2/path/properties.rs @@ -28,12 +28,12 @@ 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::Identifier; use crate::views::v2::path::TrackRange; use crate::DbPool; use crate::RedisClient; use crate::RedisConnection; use editoast_common::geometry::GeoJsonLineString; +use editoast_common::Identifier; crate::routes! { "/v2/infra/{infra_id}/path_properties" => {post}, diff --git a/editoast/src/views/v2/train_schedule.rs b/editoast/src/views/v2/train_schedule.rs index a11e5c9ab7d..3d8c05d12bc 100644 --- a/editoast/src/views/v2/train_schedule.rs +++ b/editoast/src/views/v2/train_schedule.rs @@ -25,7 +25,6 @@ use crate::modelsv2::train_schedule::TrainSchedule; use crate::modelsv2::train_schedule::TrainScheduleChangeset; use crate::modelsv2::Model; use crate::modelsv2::Retrieve; -use crate::schema::utils::Identifier; use crate::schema::v2::trainschedule::Distribution; use crate::schema::v2::trainschedule::TrainScheduleBase; use crate::views::v2::path::pathfinding_from_train; @@ -35,6 +34,7 @@ use crate::views::v2::path::TrackRange; use crate::DbPool; use crate::RedisClient; use crate::RollingStockModel; +use editoast_common::Identifier; use actix_web::web::{Data, Json, Path, Query}; use actix_web::{delete, get, post, put, HttpResponse};