Skip to main content
Solved

using multiple choice in testest


Forum|alt.badge.img
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 . 

Best answer by takashi

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
View original
Did this help you find an answer to your question?
<strong>This post is closed to further activity.</strong><br /> It may be a question with a best answer, an implemented idea, or just a post needing no comment.<br /> If you have a follow-up or related question, please <a href="https://community.safe.com/topic/new">post a new question or idea</a>.<br /> If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 1, 2014
hi,

 

you can use composite test in tester/testfilter.

 

 

you need to set up correct sequence using AND,OR,NOT and parenthises.

takashi
Evangelist
  • Best Answer
  • December 2, 2014
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

Forum|alt.badge.img
  • Author
  • December 2, 2014
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 .

takashi
Evangelist
  • December 2, 2014
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

 

    }

 

}

 

-----

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • December 4, 2014
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.

Forum|alt.badge.img
  • Author
  • December 21, 2014
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 , 

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings