[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kitinerary] /: Consider IATA BCBP title suffixes when comparing person names
From:       Volker Krause <null () kde ! org>
Date:       2018-04-30 15:11:08
Message-ID: E1fDASK-0001TA-UX () code ! kde ! org
[Download RAW message or body]

Git commit 4c9ac9cb0d7caf16552c288beb1c6b9a6a735297 by Volker Krause.
Committed on 30/04/2018 at 15:10.
Pushed by vkrause into branch 'master'.

Consider IATA BCBP title suffixes when comparing person names

M  +21   -0    autotests/jsonlddocumenttest.cpp
M  +3    -0    autotests/mergeutiltest.cpp
M  +8    -2    src/mergeutil.cpp

https://commits.kde.org/kitinerary/4c9ac9cb0d7caf16552c288beb1c6b9a6a735297

diff --git a/autotests/jsonlddocumenttest.cpp b/autotests/jsonlddocumenttest.cpp
index 39ceebd..b3daeda 100644
--- a/autotests/jsonlddocumenttest.cpp
+++ b/autotests/jsonlddocumenttest.cpp
@@ -142,6 +142,27 @@ private Q_SLOTS:
         auto res = data.value<FoodEstablishmentReservation>();
         QCOMPARE(res.partySize(), 42);
     }
+
+    void testApply()
+    {
+        Flight f1;
+        f1.setDepartureGate(QLatin1String("38"));
+        Airline a1;
+        a1.setIataCode(QLatin1String("AB"));
+        f1.setAirline(a1);
+
+        Flight f2;
+        f2.setDepartureTerminal(QLatin1String("A"));
+        Airline a2;
+        a2.setName(QLatin1String("Air Berlin"));
+        f2.setAirline(a2);
+
+        f1 = JsonLdDocument::apply(f1, f2).value<Flight>();
+        QCOMPARE(f1.departureGate(), QLatin1String("38"));
+        QCOMPARE(f1.departureTerminal(), QLatin1String("A"));
+        QCOMPARE(f1.airline().iataCode(), QLatin1String("AB"));
+        QCOMPARE(f1.airline().name(), QLatin1String("Air Berlin"));
+    }
 };
 
 QTEST_APPLESS_MAIN(JsonLdDocumentTest)
diff --git a/autotests/mergeutiltest.cpp b/autotests/mergeutiltest.cpp
index 53aacf1..6b42769 100644
--- a/autotests/mergeutiltest.cpp
+++ b/autotests/mergeutiltest.cpp
@@ -136,6 +136,9 @@ private Q_SLOTS:
         p1.setFamilyName(QLatin1String("Krause"));
         p1.setGivenName(QLatin1String("VOLKER"));
         QVERIFY(MergeUtil::isSamePerson(p1, p3));
+
+        p1.setGivenName(QLatin1String("VOLKERMR")); // IATA BCBP names with titles attached
+        QVERIFY(MergeUtil::isSamePerson(p1, p3));
     }
 
     void testIsSameLodingReservation()
diff --git a/src/mergeutil.cpp b/src/mergeutil.cpp
index 0ea46b2..47e5f13 100644
--- a/src/mergeutil.cpp
+++ b/src/mergeutil.cpp
@@ -210,8 +210,14 @@ bool MergeUtil::isSamePerson(const Person& lhs, const Person& rhs)
         return true;
     }
 
-    return equalAndPresent(lhs.familyName(), rhs.familyName(), Qt::CaseInsensitive)
-        && equalAndPresent(lhs.givenName(), rhs.givenName(), Qt::CaseInsensitive);
+    if (!equalAndPresent(lhs.familyName(), rhs.familyName(), Qt::CaseInsensitive)) {
+        return false;
+    }
+
+     // names from IATA BCBP can have "MS", "MR", "MRS" etc appended to the first name
+    return equalAndPresent(lhs.givenName(), rhs.givenName(), Qt::CaseInsensitive)
+        || lhs.givenName().startsWith(rhs.givenName(), Qt::CaseInsensitive)
+        || rhs.givenName().startsWith(rhs.givenName(), Qt::CaseInsensitive);
 
     // TODO deal with cases where on side has the name split, and the other side only has the full name
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic