droolsdrools-guvnordrools-flow

how to use array of string as condition in Drools decision table?


I am new to drools decision table, so my question may be invalid. In my decision table i am using "in" in condition column. Exampe : i have class Student and there is another class UniversityConstant. In UniversityConstant class there is array of string subject code : public static final String[] subjectCode ={"150","920","930","940","154"}; enter image description here

In this case my condition not working properly(Above picture: Not working). Instead of using string array constant of java class if i use direct subject code string than it is working(Below picture:working).

enter image description here

In my project there are lots of string array ,so it is not possible to copy paste them in decision table excel. Even in case i use string constant in UniversityConstant class which represent all subject code like public static final String subjectCodeStr1 ="\"155\",\"920\",\"930\",\"940\",\"154\"" OR public static final String subjectCodeStr2 ="155,920,930,940,154"; than also it is not working. My question is there any way to use string array constant or simple string which represents array of string of java in decision table .


Solution

  • You can declare the constant sets as

    public static final List<String> subjectCodes =
      Arrays.asList( "155","920","930","940","154" );
    

    and use

    ...getPrimarySub() memberOf $param
    ...
    UniversityConstamt.subjectCodes