Starting with Drools 5.2, general boolean expressions<br>should work, but there were problems. Which version are<br>you using?<br><br>Why doesn't averageCPU have a numeric type? Then the comparison would be straightforward (and most efficient).<br>
<br>To be on the safe side with String, use<br> $cpuUsage : cpuTracker( <br> eval( Integer.parseInt($cpuUsage.getAverageCPU()) > 60 ) )<br><br>-W<br><br><div class="gmail_quote">On 26 December 2011 06:50, bobbi_80 <span dir="ltr"><<a href="mailto:guruprasad_bobbi@infosys.com">guruprasad_bobbi@infosys.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">Hi ,<br>
<br>
I want to know if there is any way I can evaluate a string in rule language.<br>
Here is what I am doing<br>
<br>
DroolsTest.java has a class as follows.<br>
<br>
DroolsTest.java<br>
<br>
public static class cpuTracker{<br>
<br>
private String machinename;<br>
private String averageCPU;<br>
}<br>
I want to set a rule in sample.drl such that if the averageCPU is greater<br>
than 80 an action is taken.<br>
<br>
Sample.drl<br>
rule "High CPU Usage"<br>
when<br>
$cpuUsage : cpuTracker( Integer.parseInt(averageCPU) > 60 )<br>
then<br>
System.out.println("CPU usage is very high!!");<br>
end<br>
<br>
The compiler throws the following error " *no viable alternative at<br>
averageCPU for rule High CPu usage*".<br>
I am unable to convert string to int using Inetger.parseInt(). Any idea why<br>
it is throwing me an error and any help with rule language syntax that I can<br>
get online? Can't find all the answers from<br>
<a href="http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html_single/index.html" target="_blank">http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html_single/index.html</a><br>
<br>
Any help is highly appreciated.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/query-in-drools-expert-rule-language-tp3612345p3612345.html" target="_blank">http://drools.46999.n3.nabble.com/query-in-drools-expert-rule-language-tp3612345p3612345.html</a><br>
Sent from the Drools: User forum 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></span></blockquote></div><br>