<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">You need <br>
<br>
dialect "mvel"<br>
<br>
in your rule, or you will have to use Javabean-style code in the
RHS, i.e. $x.setTotalCount( $y ).<br>
<br>
This said, the rule is not correct for many reasons:<br>
1) technical: $ticket is scoped within the accumulate, and can't
be accessed externally<br>
2) event semantics: events are immutable and are not supposed to
be modified<br>
3) modelling: it does not look right to keep the total counter in
(each individual) ticket. <br>
(also, updating the ticket may cause unwanted recursions)<br>
<br>
I'd create another class:<br>
<br>
when<br>
$x: TicketStats() <br>
accumulate( $ticket : Ticket() ... )<br>
then<br>
modify ($x) { setTotalCount( $num ); }<br>
end<br>
<br>
Davide<br>
<br>
<br>
On 05/17/2013 01:34 PM, rgupta12 wrote:<br>
</div>
<blockquote
cite="mid:CAFZ1Wo3fj3qJc_2xo98CMMFG7HBso9dRgX7QYpORHQs5xTB=Jg@mail.gmail.com"
type="cite">
<div dir="ltr">any idea?<br>
<br>
Rule Compilation error : [Rule name='check sev']<br>
drools/cookbook/Rule_check_
<div dir="ltr">sev_0.java (14:699) : $ticket.totalCount cannot
be resolved to a type<br>
drools/cookbook/Rule_check_sev_0.java (16:796) : $ticket
cannot be resolved<br>
<br>
Rule Compilation error : [Rule name='check sev']<br>
drools/cookbook/Rule_check_sev_0.java (14:699) :
$ticket.totalCount cannot be resolved to a type<br>
drools/cookbook/Rule_check_sev_0.java (16:796) : $ticket
cannot be resolved<br>
<br>
<br>
<br>
<br>
package drools.cookbook;<br>
<br>
import drools.cookbook.model.Ticket<br>
<br>
<br>
declare Ticket<br>
@role(event)<br>
end<br>
<br>
<br>
<br>
rule "check sev"<br>
when<br>
<br>
accumulate( $ticket : Ticket() over window:time(5m) from
entry-point "csupport", $num : count( $ticket ))<br>
then<br>
$ticket.totalCount = $num;<br>
System.out.println("num = " + $num);<br>
update($ticket);<br>
end<br>
<br>
rule "alert sev"<br>
when<br>
Ticket(totalCount == 10)<br>
then<br>
System.out.println("ALERT ALERT!!!");<br>
end<br>
<br>
*********************************************<br>
package drools.cookbook.model;<br>
<br>
public class Ticket {<br>
public int totalCount;<br>
<br>
public int getTotalCount() {<br>
return totalCount;<br>
}<br>
<br>
public void setTotalCount(int totalCount) {<br>
this.totalCount = totalCount;<br>
}<br>
<br>
public int times;<br>
<br>
<br>
public int getTimes() {<br>
return times;<br>
}<br>
<br>
public void setTimes(int times) {<br>
this.times = times;<br>
}<br>
<br>
public String sev;<br>
<br>
public String getSev() {<br>
return sev;<br>
}<br>
<br>
public void setSev(String sev) {<br>
this.sev = sev;<br>
}<br>
<br>
<br>
}</div>
<br>
<br>
<br>
<div class="gmail_extra">
<br>
<br>
<div class="gmail_quote">On Fri, May 17, 2013 at 2:49 PM,
Matteo Cusmai <span dir="ltr"><<a moz-do-not-send="true"
href="/user/SendEmail.jtp?type=node&node=4023883&i=0"
target="_top" rel="nofollow" link="external">[hidden
email]</a>></span> wrote:<br>
<blockquote style="border-left:2px solid #CCCCCC;padding:0
1em" class="gmail_quote">
<p dir="ltr">You can use an accumulate function.</p>
<div class="gmail_quote">
<div>On 17 May 2013 20:31, "Ravi Gupta" <<a
moz-do-not-send="true"
href="/user/SendEmail.jtp?type=node&node=4023883&i=1"
target="_top" rel="nofollow" link="external">[hidden
email]</a>> wrote:<br type="attribution">
</div>
<blockquote style="border-left:2px solid
#CCCCCC;padding:0 1em" class="gmail_quote">
<div>
<div dir="ltr">How would one write a rule that
checked if say Message has been inserted into the
stream 10 times over the last 30 days?<br>
<br>
<br>
<br>
</div>
<br>
</div>
_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true"
href="/user/SendEmail.jtp?type=node&node=4023883&i=2"
target="_top" rel="nofollow" link="external">[hidden
email]</a><br>
<a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/rules-users"
target="_blank" rel="nofollow" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
</div>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a moz-do-not-send="true"
href="/user/SendEmail.jtp?type=node&node=4023883&i=3"
target="_top" rel="nofollow" link="external">[hidden
email]</a><br>
<a moz-do-not-send="true"
href="https://lists.jboss.org/mailman/listinfo/rules-users"
target="_blank" rel="nofollow" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
</div>
<br>
</div>
</div>
<br>
<hr align="left" width="300">
View this message in context: <a moz-do-not-send="true"
href="http://drools.46999.n3.nabble.com/rules-users-fusion-tp4023878p4023883.html">Re:
[rules-users] fusion</a><br>
Sent from the <a moz-do-not-send="true"
href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html">Drools:
User forum mailing list archive</a> at Nabble.com.<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a></pre>
</blockquote>
<br>
</body>
</html>