Skip to content

Commit 4a580a2

Browse files
authored
Merge pull request #958 from hove-io/tech/adapt_to_ntfs_v0.17.0_booking_rules
[tech] Adapt to ntfs v0.17.0 - Migrate ODTReservation to BookingRule
2 parents 9cf5c47 + be58411 commit 4a580a2

File tree

19 files changed

+152
-159
lines changed

19 files changed

+152
-159
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
authors = ["Hove <core@hove.com>", "Guillaume Pinot <texitoi@texitoi.eu>"]
33
name = "transit_model"
4-
version = "0.65.0"
4+
version = "0.66.0"
55
license = "AGPL-3.0-only"
66
description = "Transit data management"
77
repository = "https://github.com/hove-io/transit_model"

src/add_prefix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl AddPrefix for Collections {
185185
self.calendars.prefix(prefix_conf);
186186
self.companies.prefix(prefix_conf);
187187
self.comments.prefix(prefix_conf);
188-
self.odt_reservations.prefix(prefix_conf);
188+
self.booking_rules.prefix(prefix_conf);
189189
self.equipments.prefix(prefix_conf);
190190
self.transfers.prefix(prefix_conf);
191191
self.trip_properties.prefix(prefix_conf);

src/gtfs/read.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl Trip {
334334
codes,
335335
object_properties: PropertiesMap::default(),
336336
comment_links: LinksT::default(),
337-
odt_reservation_links: LinksT::default(),
337+
booking_rule_links: LinksT::default(),
338338
route_id: route.get_id_by_direction(self.direction),
339339
physical_mode_id: physical_mode.id,
340340
dataset_id: dataset.id.clone(),
@@ -1030,7 +1030,7 @@ fn make_lines(
10301030
codes,
10311031
object_properties: PropertiesMap::default(),
10321032
comment_links: LinksT::default(),
1033-
odt_reservation_links: LinksT::default(),
1033+
booking_rule_links: LinksT::default(),
10341034
name: r.long_name.to_string(),
10351035
forward_name: None,
10361036
backward_name: None,

src/gtfs/write.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ mod tests {
12511251
codes: BTreeSet::new(),
12521252
object_properties: PropertiesMap::default(),
12531253
comment_links: LinksT::default(),
1254-
odt_reservation_links: LinksT::default(),
1254+
booking_rule_links: LinksT::default(),
12551255
route_id: "r:01".to_string(),
12561256
physical_mode_id: "pm:01".to_string(),
12571257
dataset_id: "ds:01".to_string(),
@@ -1326,7 +1326,7 @@ mod tests {
13261326
codes: BTreeSet::default(),
13271327
object_properties: PropertiesMap::default(),
13281328
comment_links: LinksT::default(),
1329-
odt_reservation_links: LinksT::default(),
1329+
booking_rule_links: LinksT::default(),
13301330
forward_name: None,
13311331
backward_name: None,
13321332
color: None,
@@ -1373,7 +1373,7 @@ mod tests {
13731373
codes: BTreeSet::default(),
13741374
object_properties: PropertiesMap::default(),
13751375
comment_links: LinksT::default(),
1376-
odt_reservation_links: LinksT::default(),
1376+
booking_rule_links: LinksT::default(),
13771377
forward_name: Some("Hôtels - Hôtels".to_string()),
13781378
backward_name: Some("Hôtels - Hôtels".to_string()),
13791379
color: Some(objects::Rgb {

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub mod vptranslator;
8282
pub(crate) const STOP_TIMES_INIT_CAPACITY: usize = 50;
8383

8484
/// Current version of the NTFS format
85-
pub const NTFS_VERSION: &str = "0.16.1";
85+
pub const NTFS_VERSION: &str = "0.17.0";
8686

8787
/// The max distance in meters to compute the transfer
8888
pub const TRANSFER_MAX_DISTANCE: &str = "300";

src/model.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub struct Collections {
8787
pub calendars: CollectionWithId<Calendar>,
8888
pub companies: CollectionWithId<Company>,
8989
pub comments: CollectionWithId<Comment>,
90-
pub odt_reservations: CollectionWithId<ODTReservation>,
90+
pub booking_rules: CollectionWithId<BookingRule>,
9191
pub equipments: CollectionWithId<Equipment>,
9292
pub transfers: Collection<Transfer>,
9393
pub trip_properties: CollectionWithId<TripProperty>,
@@ -218,7 +218,7 @@ impl Collections {
218218
let mut data_sets_used = HashSet::<String>::new();
219219
let mut physical_modes_used = HashSet::<String>::new();
220220
let mut comments_used = HashSet::<String>::new();
221-
let mut odt_reservations_used = HashSet::<String>::new();
221+
let mut booking_rules_used = HashSet::<String>::new();
222222
let mut level_id_used = HashSet::<String>::new();
223223
let mut calendars_used = HashSet::<String>::new();
224224
let mut vjs_used = HashSet::<String>::new();
@@ -254,8 +254,8 @@ impl Collections {
254254
data_sets_used.insert(vj.dataset_id.clone());
255255
physical_modes_used.insert(vj.physical_mode_id.clone());
256256
comments_used.extend(&mut vj.comment_links.iter().map(|cl| cl.to_string()));
257-
odt_reservations_used
258-
.extend(&mut vj.odt_reservation_links.iter().map(|id| id.to_string()));
257+
booking_rules_used
258+
.extend(&mut vj.booking_rule_links.iter().map(|id| id.to_string()));
259259
vjs_used.insert(vj.id.clone());
260260
true
261261
} else {
@@ -387,8 +387,8 @@ impl Collections {
387387
networks_used.insert(l.network_id.clone());
388388
commercial_modes_used.insert(l.commercial_mode_id.clone());
389389
comments_used.extend(&mut l.comment_links.iter().map(|cl| cl.to_string()));
390-
odt_reservations_used
391-
.extend(&mut l.odt_reservation_links.iter().map(|id| id.to_string()));
390+
booking_rules_used
391+
.extend(&mut l.booking_rule_links.iter().map(|id| id.to_string()));
392392
true
393393
} else {
394394
log_object_removed("Line", &l.id);
@@ -481,9 +481,9 @@ impl Collections {
481481
comments_used.contains(&comment.id)
482482
}));
483483

484-
self.odt_reservations.retain(log_predicate(
485-
"ODTReservation",
486-
|odt_reservation: &ODTReservation| odt_reservations_used.contains(&odt_reservation.id),
484+
self.booking_rules.retain(log_predicate(
485+
"BookingRule",
486+
|booking_rule: &BookingRule| booking_rules_used.contains(&booking_rule.id),
487487
));
488488

489489
self.lines = CollectionWithId::new(lines)?;
@@ -2082,7 +2082,7 @@ mod tests {
20822082
codes: KeysValues::default(),
20832083
object_properties: PropertiesMap::default(),
20842084
comment_links: LinksT::default(),
2085-
odt_reservation_links: LinksT::default(),
2085+
booking_rule_links: LinksT::default(),
20862086
route_id: String::from("route_id"),
20872087
physical_mode_id: String::new(),
20882088
dataset_id: String::new(),

src/netex_france/route_points.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ mod tests {
127127
codes: KeysValues::default(),
128128
object_properties: PropertiesMap::default(),
129129
comment_links: LinksT::default(),
130-
odt_reservation_links: LinksT::default(),
130+
booking_rule_links: LinksT::default(),
131131
route_id: String::from("route_id"),
132132
physical_mode_id: String::from("Bus"),
133133
dataset_id: String::from("dataset_id"),

src/ntfs/mod.rs

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ struct CommentLink {
142142
}
143143

144144
#[derive(Serialize, Deserialize, Debug, Clone)]
145-
struct ODTReservationLink {
145+
struct BookingRuleLink {
146146
object_id: String,
147147
object_type: ObjectType,
148-
odt_reservation_id: String,
148+
booking_rule_id: String,
149149
}
150150

151151
#[derive(Serialize, Deserialize, Debug, Clone)]
@@ -338,7 +338,7 @@ where
338338
read::manage_stop_times(&mut collections, file_handler)?;
339339
read::manage_codes(&mut collections, file_handler)?;
340340
read::manage_comments(&mut collections, file_handler)?;
341-
read::manage_odt_reservations(&mut collections, file_handler)?;
341+
read::manage_booking_rules(&mut collections, file_handler)?;
342342
read::manage_object_properties(&mut collections, file_handler)?;
343343
read::manage_fares_v1(&mut collections, file_handler)?;
344344
read::manage_companies_on_vj(&mut collections)?;
@@ -413,7 +413,7 @@ pub fn write<P: AsRef<path::Path>>(
413413
&model.stop_locations,
414414
)?;
415415
write::write_comments(path, model)?;
416-
write::write_odt_reservations(path, model)?;
416+
write::write_booking_rules(path, model)?;
417417
write::write_codes(path, model)?;
418418
write::write_object_properties(path, model)?;
419419
write::write_fares_v1(path, model)?;
@@ -533,7 +533,7 @@ mod tests {
533533
("feed_end_date".to_string(), "20180131".to_string()),
534534
("feed_publisher_name".to_string(), "Nicaragua".to_string()),
535535
("feed_start_date".to_string(), "20180130".to_string()),
536-
("ntfs_version".to_string(), "0.16.1".to_string()),
536+
("ntfs_version".to_string(), "0.17.0".to_string()),
537537
("tartare_platform".to_string(), "dev".to_string()),
538538
],
539539
collections
@@ -622,7 +622,7 @@ mod tests {
622622
codes: KeysValues::default(),
623623
object_properties: PropertiesMap::default(),
624624
comment_links: LinksT::default(),
625-
odt_reservation_links: LinksT::default(),
625+
booking_rule_links: LinksT::default(),
626626
forward_name: Some("Hôtels - Hôtels".to_string()),
627627
backward_name: Some("Hôtels - Hôtels".to_string()),
628628
color: Some(Rgb {
@@ -649,7 +649,7 @@ mod tests {
649649
codes: KeysValues::default(),
650650
object_properties: PropertiesMap::default(),
651651
comment_links: LinksT::default(),
652-
odt_reservation_links: LinksT::default(),
652+
booking_rule_links: LinksT::default(),
653653
forward_name: None,
654654
backward_name: None,
655655
color: None,
@@ -751,7 +751,7 @@ mod tests {
751751
codes: KeysValues::default(),
752752
object_properties: PropertiesMap::default(),
753753
comment_links: LinksT::default(),
754-
odt_reservation_links: LinksT::default(),
754+
booking_rule_links: LinksT::default(),
755755
route_id: "OIF:078078001:1".to_string(),
756756
physical_mode_id: "Bus".to_string(),
757757
dataset_id: "OIF:0".to_string(),
@@ -795,7 +795,7 @@ mod tests {
795795
codes: KeysValues::default(),
796796
object_properties: PropertiesMap::default(),
797797
comment_links: LinksT::default(),
798-
odt_reservation_links: LinksT::default(),
798+
booking_rule_links: LinksT::default(),
799799
route_id: "OIF:800:TER".to_string(),
800800
physical_mode_id: "Bus".to_string(),
801801
dataset_id: "OIF:0".to_string(),
@@ -1099,30 +1099,30 @@ mod tests {
10991099
])
11001100
.unwrap();
11011101

1102-
let odt_reservations = CollectionWithId::new(vec![
1103-
ODTReservation {
1102+
let booking_rules = CollectionWithId::new(vec![
1103+
BookingRule {
11041104
id: "odt:1".to_string(),
11051105
name: Some("name:1".to_string()),
1106-
url: Some("https://reservation1".to_string()),
1106+
info_url: Some("https://reservation1".to_string()),
11071107
phone: Some("01 02 03 04 01".to_string()),
1108-
condition: Some("lundi au vendredi de 9h à 18h".to_string()),
1109-
deeplink: Some("https://deeplink1".to_string()),
1108+
message: Some("lundi au vendredi de 9h à 18h".to_string()),
1109+
booking_url: Some("https://deeplink1".to_string()),
11101110
},
1111-
ODTReservation {
1111+
BookingRule {
11121112
id: "odt:2".to_string(),
11131113
name: None,
1114-
url: Some("https://reservation2".to_string()),
1114+
info_url: Some("https://reservation2".to_string()),
11151115
phone: Some("01 02 03 04 02".to_string()),
1116-
condition: Some("lundi au samedi de 8h à 15h".to_string()),
1117-
deeplink: Some("https://deeplink2".to_string()),
1116+
message: Some("lundi au samedi de 8h à 15h".to_string()),
1117+
booking_url: Some("https://deeplink2".to_string()),
11181118
},
1119-
ODTReservation {
1119+
BookingRule {
11201120
id: "odt:3".to_string(),
11211121
name: Some("name:3".to_string()),
1122-
url: Some("https://reservation3".to_string()),
1122+
info_url: Some("https://reservation3".to_string()),
11231123
phone: Some("01 02 03 04 03".to_string()),
1124-
condition: Some("lundi au mardi de 9h à 10h".to_string()),
1125-
deeplink: Some("https://deeplink3".to_string()),
1124+
message: Some("lundi au mardi de 9h à 10h".to_string()),
1125+
booking_url: Some("https://deeplink3".to_string()),
11261126
},
11271127
])
11281128
.unwrap();
@@ -1188,7 +1188,7 @@ mod tests {
11881188
"prop_value:3".to_string()
11891189
)],
11901190
comment_links: btree_set_from_vec(vec!["c:1".to_string()]),
1191-
odt_reservation_links: btree_set_from_vec(vec!["odt:1".to_string()]),
1191+
booking_rule_links: btree_set_from_vec(vec!["odt:1".to_string()]),
11921192
forward_name: None,
11931193
backward_name: None,
11941194
color: None,
@@ -1230,7 +1230,7 @@ mod tests {
12301230
"prop_value:6".to_string()
12311231
)],
12321232
comment_links: LinksT::default(),
1233-
odt_reservation_links: btree_set_from_vec(vec!["odt:2".to_string()]),
1233+
booking_rule_links: btree_set_from_vec(vec!["odt:2".to_string()]),
12341234
route_id: "OIF:800:TER".to_string(),
12351235
physical_mode_id: "Bus".to_string(),
12361236
dataset_id: "OIF:0".to_string(),
@@ -1275,7 +1275,7 @@ mod tests {
12751275
stop_time_comments.insert(("VJ:1".to_string(), 0), "c:2".to_string());
12761276

12771277
ser_collections.comments = comments;
1278-
ser_collections.odt_reservations = odt_reservations;
1278+
ser_collections.booking_rules = booking_rules;
12791279
ser_collections.stop_areas = stop_areas;
12801280
ser_collections.stop_points = stop_points;
12811281
ser_collections.stop_locations = stop_locations;
@@ -1306,7 +1306,7 @@ mod tests {
13061306
)
13071307
.unwrap();
13081308
write::write_comments(path, &ser_collections).unwrap();
1309-
write::write_odt_reservations(path, &ser_collections).unwrap();
1309+
write::write_booking_rules(path, &ser_collections).unwrap();
13101310
write::write_codes(path, &ser_collections).unwrap();
13111311
write::write_object_properties(path, &ser_collections).unwrap();
13121312
let mut handler = PathFileHandler::new(path.to_path_buf());
@@ -1321,15 +1321,12 @@ mod tests {
13211321
read::manage_stops(&mut des_collections, &mut handler).unwrap();
13221322
read::manage_stop_times(&mut des_collections, &mut handler).unwrap();
13231323
read::manage_comments(&mut des_collections, &mut handler).unwrap();
1324-
read::manage_odt_reservations(&mut des_collections, &mut handler).unwrap();
1324+
read::manage_booking_rules(&mut des_collections, &mut handler).unwrap();
13251325
read::manage_codes(&mut des_collections, &mut handler).unwrap();
13261326
read::manage_object_properties(&mut des_collections, &mut handler).unwrap();
13271327

13281328
assert_eq!(ser_collections.comments, des_collections.comments);
1329-
assert_eq!(
1330-
ser_collections.odt_reservations,
1331-
des_collections.odt_reservations
1332-
);
1329+
assert_eq!(ser_collections.booking_rules, des_collections.booking_rules);
13331330

13341331
// test comment links
13351332
assert_eq!(
@@ -1415,31 +1412,31 @@ mod tests {
14151412
des_collections.stop_time_comments
14161413
);
14171414

1418-
// test odt reservation links
1415+
// test booking rule links
14191416
assert_eq!(
14201417
ser_collections
14211418
.lines
14221419
.get("OIF:002002003:3OIF829")
14231420
.unwrap()
1424-
.odt_reservation_links,
1421+
.booking_rule_links,
14251422
des_collections
14261423
.lines
14271424
.get("OIF:002002003:3OIF829")
14281425
.unwrap()
1429-
.odt_reservation_links
1426+
.booking_rule_links
14301427
);
14311428

14321429
assert_eq!(
14331430
ser_collections
14341431
.vehicle_journeys
14351432
.get("VJ:1")
14361433
.unwrap()
1437-
.odt_reservation_links,
1434+
.booking_rule_links,
14381435
des_collections
14391436
.vehicle_journeys
14401437
.get("VJ:1")
14411438
.unwrap()
1442-
.odt_reservation_links
1439+
.booking_rule_links
14431440
);
14441441

14451442
// test codes

0 commit comments

Comments
 (0)