Skip to content

Commit cc883e3

Browse files
SarahBellahaanisometropie
authored andcommitted
editoast, front, schemas: remove features field in rs model and remove SignalingSystem enum
1 parent 6952d14 commit cc883e3

File tree

19 files changed

+37
-86
lines changed

19 files changed

+37
-86
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ALTER TABLE rolling_stock
2+
ADD features text[] NOT NULL DEFAULT '{}',
3+
ALTER COLUMN supported_signaling_systems DROP DEFAULT,
4+
ALTER COLUMN supported_signaling_systems type jsonb USING Array_to_json(supported_signaling_systems::text[]),
5+
DROP CONSTRAINT supported_signaling_systems_no_nulls,
6+
ALTER COLUMN supported_signaling_systems SET DEFAULT ('["BAPR", "BAL", "TVM300", "TVM430"]');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
ALTER TABLE rolling_stock
3+
DROP COLUMN features,
4+
ALTER COLUMN supported_signaling_systems DROP DEFAULT,
5+
ALTER COLUMN supported_signaling_systems TYPE TEXT[] USING TRANSLATE(supported_signaling_systems::jsonb::text, '[]','{}')::TEXT[],
6+
ADD CONSTRAINT supported_signaling_systems_no_nulls CHECK (array_position(supported_signaling_systems, NULL) IS NULL),
7+
ALTER COLUMN supported_signaling_systems SET DEFAULT ('{"BAPR", "BAL", "TVM300", "TVM430"}');

editoast/openapi.yaml

+3-19
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,6 @@ components:
841841
items:
842842
$ref: '#/components/schemas/EnergySource'
843843
type: array
844-
features:
845-
items:
846-
type: string
847-
type: array
848844
gamma:
849845
$ref: '#/components/schemas/Gamma'
850846
id:
@@ -886,7 +882,7 @@ components:
886882
type: number
887883
supported_signaling_systems:
888884
items:
889-
$ref: '#/components/schemas/SignalingSystem'
885+
type: string
890886
type: array
891887
required:
892888
- id
@@ -901,7 +897,6 @@ components:
901897
- comfort_acceleration
902898
- gamma
903899
- inertia_coefficient
904-
- features
905900
- mass
906901
- rolling_resistance
907902
- loading_gauge
@@ -1925,10 +1920,6 @@ components:
19251920
items:
19261921
$ref: '#/components/schemas/EnergySource'
19271922
type: array
1928-
features:
1929-
items:
1930-
type: string
1931-
type: array
19321923
gamma:
19331924
$ref: '#/components/schemas/Gamma'
19341925
inertia_coefficient:
@@ -1968,7 +1959,7 @@ components:
19681959
type: number
19691960
supported_signaling_systems:
19701961
items:
1971-
$ref: '#/components/schemas/SignalingSystem'
1962+
type: string
19721963
type: array
19731964
required:
19741965
- name
@@ -1981,11 +1972,11 @@ components:
19811972
- comfort_acceleration
19821973
- gamma
19831974
- inertia_coefficient
1984-
- features
19851975
- mass
19861976
- rolling_resistance
19871977
- loading_gauge
19881978
- power_restrictions
1979+
- supported_signaling_systems
19891980
type: object
19901981
RollingStockError:
19911982
oneOf:
@@ -2721,13 +2712,6 @@ components:
27212712
- aspect_label
27222713
- track
27232714
type: object
2724-
SignalingSystem:
2725-
enum:
2726-
- BAL
2727-
- BAPR
2728-
- TVM300
2729-
- TVM430
2730-
type: string
27312715
SimulationPowerRestrictionRange:
27322716
properties:
27332717
code:

