[rules-users] fusion
Davide Sottara
dsotty at gmail.com
Fri May 17 16:54:14 EDT 2013
You need
dialect "mvel"
in your rule, or you will have to use Javabean-style code in the RHS,
i.e. $x.setTotalCount( $y ).
This said, the rule is not correct for many reasons:
1) technical: $ticket is scoped within the accumulate, and can't be
accessed externally
2) event semantics: events are immutable and are not supposed to be modified
3) modelling: it does not look right to keep the total counter in (each
individual) ticket.
(also, updating the ticket may cause unwanted recursions)
I'd create another class:
when
$x: TicketStats()
accumulate( $ticket : Ticket() ... )
then
modify ($x) { setTotalCount( $num ); }
end
Davide
On 05/17/2013 01:34 PM, rgupta12 wrote:
> any idea?
>
> Rule Compilation error : [Rule name='check sev']
> drools/cookbook/Rule_check_
> sev_0.java (14:699) : $ticket.totalCount cannot be resolved to a type
> drools/cookbook/Rule_check_sev_0.java (16:796) : $ticket cannot be
> resolved
>
> Rule Compilation error : [Rule name='check sev']
> drools/cookbook/Rule_check_sev_0.java (14:699) :
> $ticket.totalCount cannot be resolved to a type
> drools/cookbook/Rule_check_sev_0.java (16:796) : $ticket cannot be
> resolved
>
>
>
>
> package drools.cookbook;
>
> import drools.cookbook.model.Ticket
>
>
> declare Ticket
> @role(event)
> end
>
>
>
> rule "check sev"
> when
>
> accumulate( $ticket : Ticket() over window:time(5m) from entry-point
> "csupport", $num : count( $ticket ))
> then
> $ticket.totalCount = $num;
> System.out.println("num = " + $num);
> update($ticket);
> end
>
> rule "alert sev"
> when
> Ticket(totalCount == 10)
> then
> System.out.println("ALERT ALERT!!!");
> end
>
> *********************************************
> package drools.cookbook.model;
>
> public class Ticket {
> public int totalCount;
>
> public int getTotalCount() {
> return totalCount;
> }
>
> public void setTotalCount(int totalCount) {
> this.totalCount = totalCount;
> }
>
> public int times;
>
>
> public int getTimes() {
> return times;
> }
>
> public void setTimes(int times) {
> this.times = times;
> }
>
> public String sev;
>
> public String getSev() {
> return sev;
> }
>
> public void setSev(String sev) {
> this.sev = sev;
> }
>
>
> }
>
>
>
>
>
> On Fri, May 17, 2013 at 2:49 PM, Matteo Cusmai <[hidden email]
> </user/SendEmail.jtp?type=node&node=4023883&i=0>> wrote:
>
> You can use an accumulate function.
>
> On 17 May 2013 20:31, "Ravi Gupta" <[hidden email]
> </user/SendEmail.jtp?type=node&node=4023883&i=1>> wrote:
>
> How would one write a rule that checked if say Message has
> been inserted into the stream 10 times over the last 30 days?
>
>
>
>
> _______________________________________________
> rules-users mailing list
> [hidden email] </user/SendEmail.jtp?type=node&node=4023883&i=2>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> _______________________________________________
> rules-users mailing list
> [hidden email] </user/SendEmail.jtp?type=node&node=4023883&i=3>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> ------------------------------------------------------------------------
> View this message in context: Re: [rules-users] fusion
> <http://drools.46999.n3.nabble.com/rules-users-fusion-tp4023878p4023883.html>
> Sent from the Drools: User forum mailing list archive
> <http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html> at
> Nabble.com.
>
>
> _______________________________________________
> 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/20130517/d62a5bda/attachment-0001.html
More information about the rules-users
mailing list