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

Add validity interval to generically generated UIC 918.3 Ticket objects

parent b965393c
......@@ -14,7 +14,9 @@
},
"pnr": "9E8DXL",
"rawData": "<binary: 442 bytes>",
"seatingType": "2"
"seatingType": "2",
"validFrom": "Invalid Date",
"validUntil": "Invalid Date"
}
},
{
......@@ -34,7 +36,9 @@
},
"pnr": "9E8DXL",
"rawData": "<binary: 442 bytes>",
"seatingType": "2"
"seatingType": "2",
"validFrom": "Invalid Date",
"validUntil": "Invalid Date"
},
"contextDateTime": "Fri Feb 17 15:18:00 2012 GMT+0100",
"isNull": false,
......
......@@ -146,6 +146,12 @@ void Uic9183DocumentProcessor::preExtract(ExtractorDocumentNode &node, [[maybe_u
ticket.insert(QStringLiteral("issuedBy"), provider);
ticket.insert(QStringLiteral("ticketNumber"), p.pnr());
ticket.insert(QStringLiteral("underName"), JsonLdDocument::toJson(p.person()));
if (p.validFrom().isValid()) {
ticket.insert(QStringLiteral("validFrom"), JsonLdDocument::toJsonValue(p.validFrom()));
}
if (p.validUntil().isValid()) {
ticket.insert(QStringLiteral("validUntil"), JsonLdDocument::toJsonValue(p.validUntil()));
}
node.addResult(QJsonArray({ticket}));
}
......@@ -146,6 +146,30 @@ QString Uic9183Parser::carrierId() const
return findBlock<Uic9183Head>().issuerCompanyCodeString();
}
QDateTime Uic9183Parser::validFrom() const
{
// DB vendor block
const auto b = findBlock<Vendor0080BLBlock>();
if (b.isValid() && b.orderBlockCount() == 1) {
return QDateTime(b.orderBlock(0).validFrom(), {0, 0, 0});
}
// TODO RCT2 tickets?
return {};
}
QDateTime Uic9183Parser::validUntil() const
{
// DB vendor block
const auto b = findBlock<Vendor0080BLBlock>();
if (b.isValid() && b.orderBlockCount() == 1) {
return QDateTime(b.orderBlock(0).validTo(), {23, 59, 59});
}
// TODO RCT2 tickets?
return {};
}
Person Uic9183Parser::person() const
{
// Deutsche Bahn vendor block
......
......@@ -38,6 +38,8 @@ class KITINERARY_EXPORT Uic9183Parser
Q_PROPERTY(QString pnr READ pnr)
Q_PROPERTY(QString name READ name)
Q_PROPERTY(QString carrierId READ carrierId)
Q_PROPERTY(QDateTime validFrom READ validFrom)
Q_PROPERTY(QDateTime validUntil READ validUntil)
Q_PROPERTY(KItinerary::Person person READ person)
Q_PROPERTY(QString outboundDepartureStationId READ outboundDepartureStationId)
Q_PROPERTY(QString outboundArrivalStationId READ outboundArrivalStationId)
......@@ -69,6 +71,10 @@ public:
QString name() const;
/** The UIC carrier code. */
QString carrierId() const;
/** Begin of validity. */
QDateTime validFrom() const;
/** End of validity. */
QDateTime validUntil() const;
/** The person this ticket is issued to. */
Person person() const;
......
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