Edson Tirelli was heard to exclaim, On 12/05/06 13:55:
> May I ask you please to open a JIRA feature request for that?

Done:
http://jira.jboss.com/jira/browse/JBRULES-577

Thanks very much.

>> The docs for predicate constraints (3.17) say
>> "Functions used in a Predicate Constraint must return time constant results."
>> And this certainly isn't time constant.  Or does drools pay attention to what
>> goes into the predicate, and re-evaluate it accordingly?
>     There is a little trick here... :) as the collection is bound in the 
> LHS of the rule, if it changes, you will call modifyObject for the 
> container causing the rule to be reevaluated. So, you can use the 
> predicate.

Ahh, ok.  I thought that each constraint would be cached, but it sounds like
the caching is on a per-rule level.  Is that right?

Any ways, this is good, my problems are, for the moment, solved.

>     If the Container was a global or something else, not bound in the 
> rule LHS, it would be a problem to use the predicate. :)
> 
>     []s
>     Edson
> 
> Dirk Bergstrom wrote:
> 
>>Edson Tirelli was heard to exclaim, On 12/05/06 04:14:
>>  
>>
>>>     JBRules is working correctly in this case.
>>>     The syntax for any operator is always:
>>>[bindingVar :] <fieldName> <operator> <value>
>>>    
>>>
>>
>>OK.  However, I still think that what I'm trying to do is reasonable.  Using
>>the above syntax, I want to write:
>>
>>[bindingVar :] <fieldName> memberOf <someCollection>
>>
>>Is there any reason that this would be difficult or foolish to implement?  Not
>>that I expect it to appear in the next release, I'm just wondering if it's
>>something that should be available someday.
>>
>>  
>>
>>>   JBRules will try to find field "$things" in class Record, that 
>>>obviously does not exists, returning the error saying it can't create 
>>>the field extractor (on a side note, maybe we can improve the error 
>>>message... suggestions welcome).
>>>    
>>>
>>
>>The parser error messages are often extremely confusing, but this is one of
>>the better ones.
>>
>>  
>>
>>>    Unfortunatelly, I can't think of another way (based only on the 
>>>information you provided) to do it, except this:
>>>  collect( Record( num : number -> ( $rlis.contains(num) ) ) )
>>>    Please note that if the container is the one changing it's contents, 
>>>you should need to only modify the container, not each record object.
>>>    
>>>
>>
>>The docs for predicate constraints (3.17) say
>>
>>"Functions used in a Predicate Constraint must return time constant results."
>>
>>And this certainly isn't time constant.  Or does drools pay attention to what
>>goes into the predicate, and re-evaluate it accordingly?
>>
>>  
>>
>>>Dirk Bergstrom wrote:
>>>
>>>    
>>>
>>>>I have a container class that has a field that exposes a collection of 
>>>>record
>>>>numbers.  In the working memory, I have a bunch of record objects, and one
>>>>container object.  I want to write a rule that fires when it encounters a
>>>>container that has records matching some criteria.  Here's what I thought
>>>>would work:
>>>>
>>>>1 when
>>>>2  Container( $things : things -> ( $things.size() > 0 ) )
>>>>3  $count : ArrayList( size > 0 ) from
>>>>4   collect( Record( $things contains number, otherfield == "somevalue" ) )
>>>>5 then
>>>>6  ...
>>>>
>>>>Unfortunately, that gets me an error:
>>>>
>>>> InvalidRulePackage: Unable to create Field Extractor for '$things'
>>>>
>>>>(I determined that the problem is in line 4)
>>>>
>>>>Seems to me that what I'm doing is reasonable, and ought to work.  Is this a
>>>>bug, an oversight in drools, or is it in fact unreasonable?
>>>>
>>>>The following "works":
>>>>
>>>> collect( Record( num : number -> ( $rlis.contains(num) ) ) )
>>>>
>>>>But since the predicate is not time-constant (the list of things in the
>>>>Container will change), I'd have to modify() every Record every time I 
>>>>wanted
>>>>to re-run the rules.  That would not be very performant...
>>>>
>>>>Note that this is actually unrelated to "collect" -- this doesn't work 
>>>>either:
>>>>
>>>>1 when
>>>>2  Container( $things : things )
>>>>3  Record( $things contains number )
>>>>4 then
>>>>
>>>>(I'm using trunk, revision 8056, updated this morning)
>>>>
>>>> 
>>>>
>>>>      
>>>>
>>>    
>>>
>>
>>
>>  
>>
> 
> 


-- 
Dirk Bergstrom               [EMAIL PROTECTED]
_____________________________________________
Juniper Networks Inc.,          Computer Geek
Tel: 408.745.3182           Fax: 408.745.8905

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to