Commit 34bded7f authored by Volker Krause's avatar Volker Krause
Browse files

Add Organization::identifier property

We use this to extract UIC carrier ids found in train ticket barcodes,
which will be helpful for Itinerary/KPublicTransport to determine the
best source for querying live data for a given booking.
parent ea5c6a1d
Pipeline #71803 passed with stage
in 13 minutes and 10 seconds
......@@ -40,6 +40,13 @@
"result": [
{
"@type": "TrainReservation",
"reservationFor": {
"@type": "TrainTrip",
"provider": {
"@type": "Organization",
"identifier": "uic:0080"
}
},
"reservationNumber": "9E8DXL",
"reservedTicket": {
"@type": "Ticket",
......
......@@ -18,6 +18,7 @@ class OrganizationPrivate: public QSharedData
KITINERARY_PRIVATE_BASE_GADGET(Organization)
public:
QString name;
QString identifier;
QString description;
QUrl image;
QUrl logo;
......@@ -31,6 +32,7 @@ public:
KITINERARY_MAKE_BASE_CLASS(Organization)
KITINERARY_MAKE_PROPERTY(Organization, QString, name, setName)
KITINERARY_MAKE_PROPERTY(Organization, QString, identifier, setIdentifier)
KITINERARY_MAKE_PROPERTY(Organization, QString, description, setDescription)
KITINERARY_MAKE_PROPERTY(Organization, QUrl, image, setImage)
KITINERARY_MAKE_PROPERTY(Organization, QUrl, logo, setLogo)
......
......@@ -31,6 +31,7 @@ class KITINERARY_EXPORT Organization
{
KITINERARY_BASE_GADGET(Organization)
KITINERARY_PROPERTY(QString, name, setName)
KITINERARY_PROPERTY(QString, identifier, setIdentifier)
KITINERARY_PROPERTY(QString, description, setDescription)
KITINERARY_PROPERTY(QUrl, image, setImage)
KITINERARY_PROPERTY(QUrl, logo, setLogo)
......
......@@ -81,6 +81,7 @@ QJSValue JsApi::JsonLd::newTrainReservation() const
auto resFor = newObject(QStringLiteral("TrainTrip"));
resFor.setProperty(QStringLiteral("departureStation"), dep);
resFor.setProperty(QStringLiteral("arrivalStation"), arr);
resFor.setProperty(QStringLiteral("provider"), newObject(QStringLiteral("Organization")));
auto res = newObject(QStringLiteral("TrainReservation"));
res.setProperty(QStringLiteral("reservationFor"), resFor);
......
......@@ -54,10 +54,14 @@ void Uic9183DocumentProcessor::preExtract(ExtractorDocumentNode &node, [[maybe_u
const auto p = node.content<Uic9183Parser>();
QJsonObject trip;
trip.insert(QStringLiteral("@type"), QLatin1String("TrainTrip"));
trip.insert(QLatin1String("@type"), QLatin1String("TrainTrip"));
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(QStringLiteral("@type"), QLatin1String("Seat"));
seat.insert(QStringLiteral("seatingType"), p.seatingType());
seat.insert(QLatin1String("@type"), QLatin1String("Seat"));
seat.insert(QLatin1String("seatingType"), p.seatingType());
const auto rct2 = p.rct2Ticket();
if (rct2.isValid()) {
......
......@@ -231,6 +231,7 @@ function parsePdf(pdf, node, triggerNode) {
var reservations = parseTicket(page.text, uic918ticket);
for (var i = 0; i < reservations.length; ++i) {
reservations[i].reservedTicket.ticketToken = "aztecbin:" + Barcode.toBase64(triggerNode.content.rawData);
reservations[i].reservationFor.provider.identifier = "uic:" + triggerNode.content.carrierId;
if (triggerNode.result.length > 0) {
reservations[i].reservedTicket.name = triggerNode.result[0].reservedTicket.name;
reservations[i].underName = triggerNode.result[0].underName;
......
......@@ -15,6 +15,7 @@ function parseSsbTicket(ssb, node) {
res.reservationFor.arrivalStation.identifier = "benerail:" + ssb.type1ArrivalStationAlpha;
res.reservationFor.departureDay = ssb.type1DepartureDay(node.contextDateTime)
res.reservationFor.trainNumber = "THA " + ssb.type1TrainNumber.trim();
res.reservationFor.provider.identifier = "uic:" + ssb.issuerCode;
res.reservedTicket.ticketedSeat.seatingType = ssb.classOfTravel;
res.reservedTicket.ticketedSeat.seatSection = ssb.type1CoachNumber;
res.reservedTicket.ticketedSeat.seatNumber = ssb.type1SeatNumber;
......
......@@ -58,6 +58,7 @@ function parsePdf(pdf) {
if (ssb.departureStationNum != ssb.arrivalStationNum) {
personalRes.reservationFor.arrivalStation.identifier = "uic:" + (ssb.arrivalStationNum % 10000000)
}
personalRes.reservationFor.provider.identifier = "uic:" + ssb.issuerCode;
var bitArray = Barcode.toBitArray(barcode);
var seatNum = bitArray.readNumberMSB(31*8 + 2, 7);
......
......@@ -24,6 +24,7 @@ function parseSsbBarcode(ssb, node)
// for station codes see: https://rata.digitraffic.fi/api/v1/metadata/stations
res.reservationFor.departureStation.identifier = "vrfi:" + ssb.departureStationAlpha;
res.reservationFor.arrivalStation.identifier = "vrfi:" + ssb.arrivalStationAlpha;
res.reservationFor.provider.identifier = "uic:" + ssb.issuerCode;
res.reservedTicket.ticketToken = "aztectbin:" + Barcode.toBase64(ssb.rawData);
res.reservedTicket.ticketedSeat.seatingType = ssb.classOfTransport;
......
Markdown is supported
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