I tried to create the following rule using a simple drl to just count the 
number of Asset facts in memory. 
An Asset can be a very simple class. I am not sure if the fields or methods are 
really relevant in this rule.

rule " Count number of Assets Rule"
dialect "mvel"
when
asset:Asset()ArrayList($total:size >0)  from collect ( asset)
then
System.out.println(" Number of Assets in memory"+total);
end
This fails. my understanding of how collect works seems to be wrong :(
can you please correct the mistake I might be doing here ?

--- On Sat, 9/3/11, Michael Anstis <[email protected]> wrote:

From: Michael Anstis <[email protected]>
Subject: Re: [rules-users] How to count number of facts of a type in memory?
To: "Rules Users List" <[email protected]>
Date: Saturday, September 3, 2011, 1:24 PM

Sure, just look at the examples of "collect".

You could use a XLS decision table, or IIRC a guided DRL rule in Guvnor - just 
not the web guided decision table.

2011/9/3 puja nandamuri <[email protected]>


Michael,
ThankYou for your speedy feedback.
Is it possible to count the number of fact types in a drl if not in a Guided 
decision table editor ?

--- On Sat, 9/3/11, Michael Anstis <[email protected]> wrote:


From: Michael Anstis <[email protected]>

Subject: Re: [rules-users] How to count number of facts of a type in memory?
To: "Rules Users List" <[email protected]>
Date: Saturday, September 3, 2011, 11:27 AM


It is not possible with the web guided decision table at this stage as you need 
to use "collect" as you rightly suspect.

We have numerous improvements to complete to make the web editor more
 powerful.


2011/9/3 puja nandamuri <[email protected]>


Hi,
How can I count the number of facts of a partilcuar type inserted into the 
rules session?


lets say, I insert several instances of fact called Asset into the rules 
session.
I need to write a web guided decision table that outputs a specifc text value 
in an action column based on the number of assets in memory.




numberofAssets      result
1                            result12                            result23       
                   
  result3
How can I create a condition column that counts the number of Assets in memory ?


question2:
If I want to write a drl  that needs to count number of Assets in memory and 
print that value, can I use a collect from or is it only used with a Collection 
?


As always ,
 Thank You all for your fast responses and ideas.
Thanks,
Ram
_______________________________________________



rules-users mailing list

[email protected]

https://lists.jboss.org/mailman/listinfo/rules-users





-----Inline Attachment Follows-----

_______________________________________________
rules-users mailing list
[email protected]

https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________


rules-users mailing list

[email protected]

https://lists.jboss.org/mailman/listinfo/rules-users





-----Inline Attachment Follows-----

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to