[rules-users] Minor Issue in writing DSL

Edson Tirelli tirelli at post.com
Tue Aug 21 13:55:56 EDT 2007


   Saleem,

   For sure, your mapping must have some typo or mistake. A rule like this
works and is correct:

rule XYZ
when
    ObjectA( application==true || banker==true || officer==true )
then
  // do something
end

    Drools does NOT inspect object fields... only public methods.

    If you are using a DSL, make sure your "drl" file is named "dslr" (this
is new in 4.0), so when you open it in eclipse, you have a tab that shows
you the result of the DSL template processing. This way you will be able to
see any eventual mapping mistake.

    []s
    Edson


2007/8/21, Saleem Lakhani <Saleem.Lakhani at citizensfla.com>:
>
>  When I use the syntax below and write like:
>
>
>
> [when]ABC=ObjectA(application==true || banker==true || officer==true)
>
>
>
> on drl it gives me the following error:
>
>
>
> Multiple markers at this line:
>
> -        unknown:116:39 Unexpected token '=='
>
> -        unknown:116:25 Unexpected token '||'
>
> -        unknown:116:64 Unexpected token '=='
>
>
>
> Again, there are NO attributes in ObjectA named application, banker or
> officer.
>
>
>
> Thanks
>
>
>
>
>
>
>
> -----Original Message-----
> *From:* rules-users-bounces at lists.jboss.org [mailto:
> rules-users-bounces at lists.jboss.org] *On Behalf Of *Edson Tirelli
> *Sent:* Tuesday, August 21, 2007 9:49 AM
> *To:* Rules Users List
> *Subject:* Re: [rules-users] Minor Issue in writing DSL
>
>
>
>
>    Drools respects encapsulation, so it works with javabean method name
> conventions. If you have a method isApplication() that returns a boolean,
> does not matter how your class calculates the return value. Same for any
> other method. In 4.0, you can write:
>
> ObjectA( application == true || banker == true )
>
>    To map that as a DSL, just follow your usual procedure and syntax.
>
>    []s
>    Edson
>
> 2007/8/21, Saleem Lakhani < Saleem.Lakhani at citizensfla.com>:
>
> Hi,
>
>
>
> If I had a rule written in DSL using Drools 3.0 like;
>
>
>
> 1.      [when] when1=r : ObjectA( )
>
> 2.      [when] when2=eval(r.isApplication() || r.isBanker())
>
>
>
> There are no attributes in class Object with name application and banker
> but there are methods in ObjectA with names isApplication() & isBanker()
> which does some work and return Boolean based on some facts.
>
>
>
> What is the correct way of writing the same rule using Drools 4.0 ?
>
>
>
> Also, if the above attributes were present in ObjectA what would have been
> the best way to write it in DSL using Drools 4.0
>
>
>
> Thanks,
>
>
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> --
>   Edson Tirelli
>   Software Engineer - JBoss Rules Core Developer
>   Office: +55 11 3529-6000
>   Mobile: +55 11 9287-5646
>   JBoss, a division of Red Hat @ www.jboss.com
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070821/b5c48ed7/attachment.html 


More information about the rules-users mailing list