[rules-users] How do I assign a local variable from a function call?

Samuel Doyle sdoyle_2 at yahoo.com
Fri Aug 15 19:29:10 EDT 2008


4.0.7

This works if I do $changedEventCodes : List( ) from SubmissionReviewRulesActionHelper.checkIfEventCodesExist(
submission, entityManager );

However, there might be something added to the function after the call for example in terms of a message passed to the end user. I don't want to have to depend on the
Java method to handle the formatting for rule. It should simply be concerned with returning the requested data.

One more thing I noticed that was odd to. For this particular rule I can't filter it out. 

I have a .drl with 4 rules. If I do something like this:

this.workingMemory.fireAllRules( new RuleNameStartsWithAgendaFilter( "FIRST" ) );

This rule which is clearly starting with "SECOND" fires as well.

The other rules THIRD and FOURTH behave as expected and do not fire but this one still does. Could it be something to do with calling a static method?



----- Original Message ----
From: Mark Proctor <mproctor at codehaus.org>
To: Rules Users List <rules-users at lists.jboss.org>
Sent: Friday, August 15, 2008 2:48:17 PM
Subject: Re: [rules-users] How do I assign a local variable from a function call?

What version of drools you using? I think I remember some issue with
calling functions directly from a "from" - not sure if it was fixed for
4.0.7 or if is in the upcomfing 4.0.8.

Mark
Samuel Doyle wrote: 
Yes here is the full thing.

function List doEventCodesExist( Submission submission, EntityManager
entityManager )
{
   return SubmissionReviewRulesActionHelper.checkIfEventCodesExist(
submission, entityManager );
}

rule "SECOND Event Codes must not exist - EPC"
// 4(2)
    when
        $event: Event( );
        $submission: Submission( );
        $entityManager : EntityManager( );
        $changedEventCodes : List( ) from doEventCodesExist(
$submission, $entityManager );
        eval( $changedEventCodes.size() > 0 );
    then
        $event.addReviewIssue( new ReviewIssue( $event, $submission,
SubmissionReviewConstants.SUBMISSION,
           ReviewCriticality.CRITICAL, SectionFiltersEnum.SUBMISSION,
           $changedEventCodes + "
submissionReview.submission.eventCodesAlreadyExist" ) );
end



-----
Original Message ----
From: Mark Proctor <mproctor at codehaus.org>
To: Rules Users List <rules-users at lists.jboss.org>
Sent: Friday, August 15, 2008 1:29:16 PM
Subject: Re: [rules-users] How do I assign a local variable from a
function call?

Did you try adding types to your functions like the documentation says?

samd wrote: 
Nobody knows?


samd wrote:

All I want to do is something simple like the following:

$changedList: java.util.List( ) from getChangedList( $x, $y );

Then in the same .drl file a function something like:

function List getChangedList( $x, $y )
{
    return JavaClass.staticDoSomethingToGetListMethod( $x, $y);
}

I have tried doing this and I get:

Unable to build expression for 'from' node 'getChangedList( $x, $y)'

It looks like there is supposed to be something in between the from and
the function? I have been looking for examples for something like this and
have not found any.

Thanks




________________________________

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080815/7cf8e1a8/attachment.html 


More information about the rules-users mailing list