我在drools中使用insertLogical()。
以下是规则:
rule "logical insert"
salience 100
when
$p : Person( $number : number > 1, $name : name == "AB" || name == "AC" )
not ( exists( PersonConfig( person == $p )))
then
System.out.println("Inserted PC");
insertLogical(new PersonConfig(16,$name,$p));
end
rule "Check Inserted"
salience 90
when
$pc : PersonConfig( )
then
System.out.println("Inserted PC Object: "+$pc);
end
rule "Retract Person Config Rule When Clause"
salience 80
when
$p : Person( number > 1, name == "AB" || name == "AC" )
then
System.out.println("Retracting : "+$p);
//$p.setName("BD");
//retract($p);
update($p);
end
rule "Checking Person Config Exist"
salience 70
when
not ( exists( PersonConfig( ) ))
then
System.out.println("PC not Exists");
end
下面我要做的是:
也就是说,如果没有具有相同人引用的属性的PersonConfig对象。但这是行不通的。
请检查并提供一些解决方案。
谢谢
发布于 2015-05-03 14:41:20
通过@PropertyReactive注释;它按照我的expectation.It工作,不会重新激活“逻辑插入”规则,也不会进入循环。
发布于 2015-05-03 13:29:50
我找到了一种通过@PropertyReactive批注的方法。通过这种方式,它正在按照我的期望工作。
https://stackoverflow.com/questions/30013925
复制相似问题