Drools - 表示要在每列而不是行中应用的规则中的表单

时间:2015-10-12 20:56:02

标签: drools

我有很多传播表,其结构如下:

| Column A | Column B |
---------------------
| ____ a ___ | ____ A2 ____ |
---------------------
| ____ b ___ | ____ B4 ____ |
---------------------
| ____ c ___ | ____ S4 ____ |
---------------------

请注意,列表很大。

我有两个字符串,如果第一列存在于A列的任何行中,第二个字符串存在于B列的任何行中,则必须应用某些操作。

有人可以帮助表示这些规则的最佳方式,正如我所知,每行应用决策表操作。

1 个答案:

答案 0 :(得分:0)

使用某个库根据以下类将电子表格读入对象:

class TwoColumns {
    private List<String> colA;
    private List<String> colB;
    // constructor, getters,...
}

A列的所有字符串都在colA中,B列的所有字符串都在colB中。 - 使用两个String值定义另一个类:

class TwoStrings {
    private String strA;
    private String strB;
    // constructor, getters,...
}

插入TwoColumns对象和一个TwoStrings对象并使用此规则:

rule findTwoStrings
when
    TwoStrings( $a: strA, $b: strB )
    TwoColumns( colA contains $a, colB contains $b )
then
    System.out.println( $a + " and " + $b + " can be found" );
end

如果您需要同时搜索这些“多个电子表格”,请在TwoColumns对象中添加一个名称,以便识别匹配的对象。