Starting with Drools 5.2, general boolean expressions
should work, but there were problems. Which version are
you using?

Why doesn't averageCPU have a numeric type? Then the comparison would be straightforward (and most efficient).

To be on the safe side with String, use
   $cpuUsage : cpuTracker(
      eval( Integer.parseInt($cpuUsage.getAverageCPU()) > 60 ) )

-W

On 26 December 2011 06:50, bobbi_80 <guruprasad_bobbi@infosys.com> wrote:
Hi ,

I want to know if there is any way I can evaluate a string in rule language.
Here is what I am doing

DroolsTest.java has a class as follows.

DroolsTest.java

       public static class cpuTracker{

               private String machinename;
               private String averageCPU;
       }
I want to set a rule in sample.drl such that if the averageCPU is greater
than 80 an action is taken.

Sample.drl
rule "High CPU Usage"
       when
               $cpuUsage : cpuTracker( Integer.parseInt(averageCPU) > 60 )
       then
               System.out.println("CPU usage is very high!!");
end

The compiler throws the following error " *no viable alternative at
averageCPU for rule High CPu usage*".
I am unable to convert string to int using Inetger.parseInt(). Any idea why
it is throwing me an error and any help with rule language syntax that I can
get online? Can't find all the answers from
http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html_single/index.html

Any help is highly appreciated.

--
View this message in context: http://drools.46999.n3.nabble.com/query-in-drools-expert-rule-language-tp3612345p3612345.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users