[rules-users] using complex evaluate expressions with DSL

maverik j maverikj348 at gmail.com
Tue Jan 4 01:54:26 EST 2011


cool...this was of great help, I will try this out I think it shoudl solve
the purpose.

Thanks once again,
Maverik

2011/1/3 Wolfgang Laun <wolfgang.laun at gmail.com>

> Try using eval as a last resort. A better (smaller, more robust) DSL can be
> designed around facts and their attributes.
>
> "||" (and "OR") can be used, but setting parentheses in order to get the
> priority right is difficult. In constraints, you may have to resort to
> "memberof" or "not memberof".
>
> Your sample isn't self-contained. But I think that the following DSL and
> the DSLR might give you some ideas how to proceed.
>
> [keyword][]check that {conditions}= eval( {conditions} )
> [keyword][]AND = &&
> [keyword][]OR  = ||
>
> [when][][Tt]here is an? {entity}= {entity}: {entity}()
> [when][][Tt]here is at least one {entity}= exists {entity}: {entity}()
>
> [when][]the {entity:\w+}'s {attr:\w+} = {entity}.get{attr}()
>
> [when][]- with a valid {attr} = {attr}: {attr} != null
> [when][]- with {attr} not equal to {value} = {attr} != {value}
> [when][]- eval\( {whatever} \)=eval( {whatever} )
>
> [when][] {attr:\S+} follows pattern {pattern:\S+} =  {attr}.matches(
> {pattern} )
> [when][] {attr:\S+} not equals? {value:\S+} = ! {attr}.equals( {value} )
> [when][] {attr:\S+} is valid  =  {attr} != null
>
> rule "Rule 5"
> when
>     There is a Department
>     There is at least one Person
>     - with name not equal to "xxx"
>     - with a valid subordinate
>     - check that the Person's Id is valid AND the Department's Id follows
> pattern "I" AND the Department's HeadOfDpt not equal name
> then
> end
>
> Notice that "-check that..." must be written as a single line.
>
> -W
>
>
>
>
> 2011/1/3 maverik j <maverikj348 at gmail.com>
>
>>   Hi,
>>
>>  We are planning to use DSL/DSRL approach with generic DSL template like
>> say
>>
>> [condition][]The {object} has valid {field}={object}({field} != null )
>>
>> [condition][]there is object {*obj*} that = {*obj*}()
>>
>> [condition][]- has {*attr*} equal {*val*} = {*attr*} == {*val*}
>>
>> [condition][]- has valid {*attr*} = {*attr*} != null
>>
>> [condition][]- and has {*attr*} equal {value}= && {*attr*} == {value}
>>
>> But there are quite few of requirements like to have DSL rules that can
>> generate expression as follows:
>> exists Employee(
>>    attribute name not equals "xxx"
>>    && the attribute subOrdinate is not null
>>    && eval(
>>    the attribute $dept.getId() is not null
>>    && attribute $dept.getId() follows pattern "I"
>>    && ( ! (the attribute $dept.getHeadOfDpt() equals name)
>>    )
>> )
>>
>> I am not sure if this is possible with DSL. Using '-' operator we cannot
>> really add '&&', '||' conditions it by-default expands to ',' separated and
>> conditions. And wirtting generic rules with and/or is not really dynamic to
>> allow any number of expressions in evaluation.
>>
>> i am struggling to get this run since long time so any help/thoughts on
>> this would be  highly appriciable !!!
>>
>> Thanks & Regards,
>> -Maverik
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> 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/20110104/a748d0f9/attachment.html 


More information about the rules-users mailing list