Commit 894c1c35 authored by Volker Krause's avatar Volker Krause
Browse files

Handle more transport modes for filtering triangle elements

Mixed train/bus tickets will appear merged as just one mode, so we need
to accept a mismatching type if everything else matches.
parent d0b98cd0
[
{
"@context": "http://schema.org",
"@type": "TrainReservation",
"reservationFor": {
"@type": "TrainTrip",
"arrivalStation": {
"@type": "TrainStation",
"name": "Köln Hbf"
},
"arrivalTime": "2014-01-24T12:09:00",
"departureDay": "2014-01-24",
"departureStation": {
"@type": "TrainStation",
"name": "Berlin Hbf"
},
"departureTime": {
"@type": "QDateTime",
"@value": "2014-01-24T07:46:00+01:00",
"timezone": "Europe/Berlin"
},
"trainNumber": "ICE 123"
},
"reservationNumber": "XXX007",
"reservationStatus": "http://schema.org/ReservationConfirmed"
},
{
"@context": "http://schema.org",
"@type": "BusReservation",
"reservationFor": {
"@type": "BusTrip",
"arrivalBusStop": {
"@type": "BusStation",
"name": "Bonn Hbf"
},
"arrivalTime": {
"@type": "QDateTime",
"@value": "2014-01-24T13:45:00+01:00",
"timezone": "Europe/Berlin"
},
"busNumber": "Bus 42",
"departureBusStop": {
"@type": "BusStation",
"name": "Köln Hbf"
},
"departureTime": "2014-01-24T12:17:00"
},
"reservationNumber": "XXX007",
"reservationStatus": "http://schema.org/ReservationConfirmed"
}
]
[
{
"@context": "http://schema.org",
"@type": "TrainReservation",
"reservationFor": {
"@type": "TrainTrip",
"arrivalStation": {
"@type": "TrainStation",
"name": "Bonn Hbf"
},
"arrivalTime": {
"@type": "QDateTime",
"@value": "2014-01-24T13:45:00+01:00",
"timezone": "Europe/Berlin"
},
"departureDay": "2014-01-24",
"departureStation": {
"@type": "TrainStation",
"name": "Berlin Hbf"
},
"departureTime": {
"@type": "QDateTime",
"@value": "2014-01-24T07:46:00+01:00",
"timezone": "Europe/Berlin"
}
},
"reservationStatus": "http://schema.org/ReservationConfirmed"
},
{
"@context": "http://schema.org",
"@type": "TrainReservation",
"reservationFor": {
"@type": "TrainTrip",
"arrivalStation": {
"@type": "TrainStation",
"name": "Köln Hbf"
},
"arrivalTime": "2014-01-24T12:09:00",
"departureDay": "2014-01-24",
"departureStation": {
"@type": "TrainStation",
"name": "Berlin Hbf"
},
"departureTime": {
"@type": "QDateTime",
"@value": "2014-01-24T07:46:00+01:00",
"timezone": "Europe/Berlin"
},
"trainNumber": "ICE 123"
},
"reservationNumber": "XXX007",
"reservationStatus": "http://schema.org/ReservationConfirmed"
},
{
"@context": "http://schema.org",
"@type": "BusReservation",
"reservationFor": {
"@type": "BusTrip",
"arrivalBusStop": {
"@type": "BusStation",
"name": "Bonn Hbf"
},
"arrivalTime": {
"@type": "QDateTime",
"@value": "2014-01-24T13:45:00+01:00",
"timezone": "Europe/Berlin"
},
"departureBusStop": {
"@type": "BusStation",
"name": "Köln Hbf"
},
"departureTime": "2014-01-24T12:17:00",
"busNumber": "Bus 42"
},
"reservationNumber": "XXX007",
"reservationStatus": "http://schema.org/ReservationConfirmed"
}
]
......@@ -615,9 +615,16 @@ bool isSameTicketToken(const QVariant &lhs, const QVariant &rhs)
return false;
}
static bool isCompatibleLocationChange(const QVariant &lhs, const QVariant &rhs)
{
const bool lhsTrainOrBus = JsonLd::isA<TrainReservation>(lhs) || JsonLd::isA<BusReservation>(lhs);
const bool rhsTrainOrBus = JsonLd::isA<TrainReservation>(rhs) || JsonLd::isA<BusReservation>(rhs);
return (lhsTrainOrBus && rhsTrainOrBus) || (JsonLd::isA<FlightReservation>(lhs) && JsonLd::isA<FlightReservation>(rhs));
}
bool MergeUtil::hasSameDeparture(const QVariant &lhs, const QVariant &rhs)
{
if (lhs.userType() != rhs.userType() || !JsonLd::isA<TrainReservation>(lhs)) {
if (!isCompatibleLocationChange(lhs, rhs)) {
return false;
}
const auto lhsRes = JsonLd::convert<Reservation>(lhs);
......@@ -631,7 +638,7 @@ bool MergeUtil::hasSameDeparture(const QVariant &lhs, const QVariant &rhs)
bool MergeUtil::hasSameArrival(const QVariant &lhs, const QVariant &rhs)
{
if (lhs.userType() != rhs.userType() || !JsonLd::isA<TrainReservation>(lhs)) {
if (!isCompatibleLocationChange(lhs, rhs)) {
return false;
}
const auto lhsRes = JsonLd::convert<Reservation>(lhs);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment