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

Extract passenger name from IATA BCBP too

parent 72130219
......@@ -19,6 +19,10 @@
},
"flightNumber": "834"
},
"reservationNumber": "ABC123"
"reservationNumber": "ABC123",
"underName": {
"@type": "Person",
"name": "DESMARAIS/LUC"
}
}
]
......@@ -19,6 +19,10 @@
},
"flightNumber": "834"
},
"reservationNumber": "AB12C3"
"reservationNumber": "AB12C3",
"underName": {
"@type": "Person",
"name": "DESMARAIS/LUC"
}
}
]
......@@ -19,6 +19,10 @@
},
"flightNumber": "123"
},
"reservationNumber": "ABC123"
"reservationNumber": "ABC123",
"underName": {
"@type": "Person",
"name": "GRANDMAIRE/MELANIE"
}
}
]
......@@ -19,7 +19,11 @@
},
"flightNumber": "834"
},
"reservationNumber": "AB12C3"
"reservationNumber": "AB12C3",
"underName": {
"@type": "Person",
"name": "DESMARAIS/LUC"
}
},
{
"@context": "http://schema.org",
......@@ -41,6 +45,10 @@
},
"flightNumber": "3664"
},
"reservationNumber": "DEF456"
"reservationNumber": "DEF456",
"underName": {
"@type": "Person",
"name": "DESMARAIS/LUC"
}
}
]
......@@ -19,7 +19,11 @@
},
"flightNumber": "123"
},
"reservationNumber": "ABC123"
"reservationNumber": "ABC123",
"underName": {
"@type": "Person",
"name": "GRANDMAIRE/MELANIE"
}
},
{
"@context": "http://schema.org",
......@@ -41,6 +45,10 @@
},
"flightNumber": "49"
},
"reservationNumber": "DEF456"
"reservationNumber": "DEF456",
"underName": {
"@type": "Person",
"name": "GRANDMAIRE/MELANIE"
}
}
]
......@@ -10,6 +10,7 @@ set(kitinerary_lib_srcs
datatypes/bustrip.cpp
datatypes/flight.cpp
datatypes/person.cpp
datatypes/place.cpp
datatypes/reservation.cpp
datatypes/ticket.cpp
......@@ -78,6 +79,7 @@ ecm_generate_headers(KItinerary_Datatypes_HEADERS
Datatypes
Flight
Reservation
Person
Place
Ticket
TrainTrip
......
/*
Copyright (C) 2018 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "person.h"
#include "datatypes_p.h"
using namespace KItinerary;
namespace KItinerary {
class PersonPrivate : public QSharedData
{
public:
QString name;
QString email;
};
KITINERARY_MAKE_SIMPLE_CLASS(Person)
KITINERARY_MAKE_PROPERTY(Person, QString, name, setName)
KITINERARY_MAKE_PROPERTY(Person, QString, email, setEmail)
}
#include "moc_person.cpp"
/*
Copyright (C) 2018 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KITINERARY_PERSON_H
#define KITINERARY_PERSON_H
#include "kitinerary_export.h"
#include "datatypes.h"
namespace KItinerary {
class PersonPrivate;
/** A person
* @see https://schema.org/Person
*/
class KITINERARY_EXPORT Person
{
KITINERARY_GADGET(Person)
KITINERARY_PROPERTY(QString, name, setName)
KITINERARY_PROPERTY(QString, email, setEmail)
private:
QExplicitlySharedDataPointer<PersonPrivate> d;
};
}
Q_DECLARE_METATYPE(KItinerary::Person)
#endif // KITINERARY_PERSON_H
......@@ -32,6 +32,7 @@ public:
QString reservationNumber;
QVariant reservationFor;
QVariant reservedTicket;
QVariant underName;
QUrl cancelReservationUrl;
QUrl modifyReservationUrl;
QString ticketToken;
......@@ -42,6 +43,7 @@ KITINERARY_MAKE_ABSTRACT_CLASS(Reservation)
KITINERARY_MAKE_PROPERTY(Reservation, QString, reservationNumber, setReservationNumber)
KITINERARY_MAKE_PROPERTY(Reservation, QVariant, reservationFor, setReservationFor)
KITINERARY_MAKE_PROPERTY(Reservation, QVariant, reservedTicket, setReservedTicket)
KITINERARY_MAKE_PROPERTY(Reservation, QVariant, underName, setUnderName)
KITINERARY_MAKE_PROPERTY(Reservation, QUrl, cancelReservationUrl, setCancelReservationUrl)
KITINERARY_MAKE_PROPERTY(Reservation, QUrl, modifyReservationUrl, setModifyReservationUrl)
KITINERARY_MAKE_PROPERTY(Reservation, QString, ticketToken, setTicketToken)
......
......@@ -36,6 +36,7 @@ class KITINERARY_EXPORT Reservation
KITINERARY_PROPERTY(QString, reservationNumber, setReservationNumber)
KITINERARY_PROPERTY(QVariant, reservationFor, setReservationFor)
KITINERARY_PROPERTY(QVariant, reservedTicket, setReservedTicket)
KITINERARY_PROPERTY(QVariant, underName, setUnderName)
// Google extension
KITINERARY_PROPERTY(QUrl, cancelReservationUrl, setCancelReservationUrl)
......
......@@ -18,9 +18,10 @@
#include "iatabcbpparser.h"
#include "logging.h"
#include "datatypes/flight.h"
#include "datatypes/reservation.h"
#include "datatypes/place.h"
#include <KItinerary/Flight>
#include <KItinerary/Reservation>
#include <KItinerary/Person>
#include <KItinerary/Place>
#include <QVariant>
......@@ -94,7 +95,11 @@ QVector<QVariant> IataBcbpParser::parse(const QString& message)
result.reserve(legCount);
FlightReservation res1;
// TODO: 20x passenger name
Person person;
const auto fullName = message.midRef(2, 20).trimmed();
// TODO split in family and given name
person.setName(fullName.toString());
res1.setUnderName(QVariant::fromValue(person));
const auto varSize = parseRepeatedMandatorySection(message.midRef(UniqueMandatorySize), res1);
int index = UniqueMandatorySize + RepeastedMandatorySize;
......
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