<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:D="DAV:" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="&#1;" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:"Palatino Linotype";
        panose-1:2 4 5 2 5 5 5 3 3 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I don’t know your circumstances, but you might question why rank
is a String in the first place.  Is the UI unduly influencing your data model? 
You could always add a synthetic getter to your model itself and evade the eval
altogether:<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>public  int getRankInt() { … }<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>That’s an ugly hack, but if your rank attribute is really an
integer anyway… <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>In any case, I’d suggest that you add a guard in your conversion
utility to check for “” and null Strings maybe default to 0 or throw some
exception.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Cheers,<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>-Jess<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <b>On Behalf Of </b>M.DILIP KUMAR<br>
<b>Sent:</b> Tuesday, December 02, 2008 5:40 AM<br>
<b>To:</b> Rules Users List<br>
<b>Subject:</b> Re: [rules-users] Inline eval problem!<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0>
 <tr>
  <td valign=top style='padding:0in 0in 0in 0in'>
  <div>
  <p class=MsoNormal>Hi ,<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;&nbsp; i can suggest one more way to solve it. Dont
  create instance in when part.<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>Instead of better you convert that helper class method as
  static methods.<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>So that u can call that method directly . but before that
  u should import that helper class in drl file.<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;&nbsp; Or second way u can directly write a method
  in ur drl file itself.<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal><br>
  Example :<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;<b><span style='font-size:10.0pt;color:#960000'><o:p></o:p></span></b></p>
  </div>
  <div>
  <p class=MsoNormal><b><span style='font-size:10.0pt;color:#960000'>import</span></b><span
  style='font-size:10.0pt'>
  com.g2x.agility.leads.workflow.rulesengine.RuleUtilities;<o:p></o:p></span></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>rule&quot;ConvertRule&quot;<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>when <o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  eval ( RuleUtilities.getStringToInteger( age) &gt; 40)<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>// getStringToInteger(String age) is static method<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>then <o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;&nbsp;&nbsp; System.out.print(&quot;XXXXName&quot;);<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>end<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal>&nbsp;<o:p></o:p></p>
  </div>
  <div>
  <p class=MsoNormal><o:p>&nbsp;</o:p></p>
  </div>
  <div>
  <div>
  <div>
  <p class=MsoNormal><b><i><span style='font-size:10.0pt;font-family:"Arial","sans-serif";
  color:#AA4D4E'>Defeat yourself today!</span><span style='color:blue'><o:p></o:p></span></i></b></p>
  </div>
  </div>
  <div>
  <div>
  <p class=MsoNormal><b><i><span style='font-size:10.0pt;font-family:"Palatino Linotype","serif";
  color:maroon'>____________________________</span></i></b><b><i><span
  style='font-size:10.0pt;color:black'> </span><span style='color:blue'><o:p></o:p></span></i></b></p>
  </div>
  </div>
  <p class=MsoNormal>&nbsp;&nbsp;&nbsp; <em><b><span style='color:#C49B71'>DILIP&nbsp;
  KUMAR.M</span></b></em><o:p></o:p></p>
  </div>
  <p class=MsoNormal><br>
  <br>
  --- On <b>Tue, 2/12/08, vanshi <i>&lt;nilu.thakur@gmail.com&gt;</i></b>
  wrote:<o:p></o:p></p>
  <p class=MsoNormal style='margin-bottom:12.0pt'>From: vanshi
  &lt;nilu.thakur@gmail.com&gt;<br>
  Subject: [rules-users] Inline eval problem!<br>
  To: rules-users@lists.jboss.org<br>
  Date: Tuesday, 2 December, 2008, 10:38 AM<o:p></o:p></p>
  <pre>I need to convert a variable from string to intger in the rule. That variable<o:p></o:p></pre><pre>here is rank, so, I create a helper class called 'Conversion' with just<o:p></o:p></pre><pre>one<o:p></o:p></pre><pre>function/method, which is supposed to convert the string argument passed to<o:p></o:p></pre><pre>it, to an integer and then I call that method in rule as inline eval.<o:p></o:p></pre><pre>What's<o:p></o:p></pre><pre>wrong here because this is not working and I don't want to change<o:p></o:p></pre><pre>'When'<o:p></o:p></pre><pre>part too much because it has 10 or so other variable with &amp;&amp;<o:p></o:p></pre><pre>connective,<o:p></o:p></pre><pre>which I've removed for clarity here. Any input would be appreciated much.<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>package harules;<o:p></o:p></pre><pre>import com.hibernate.Person;<o:p></o:p></pre><pre>import com.uhg.utils.Conversion;<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>rule &quot;one&quot;<o:p></o:p></pre><pre>salience 10<o:p></o:p></pre><pre>        when<o:p></o:p></pre><pre>        $con: Conversion();<o:p></o:p></pre><pre>        pers: Person(age!= null , age &gt;= 18 , eval($con.getInteger(rank) &gt; 140))<o:p></o:p></pre><pre>        then<o:p></o:p></pre><pre>        System.out.println(&quot;Evaluated true&quot;);<o:p></o:p></pre><pre>end<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>//content of Conversion class<o:p></o:p></pre><pre>package com.utils;<o:p></o:p></pre><pre>public class Conversion {<o:p></o:p></pre><pre>public Integer getInteger(String s)<o:p></o:p></pre><pre>{<o:p></o:p></pre><pre>        return Integer.parseInt(s);<o:p></o:p></pre><pre>}<o:p></o:p></pre><pre>}<o:p></o:p></pre><pre>-- <o:p></o:p></pre><pre>View this message in context:<o:p></o:p></pre><pre>http://www.nabble.com/Inline-eval-problem%21-tp20786253p20786253.html<o:p></o:p></pre><pre>Sent from the drools - user mailing list archive at Nabble.com.<o:p></o:p></pre><pre><o:p>&nbsp;</o:p></pre><pre>_______________________________________________<o:p></o:p></pre><pre>rules-users mailing list<o:p></o:p></pre><pre>rules-users@lists.jboss.org<o:p></o:p></pre><pre>https://lists.jboss.org/mailman/listinfo/rules-users<o:p></o:p></pre></td>
 </tr>
</table>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Calibri","sans-serif"'><o:p>&nbsp;</o:p></span></p>

<div class=MsoNormal align=center style='text-align:center'><span
style='font-size:10.0pt;font-family:"Calibri","sans-serif"'>

<hr size=1 width="100%" align=center>

</span></div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Calibri","sans-serif"'>Add
more friends to your messenger and enjoy! <a
href="http://in.rd.yahoo.com/tagline_messenger_6/*http:/messenger.yahoo.com/invite/">Invite
them now.</a><o:p></o:p></span></p>

</div>

</body>

</html>