Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
605bab7f
Commit
605bab7f
authored
Jul 26, 2022
by
Volker Krause
Browse files
Add merging rules for boat/ferry trips
parent
b1b669cd
Pipeline
#209144
passed with stage
in 9 minutes and 3 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/lib/mergeutil.cpp
View file @
605bab7f
...
...
@@ -11,6 +11,7 @@
#include
"stringutil.h"
#include
"sortutil.h"
#include
<KItinerary/BoatTrip>
#include
<KItinerary/BusTrip>
#include
<KItinerary/Event>
#include
<KItinerary/Flight>
...
...
@@ -68,6 +69,7 @@ static bool prefixConflictIfPresent(const T &lhs, const T &rhs)
static
bool
isSameFlight
(
const
Flight
&
lhs
,
const
Flight
&
rhs
);
static
bool
isSameTrainTrip
(
const
TrainTrip
&
lhs
,
const
TrainTrip
&
rhs
);
static
bool
isSameBusTrip
(
const
BusTrip
&
lhs
,
const
BusTrip
&
rhs
);
static
bool
isSameBoatTrip
(
const
BoatTrip
&
lhs
,
const
BoatTrip
&
rhs
);
static
bool
isSameLodingBusiness
(
const
LodgingBusiness
&
lhs
,
const
LodgingBusiness
&
rhs
);
static
bool
isSameFoodEstablishment
(
const
FoodEstablishment
&
lhs
,
const
FoodEstablishment
&
rhs
);
static
bool
isSameTouristAttractionVisit
(
const
TouristAttractionVisit
&
lhs
,
const
TouristAttractionVisit
&
rhs
);
...
...
@@ -177,6 +179,21 @@ bool MergeUtil::isSame(const QVariant& lhs, const QVariant& rhs)
return
isSameBusTrip
(
lhsTrip
,
rhsTrip
);
}
// boat
if
(
JsonLd
::
isA
<
BoatReservation
>
(
lhs
))
{
const
auto
lhsRes
=
lhs
.
value
<
BoatReservation
>
();
const
auto
rhsRes
=
rhs
.
value
<
BoatReservation
>
();
if
(
lhsRes
.
reservationNumber
()
!=
rhsRes
.
reservationNumber
())
{
return
false
;
}
return
isSame
(
lhsRes
.
reservationFor
(),
rhsRes
.
reservationFor
());
}
if
(
JsonLd
::
isA
<
BoatTrip
>
(
lhs
))
{
const
auto
lhsTrip
=
lhs
.
value
<
BoatTrip
>
();
const
auto
rhsTrip
=
rhs
.
value
<
BoatTrip
>
();
return
isSameBoatTrip
(
lhsTrip
,
rhsTrip
);
}
// hotel: booking ref, checkin day, name match
if
(
JsonLd
::
isA
<
LodgingReservation
>
(
lhs
))
{
const
auto
lhsRes
=
lhs
.
value
<
LodgingReservation
>
();
...
...
@@ -391,6 +408,13 @@ static bool isSameBusTrip(const BusTrip &lhs, const BusTrip &rhs)
return
lhs
.
busName
()
==
rhs
.
busName
()
&&
lhs
.
busNumber
()
==
rhs
.
busNumber
()
&&
lhs
.
departureTime
()
==
rhs
.
departureTime
();
}
static
bool
isSameBoatTrip
(
const
BoatTrip
&
lhs
,
const
BoatTrip
&
rhs
)
{
return
lhs
.
departureTime
()
==
rhs
.
departureTime
()
&&
LocationUtil
::
isSameLocation
(
lhs
.
departureBoatTerminal
(),
rhs
.
departureBoatTerminal
())
&&
LocationUtil
::
isSameLocation
(
lhs
.
arrivalBoatTerminal
(),
rhs
.
arrivalBoatTerminal
());
}
static
bool
isSameLodingBusiness
(
const
LodgingBusiness
&
lhs
,
const
LodgingBusiness
&
rhs
)
{
if
(
lhs
.
name
().
isEmpty
()
||
rhs
.
name
().
isEmpty
())
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment