Tôi cần một chút trợ giúp với Drools eval và gán biến.Drools lấy dữ kiện từ cơ sở dữ liệu tại thời gian chạy
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
Trong quy tắc này, tôi cố gắng truy cập kho lưu trữ và nhận các yêu cầu hoạt động cho người dùng hiện tại. Quy tắc biên dịch và thực hiện mà không có bất kỳ ngoại lệ hoặc cảnh báo nào. Trong chế độ gỡ lỗi, có thể thấy rằng kho lưu trữ trả về danh sách không trống và tôi hy vọng sẽ thấy thông báo bàn điều khiển 'Bạn có các yêu cầu hoạt động' nhưng điều này không xảy ra. Tôi nghĩ rằng vấn đề là ở dòng này
$activeRequests : List() from $repository.findActiveRequestsByEmployee($user.getValue())
vì quy tắc này hoạt động tốt
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
Vì vậy, ai đó có thể chỉ cho tôi làm thế nào để giải quyết vấn đề này?
Cảm ơn!