2011/1/4 Wolfgang Laun <wolfgang.laun(a)gmail.com>
2011/1/4 maverik j <maverikj348(a)gmail.com>
is there any restriction in terms of using custom function in condition
> etc.
> If I add function evaluation to conditions its messing up with dsl. For
> pattern matching if I use custom function defined in drl then its not able
> to parse that properly
>
> [when][] {attr:\S+} follows pattern {pattern:\S+} =
> funcToEvalPattern({attr},( {pattern} )
>
Is this exactly what you have in the DSL definition? It's syntactically
incorrect.
Sorry for that, it is actually
[when][] {*attr*} follows pattern {pattern} = startsWithFunction(
{*attr*},
{pattern} )
>
> and is being added as last statement in DSL (for testing purpose I am
> using same dsl as you have shown)
>
in this case it is getting translated to
> exists(Person:Person(subordinate != null , startsWithFunction( *eval*(
> name, "I" ) ) )
> where as I was hoping this to be
> exists(Person:Person(subordinate != null , *eval *(startsWithFunction(
> name, "I" ) ) )
>
>
I cannot reproduce this. But it may depend on the order of your entries in
you DSL file.
Actually I tried changing order as well but didnt worked. I have actually
defined
these common functions in drl and added that to knowledgebase along
with these DSL and DSLR.
-W
> Regards,
> -Maverik
>
> On Tue, Jan 4, 2011 at 12:24 PM, maverik j <maverikj348(a)gmail.com> wrote:
>
>> 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(a)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(a)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(a)lists.jboss.org
>>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users