This looks as if you inserted some object ServiceBean extends HashMap as a fact? Whatever for? Originally, this was class Service.<br><br>Make sure to distinguish template expansion from rule execution.<br><br>The former should result in a DRL file containing several rules (all with different names!).<br>
<br>-W<br><br><br><br><div class="gmail_quote">2011/6/1 ChrisMu <span dir="ltr"><<a href="mailto:christopher.mullard@credit-suisse.com">christopher.mullard@credit-suisse.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div dir="ltr" align="left"><span><font face="Arial" size="2" color="#0000ff">I get this exception:</font></span></div>
<div><font face="Arial" size="2" color="#0000ff">Exception in thread "main"
org.drools.runtime.rule.ConsequenceException: rule: RFI1</font></div>
<div> </div>
<div><font face="Arial" size="2" color="#0000ff"> at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)<br> at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:927)<br> at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856)<br> at
org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1071)<br> at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:785)<br> at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:751)<br> at
org.drools.template.parser.TemplateDataListener.finishSheet(TemplateDataListener.java:121)<br> at
org.drools.template.DataProviderCompiler.finishData(DataProviderCompiler.java:100)<br> at
org.drools.template.DataProviderCompiler.processData(DataProviderCompiler.java:95)<br> at
org.drools.template.DataProviderCompiler.compile(DataProviderCompiler.java:73)<br> at
org.drools.template.ObjectDataCompiler.compile(ObjectDataCompiler.java:44)<br> at
org.drools.examples.decisiontable.TemplateParser.<init>(TemplateParser.java:33)<br> at
org.drools.examples.decisiontable.TemplateParser.main(TemplateParser.java:18)<br>Caused
by: java.lang.RuntimeException: [Error: unable to resolve method:
java.util.HashMap.value() [arglength=0]]<br>[Near : {... Unknown
....}]<br>
^<br>[Line: 1, Column: 0]<br> at
org.drools.template.parser.DefaultGenerator.generate(DefaultGenerator.java:73)<br> at
org.drools.template.parser.Rule_RFI1_0.defaultConsequence(Rule_RFI1_0.java:7)<br> at
org.drools.template.parser.Rule_RFI1_0DefaultConsequenceInvoker.evaluate(Rule_RFI1_0DefaultConsequenceInvoker.java:30)<br> at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)<br> ...
11 more<br>Caused by: [Error: unable to resolve method:
java.util.HashMap.value() [arglength=0]]<br>[Near : {... Unknown
....}]<br>
^<br>[Line: 1, Column: 0]<br> at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:932)<br> at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getBeanProperty(ReflectiveAccessorOptimizer.java:592)<br> at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:311)<br> at
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:137)<br></font></div>
<div dir="ltr" align="left"><span><font face="Arial" size="2" color="#0000ff"></font></span> </div>
<div><span></span><font face="Arial" size="2" color="#0000ff">My rule template is virtually the same<span> (name is a literal)</span>:</font></div>
<div><font face="Arial" size="2" color="#0000ff">rule "</font><a href="http://user/SendEmail.jtp?type=node&node=3010031&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a><font face="Arial"><font color="#0000ff"><font size="2">}"<br>
when <br> $service:ServiceBean(name == "DiscountCurve", value
== "@{value}") <div class="im"><br> $riskType:RiskType()<br>then
<br> $riskType.setName("@{type}");<br></div> $riskType.setValue("@{<span>value</span>}");<br>end template<span></span></font></font></font><br></div>
<div dir="ltr" lang="en-us" align="left">
<hr>
<font face="Tahoma" size="2"><b>From:</b> Wolfgang Laun-2 [via Drools]
[mailto:<a href="http://user/SendEmail.jtp?type=node&node=3010031&i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a>] <br><b>Sent:</b> 01
June 2011 10:33<br><b>To:</b> Mullard, Christopher<br><b>Subject:</b> Re:
[rules-users] Smart Templates<br></font><br></div><div class="im">
<div></div>There is a way, provided the required information is available at the
time the rule is created.<br><br>There is a detailed section in the Expert
manual explaining how to call template expansion with either a Collection of Map
objects or a Collection of JavaBean objects. Taking beans, you would
have<br><br>ServiceBean( String name, String value )<br>String getName<br>String
getValue<br>String getType(){<br></div>Â Â if( "AAA".equals( value ) )
return "Type1";<br>Â Â if( "XYZ".equals( value ) ) return
"Type2";<br>Â Â ...<div class="im"><br>}<br><br>You create a collection of such
Objects, and call the expander for a template like this:<br><br>rule
"DC_@{row.rowNumber}" <br>when <br></div>Â Â $service: Service(name ==
"@{service}", value == "@{value}") <br>Â Â $riskType: RiskType()
<br>then <br>Â Â $riskType.setName("@{type}"); <br>
<div>Â Â $riskType.setAtt(0,"@{value}"); <br>end
</div><br>-W<br><br><br><br>
<div class="gmail_quote">2011/6/1 ChrisMu <span dir="ltr"><<a href="http://user/SendEmail.jtp?type=node&node=3009984&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 2px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding: 0px 1em;"><div class="im">
<div dir="ltr" align="left"><span><font face="Arial" size="2" color="#0000ff">So in
essence, there's no way to use a function to insert a string literal into a
rule from a template?</font></span></div><br>
<div dir="ltr" lang="en-us" align="left">
<hr>
<font face="Tahoma" size="2"><b>From:</b> FrankVhh [via Drools] [mailto:<a href="http://user/SendEmail.jtp?type=node&node=3009838&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>]
<br><b>Sent:</b> 31 May 2011 17:20<br><b>To:</b> Mullard,
Christopher<br><b>Subject:</b> RE: Smart Templates<br></font><br></div>
<div></div>But then that would call the service.getType() method when the rule
is <br>run wouldn't it? <br>-> Yes <br></div>Â <br><div class="im">I'm trying create
explicit, simple rules to avoid doing extra work when <br>running data through
them. <br>-> OK, in essence, I like that :-) <br></div>Â <br><div class="im">How would you
use a rule to set the value within another rule? <br>-> I am not sure that
I follow you here... <br>If you want to avoid to execute the getType()-service
at rule execution, then you would need to add an attribute name to your
object, and call getType() before creating the rules. <br><br>Alternatively,
you can insert an intermediate value whose value will be set by another rule
and then use this intermediate value in your DC rules. <br><br>When
<br>Service(value = "AAA") <br>Then <br>String name = "Type1";
<br>insert(name); <br><br>Something like this... but make sure not to create a
loop :-) <br><br>Regards, <br>Frank <br><br>
</div><blockquote style="border-left: 2px solid rgb(204, 204, 204); padding: 0px 1em;">
<div>
<div style="font-weight: bold;">ChrisMu wrote:</div>
<div><div class="im">But then that would call the service.getType() method when the rule is
<br>run wouldn't it? <br></div>Â <br><div class="im">I'm trying create explicit, simple
rules to avoid doing extra work when <br>running data through them.
<br></div>Â <br><div class="im">How would you use a rule to set the value within another
rule? <br></div>Â <br><div class="im">Thanks <br>Chris
<br><br>________________________________ <br><br>From: FrankVhh [via Drools]
<br>[mailto:<a href="http://user/SendEmail.jtp?type=node&node=3006773&i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>] <br>Sent: 31
May 2011 16:48 <br>To: Mullard, Christopher <br>Subject: Re: Smart Templates
<br><br><br>Hi, <br><br>The way I see it, this is the way your template
should look like. I do <br>not see the need to use eval() at all.
<br><br>rule "DC_0" <br>when <br></div>Â Â $service: Service(name ==
"@{service}", value == "@{value}") <br>Â Â $riskType: RiskType()
<br>then <br>Â Â
$riskType.setName($service.getType("@{value}")); <br>Â Â
$riskType.setAtt(0,"@{value}"); <br><div class="im">end <br><br>I am assuming that RiskType
is already inserted in WM, but you could <br>just as well create a new
object in the then-part of the rule. <br><br>In stead of using the
java-function to determine the name, you might <br>actually just as well
create an other rule that sets the name according <br>to the value, thus
putting the entire decision logic in rules. <br><br>Hope this helps.
<br><br>Regards, <br>Frank <br><br><br><br></div>Â Â Â Â
ChrisMu wrote: <br>Â Â Â Â Hi, <br>Â Â
  <br>     I'm trying to get
a template (.drt) to generate 2 rules (.drl) <br><div class="im">from 2 datasets but by
doing a little bit more work than direct <br>substitution. <br></div>Â
   <br>    Data
(service,value): <br>Â Â Â Â DC, AAA <br>Â
   DC, XYZ <br>   Â
<br>Â Â Â Â Idea for the template - if value is of
type1 then create Type <br><div class="im">object with 'Type1' as name. If value is of
type2, use 'Type2' as name: <br></div>Â Â Â Â <br>Â
   rule "DC_@{row.rowNumber}" <br> Â
  when <br>     Â
Service(name == "DC") Â Â <br>Â Â Â Â
then <br>Â Â Â Â Â Â
Type.setName(eval(Service.getType(@{value}))) <br>Â Â Â
   Type.setAtt(0,@{value}) <br>  Â
 end template <br>    <br> Â
  eval(Service.getType(@{arg0})) should take 'AAA' or 'XYZ'
etc as <br><div class="im">arg and return a string Type1/Type2 etc. <br></div>Â Â
  <br>    This would then generate
2 rules that look like: <br>Â Â Â Â <br>Â
   rule "DC_0" <br>    when
<br>Â Â Â Â Â Â Service(name == "DC",
value == "AAA") Â Â <br>Â Â Â Â then
<br>Â Â Â Â Â Â
RiskType.setName("Type1") <br>Â Â Â Â Â
 RiskType.setAtt(0,"AAA") <br>   Â
<br>Â Â Â Â rule "DC_1" <br>Â Â Â
 when <br>     Â
Service(name == "DC", value == "XYZ") Â Â <br>Â Â
  then <br>     Â
RiskType.setName("Type2") <br>Â Â Â Â Â
 RiskType.setAtt(0,"XYZ") <br>   Â
<br>Â Â Â Â ...is this possible at all? I'm trying
to avoid the eval step <br><div class="im">being done in the actual rule (.drl) .
<br></div>Â Â Â Â <br>Â Â Â Â
Thanks <br>Â Â Â Â <br>Â Â Â
 Chris <br><div class="im"><br><br><br>________________________________ <br><br>If
you reply to this email, your message will be added to the discussion
<br>below: <br><a href="http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006589.html" rel="nofollow" link="external" target="_blank">http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006589.html</a><br>
<br>To
unsubscribe from Smart Templates, click here <br><<a href="http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubs" rel="nofollow" link="external" target="_blank">http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubs</a><br>
cribe_by_code&node=3006479&code=Y2hyaXN0b3BoZXIubXVsbGFyZEBjcmVkaXQtc3Vp
<br>c3NlLmNvbXwzMDA2NDc5fDE5NzczMDY1MzE=> .
<br><br>===============================================================================
<br>Please access the attached hyperlink for an important electronic
communications disclaimer: <br></div><a href="http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html" rel="nofollow" link="external" target="_blank">http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html</a>Â
<br>===============================================================================
</div></div></blockquote><div class="im"><br><br>
<hr noshade size="1" color="#cccccc">
<div style="font-family: tahoma,geneva,helvetica,arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; color: rgb(68, 68, 68); font-size-adjust: none; font-stretch: normal;">
<div style="font-weight: bold;">If you reply to this email, your message will
be added to the discussion below:</div><a href="http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006773.html" rel="nofollow" link="external" target="_blank">http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006773.html</a>
</div>
<div style="margin-top: 0.4em; font-family: tahoma,geneva,helvetica,arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; color: rgb(102, 102, 102); font-size-adjust: none; font-stretch: normal;">
To
unsubscribe from Smart Templates, <a rel="nofollow" link="external">click here</a>. </div><br>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: Courier;" lang="EN-US">==============================================================================<br>Please
access the attached hyperlink for an important electronic communications
disclaimer:<br><a href="http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html" rel="nofollow" link="external" target="_blank">http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html</a><br>==============================================================================</span></p>
<br><br>
<hr width="300" align="left">
View this message in context: <a href="http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3009838.html" rel="nofollow" link="external" target="_blank">RE: Smart Templates</a><br>Sent
from the <a href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html" rel="nofollow" link="external" target="_blank">Drools: User forum mailing list
archive</a> at
Nabble.com.<br><br>_______________________________________________<br>rules-users
mailing list<br></div><a href="http://user/SendEmail.jtp?type=node&node=3009984&i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a><div class="im"><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" link="external" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></div></blockquote></div><br><br>_______________________________________________
<br>rules-users mailing list <br><a href="http://user/SendEmail.jtp?type=node&node=3009984&i=2" rel="nofollow" link="external" target="_blank">[hidden email]</a> <br><div class="im"><a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" link="external" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br><br>
</div><hr noshade size="1" color="#cccccc">
<div style="font-family: tahoma,geneva,helvetica,arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 12px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(68, 68, 68);">
<div class="im">
<div style="font-weight: bold;">If you reply to this email, your message will be
added to the discussion below:</div></div><a href="http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3009984.html" rel="nofollow" link="external" target="_blank">http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3009984.html</a>
</div><div class="im">
<div style="margin-top: 0.4em; font-family: tahoma,geneva,helvetica,arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(102, 102, 102);">
To
unsubscribe from Smart Templates, <a rel="nofollow" link="external">click
here</a>. </div> <br><p class="MsoNormal"><span style="font-size: 8pt; font-family: Courier;" lang="EN-US">==============================================================================<br>Please access the attached hyperlink for an important electronic communications disclaimer:<br>
<a href="http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html" rel="nofollow" link="external" target="_blank">http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html</a><br>==============================================================================</span></p>
<br>
        
<br><hr width="300" align="left"></div>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3010031.html" target="_blank">RE: [rules-users] Smart Templates</a><div><div></div><div class="h5"><br>
Sent from the <a href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html" target="_blank">Drools: User forum mailing list archive</a> at Nabble.com.<br></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>