@@ -4,10 +4,12 @@ use crate::error::Result;
4
4
use crate :: models:: TrackSectionModel ;
5
5
use crate :: RetrieveBatchUnchecked ;
6
6
use editoast_schemas:: infra:: TrackOffset ;
7
+ use editoast_schemas:: train_schedule:: OperationalPointReference ;
7
8
use std:: collections:: HashMap ;
8
9
use std:: collections:: HashSet ;
9
10
10
11
use editoast_models:: DbConnection ;
12
+ use editoast_schemas:: train_schedule:: OperationalPointIdentifier ;
11
13
use editoast_schemas:: train_schedule:: PathItemLocation ;
12
14
13
15
use crate :: models:: OperationalPointModel ;
@@ -93,26 +95,32 @@ impl PathItemCache {
93
95
let mut result: Vec < Vec < _ > > = Vec :: default ( ) ;
94
96
let mut invalid_path_items = Vec :: new ( ) ;
95
97
for ( index, & path_item) in path_items. iter ( ) . enumerate ( ) {
98
+ dbg ! ( & path_item) ;
96
99
let track_offsets = match path_item {
97
100
PathItemLocation :: TrackOffset ( track_offset) => {
98
101
vec ! [ track_offset. clone( ) ]
99
102
}
100
- PathItemLocation :: OperationalPointId { operational_point } => {
101
- match self . get_from_id ( & operational_point. 0 ) {
102
- Some ( op) => op. track_offset ( ) ,
103
- None => {
104
- invalid_path_items. push ( InvalidPathItem {
105
- index,
106
- path_item : path_item. clone ( ) ,
107
- } ) ;
108
- continue ;
109
- }
103
+ PathItemLocation :: OperationalPointReference ( OperationalPointReference {
104
+ reference : OperationalPointIdentifier :: OperationalPointId { operational_point } ,
105
+ ..
106
+ } ) => match self . get_from_id ( & operational_point. 0 ) {
107
+ Some ( op) => op. track_offset ( ) ,
108
+ None => {
109
+ invalid_path_items. push ( InvalidPathItem {
110
+ index,
111
+ path_item : path_item. clone ( ) ,
112
+ } ) ;
113
+ continue ;
110
114
}
111
- }
112
- PathItemLocation :: OperationalPointDescription {
113
- trigram,
114
- secondary_code,
115
- } => {
115
+ } ,
116
+ PathItemLocation :: OperationalPointReference ( OperationalPointReference {
117
+ reference :
118
+ OperationalPointIdentifier :: OperationalPointDescription {
119
+ trigram,
120
+ secondary_code,
121
+ } ,
122
+ ..
123
+ } ) => {
116
124
let ops = self
117
125
. get_from_trigram ( & trigram. 0 )
118
126
. cloned ( )
@@ -127,10 +135,14 @@ impl PathItemCache {
127
135
}
128
136
track_offsets_from_ops ( & ops)
129
137
}
130
- PathItemLocation :: OperationalPointUic {
131
- uic,
132
- secondary_code,
133
- } => {
138
+ PathItemLocation :: OperationalPointReference ( OperationalPointReference {
139
+ reference :
140
+ OperationalPointIdentifier :: OperationalPointUic {
141
+ uic,
142
+ secondary_code,
143
+ } ,
144
+ ..
145
+ } ) => {
134
146
let ops = self
135
147
. get_from_uic ( i64:: from ( * uic) )
136
148
. cloned ( )
@@ -183,15 +195,25 @@ fn collect_path_item_ids(path_items: &[&PathItemLocation]) -> (Vec<String>, Vec<
183
195
184
196
for item in path_items {
185
197
match item {
186
- PathItemLocation :: OperationalPointDescription { trigram, .. } => {
198
+ PathItemLocation :: OperationalPointReference ( OperationalPointReference {
199
+ reference : OperationalPointIdentifier :: OperationalPointDescription { trigram, .. } ,
200
+ ..
201
+ } ) => {
187
202
trigrams. push ( trigram. clone ( ) . 0 ) ;
188
203
}
189
- PathItemLocation :: OperationalPointUic { uic, .. } => {
204
+ PathItemLocation :: OperationalPointReference ( OperationalPointReference {
205
+ reference : OperationalPointIdentifier :: OperationalPointUic { uic, .. } ,
206
+ ..
207
+ } ) => {
190
208
ops_uic. push ( i64:: from ( * uic) ) ;
191
209
}
192
- PathItemLocation :: OperationalPointId {
193
- operational_point, ..
194
- } => {
210
+ PathItemLocation :: OperationalPointReference ( OperationalPointReference {
211
+ reference :
212
+ OperationalPointIdentifier :: OperationalPointId {
213
+ operational_point, ..
214
+ } ,
215
+ ..
216
+ } ) => {
195
217
ops_id. push ( operational_point. clone ( ) . 0 ) ;
196
218
}
197
219
_ => { }
0 commit comments