Commit b14e1930 authored by Volker Krause's avatar Volker Krause
Browse files

Generate top-level Ticket results for UIC 918.3 containers

Those end up being used if nothing subsequently produce a full train
reservation or program membership card out of this.
parent 840f693e
Pipeline #185505 passed with stage
in 2 minutes and 24 seconds
......@@ -2,6 +2,7 @@
{
"content": {
"carrierId": "0080",
"name": "Normalpreis",
"outboundArrivalStationId": "",
"outboundDepartureStationId": "",
"person": {
......@@ -21,6 +22,7 @@
],
"content": {
"carrierId": "0080",
"name": "Normalpreis",
"outboundArrivalStationId": "",
"outboundDepartureStationId": "",
"person": {
......@@ -39,22 +41,17 @@
"mimeType": "internal/uic9183",
"result": [
{
"@type": "TrainReservation",
"reservationFor": {
"@type": "TrainTrip",
"provider": {
"@type": "Organization",
"identifier": "uic:0080"
}
"@type": "Ticket",
"issuedBy": {
"@type": "Organization",
"identifier": "uic:0080"
},
"reservationNumber": "9E8DXL",
"reservedTicket": {
"@type": "Ticket",
"ticketToken": "aztecbin:I1VUMDEwMDgwMDAwMDIwLAIUGue7pQWksx4NCGj9cJzioDvHG2ICFGnc04h8A1eHmpP6hrOkqvuyoaofAAAAADAzNzR4nH2Rv07CUBTGkUFdXHyCJi5QqZ57+p8NbCsNFJMWCMhAiGhsQDSlkuiTsLk4ysqig0lfwEE3H8Zz5Y+YGDvcfvc7v/vd09N6p2QXLGAAqgxggGkbVrMi6am1h+mACAyZygywbMvmoGsBApBhMpQV7hQr5CjMBIVoX3Fa1qnaWg/CRQ4a87eBqmpq5KNvOdis1sveX7QG8oqmOKYFwPtlrHodXXUHN9F5OCKLuiGKhMxFgYSyFCYJDSUmMTMghttAgtcxoCNMJaWWk9lgSBuNZzlRd9i/uI3ijNcNh9n9ozC+o5r+T81YC0HG+2i4hbxQ809cMXCPi6JXEyuemHFKh47jOVmiqFVUL5PHZJa8RIJP4kHoJ9Ozfkfq5A8I0HiL/Kvw+2bqG5mp82krNBONj55qdLOMP+dyozh5Fvy938H8UKPOJ2fMf0o6Tcv7JN56m4xz7dRGrv26GP3T9ufmzmR8vxvS5mNB9IjoLYnpivgC6qKSSw==",
"ticketedSeat": {
"@type": "Seat",
"seatingType": "2"
}
"name": "Normalpreis",
"ticketNumber": "9E8DXL",
"ticketToken": "aztecbin:I1VUMDEwMDgwMDAwMDIwLAIUGue7pQWksx4NCGj9cJzioDvHG2ICFGnc04h8A1eHmpP6hrOkqvuyoaofAAAAADAzNzR4nH2Rv07CUBTGkUFdXHyCJi5QqZ57+p8NbCsNFJMWCMhAiGhsQDSlkuiTsLk4ysqig0lfwEE3H8Zz5Y+YGDvcfvc7v/vd09N6p2QXLGAAqgxggGkbVrMi6am1h+mACAyZygywbMvmoGsBApBhMpQV7hQr5CjMBIVoX3Fa1qnaWg/CRQ4a87eBqmpq5KNvOdis1sveX7QG8oqmOKYFwPtlrHodXXUHN9F5OCKLuiGKhMxFgYSyFCYJDSUmMTMghttAgtcxoCNMJaWWk9lgSBuNZzlRd9i/uI3ijNcNh9n9ozC+o5r+T81YC0HG+2i4hbxQ809cMXCPi6JXEyuemHFKh47jOVmiqFVUL5PHZJa8RIJP4kHoJ9Ozfkfq5A8I0HiL/Kvw+2bqG5mp82krNBONj55qdLOMP+dyozh5Fvy938H8UKPOJ2fMf0o6Tcv7JN56m4xz7dRGrv26GP3T9ufmzmR8vxvS5mNB9IjoLYnpivgC6qKSSw==",
"ticketedSeat": {
"@type": "Seat",
"seatingType": "2"
},
"underName": {
"@context": "http://schema.org",
......
......@@ -3,6 +3,7 @@
"@context": "http://schema.org",
"@type": "Uic9183Parser",
"carrierId": "0080",
"name": "Normalpreis",
"person": {
"@type": "Person",
"familyName": "häöür Räß",
......
......@@ -58,7 +58,6 @@ void Uic9183DocumentProcessor::preExtract(ExtractorDocumentNode &node, [[maybe_u
QJsonObject provider;
provider.insert(QLatin1String("@type"), QLatin1String("Organization"));
provider.insert(QLatin1String("identifier"), QJsonValue(QLatin1String("uic:") + p.carrierId()));
trip.insert(QLatin1String("provider"), provider);
QJsonObject seat;
seat.insert(QLatin1String("@type"), QLatin1String("Seat"));
seat.insert(QLatin1String("seatingType"), p.seatingType());
......@@ -122,14 +121,25 @@ void Uic9183DocumentProcessor::preExtract(ExtractorDocumentNode &node, [[maybe_u
}
}
QJsonObject res;
res.insert(QStringLiteral("@type"), QLatin1String("TrainReservation"));
// we have enough for a full TrainReservation result
if (trip.size() > 1) {
trip.insert(QLatin1String("provider"), provider);
QJsonObject res;
res.insert(QStringLiteral("@type"), QLatin1String("TrainReservation"));
res.insert(QStringLiteral("reservationFor"), trip);
res.insert(QStringLiteral("reservationNumber"), p.pnr());
res.insert(QStringLiteral("reservedTicket"), ticket);
res.insert(QStringLiteral("underName"), JsonLdDocument::toJson(p.person()));
node.addResult(QJsonArray({res}));
return;
}
res.insert(QStringLiteral("reservationNumber"), p.pnr());
res.insert(QStringLiteral("reservedTicket"), ticket);
res.insert(QStringLiteral("underName"), JsonLdDocument::toJson(p.person()));
node.addResult(QJsonArray({res}));
// only Ticket
ticket.insert(QStringLiteral("name"), p.name());
ticket.insert(QStringLiteral("issuedBy"), provider);
ticket.insert(QStringLiteral("ticketNumber"), p.pnr());
ticket.insert(QStringLiteral("underName"), JsonLdDocument::toJson(p.person()));
node.addResult(QJsonArray({ticket}));
}
......@@ -126,6 +126,21 @@ QString Uic9183Parser::pnr() const
return findBlock<Uic9183Head>().ticketKey().left(6);
}
QString Uic9183Parser::name() const
{
// DB vendor block
const auto b = findBlock<Vendor0080BLBlock>();
if (b.isValid()) {
const auto sblock = b.findSubBlock("001");
if (!sblock.isNull()) {
return QString::fromUtf8(sblock.content(), sblock.contentSize());
}
}
// TODO RCT2 tickets
return {};
}
QString Uic9183Parser::carrierId() const
{
return findBlock<Uic9183Head>().issuerCompanyCodeString();
......
......@@ -36,6 +36,7 @@ class KITINERARY_EXPORT Uic9183Parser
{
Q_GADGET
Q_PROPERTY(QString pnr READ pnr)
Q_PROPERTY(QString name READ name)
Q_PROPERTY(QString carrierId READ carrierId)
Q_PROPERTY(KItinerary::Person person READ person)
Q_PROPERTY(QString outboundDepartureStationId READ outboundDepartureStationId)
......@@ -64,6 +65,8 @@ public:
/** The booking reference. */
QString pnr() const;
/** Ticket name. */
QString name() const;
/** The UIC carrier code. */
QString carrierId() const;
/** The person this ticket is issued to. */
......
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