我需要一些有关 Drools eval 和变量分配的帮助。
rule "check that no previously submitted requests exist"
when
$user : UserFormField( name == 'employeeId', value != null )
$repository : Repository( )
$activeRequests : List( ) from $repository.findActiveRequestsByEmployee( $user.getValue() ) # call to repository
eval( $activeRequests.size() > 0 )
then
System.err.println(' You have active requests: ' + ((Request)$activeRequests.get(0)).getTitle);
insert(Boolean.TRUE);
end
在此规则中,我尝试访问存储库并获取当前用户的活动请求。规则编译并执行,没有任何异常或警告。在调试模式下,可以看到存储库返回非空列表,我希望看到控制台消息“您有活动请求”,但这不会发生。我认为问题出在这一行
$activeRequests : List( ) from $repository.findActiveRequestsByEmployee( $user.getValue() )
因为这条规则很好用
rule "check that no previously submitted requests exist"
when
$user : UserFormField( name == 'employeeId', value != null )
$repository : Repository( )
eval( $repository.findActiveRequestsByEmployee($user.getValue()).size() > 0 )
then
System.err.println(' You have active requests !' );
insert(Boolean.TRUE);
end
那么有人可以指出我如何解决这个问题吗?
谢谢!