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
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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users