What *exactly* do you expect as the output of this parser for *this* example?
-W
On 21/01/2014, neal <swapnilaute(a)gmail.com> wrote:
Below is the template to generate the rule statement (It is basic
one).
What I want to do is to read the string and convert into object.
package @{package};
@foreach{importEntry : imports}
import @{importEntry};
@end{}
@foreach{importEntry : staticImports}
import static @{importEntry};
@end{}
rule "@{ruleName}"
dialect "@{dialectName}"
salience @{salienceValue}
enabled @{enableValue}
when
@foreach{modelObject : modelObjects} @{modelObject.referenceName} :
@{modelObject.referenceType} ( @foreach{ attribute :
modelObject.attributes}
@{attribute.name} @{attribute.operator} "(a){attribute.value}" @end{} )
@end{}
then
// tempate data to set attribute
end
/ code to run the tempate
TemplateRegistry RULE_REGISTRY = new SimpleTemplateRegistry();
RULE_REGISTRY.addNamedTemplate( "rules",
getCompiledTemplate(prepareSimpleTemplate()));
System.out.println(TemplateRuntime.execute(
RULE_REGISTRY.getNamedTemplate( "rules" ),
getMap(),RULE_REGISTRY ));
}
// method to get tempate in string
public static String prepareSimpleTemplate() {
return StringUtils.readFileAsString(new InputStreamReader(
MvelDemo.class.getResourceAsStream("RuleTemplate.mvel")));
}
The rule statement generated is:
package some;
import rout.Vo;
rule "Row_001"
dialect "mvel"
salience 10
enabled true
when
vo : Vo ( type_code == "S" )
then
vo.a_name = "X"
end
How to generate object model from String generated from MVEL template? Is
there any parser available to convert String into Object model in MVEL?
--
View this message in context:
http://drools.46999.n3.nabble.com/How-to-create-object-model-parse-into-o...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users