[rules-users] [MVEL]user typed in free format expression and advanced property/expression handler integration issue

kapokfly ivan.jiang.ww at foxmail.com
Sat Dec 3 12:40:19 EST 2011


I have been trying and evaluating MVEL in past few days and in general, I
love this small kids but with 1 doubt needs ask for suggestions here. 

The key scenario is, we have an UI to allow users type in free format
expression and we have a couple of custom property/variable even expression
handler classes needs to be integrated with. 

Example sub-expression: 
1) person.name.isVisiable --> Please note, the isVisisble is not a java
property of name (it is name field's meta data which requires a quite
different resolver other than how we resolve the person and how we resolve
to name field). 
2) person.name --> normal property resolver. 

Now with the user typed in expression:
 (person.name.isVisiable == true) && (person.name == "Joe Wang"), what is
the best way to utilize MVEL to be able to parse/compile and execute this
expression? 

the first thing the API needs to know is whether it is a meta field
evaluation or a normal java property evaluation, there is no such clue on
user typed in expression unless we can parse the expression and scan its
full text like 'person.name.isVisiable'

The thing I am currently looking at is @Interceptor or custom function, and
looking for a way to be able to translate the expression into an easier
format like (@meta person.name.isVisiable == true) && (person.name == "Joe
Wang"). 

Is there any API in MVEL exists can make such transformation easier? Or
maybe we can use a hidden field on UI to append @meta tag when user types
in? 

Once 1st question is satisfied, the next one should be how we should proceed
@meta interceptor with the ASTNode passed in. 

Looking forward to your comments. 

Thanks.

-----
Ivan, your Panda, forever
--
View this message in context: http://drools.46999.n3.nabble.com/MVEL-user-typed-in-free-format-expression-and-advanced-property-expression-handler-integration-issue-tp3557472p3557472.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list