Skip to content
GitLab
Menu
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
1f5eddff
Commit
1f5eddff
authored
May 21, 2021
by
Volker Krause
Browse files
Implement extractor script filtering against IATA BCBPs
parent
a8e61e0f
Changes
3
Hide whitespace changes
Inline
Side-by-side
autotests/extractorfiltertest.cpp
View file @
1f5eddff
...
...
@@ -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
}
};
...
...
src/lib/processors/iatabcbpdocumentprocessor.cpp
View file @
1f5eddff
...
...
@@ -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
;
}
src/lib/processors/iatabcbpdocumentprocessor.h
View file @
1f5eddff
...
...
@@ -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
;
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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