Edson,

 What about sugar to be able to write DSLs dor this:
   DLS:
       A Person
          - having age equals to 10
          - or equals to 15
          - or greather than 20

  DRL:
     p: Person( age == 10
                || == 15
                || > 20)

Right now, the " - <expression>" put a 'comma' at the end of the line making this:
     p: Person( age == 10, || == 15, || > 20)

What throws errors...

Is it possible to do that? I love the || == <value> thing in each line...

Thanks.

On 21-08-2007, at 16:14, Saleem Lakhani wrote:

Thanks Edson. That helped. One more thing, can’t we execute something simple like: ObjectA(units != families)

When both units & families are defined as int in ObjectA with their public get and set methods. This is the exception I am receiving.


org.drools.rule.InvalidRulePackage: Unable to return Declaration for identifier 'families' : [Rule name=Rule6, agendaGroup=Rating, salience=0, no-loop=false] Its even showing correctly in drl editor. If I swap the positions of units & families then the same exception is thrown for ‘units’.


regards,

saleem

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:rules-users- [EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: Tuesday, August 21, 2007 1:56 PM
To: Rules Users List
Subject: Re: [rules-users] Minor Issue in writing DSL



   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 < [EMAIL PROTECTED]>:

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: [EMAIL PROTECTED] [mailto: rules-users- [EMAIL PROTECTED] 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 < [EMAIL PROTECTED]>:

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
[email protected]
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
[email protected]
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
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users


Felipe Piccolini M.
[EMAIL PROTECTED]




_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to