[rules-users] Does Drools Fusion support "Group By" clause ?

Edson Tirelli ed.tirelli at gmail.com
Tue Jan 4 09:10:22 EST 2011


   Sorry, my mistake. Wolfgang's suggestion works, but you can also
simply define type as the key on sales type:

declare SalesType
    type : String @key
end

   Logical insertions always use equality method, even if regular
insertions use identity.

   Edson


2011/1/4 Wolfgang Laun <wolfgang.laun at gmail.com>:
>
>
> On 4 January 2011 11:15, Gabor Szokoli <szocske at gmail.com> wrote:
>>
>> Hi,
>>
>> Purely for educational purposes I am trying to figure out how this
>> will work when multiple Sale instances share the same "type" string.
>>
>> It seems to me that under the default "identity" assertion mode of the
>> Working Memory, as many SaleType instances would be maintained as
>> there are unexpired Sale events. In the degenerate case of all n Sale
>> instances sharing the same type string, rules that bind a SaleType
>> variable on their LHS should fire n times more than expected.
>
> This is n - 1 times :-)
>
> The fix is simple:
>
> when
>      Sale( $type : type )
>      not SaleType( type == $type )
> then
>      insertLogical( new SaleType( $type ) );
>
> -W
>
>>
>> Am I missing something?
>>
>> On the other hand "declare" creates a constructor with parameters? Neat!
>>
>> On Mon, Jan 3, 2011 at 4:28 PM, Edson Tirelli <ed.tirelli at gmail.com>
>> wrote:
>> >
>> > declare SaleType
>> >    type : String
>> > end
>> >
>> > rule "register types"
>> > when
>> >     Sale( $type : type )
>> > then
>> >     insertLogical( new SaleType( $type ) );
>> > end
>> >
>>
>> _______________________________________________
>> 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
>
>



-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com




More information about the rules-users mailing list