Hi Dean,<div><br></div><div>Is the encoded value used elsewhere within your organisation from the same object model?</div><div><br></div><div>It&#39;d make a compelling reason to suggest your model is enriched to expose the decoded flags if they are (e.g. reporting).</div>
<div><br></div><div>However all is not lost:-</div><div><br></div><div>(1) You can use &quot;matches&quot; regular expressions (as you identified):-</div><div><br></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">rule &quot;one&quot;</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    when</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">        $c : Claim( claimStatus matches ^.{4}1324.{0,} )</font></div>
<div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace; ">    then</span></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">        //Something</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">end</font></div></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div>(2) You can use &quot;eval&quot;:-</div>
<div><br></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">rule &quot;two&quot;</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    when</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">        Claim( $cs : claimStatus )</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">        eval($cs.substring(3, 7).equals(&quot;1234&quot;))</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    then</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">        //Something</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">end</font></div>
<div><br></div><div>(3) You can use &quot;from&quot; and a global helper class:-</div><div><br></div><div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">global MyDecoder myDecoder </font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">rule &quot;three&quot;</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    when</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">        Claim( $cs : claimStatus )</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">        String( toString == &quot;1234&quot; ) from myDecoder.decodeClaimStatus($cs)</font></div>
<div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">    then</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">        //Something</font></div><div><font class="Apple-style-span" face="&#39;courier new&#39;, monospace">end</font></div>
</div><div><br>See attached example project for the last option.</div><div><br></div><div>You could then use DSL to &quot;hide&quot; the technical implementations for your users.</div><div><br></div><div>With kind regards,</div>
<div><br></div><div>Mike</div><div><br></div><div><div class="gmail_quote">2010/10/20 Dean Whisnant <span dir="ltr">&lt;<a href="mailto:dean@basys.com">dean@basys.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">









<div lang="EN-US" link="blue" vlink="purple">

<div>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Hello,</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">In designing our rules system to allow users and analysts to
create and edit rules (through Guvnor) we have a requirement that some of the
fields be able to be evaluated for specific characters in specific positions of
the string.  See the following examples:</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Example 1: The string named “claimStatus” contains
various flags all pushed together in a string.  It might look like “ABS1324BB7”. 
Together this field means about nothing, but position 4-7 (1324) is an
important code that they want to evaluate. A business rule for this would be if
position 4-7 in claimStatus = “1324” then we categorize that claims
for some reason.  </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">In loose java syntax I would likely use ‘if
claimStatus.substring(3,4) = “1324” then do something.</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I could have the user program a formula using the substring
method, but that would be quite inefficient and a lot of information for them
to figure out.</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">I could have the user say claimStatus matches ^.{4}1324.{0,} but
this regular expression is quite cryptic.</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">While at Rulesfest I ran the topic by a couple folks there and
they thought that posing it to the community might be a good idea.  Is
there another way you could see doing this?  Is there a DSL format that
might get us to where we want?</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Ideas that have been thought of included creating a variable
that is already just the 4 characters we are after, but there are dozens of
fields that could hold this info and that would increase our data model which
is already quite verbose.  We also looked at allowing them to create a
variable when they need it and then just reuse that in rules, but I’m not
certain how we would do this with as many fields.</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">To add to it, the regular expression I listed is for one of the
fields in these streams, we also have needs to pull out other positions as
well.</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Your thoughts and ideas on this are appreciated.</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Thank you!</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D"> </span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">Dean Whisnant</span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;color:#1F497D">basys, inc.</span></p>

</div>

</div>


<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>
<br></blockquote></div><br></div>