Commit 81989879 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Generalize isValidElement to LocalBusiness

Now that we have this base type for LodgingBusiness and FoodEstablishment, make the check generic.

Differential Revision: https://phabricator.kde.org/D27610
parent 47908591
......@@ -81,14 +81,9 @@ static bool filterFoodReservation(const FoodEstablishmentReservation &res)
return res.startTime().isValid();
}
static bool filterFoodEstablishment(const FoodEstablishment &res)
static bool filterLocalBusiness(const LocalBusiness &business)
{
return !res.name().isEmpty();
}
static bool filterLodgingBusiness(const LodgingBusiness &hotel)
{
return !hotel.name().isEmpty();
return !business.name().isEmpty();
}
bool ExtractorValidator::isValidElement(const QVariant &elem)
......@@ -124,11 +119,8 @@ bool ExtractorValidator::isValidElement(const QVariant &elem)
if (JsonLd::isA<Event>(elem)) {
return filterEvent(elem.value<Event>());
}
if (JsonLd::isA<FoodEstablishment>(elem)) {
return filterFoodEstablishment(elem.value<FoodEstablishment>());
}
if (JsonLd::isA<LodgingBusiness>(elem)) {
return filterLodgingBusiness(elem.value<LodgingBusiness>());
if (JsonLd::canConvert<LocalBusiness>(elem)) {
return filterLocalBusiness(JsonLd::convert<LocalBusiness>(elem));
}
// types without specific filters yet
......
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