How to test against multiple choice result in tester , when using single choice it works find , but not with multiple choice , we tried in and list but it does not work .
Page 1 / 1
hi,
you can use composite test in tester/testfilter.
you need to set up correct sequence using AND,OR,NOT and parenthises.
Hi,
You need to test value(s) specified through a "Choice (Multiple)" type user parameter?
In fact, multiple choices in the parameter will be stored as a character string with space-separated format.
So, in some cases, you can test the value simply by the "Contains" operator.
Even if the operator doesn't satisfy your requirement, there are ways. The solution depends on the actual condition and your requirement.
Takashi
The problem contain might bring unwanted result exxample if we test "a" contain "abc" "x" "y" , we need to do exact search , need to filter all rows that selected by the multiple choice , multiple choice contain a domain value .
A test clause like this doesn't work?
Left Value: $(MULTI_CHOICE_PARAM)
Operator: Contains
Right Value: <a value used to test if a choice exactly matches>
Alternatively, if every choice value doesn't contain whitespace, you can use the AttributeSplitter (set "Delimiter or String Format" to a whitespace) to create a list containing the multiple choices, and then you can search exactly matched element in the list with the ListSearcher.
However, if a choice value could contain whitespace(s), the AttributeSplitter doesn't work. In such a case, a script can be used to create a list. I think Tcl is easier.
Script example for a TclCaller:
-----
proc paramToList {} {
global FME_MacroValues
set i 0
foreach choice $FME_MacroValues(MULTI_CHOICE_PARAM) {
FME_SetAttribute "_list{$i}" $choice
incr i
}
}
-----
I build a custom for doing things like that
:

This one is build using tcl:
#----------------
# compare list a with b
# Substract
#----------------
proc Listoperations {a b} {
FME_SetAttribute Union_Excl [List_Exclusive_Union $a $b]
FME_SetAttribute Union_Incl [List_inclusive_Union $a $b]
FME_SetAttribute RDiff [right_difference $a $b]
FME_SetAttribute LDiff [left_difference $a $b]
FME_SetAttribute Intersect [left_difference [List_inclusive_Union $a $b] [List_Exclusive_Union $a $b]]
}
proc List_Exclusive_Union {a b} {
set excl_union_list [List_inclusive_Union [right_difference $a $b] [left_difference $a $b]]
return $excl_union_list
}
proc List_inclusive_Union {a b} {
set incl_union_list [concat $a $b]
return $incl_union_list
}
proc right_difference {a b} {
set rdiff {}
foreach i $b {
if {[lsearch -exact $a $i]==-1} {
lappend rdiff $i}
}
return $rdiff
}
proc left_difference {a b} {
set ldiff {}
foreach i $a {
if {[lsearch -exact $b $i]==-1} {
lappend ldiff $i}
}
return $ldiff
}
As you can see it is in essence similar to Tkashi's Python bit.
I just added all the variants to it.
The lists a and b attributes are created using :
@Evaluate([list [split {$(a)} {}]])
You can use it even if it contains whitespaces, {$(a)} the accolades take care that everything within $(a) is teated as a string. For instance "$(a)" would be a problem with reserved characters or spaces.
Thanks all , I tested using Takashi suggestion with contain operators and it is working fine , I did not try the script so I can not confirm if it works with the script method .
Thanks ,