<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>Hi Avneesh (guessing your name from your email address),</div><div><br></div><div>I'm curious what you're actually trying to do. Especially as you refer to "companyDivision" as a rule and as a function in different parts of your email.</div><div><br></div><div>If you intend to apply a function to all objects, is there any reason for it to be a guided rule in Guvnor?&nbsp;As Mike mentions, you could create a free-format DRL "technical rule" exactly as you wrote it below. It's perfectly fine to mix the two up. Some rules suit management by a 'business' person within a guided editor and others suit being hard-coded by a developer.</div><div><br></div><div>With the example you provide, it looks like you're trying to clone a fact when it is inserted and call a function using the cloned fact as an argument.</div><div><br></div><div>If you have a guided rule or decision table which inserts a fact, and you wish to apply a rule/function to the fact after being processed by the first rule, you can do things like set a flag on that fact or insert a new fact type, which the technical free-form DRL rule matches.</div><div><br></div><div>As a very trivial example:</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>when</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>$company:&nbsp;CompanyBean(!companyDivisionValidated)</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>then</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>companyDivision($company);</div><div><br></div><div>Steve</div></div><br><div><div>On 5 Sep 2012, at 10:02, Michael Anstis &lt;<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Forwarded to mailing list.<br><br>You would have to consider use of free-format DRL in this scenario.<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername"></b> <span dir="ltr">&lt;<a href="mailto:avneesh.sisodia@intelegencia.com">avneesh.sisodia@intelegencia.com</a>&gt;</span><br>
Date: 4 September 2012 12:33<br>Subject: how to import function in drl file on guvnor<br>To: <a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a><br><br><br>Hello mantis,<br>
I am very new in drools and guvnor users. I have a problem during making rules. I want to use my predefined functions in rule execution.<br>
Suppose I have a rule "companyDivision" and i want to import it into my rule file like this:<br>
<br>
package com.exp.test<br>
<br>
import com.abc.bean.CompanyBean<br>
import function<br>
&nbsp; &nbsp; &nbsp; &nbsp; com.abc.util.Validation.companyDivision;<br>
<br>
rule "CompanyInfo"<br>
&nbsp; &nbsp; &nbsp; &nbsp; dialect "mvel"<br>
&nbsp; &nbsp; &nbsp; &nbsp; when<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CompanyBean( businessType == "ABC" , insuranceProgram == "XYZ" )<br>
&nbsp; &nbsp; &nbsp; &nbsp; then<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CompanyBean fact0 = new CompanyBean();<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fact0.setBusinessType( "ABC" );<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fact0.setInsuranceProgram( "XYZ" );<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; companyDivision(fact0 );<br>
end<br>
<br>
<br>
How I can do this.<br>
I am doing following steps to c\generate rules::<br>
1. creating com.exp.test package<br>
2. uploading jar(model) file which included all pojo files of application<br>
3. creating "CompanyInfo" rule<br>
<br>
rule file generated by guvnor is like this:::<br>
<br>
package com.exp.test<br>
<br>
import com.abc.bean.CompanyBean<br>
<br>
<br>
rule "CompanyInfo"<br>
&nbsp; &nbsp; &nbsp; &nbsp; dialect "mvel"<br>
&nbsp; &nbsp; &nbsp; &nbsp; when<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CompanyBean( businessType == "ABC" , insuranceProgram == "XYZ" )<br>
&nbsp; &nbsp; &nbsp; &nbsp; then<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CompanyBean fact0 = new CompanyBean();<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fact0.setBusinessType( "ABC" );<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fact0.setInsuranceProgram( "XYZ" );<br>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert(fact0 );<br>
end<br>
<br>
I have only two options there 1. insert and 2. insert logically.<br>
but on place of insert and insert logically I want to use "companyDivision" function.<br>
Please guys tell me how it is possible.<br>
Thanks<br>
</div><br>
_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/rules-users<br></blockquote></div><br></body></html>