Commit 8bd895d3 authored by Volker Krause's avatar Volker Krause
Browse files

Provide a full issuer organization object from the UIC 918.3 parser

With ERA FCB we can have more information than just the UIC company code
for this now.
parent 0382eb5b
Pipeline #255982 passed with stage
in 12 minutes and 11 seconds
......@@ -2,6 +2,35 @@
{
"content": {
"carrierId": "0080",
"issuer": {
"address": {
"addressCountry": "",
"addressLocality": "",
"addressRegion": "",
"className": "PostalAddress",
"isEmpty": true,
"postalCode": "",
"streetAddress": ""
},
"className": "Organization",
"description": "",
"email": "",
"geo": {
"className": "GeoCoordinates",
"isValid": false,
"latitude": null,
"longitude": null
},
"geoUri": "",
"identifier": "uic:0080",
"image": "",
"logo": "",
"name": "",
"potentialAction": [
],
"telephone": "",
"url": ""
},
"name": "Normalpreis",
"outboundArrivalStationId": "",
"outboundDepartureStationId": "",
......@@ -24,6 +53,35 @@
],
"content": {
"carrierId": "0080",
"issuer": {
"address": {
"addressCountry": "",
"addressLocality": "",
"addressRegion": "",
"className": "PostalAddress",
"isEmpty": true,
"postalCode": "",
"streetAddress": ""
},
"className": "Organization",
"description": "",
"email": "",
"geo": {
"className": "GeoCoordinates",
"isValid": false,
"latitude": null,
"longitude": null
},
"geoUri": "",
"identifier": "uic:0080",
"image": "",
"logo": "",
"name": "",
"potentialAction": [
],
"telephone": "",
"url": ""
},
"name": "Normalpreis",
"outboundArrivalStationId": "",
"outboundDepartureStationId": "",
......@@ -47,6 +105,7 @@
{
"@type": "Ticket",
"issuedBy": {
"@context": "http://schema.org",
"@type": "Organization",
"identifier": "uic:0080"
},
......
......@@ -3,6 +3,10 @@
"@context": "http://schema.org",
"@type": "Uic9183Parser",
"carrierId": "0080",
"issuer": {
"@type": "Organization",
"identifier": "uic:0080"
},
"name": "Normalpreis",
"person": {
"@type": "Person",
......
......@@ -90,9 +90,6 @@ void Uic9183DocumentProcessor::preExtract(ExtractorDocumentNode &node, [[maybe_u
trip.insert(QLatin1String("@type"), QLatin1String("TrainTrip"));
QJsonObject returnTrip;
returnTrip.insert(QLatin1String("@type"), QLatin1String("TrainTrip"));
QJsonObject provider;
provider.insert(QLatin1String("@type"), QLatin1String("Organization"));
provider.insert(QLatin1String("identifier"), QJsonValue(QLatin1String("uic:") + p.carrierId()));
QJsonObject seat;
seat.insert(QLatin1String("@type"), QLatin1String("Seat"));
......@@ -170,7 +167,7 @@ void Uic9183DocumentProcessor::preExtract(ExtractorDocumentNode &node, [[maybe_u
// we have enough for a full TrainReservation result
if (isValidTrip(trip)) {
trip.insert(QLatin1String("provider"), provider);
trip.insert(QLatin1String("provider"), JsonLdDocument::toJson(p.issuer()));
QJsonArray results;
QJsonObject res;
......@@ -192,7 +189,7 @@ void Uic9183DocumentProcessor::preExtract(ExtractorDocumentNode &node, [[maybe_u
// only Ticket
ticket.insert(QStringLiteral("name"), p.name());
ticket.insert(QStringLiteral("issuedBy"), provider);
ticket.insert(QStringLiteral("issuedBy"), JsonLdDocument::toJson(p.issuer()));
ticket.insert(QStringLiteral("ticketNumber"), p.pnr());
ticket.insert(QStringLiteral("underName"), JsonLdDocument::toJson(p.person()));
if (p.validFrom().isValid()) {
......
......@@ -218,7 +218,7 @@ function parseReservation(pdf) {
function applyUic9183ToReservation(res, uicCode)
{
res.reservationNumber = uicCode.pnr;
res.reservationFor.provider.identifier = "uic:" + uicCode.carrierId;
res.reservationFor.provider = JsonLd.toJson(uicCode.issuer);
const bl = uicCode.block('0080BL');
let sb = bl.findSubBlock('009');
if (sb) {
......
......@@ -245,6 +245,16 @@ QString Uic9183Parser::carrierId() const
return header().signerCompanyCode();
}
Organization Uic9183Parser::issuer() const
{
Organization issuer;
issuer.setIdentifier(QLatin1String("uic:") + carrierId());
if (const auto fcb = findBlock<Fcb::UicRailTicketData>(); fcb.isValid() && fcb.issuingDetail.issuerNameIsSet()) {
issuer.setName(fcb.issuingDetail.issuerName);
}
return issuer;
}
QDateTime Uic9183Parser::validFrom() const
{
// ERA FCB
......
......@@ -8,6 +8,7 @@
#include "kitinerary_export.h"
#include <KItinerary/Organization>
#include <KItinerary/Person>
#include <QExplicitlySharedDataPointer>
......@@ -38,6 +39,7 @@ class KITINERARY_EXPORT Uic9183Parser
Q_PROPERTY(QString pnr READ pnr)
Q_PROPERTY(QString name READ name)
Q_PROPERTY(QString carrierId READ carrierId)
Q_PROPERTY(KItinerary::Organization issuer READ issuer)
Q_PROPERTY(QDateTime validFrom READ validFrom)
Q_PROPERTY(QDateTime validUntil READ validUntil)
Q_PROPERTY(KItinerary::Person person READ person)
......@@ -71,6 +73,8 @@ public:
QString name() const;
/** The UIC carrier code. */
QString carrierId() const;
/** Full issuer organization element. */
Organization issuer() const;
/** Begin of validity. */
QDateTime validFrom() const;
/** End of validity. */
......
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