[rules-users] How to generate rule statements using MVEL 2.0 template?
Michael Anstis
michael.anstis at gmail.com
Wed Jan 15 04:24:21 EST 2014
You could take a look at drools-templates, and relevant sections in the
user guide, as a starter.
If that does not cover your requirements take a look at drools-templates
source code on github.
Alternatively have a look for MVEL templates on Google (other search
engines are available).
With kind regards,
Mike
Sent on the move
On 15 Jan 2014 09:20, "neal" <swapnilaute at gmail.com> wrote:
> I came to know through drool user forum that a drl file can be created
> using
> recursive MVEL 2.0 template.
> I am trying like below.
>
> public static String prepareRule(String RuleName){
> String template = "\n rule \""+RuleName+"\" "+
> "\n dialect \"mvel\" "+
> "\n salience \"10\" " +
> "\n when" +
> "\n demo : Demo( one == \"N\" , two ==
> \"C\" , three == 1005 )" +
> "\n then" +
> "\n demo.setFirst( 4003 );" +
> "\n demo.setLast( 4003 );" +
> "\n demo.setRuleID( \"SEQ_1\" );";
> return template;
> }
>
> public static String getRuleAsString(String template){
> Map vars = new HashMap();
> return (String) TemplateRuntime.eval(template,vars);
> }
>
> public static void main(String[] args) {
>
> System.out.println(getRuleAsString(prepareRule("Rule 1")));
> }
>
> When i am printing it out, It is generating rule skeleton. I am planning to
> create whole rule stuff passing arguments like rule name in the example. Am
> i doing correct?
> How to do it correctly?
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/How-to-generate-rule-statements-using-MVEL-2-0-template-tp4027692.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20140115/9c28386d/attachment.html
More information about the rules-users
mailing list