[rules-users] Testing the count of a pattern binding variable

Stephen Masters stephen.masters at me.com
Tue Feb 19 05:29:57 EST 2013


Assuming that you don't have an infinite variety of accumulations you're trying to use, something I have done previously is to create DRL technical rule to generate accumulated values, which the DSL then uses as constraints.

i.e.

rule "Generate sensor counts"
when
	$sensor : Sensor()
	accumulate($sensor; $count:count(1); $count >3)
then
	insert(new SensorCount($count));
end

… then your DSL can be something simple like:

When there are more than 5 sensors = SensorCount(count > 5)




On 19 Feb 2013, at 06:21, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:

> What (I think) you are trying to do is not possible.
> 
> But I wouldn't say that it cannot be done using DSL. What sort of
> collect/accumulate do you need?
> 
> -W
> 
> On 18/02/2013, David R Robison <drrobison at openroadsconsulting.com> wrote:
>> I am developing rules using DSL so, from what I understand, I cannot use
>> collect and accumulate in some of my DSL definitions (especially when
>> using clauses that begin with a hyphen). So what I want to do is to test
>> the count of a pattern binding variable, such as
>> 
>> when
>>     $sensors : Sensor()
>>     accumulate($sensor; $count : count(1); $count > 3)
>> then
>>     ...
>> 
>> Is something like this possible? I cannot seem to make it work.
>> David
>> 
>> --
>> 
>> David R Robison
>> Open Roads Consulting, Inc.
>> 103 Watson Road, Chesapeake, VA 23320
>> phone: (757) 546-3401
>> e-mail: drrobison at openroadsconsulting.com
>> web: http://openroadsconsulting.com
>> blog: http://therobe.blogspot.com
>> book:
>> http://www.xulonpress.com/bookstore/bookdetail.php?PB_ISBN=9781597816526
>> 
>> 
>> 
>> This email communication (including any attachments) may contain
>> confidential and/or privileged material intended solely for the individual
>> or entity to which it is addressed.
>> If you are not the intended recipient, please delete this email
>> immediately.
>> 
>> 
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list