流口水日期强制和条件OR

时间:2013-10-09 04:37:28

标签: drools

如果我尝试使用条件为日期类型的简单Drools规则并使用条件OR(||),则会出现以下错误。如果我将||更改为&&,则可以正常使用。这是一个错误,已知限制或我的规则有什么问题吗? 我正在使用Drools 5.5.0 Final

规则文件

package net.madhura.drools.rules

import net.madhura.drools.DateContainer;

dialect "mvel"

rule "Test rule"
when
    $container: DateContainer(
        date >= "15-Oct-2013" || date <= "01-Oct-2013"
    )
then
    System.out.println("working");
end

DateContainer类

package net.madhura.drools;

import java.util.Date;

public class DateContainer {

    private Date date;

    public DateContainer(Date date) {
        this.date = date;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }
}

错误

Unable to Analyse Expression date >= "15-Oct-2013" || date <= "01-Oct-2013":
[Error: Comparison operation requires compatible types. Found class java.util.Date and class java.lang.String]
[Near : {... date >= "15-Oct-2013" || date <= "01-Oct-2013" ....}]
                                              ^
[Line: 9, Column: 1] : [Rule name='Test rule']

2 个答案:

答案 0 :(得分:1)

显然这是一个Drools错误,现在已修复。错误报告为here

答案 1 :(得分:-1)

$container: DateContainer(date >= DateUtils.addDays(date ,-15))