Commit 1f5eddff authored by Volker Krause's avatar Volker Krause
Browse files

Implement extractor script filtering against IATA BCBPs

parent a8e61e0f
......@@ -147,6 +147,10 @@ private Q_SLOTS:
std::vector<ExtractorDocumentNode> matches;
filter.allMatches(root, matches);
QCOMPARE(matches.size(), 1);
filter.setFieldName(s("operatingCarrierDesignator"));
filter.setPattern(s("AK"));
QVERIFY(filter.matches(root));
#endif
}
};
......
......@@ -33,3 +33,22 @@ void IataBcbpDocumentProcessor::preExtract(ExtractorDocumentNode &node, [[maybe_
const auto bcbp = node.content<IataBcbp>();
node.addResult(IataBcbpParser::parse(bcbp, node.contextDateTime().date()));
}
bool IataBcbpDocumentProcessor::matches(const ExtractorFilter &filter, const ExtractorDocumentNode &node) const
{
const auto bcbp = node.content<IataBcbp>();
const auto ums = bcbp.uniqueMandatorySection();
const auto ucs = bcbp.uniqueConditionalSection();
if (matchesGadget(filter, &ums) || matchesGadget(filter, &ucs)) {
return true;
}
const auto legCount = ums.numberOfLegs();
for (int i = 0; i < legCount; ++i) {
const auto rms = bcbp.repeatedMandatorySection(i);
const auto rcs = bcbp.repeatedConditionalSection(i);
if (matchesGadget(filter, &rms) || matchesGadget(filter, &rcs)) {
return true;
}
}
return false;
}
......@@ -18,6 +18,7 @@ public:
bool canHandleData(const QByteArray &encodedData, QStringView fileName) const override;
ExtractorDocumentNode createNodeFromData(const QByteArray &encodedData) const override;
void preExtract(ExtractorDocumentNode &node, const ExtractorEngine *engine) const override;
bool matches(const ExtractorFilter &filter, const ExtractorDocumentNode &node) const override;
};
}
......
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