Commit 9e06e9b8 authored by Volker Krause's avatar Volker Krause
Browse files

Add basic boat/ferry data model, now that schema.org has that

parent 0f888bb1
Pipeline #72799 passed with stage
in 12 minutes and 52 seconds
......@@ -9,6 +9,7 @@ add_library(KPim::Itinerary ALIAS KPimItinerary)
target_sources(KPimItinerary PRIVATE
datatypes/action.cpp
datatypes/boattrip.cpp
datatypes/brand.cpp
datatypes/bustrip.cpp
datatypes/creativework.cpp
......@@ -201,6 +202,7 @@ ecm_generate_headers(KItinerary_KnowledgeDb_FORWARDING_HEADERS
ecm_generate_headers(KItinerary_Datatypes_FORWARDING_HEADERS
HEADER_NAMES
Action
BoatTrip
Brand
BusTrip
CreativeWork
......
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "boattrip.h"
#include "datatypes_p.h"
#include <QDateTime>
using namespace KItinerary;
namespace KItinerary {
class BoatTripPrivate : public QSharedData
{
public:
QString name;
BoatTerminal arrivalBoatTerminal;
QDateTime arrivalTime;
BoatTerminal departureBoatTerminal;
QDateTime departureTime;
};
KITINERARY_MAKE_SIMPLE_CLASS(BoatTrip)
KITINERARY_MAKE_PROPERTY(BoatTrip, QString, name, setName)
KITINERARY_MAKE_PROPERTY(BoatTrip, BoatTerminal, arrivalBoatTerminal, setArrivalBoatTerminal)
KITINERARY_MAKE_PROPERTY(BoatTrip, QDateTime, arrivalTime, setArrivalTime)
KITINERARY_MAKE_PROPERTY(BoatTrip, BoatTerminal, departureBoatTerminal, setDepartureBoatTerminal)
KITINERARY_MAKE_PROPERTY(BoatTrip, QDateTime, departureTime, setDepartureTime)
KITINERARY_MAKE_OPERATOR(BoatTrip)
}
#include "moc_boattrip.cpp"
/*
SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KITINERARY_BOATTRIP_H
#define KITINERARY_BOATTRIP_H
#include "kitinerary_export.h"
#include "datatypes.h"
#include "place.h"
class QDateTime;
namespace KItinerary {
class BoatTripPrivate;
/** A boat or ferry trip.
* @see https://schema.org/BoatTrip
*/
class KITINERARY_EXPORT BoatTrip
{
KITINERARY_GADGET(BoatTrip)
KITINERARY_PROPERTY(QString, name, setName)
KITINERARY_PROPERTY(KItinerary::BoatTerminal, arrivalBoatTerminal, setArrivalBoatTerminal)
KITINERARY_PROPERTY(QDateTime, arrivalTime, setArrivalTime)
KITINERARY_PROPERTY(KItinerary::BoatTerminal, departureBoatTerminal, setDepartureBoatTerminal)
KITINERARY_PROPERTY(QDateTime, departureTime, setDepartureTime)
private:
QExplicitlySharedDataPointer<BoatTripPrivate> d;
};
}
Q_DECLARE_METATYPE(KItinerary::BoatTrip)
#endif // KITINERARY_BOATTRIP_H
......@@ -103,6 +103,13 @@ KITINERARY_MAKE_SUB_CLASS(Airport, Place)
KITINERARY_MAKE_PROPERTY(Airport, QString, iataCode, setIataCode)
KITINERARY_MAKE_OPERATOR(Airport)
class BoatTerminalPrivate : public PlacePrivate
{
KITINERARY_PRIVATE_GADGET(BoatTerminal)
};
KITINERARY_MAKE_SUB_CLASS(BoatTerminal, Place)
KITINERARY_MAKE_OPERATOR(BoatTerminal)
class TrainStationPrivate : public PlacePrivate
{
KITINERARY_PRIVATE_GADGET(TrainStation)
......
......@@ -97,6 +97,14 @@ class KITINERARY_EXPORT Airport : public Place
KITINERARY_PROPERTY(QString, iataCode, setIataCode)
};
/** Boat or ferry terminal.
* @see https://schema.org/BoatTerminal
*/
class KITINERARY_EXPORT BoatTerminal : public Place
{
KITINERARY_GADGET(BoatTerminal)
};
/** Train station.
* @see https://schema.org/TrainStation
*/
......@@ -128,6 +136,7 @@ Q_DECLARE_METATYPE(KItinerary::Place)
Q_DECLARE_METATYPE(KItinerary::GeoCoordinates)
Q_DECLARE_METATYPE(KItinerary::PostalAddress)
Q_DECLARE_METATYPE(KItinerary::Airport)
Q_DECLARE_METATYPE(KItinerary::BoatTerminal)
Q_DECLARE_METATYPE(KItinerary::TrainStation)
Q_DECLARE_METATYPE(KItinerary::BusStation)
Q_DECLARE_METATYPE(KItinerary::TouristAttraction)
......
......@@ -144,6 +144,13 @@ KITINERARY_MAKE_PROPERTY(TaxiReservation, Place, pickupLocation, setPickupLocati
KITINERARY_MAKE_OPERATOR(TaxiReservation)
class BoatReservationPrivate : public ReservationPrivate
{
KITINERARY_PRIVATE_GADGET(BoatReservation)
};
KITINERARY_MAKE_SUB_CLASS(BoatReservation, Reservation)
KITINERARY_MAKE_OPERATOR(BoatReservation)
}
template <>
......
......@@ -152,6 +152,14 @@ class KITINERARY_EXPORT TaxiReservation : public Reservation
KITINERARY_PROPERTY(KItinerary::Place, pickupLocation, setPickupLocation)
};
/** A boat or ferry reservation.
* @see https://schema.org/BoatReservation
*/
class KITINERARY_EXPORT BoatReservation : public Reservation
{
KITINERARY_GADGET(BoatReservation)
};
}
......@@ -163,5 +171,5 @@ Q_DECLARE_METATYPE(KItinerary::BusReservation)
Q_DECLARE_METATYPE(KItinerary::FoodEstablishmentReservation)
Q_DECLARE_METATYPE(KItinerary::EventReservation)
Q_DECLARE_METATYPE(KItinerary::RentalCarReservation)
Q_DECLARE_METATYPE(KItinerary::TaxiReservation)
Q_DECLARE_METATYPE(KItinerary::BoatReservation)
......@@ -9,6 +9,7 @@
#include "logging.h"
#include <KItinerary/Action>
#include <KItinerary/BoatTrip>
#include <KItinerary/Brand>
#include <KItinerary/BusTrip>
#include <KItinerary/CreativeWork>
......@@ -65,6 +66,9 @@ static void registerBuiltInTypes(std::vector<TypeInfo> &r)
add<Action>(r);
add<Airline>(r);
add<Airport>(r);
add<BoatReservation>(r);
add<BoatTerminal>(r);
add<BoatTrip>(r);
add<Brand>(r);
add<BusReservation>(r);
add<BusStation>(r);
......
......@@ -6,6 +6,7 @@
#include "locationutil.h"
#include <KItinerary/BoatTrip>
#include <KItinerary/BusTrip>
#include <KItinerary/Event>
#include <KItinerary/Flight>
......@@ -30,7 +31,7 @@ bool LocationUtil::isLocationChange(const QVariant &res)
}
return !isSameLocation(pickup, dropoff);
}
return JsonLd::isA<FlightReservation>(res) || JsonLd::isA<TrainReservation>(res) || JsonLd::isA<BusReservation>(res) || JsonLd::isA<TaxiReservation>(res);
return JsonLd::isA<FlightReservation>(res) || JsonLd::isA<TrainReservation>(res) || JsonLd::isA<BusReservation>(res) || JsonLd::isA<TaxiReservation>(res) || JsonLd::isA<BoatReservation>(res);
}
QVariant LocationUtil::arrivalLocation(const QVariant &res)
......@@ -47,6 +48,9 @@ QVariant LocationUtil::arrivalLocation(const QVariant &res)
if (JsonLd::isA<RentalCarReservation>(res)) {
return res.value<RentalCarReservation>().dropoffLocation();
}
if (JsonLd::isA<BoatReservation>(res)) {
return res.value<BoatReservation>().reservationFor().value<BoatTrip>().arrivalBoatTerminal();
}
return {};
}
......@@ -67,6 +71,9 @@ QVariant LocationUtil::departureLocation(const QVariant &res)
if (JsonLd::isA<TaxiReservation>(res)) {
return res.value<TaxiReservation>().pickupLocation();
}
if (JsonLd::isA<BoatReservation>(res)) {
return res.value<BoatReservation>().reservationFor().value<BoatTrip>().departureBoatTerminal();
}
return {};
}
......
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