Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

editoast: move infra items to editoast_schemas part 2 #7246

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions editoast/editoast_schemas/src/infra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ mod electrical_profiles;
mod electrification;
mod endpoint;
mod neutral_section;
mod operational_point;
mod route;
mod side;
mod sign;
mod signal;
mod speed_section;
mod switch;
mod switch_type;
mod track_endpoint;
Expand All @@ -32,12 +35,20 @@ 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;
pub use sign::Sign;
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
1 change: 1 addition & 0 deletions editoast/src/converters/generate_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions editoast/src/converters/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ 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;
use editoast_schemas::infra::Speed;
use editoast_schemas::infra::SpeedSection;
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;
Expand All @@ -22,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
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/generated_data/error/speed_sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 7 additions & 4 deletions editoast/src/infra_cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ 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;
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;
Expand All @@ -53,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)]
Expand Down Expand Up @@ -860,16 +863,16 @@ 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 crate::schema::Route;
use crate::schema::SpeedSection;
use editoast_common::Identifier;
use editoast_common::NonBlankString;
use editoast_schemas::infra::ApplicableDirections;
use editoast_schemas::infra::ApplicableDirectionsTrackRange;
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;
use editoast_schemas::infra::SwitchPortConnection;
use editoast_schemas::infra::SwitchType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/infra_cache/object_cache/route_cache.rs
Original file line number Diff line number Diff line change
@@ -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> {
Expand Down
Original file line number Diff line number Diff line change
@@ -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> {
Expand Down
12 changes: 6 additions & 6 deletions editoast/src/infra_cache/operation/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ use serde_json::Value;
use super::OperationError;
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::OperationalPoint;
use editoast_schemas::infra::Route;
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;
Expand Down Expand Up @@ -250,14 +250,14 @@ 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::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::OperationalPoint;
use editoast_schemas::infra::Route;
use editoast_schemas::infra::Signal;
use editoast_schemas::infra::SpeedSection;
use editoast_schemas::infra::Switch;
use editoast_schemas::infra::SwitchType;

Expand Down
3 changes: 3 additions & 0 deletions editoast/src/modelsv2/infra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ 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;
use editoast_schemas::infra::Switch;
use editoast_schemas::infra::SwitchType;
use editoast_schemas::primitives::OSRDIdentified;
Expand Down
10 changes: 7 additions & 3 deletions editoast/src/modelsv2/infra_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,14 @@ infra_model!(
OperationalPointModel,
infra_object_operational_point,
infra_layer_operational_point,
schema::OperationalPoint
editoast_schemas::infra::OperationalPoint
);

infra_model!(RouteModel, infra_object_route, schema::Route);
infra_model!(
RouteModel,
infra_object_route,
editoast_schemas::infra::Route
);

infra_model!(
SignalModel,
Expand All @@ -189,7 +193,7 @@ infra_model!(
SpeedSectionModel,
infra_object_speed_section,
infra_layer_speed_section,
schema::SpeedSection
editoast_schemas::infra::SpeedSection
);

infra_model!(
Expand Down
11 changes: 0 additions & 11 deletions editoast/src/schema/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
mod errors;
pub mod operational_point;
mod railjson;
mod route;
mod speed_section;
pub mod track_section;
pub mod utils;
pub mod v2;
Expand All @@ -11,16 +8,8 @@ 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 route::Route;
pub use route::RoutePath;
pub use speed_section::Speed;
pub use speed_section::SpeedSection;
pub use track_section::TrackSection;

cfg_if! {
Expand Down
6 changes: 3 additions & 3 deletions editoast/src/schema/railjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use derivative::Derivative;
use serde::Deserialize;
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::OperationalPoint;
use editoast_schemas::infra::Route;
use editoast_schemas::infra::Signal;
use editoast_schemas::infra::SpeedSection;
use editoast_schemas::infra::Switch;
use editoast_schemas::infra::SwitchType;

Expand Down
8 changes: 4 additions & 4 deletions editoast/src/views/infra/auto_fixes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,7 @@ 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::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;
Expand All @@ -351,7 +347,11 @@ 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;
use editoast_schemas::infra::Switch;
use editoast_schemas::infra::TrackEndpoint;
use editoast_schemas::infra::Waypoint;
Expand Down
2 changes: 1 addition & 1 deletion editoast/src/views/infra/auto_fixes/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions editoast/src/views/infra/auto_fixes/speed_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading
Loading