editoast/src/models/rolling_stock/light_rolling_stock.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use crate::error::Result;
2-
use crate::models::rolling_stock::rolling_stock_livery::RollingStockLiveryMetadata;
2+
use crate::models::{rolling_stock::rolling_stock_livery::RollingStockLiveryMetadata, TextArray};
33
use crate::schema::rolling_stock::light_rolling_stock::{
44
LightEffortCurves, LightRollingStock, LightRollingStockWithLiveries,
55
};
6-
use crate::schema::rolling_stock::{
7-
EnergySource, Gamma, RollingResistance, RollingStockMetadata, SignalingSystem,
8-
};
6+
use crate::schema::rolling_stock::{EnergySource, Gamma, RollingResistance, RollingStockMetadata};
97
use crate::tables::rolling_stock;
108
use crate::views::pagination::{Paginate, PaginatedResponse};
119
use crate::DbPool;
@@ -39,7 +37,6 @@ pub struct LightRollingStockModel {
3937
gamma: DieselJson<Gamma>,
4038
inertia_coefficient: f64,
4139
pub base_power_class: Option<String>,
42-
features: Vec<Option<String>>,
4340
mass: f64,
4441
#[schema(value_type = RollingResistance)]
4542
rolling_resistance: DieselJson<RollingResistance>,
@@ -53,8 +50,8 @@ pub struct LightRollingStockModel {
5350
electrical_power_startup_time: Option<f64>,
5451
raise_pantograph_time: Option<f64>,
5552
pub version: i64,
56-
#[schema(value_type = Vec<SignalingSystem>)]
57-
supported_signaling_systems: DieselJson<Vec<SignalingSystem>>,
53+
#[diesel(deserialize_as = TextArray)]
54+
supported_signaling_systems: Vec<String>,
5855
}
5956

6057
impl LightRollingStockModel {
@@ -114,7 +111,6 @@ impl From<LightRollingStockModel> for LightRollingStock {
114111
comfort_acceleration: rolling_stock_model.comfort_acceleration,
115112
gamma: rolling_stock_model.gamma,
116113
inertia_coefficient: rolling_stock_model.inertia_coefficient,
117-
features: rolling_stock_model.features.into_iter().flatten().collect(),
118114
mass: rolling_stock_model.mass,
119115
rolling_resistance: rolling_stock_model.rolling_resistance,
120116
loading_gauge: rolling_stock_model.loading_gauge,

editoast/src/models/rolling_stock/mod.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::models::rolling_stock::rolling_stock_livery::RollingStockLiveryMetada
1313
use crate::models::{Create, Identifiable, TextArray, Update};
1414
use crate::schema::rolling_stock::{
1515
EffortCurves, EnergySource, Gamma, RollingResistance, RollingStock, RollingStockCommon,
16-
RollingStockMetadata, RollingStockWithLiveries, SignalingSystem,
16+
RollingStockMetadata, RollingStockWithLiveries,
1717
};
1818
use crate::schema::track_section::LoadingGaugeType;
1919
use crate::tables::rolling_stock;
@@ -97,9 +97,6 @@ pub struct RollingStockModel {
9797
#[diesel(deserialize_as = Option<String>)]
9898
#[schema(value_type = Option<String>)]
9999
pub base_power_class: Option<Option<String>>,
100-
#[diesel(deserialize_as = TextArray)]
101-
#[schema(value_type = Vec<String>)]
102-
pub features: Option<Vec<String>>,
103100
#[diesel(deserialize_as = f64)]
104101
#[schema(value_type = f64)]
105102
pub mass: Option<f64>,
@@ -130,9 +127,9 @@ pub struct RollingStockModel {
130127
#[diesel(deserialize_as = i64)]
131128
#[schema(value_type = i64)]
132129
pub version: Option<i64>,
133-
#[diesel(deserialize_as = DieselJson<Vec<SignalingSystem>>)]
134-
#[schema(value_type = Vec<SignalingSystem>)]
135-
pub supported_signaling_systems: Option<DieselJson<Vec<SignalingSystem>>>,
130+
#[diesel(deserialize_as = TextArray)]
131+
#[schema(value_type = Vec<String>)]
132+
pub supported_signaling_systems: Option<Vec<String>>,
136133
}
137134

138135
fn validate_rolling_stock(
@@ -288,7 +285,6 @@ impl From<RollingStockModel> for RollingStockCommon {
288285
comfort_acceleration: rolling_stock_model.comfort_acceleration.unwrap(),
289286
gamma: rolling_stock_model.gamma.unwrap().0,
290287
inertia_coefficient: rolling_stock_model.inertia_coefficient.unwrap(),
291-
features: rolling_stock_model.features.unwrap(),
292288
mass: rolling_stock_model.mass.unwrap(),
293289
rolling_resistance: rolling_stock_model.rolling_resistance.unwrap().0,
294290
loading_gauge: rolling_stock_model.loading_gauge.unwrap(),
@@ -298,7 +294,7 @@ impl From<RollingStockModel> for RollingStockCommon {
298294
.electrical_power_startup_time
299295
.unwrap(),
300296
raise_pantograph_time: rolling_stock_model.raise_pantograph_time.unwrap(),
301-
supported_signaling_systems: rolling_stock_model.supported_signaling_systems.unwrap().0,
297+
supported_signaling_systems: rolling_stock_model.supported_signaling_systems.unwrap(),
302298
}
303299
}
304300
}

editoast/src/schema/rolling_stock/light_rolling_stock.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use utoipa::ToSchema;
66

77
use crate::models::rolling_stock::rolling_stock_livery::RollingStockLiveryMetadata;
88

9-
use super::{EnergySource, Gamma, RollingResistance, RollingStockMetadata, SignalingSystem};
9+
use super::{EnergySource, Gamma, RollingResistance, RollingStockMetadata};
1010

1111
crate::schemas! {
1212
LightRollingStock,
@@ -45,8 +45,6 @@ pub struct LightRollingStock {
4545
pub gamma: DieselJson<Gamma>,
4646
#[diesel(sql_type = Double)]
4747
pub inertia_coefficient: f64,
48-
#[diesel(sql_type = Array<Text>)]
49-
pub features: Vec<String>,
5048
#[diesel(sql_type = Double)]
5149
pub mass: f64,
5250
#[diesel(sql_type = Jsonb)]
@@ -67,9 +65,8 @@ pub struct LightRollingStock {
6765
#[serde(skip)]
6866
#[diesel(sql_type = BigInt)]
6967
pub version: i64,
70-
#[diesel(sql_type = Jsonb)]
71-
#[schema(value_type = Vec<SignalingSystem>)]
72-
pub supported_signaling_systems: DieselJson<Vec<SignalingSystem>>,
68+
#[diesel(sql_type = Array<Text>)]
69+
pub supported_signaling_systems: Vec<String>,
7370
}
7471

7572
#[derive(Debug, QueryableByName, Serialize, Deserialize, ToSchema)]

editoast/src/schema/rolling_stock/mod.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ crate::schemas! {
2929
EnergyStorage,
3030
RefillLaw,
3131
RollingStockLivery,
32-
SignalingSystem,
3332
light_rolling_stock::schemas(),
3433
}
3534

@@ -48,7 +47,6 @@ pub struct RollingStockCommon {
4847
pub comfort_acceleration: f64,
4948
pub gamma: Gamma,
5049
pub inertia_coefficient: f64,
51-
pub features: Vec<String>,
5250
pub mass: f64,
5351
pub rolling_resistance: RollingResistance,
5452
#[schema(value_type = LoadingGaugeType)]
@@ -64,8 +62,7 @@ pub struct RollingStockCommon {
6462
/// The time it takes to raise this train's pantograph in seconds. Is null if the train is not electric.
6563
#[schema(example = 15.0)]
6664
pub raise_pantograph_time: Option<f64>,
67-
#[serde(default)]
68-
pub supported_signaling_systems: Vec<SignalingSystem>,
65+
pub supported_signaling_systems: Vec<String>,
6966
}
7067

7168
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ToSchema)]
@@ -265,17 +262,6 @@ pub enum EnergySource {
265262
},
266263
}
267264

268-
#[derive(Clone, Debug, PartialEq, EnumString, Deserialize, Serialize, ToSchema)]
269-
#[strum(serialize_all = "UPPERCASE")]
270-
#[serde(rename_all = "UPPERCASE")]
271-
#[serde(deny_unknown_fields)]
272-
pub enum SignalingSystem {
273-
Bal,
274-
Bapr,
275-
Tvm300,
276-
Tvm430,
277-
}
278-
279265
#[cfg(test)]
280266
mod tests {
281267
use crate::schema::rolling_stock::EffortCurve;

editoast/src/tables.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ diesel::table! {
412412
inertia_coefficient -> Float8,
413413
#[max_length = 255]
414414
base_power_class -> Nullable<Varchar>,
415-
features -> Array<Nullable<Text>>,
416415
mass -> Float8,
417416
rolling_resistance -> Jsonb,
418417
#[max_length = 16]
@@ -423,7 +422,7 @@ diesel::table! {
423422
electrical_power_startup_time -> Nullable<Float8>,
424423
raise_pantograph_time -> Nullable<Float8>,
425424
version -> Int8,
426-
supported_signaling_systems -> Jsonb,
425+
supported_signaling_systems -> Array<Nullable<Text>>,
427426
}
428427
}
429428

editoast/src/tests/example_rolling_stock_1.json

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"startup_acceleration": 0.05,
99
"comfort_acceleration": 0.25,
1010
"inertia_coefficient": 1.05,
11-
"features": ["TVM300", "TVM430", "ETCS1", "ETCS2", "KVB"],
1211
"name": "fast_rolling_stock",
1312
"mass": 900000.0,
1413
"loading_gauge": "G1",

editoast/src/tests/example_rolling_stock_2_energy_sources.json

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"startup_acceleration": 0.25,
99
"comfort_acceleration": 0.12,
1010
"inertia_coefficient": 1.02,
11-
"features": [],
1211
"name": "other_rolling_stock",
1312
"mass": 50000.0,
1413
"loading_gauge": "G2",

editoast/src/tests/example_rolling_stock_3.json

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"startup_acceleration": 0.25,
99
"comfort_acceleration": 0.12,
1010
"inertia_coefficient": 1.02,
11-
"features": [],
1211
"name": "other_rolling_stock",
1312
"mass": 50000.0,
1413
"loading_gauge": "G2",

editoast/src/tests/small_infra/stdcm/test_1/stdcm_core_payload.json

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@
9898
"value": 0.5
9999
},
100100
"inertia_coefficient": 1.2,
101-
"features": [],
102101
"mass": 132000,
103102
"rolling_resistance": {
104103
"type": "davis",

editoast/src/views/rolling_stocks/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,14 @@ impl From<RollingStockForm> for RollingStockModel {
137137
comfort_acceleration: Some(rolling_stock.common.comfort_acceleration),
138138
gamma: Some(DieselJson(rolling_stock.common.gamma)),
139139
inertia_coefficient: Some(rolling_stock.common.inertia_coefficient),
140-
features: Some(rolling_stock.common.features),
141140
mass: Some(rolling_stock.common.mass),
142141
rolling_resistance: Some(DieselJson(rolling_stock.common.rolling_resistance)),
143142
loading_gauge: Some(rolling_stock.common.loading_gauge),
144143
power_restrictions: Some(rolling_stock.common.power_restrictions),
145144
energy_sources: Some(DieselJson(rolling_stock.common.energy_sources)),
146145
electrical_power_startup_time: Some(rolling_stock.common.electrical_power_startup_time),
147146
raise_pantograph_time: Some(rolling_stock.common.raise_pantograph_time),
148-
supported_signaling_systems: Some(DieselJson(
149-
rolling_stock.common.supported_signaling_systems,
150-
)),
147+
supported_signaling_systems: Some(rolling_stock.common.supported_signaling_systems),
151148
..Default::default()
152149
}
153150
}

front/src/common/api/osrdEditoastApi.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1591,13 +1591,11 @@ export type RollingResistance = {
15911591
C: number;
15921592
type: string;
15931593
};
1594-
export type SignalingSystem = 'BAL' | 'BAPR' | 'TVM300' | 'TVM430';
15951594
export type LightRollingStock = {
15961595
base_power_class?: string | null;
15971596
comfort_acceleration: number;
15981597
effort_curves: LightEffortCurves;
15991598
energy_sources: EnergySource[];
1600-
features: string[];
16011599
gamma: Gamma;
16021600
id: number;
16031601
inertia_coefficient: number;
@@ -1615,7 +1613,7 @@ export type LightRollingStock = {
16151613
rolling_resistance: RollingResistance;
16161614
startup_acceleration: number;
16171615
startup_time: number;
1618-
supported_signaling_systems: SignalingSystem[];
1616+
supported_signaling_systems: string[];
16191617
};
16201618
export type RollingStockLiveryMetadata = {
16211619
compound_image_id?: number | null;
@@ -1889,7 +1887,6 @@ export type RollingStockCommon = {
18891887
effort_curves: EffortCurves;
18901888
electrical_power_startup_time?: number | null;
18911889
energy_sources?: EnergySource[];
1892-
features: string[];
18931890
gamma: Gamma;
18941891
inertia_coefficient: number;
18951892
length: number;
@@ -1904,7 +1901,7 @@ export type RollingStockCommon = {
19041901
rolling_resistance: RollingResistance;
19051902
startup_acceleration: number;
19061903
startup_time: number;
1907-
supported_signaling_systems?: SignalingSystem[];
1904+
supported_signaling_systems: string[];
19081905
};
19091906
export type RollingStock = RollingStockCommon & {
19101907
id: number;

front/src/modules/rollingStock/components/RollingStockCard/RollingStockCardDetail.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,6 @@ export default function RollingStockCardDetail({
122122
</table>
123123
</div>
124124
<div className="col-sm-6">
125-
{rollingStock.features && rollingStock.features.length > 0 && (
126-
<div className="pb-1">
127-
{t('features')}
128-
<span className="ml-1">{rollingStock.features.join(', ')}</span>
129-
</div>
130-
)}
131125
{rollingStock.power_restrictions &&
132126
Object.keys(rollingStock.power_restrictions).length !== 0 && (
133127
<table className="rollingstock-details-table mb-1">

front/src/modules/rollingStock/helpers/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ export const rollingStockEditorQueryArg = (
140140
value: data.gammaValue,
141141
},
142142
inertia_coefficient: data.inertiaCoefficient,
143-
features: [],
144143
mass: data.mass * 1000, // Here we receive a value in ton which will be interpreted in kg by the server.
145144
rolling_resistance: {
146145
A: data.rollingResistanceA,
@@ -169,6 +168,7 @@ export const rollingStockEditorQueryArg = (
169168
modes: validCurves,
170169
},
171170
base_power_class: data.basePowerClass,
171+
supported_signaling_systems: []
172172
};
173173
};
174174

0 commit comments

Comments
 (0)