The rule you have shown is not capable of producing that error message. Which version of Drools are you using?<br><br>(1) You cannot use "=" (in: MyEvent(prop1="XYZ") to compare two values.<br>(2) You cannot use "matches" in eval, where Java expressions are expected (in: eval((prop3 matches ...).<br>
(3) You must use one argument for a call to count (in: accumulate(..., count())), even though this argument does not matter.<br>(4) You should not use eval where it is not necessary.<br>(5) Your must use correct regular expressions, there is an error in: matches ("MatchOne|MatchTwo){1}::"+... and also in: matches "(second|Third{1}_CONNECT".<br>
(6) It is highly unusual to use a repeat count of 1 for a subpattern in a regular expression.<br><br>Anyway, below is a correct version of the LHS <i><b>except for the patterns, </b></i>where I don't know what you really need to match.<br>
<br>Moreover, I urgently suggest that you<br><ul><li>DO NOT post the same question twice within 24 hours. Cleaning up the mess takes time.</li><li>Read the Drools Expert documentation before you write rules.</li><li>Start with simple conditions and test that they work.</li>
<li>Read the Drools Expert documentation.</li><li>Build and test more complex patterns once simple patterns work as expected.<br></li><li>Read the Java documentation on regular expressions.<br></li></ul>The following code has been compiled successfully using Drools 5.1.1, but some regular expressions contain errors, which will throw an exception at runtime.<br>
<br>declare MyEvent<br> @role( event )<br> prop1 : String<br> prop2 : int<br> prop3 : String<br>end<br><br>function String getFirstNameRegex(){ return "blah"; }<br>function String getMMSCNameRegex(){ return "gaga"; }<br>
function String getServerID(){ return "R2D2"; }<br>function int getNodeCount(){ return 20; }<br>function int getConnectionCount(){ return 20; }<br>function int getThirdNodeCount(){ return 20; }<br><br>rule "or-or-or"<br>
when<br> MyEvent(prop1 == "XYZ") over window:time(1m) from entry-point MyStream<br> or<br> ( MyEvent() over window:time(1m) from entry-point MyStream<br> and<br> Number($i1 : doubleValue > (getNodeCount()*0.35) ) from accumulate(<br>
MyEvent(<br> prop1 == "CONNECT",<br> prop2 == 3,<br> prop3 matches ("match " + getFirstNameRegex() + " Connect")<br>
) over window:time(1m) from entry-point MyStream,<br> count(1) )<br> )<br> or<br> ( MyEvent() over window:time(1m) from entry-point MyStream<br> and<br> Number($i2 : doubleValue > (getConnectionCount()*0.4) ) from accumulate(<br>
MyEvent(<br> prop1 matches "(second|Third{1}_CONNECT",<br> prop2 == 1,<br> prop3 matches ("MatchOne|MatchTwo){1}::" + getMMSCNameRegex()+", failure")<br>
) over window:time(1m) from entry-point MyStream,<br> count(1) )<br> )<br> or<br> ( MyEvent() over window:time(1m) from entry-point MyStream<br> and<br> Number($i3 : doubleValue > (getThirdNodeCount()*0.5) ) from accumulate(<br>
MyEvent(<br> prop1 matches "(E1|E2){1}_CONNECT",<br> prop2 == 3,<br> prop3 matches ("REPT (one|five|seven){1}::" + getServerID()+" is down")<br>
) over window:time(1m) from entry-point MyStream,<br> count(1) )<br> )<br>then<br> System.out.println( "match" );<br>end<br><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
</blockquote>-W<br><br><br><br><br><div class="gmail_quote">On 28 January 2011 07:08, Ayush <span dir="ltr"><<a href="mailto:ayush.vatsyayan@alcatel-lucent.com">ayush.vatsyayan@alcatel-lucent.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>
When I'm trying to execute multiple evals I'm getting errors. Below is what<br>
I'm trying to do<br>
<br>
MyEvent(prop1="XYZ") over window:time(1m) from entry-point<br>
MyStream<br>
or<br>
(MyEvent() over window:time(1m) from entry-point MyStream<br>
and<br>
Number($i1 : doubleValue)<br>
from accumulate(<br>
MyEvent(<br>
prop1 == "CONNECT",<br>
prop2 == 3,<br>
eval((prop3 matches ("match "+getFirstNameRegex()+"<br>
Connect")) == true)<br>
) over window:time(1m) from entry-point MyStream,<br>
count()<br>
)<br>
and<br>
eval($i1 > getNodeCount()*0.35))<br>
or<br>
(MyEvent() over window:time(1m) from entry-point MyStream<br>
and<br>
Number($i2 : doubleValue)<br>
from accumulate(<br>
MyEvent(<br>
prop1 matches "(second|Third{1}_CONNECT",<br>
prop2 == 1,<br>
eval((prop3 matches<br>
("MatchOne|MatchTwo){1}::"+getMMSCNameRegex()+", failure")) == true)<br>
) over window:time(1m) from entry-point MyStream,<br>
count()<br>
)<br>
and<br>
eval($i2 > getConnectionCount()*0.4))<br>
or<br>
(MyEvent() over window:time(1m) from entry-point MyStream<br>
and<br>
Number($i3 : doubleValue)<br>
from accumulate(<br>
MyEvent(<br>
prop1 matches "(E1|E2){1}_CONNECT",<br>
prop2 == 3,<br>
eval((prop3 matches ("REPT (one|five|seven){1}::<br>
"+getServerID()+" is down")) == true)<br>
) over window:time(1m) from entry-point MyStream,<br>
count()<br>
)<br>
and<br>
eval($i3 > getThirdNodeCount()*0.5))<br>
<br>
When I'm trying to execute the above LHS I get<br>
org.drools.rule.InvalidPatternException: Required Declarations not bound:<br>
'$i1'.<br>
<br>
I even tried using below approach<br>
<br>
AlertReceivedEvent() over window:time(1m) from entry-point<br>
NotificationStream<br>
<br>
$I1 : Double() from getIsgNodeCount()<br>
<br>
Number(doubleValue > $I1) from accumulate(<br>
AlertReceivedEvent(<br>
entity == "NPMMS_NE_CONNECT",<br>
probableCause == 3,<br>
eval((specificProblems matches ("REPT ISG<br>
NPMMS::Unable to connect to "+getPxmmsNameRegex()+" node: PXMMS")) == true)<br>
) over window:time(1m) from entry-point<br>
NotificationStream, count()<br>
)<br>
<br>
<br>
But when I'm placing parentheses () around it, it throws exception stating<br>
mismatched input '$I1' expecting ')' in rule. For now I'd placed these 3<br>
statements in separate rules. Can anyone please help me solving it? Thanks<br>
in advance.<br>
<font color="#888888">--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Problem-implementing-multiple-evals-tp2365761p2365761.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Problem-implementing-multiple-evals-tp2365761p2365761.html</a><br>
Sent from the Drools - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>