Commit 6762f54b authored by Volker Krause's avatar Volker Krause
Browse files

Emit top-level Ticket objects for VDV eTickets

Similar as with UIC 918.3, we were generating usually invalid train
reservations here, which no extractor relied on anymore. Generating
Ticket objects OTOH allows to import these tickets into Itinerary.
parent 16bd5246
Pipeline #185627 passed with stage
in 3 minutes and 48 seconds
......@@ -40,9 +40,6 @@ void VdvDocumentProcessor::preExtract(ExtractorDocumentNode &node, [[maybe_unuse
{
const auto vdv = node.content<VdvTicket>();
QJsonObject trip;
trip.insert(QStringLiteral("@type"), QLatin1String("TrainTrip"));
trip.insert(QStringLiteral("departureDay"), vdv.beginDateTime().date().toString(Qt::ISODate));
QJsonObject seat;
seat.insert(QStringLiteral("@type"), QLatin1String("Seat"));
switch (vdv.serviceClass()) {
......@@ -63,13 +60,12 @@ void VdvDocumentProcessor::preExtract(ExtractorDocumentNode &node, [[maybe_unuse
ticket.insert(QStringLiteral("ticketedSeat"), seat);
if (vdv.serviceClass() == VdvTicket::FirstClassUpgrade) {
ticket.insert(QStringLiteral("name"), i18n("Upgrade"));
} else {
ticket.insert(QStringLiteral("name"), i18n("Ticket"));
}
QJsonObject res;
res.insert(QStringLiteral("@type"), QLatin1String("TrainReservation"));
res.insert(QStringLiteral("reservationFor"), trip);
res.insert(QStringLiteral("reservationNumber"), vdv.ticketNumber());
res.insert(QStringLiteral("reservedTicket"), ticket);
res.insert(QStringLiteral("underName"), JsonLdDocument::toJson(vdv.person()));
node.addResult(QJsonArray({res}));
ticket.insert(QStringLiteral("ticketNumber"), vdv.ticketNumber());
ticket.insert(QStringLiteral("validFrom"), JsonLdDocument::toJsonValue(vdv.beginDateTime()));
ticket.insert(QStringLiteral("validUntil"), JsonLdDocument::toJsonValue(vdv.endDateTime()));
ticket.insert(QStringLiteral("underName"), JsonLdDocument::toJson(vdv.person()));
node.addResult(QJsonArray({ticket}));
}
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