[rules-users] RE: rules-users Digest, Vol 12, Issue 16

Dr. Gernot Starke gs at gernotstarke.de
Thu Nov 8 03:52:58 EST 2007


Sikkandar,

regard a rule-semaphore as a "guard": It's a variable which you use  
on left hand side of rules:

rule 1
when Guard g
<other conditions>
then
<RHS>
end

You can set the semaphore in any other rule to control which other
rules you want to disable or enable...

(If you need background on semaphores, have a look in Operating- 
Systems literature)
regards,
Gernot

Am 08.11.2007 um 08:40 schrieb Sikkandar Nawabjan:

> am sorry i understand partially. i don't know to use semaphores to  
> control rule. can you give some example
>
> Message: 4
> Date: Wed, 07 Nov 2007 20:23:05 +0000
> From: Mark Proctor <mproctor at codehaus.org>
> Subject: Re: [rules-users] RE: How to stop firing rules from dependent
>         object
> To: Rules Users List <rules-users at lists.jboss.org>
> Message-ID: <47321EA9.7060100 at codehaus.org>
> Content-Type: text/plain; charset="iso-8859-1"
>
> you'll have to setup rules that detect the state of the working memory
> that then uses semaphores to control which rules can fire.
>
> Mark
> Sikkandar Nawabjan wrote:
>> Hi,
>>
>> I have 2 Objects and its corresponding drl/dsls to validate the rule
>>
>> ObjectA -  A.drl,A.dsl
>>
>> ObjectB - B.drl,B.dsl
>>
>> when i insert ObjectA i want the rules in A.drl to be fired.
>>
>> when i insert ObjectB along with ObjectA i want to fire rules only  
>> from B.drl
>>
>> There are some rule in B.drl requires ObjectA.so i need to insert  
>> always ObjectA with ObjectB. At the same time i don't want the  
>> rule from A.drl
>>
>> How to do that?
>>
>> Thanks and Regs,
>>
>> Basha
>>
>
>
> Sikkandar Basha	   	
> Tech Lead                         WPEPDS
>   	
> 	
>  UST Global<http://intranet.ustri.com/email/UST-logo.jpg> 	B5N 144,  
> Bhavani
> Technopark, Trivandrum, India
> sikkandar.nawabjan at ust-global.com <mailto:sikkandar.nawabjan at ust- 
> global.com>
> T: +91-471-2335777 Extn: 6802036
> M: +91-9946555330
> F:  +91-471-2527276
>
> ________________________________
>
> From: rules-users-bounces at lists.jboss.org on behalf of rules-users- 
> request at lists.jboss.org
> Sent: Thu 11/8/2007 5:21 AM
> To: rules-users at lists.jboss.org
> Subject: rules-users Digest, Vol 12, Issue 16
>
>
>
> Send rules-users mailing list submissions to
>         rules-users at lists.jboss.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.jboss.org/mailman/listinfo/rules-users
> or, via email, send a message with subject or body 'help' to
>         rules-users-request at lists.jboss.org
>
> You can reach the person managing the list at
>         rules-users-owner at lists.jboss.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of rules-users digest..."
>
>
> Today's Topics:
>
>    1. inconsistency with 'collect' and the '||' operator (Adrian  
> Cowham)
>    2. Re: inconsistency with 'collect' and the '||' operator (Adrian)
>    3. RE: Combine DSL and Java Code? (Raj, Govinda (Mohan))
>    4. Re: RE: How to stop firing rules from dependent object
>       (Mark Proctor)
>    5. Re: inconsistency with 'collect' and the '||' operator (Mike D)
>    6. Re: Combine DSL and Java Code? (Edson Tirelli)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 7 Nov 2007 10:35:17 -0800
> From: "Adrian Cowham" <adrian.cowham at gmail.com>
> Subject: [rules-users] inconsistency with 'collect' and the '||'
>         operator
> To: rules-users at lists.jboss.org
> Message-ID:
>         <470fffa10711071035o4792e8ebs65c3d16551f10859 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> I'm running into an issue where the || operator embedded in a  
> collect CE
> isn't working as expected. The rule I have is
>
> rule Grant Access"
>     when
>         $request : AccessRequest($name : username, $ID : sessionID,  
> $loc :
> accessLocation, $day : dayOfAccess)
>         $user : NetworkUser(username == $name)
>         $group : UserGroup(users contains $user)
>         $locationRules : ArrayList(size > 0) from
>             collect (AccessRule((allowedLocation == "ANY" ||  
> allowedLocation
> == $loc), allowAccess == "false")
>             from $group.getRules())
>     then
>         # access granted
>
> end
>
>
> The issue I'm having is with AccessRule((allowedLocation == "ANY" ||
> allowedLocation == $loc), allowAccess == "false"), this translate  
> to "all
> access rules that have the allowed location set to ANY or set to the
> location the user is logging in from". I created a UserGroup named "
> super.users" that contains a user named "root" and a single rule  
> that allows
> access from ANY location. However, when I simulate a login with "root"
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.jboss.org/pipermail/rules-users/attachments/ 
> 20071107/451e832f/attachment-0001.html
>
> ------------------------------
>
> Message: 2
> Date: Wed, 7 Nov 2007 19:53:36 +0000 (UTC)
> From: Adrian <adrian.cowham at gmail.com>
> Subject: [rules-users] Re: inconsistency with 'collect' and the '||'
>         operator
> To: rules-users at lists.jboss.org
> Message-ID: <loom.20071107T195056-299 at post.gmane.org>
> Content-Type: text/plain; charset=us-ascii
>
> Adrian Cowham <adrian.cowham <at> gmail.com> writes:
>
>>
>> I'm running into an issue where the || operator embedded in a  
>> collect CE isn't
> working as expected. The rule I have is rule Grant Access"
>>     when
>>         $request : AccessRequest($name : username, $ID :  
>> sessionID, $loc :
> accessLocation, $day : dayOfAccess)
>>         $user : NetworkUser(username == $name)
>>         $group : UserGroup(users contains $user)
>>         $locationRules : ArrayList(size > 0) from
>>             collect (AccessRule((allowedLocation == "ANY" ||  
>> allowedLocation
> == $loc), allowAccess == "false")
>>             from $group.getRules())
>>     then
>>         # access grantedendThe issue I'm having is with
> AccessRule((allowedLocation == "ANY" || allowedLocation == $loc),  
> allowAccess ==
> "false"), this translate to "all access rules that have the allowed  
> location set
> to ANY or set to the location the user is logging in from". I  
> created a
> UserGroup named "
>> super.users" that contains a user named "root" and a single rule  
>> that allows
> access from ANY location. However, when I simulate a login with "root"
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users <at> lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
> Please ignore this email, I sent this one by accident pre-maturely.  
> I sent my
> final draft shortly after. Sorry.
>
> a
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 7 Nov 2007 17:46:46 -0000
> From: "Raj, Govinda (Mohan)" <mohan at hp.com>
> Subject: RE: [rules-users] Combine DSL and Java Code?
> To: "Rules Users List" <rules-users at lists.jboss.org>
> Message-ID:
>          
> <4CE2D0FBADA2D04FB93A01341FA2CE5502B8019A at G3W0067.americas.hpqcorp.net 
> >
>
> Content-Type: text/plain; charset="utf-8"
>
> Try changing DSL
>
> from
> [consequence][]write "{value}" to stdout=System.out.println 
> ("{value}");
> To
> [consequence][]write {value} to stdout=System.out.println( {value} );
>
> And see if it works.
>
> --Mohan
>
> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org
> [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Markus  
> Helbig
> Sent: Wednesday, November 07, 2007 8:09 AM
> To: rules-users at lists.jboss.org
> Subject: [rules-users] Combine DSL and Java Code?
>
> Hi,
>
> following example:
>
> Item Class:
>
> public class MyItem {
>
>       public MyItem() {}
>
>       public String getMessage()
>       {
>             return "Hello World!";
>       }
>
> }
>
> DSL:
>
> [condition][]is of type MyItem=MyItem()
> [consequence][]write "{value}" to stdout=System.out.println 
> ("{value}");
>
> DSRL File:
>
> rule
>     when
>            $item: is of type MyItem
>     then
>            write $item.getMessage() to stdout
> end
>
> Is this "write $item.getMessage() to stdout" possible in any way?
> Currently i'm not able to get it to work ...
>
> Cheers
>
> Markus
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: smime.p7s
> Type: application/x-pkcs7-signature
> Size: 4786 bytes
> Desc: not available
> Url : http://lists.jboss.org/pipermail/rules-users/attachments/ 
> 20071107/7f583b3a/smime-0001.bin
>
> ------------------------------
>
> Message: 4
> Date: Wed, 07 Nov 2007 20:23:05 +0000
> From: Mark Proctor <mproctor at codehaus.org>
> Subject: Re: [rules-users] RE: How to stop firing rules from dependent
>         object
> To: Rules Users List <rules-users at lists.jboss.org>
> Message-ID: <47321EA9.7060100 at codehaus.org>
> Content-Type: text/plain; charset="iso-8859-1"
>
> you'll have to setup rules that detect the state of the working memory
> that then uses semaphores to control which rules can fire.
>
> Mark
> Sikkandar Nawabjan wrote:
>> Hi,
>>
>> I have 2 Objects and its corresponding drl/dsls to validate the rule
>>
>> ObjectA -  A.drl,A.dsl
>>
>> ObjectB - B.drl,B.dsl
>>
>> when i insert ObjectA i want the rules in A.drl to be fired.
>>
>> when i insert ObjectB along with ObjectA i want to fire rules only  
>> from B.drl
>>
>> There are some rule in B.drl requires ObjectA.so i need to insert  
>> always ObjectA with ObjectB. At the same time i don't want the  
>> rule from A.drl
>>
>> How to do that?
>>
>> Thanks and Regs,
>>
>> Basha
>>
>>
>> --------------------------------------------------------------------- 
>> ---
>>
>> _______________________________________________
>> 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/ 
> 20071107/04f8801f/attachment-0001.html
>
> ------------------------------
>
> Message: 5
> Date: Wed, 7 Nov 2007 13:36:33 -0800 (PST)
> From: Mike D <mike.dalaker at kewill.com>
> Subject: Re: [rules-users] inconsistency with 'collect' and the '||'
>         operator
> To: rules-users at lists.jboss.org
> Message-ID: <13636646.post at talk.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
>
> did you try  AccessRule((allowedLocation in ("ANY", $loc)?
>
>
> Adrian Cowham wrote:
>>
>> I'm running into an issue where the || operator embedded in a  
>> collect CE
>> isn't working as expected. The rule I have is
>>
>> rule Grant Access"
>>     when
>>         $request : AccessRequest($name : username, $ID :  
>> sessionID, $loc :
>> accessLocation, $day : dayOfAccess)
>>         $user : NetworkUser(username == $name)
>>         $group : UserGroup(users contains $user)
>>         $locationRules : ArrayList(size > 0) from
>>             collect (AccessRule((allowedLocation == "ANY" ||
>> allowedLocation
>> == $loc), allowAccess == "false")
>>             from $group.getRules())
>>     then
>>         # access granted
>>
>> end
>>
>>
>> The issue I'm having is with AccessRule((allowedLocation == "ANY" ||
>> allowedLocation == $loc), allowAccess == "false"), this translate  
>> to "all
>> access rules that have the allowed location set to ANY or set to the
>> location the user is logging in from". I created a UserGroup named "
>> super.users" that contains a user named "root" and a single rule that
>> allows
>> access from ANY location. However, when I simulate a login with  
>> "root"
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> --
> View this message in context: http://www.nabble.com/inconsistency- 
> with-%27collect%27-and-the-%27%7C%7C%27-operator- 
> tf4766961.html#a13636646
> Sent from the drools - user mailing list archive at Nabble.com.
>
>
>
> ------------------------------
>
> Message: 6
> Date: Wed, 7 Nov 2007 14:50:36 -0200
> From: "Edson Tirelli" <tirelli at post.com>
> Subject: Re: [rules-users] Combine DSL and Java Code?
> To: "Rules Users List" <rules-users at lists.jboss.org>
> Message-ID:
>         <e6dd5ba30711070850u5957090gf0fcb50c7fa5a9a1 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
>   Markus, did you tried:
>
> [consequence][]write {value} to stdout=System.out.println({value});
>
>    With the line:
>
> write $item.getMessage() to stdout
>
>     []s
>     Edson
>
> 2007/11/7, Markus Helbig <mhelbig81 at googlemail.com>:
>>
>> Hi,
>>
>> following example:
>>
>> Item Class:
>>
>> public class MyItem {
>>
>>       public MyItem() {}
>>
>>       public String getMessage()
>>       {
>>             return "Hello World!";
>>       }
>>
>> }
>>
>> DSL:
>>
>> [condition][]is of type MyItem=MyItem()
>> [consequence][]write "{value}" to stdout=System.out.println 
>> ("{value}");
>>
>> DSRL File:
>>
>> rule
>>     when
>>            $item: is of type MyItem
>>     then
>>            write $item.getMessage() to stdout
>> end
>>
>> Is this "write $item.getMessage() to stdout" possible in any way?
>> Currently i'm not able to get it to work ...
>>
>> Cheers
>>
>> Markus
>> _______________________________________________
>> 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/ 
> 20071107/fb33c17d/attachment.html
>
> ------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> End of rules-users Digest, Vol 12, Issue 16
> *******************************************
>
>
> <winmail.dat>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

Dr. Gernot Starke
Doing IT Right

---
Willi-Lauf Allee 43, D-50858 Köln
gs at gernotstarke.de,
  +49 (0) 177 - 728 2570
http://www.gernotstarke.de
Blog: http://it-and-more.blogspot.com
****************************************
Das freie Portal für Software-Architekten:
http://www.arc42.de






More information about the rules-users mailing list