[rules-users] Drools eval and variable assigning.

droolsNewbie bsuir820601 at gmail.com
Mon May 27 02:20:15 EDT 2013


I need a little help with Drools eval and variable assigning.

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

In this rule I try to access repository and get active requests for current
user. Rule compiles and executes without any exceptions or warnings. In
debug mode it can be seen that repository returns non empty list and I
expect to see console message 'You have active requests' but this doesn't
happen. I think the problem is in this line

$activeRequests : List( ) from $repository.findActiveRequestsByEmployee(
$user.getValue() )

because this rule works fine 
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

So could someone point me how to solve this problem?
Thanks!



--
View this message in context: http://drools.46999.n3.nabble.com/Drools-eval-and-variable-assigning-tp4023977.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list