Hi, i think that if you do:
$sprinkler : Sprinkler(room != "", roomId == $fire.roomId)
that should work.
You should avoid eval and use it just as a last resort.
Regards
2010/6/10 Fnu Mahalakshmi <FMahalakshmi(a)nyx.com>
Hi guys,
Thanks for the response.
When I store data as a collection the rules don't seem to get fired. I
think the data is not being read.
I tried everything suggested.
So broke down the data storing them as individual java bean objects.
Is this a possibility??
Rule
When
$fire : Fire(room != null, status == true)
$sprinkler : Sprinkler(room != "")
Eval($sprinkler.getRoomId == $fire.getRoomId) //this doesn't work. Anyway
I
can compare 2 values in my
rules????
Then
Modify($sprinkler){
setSprinklerStatus(true);
}
I am trying to check if the fire for the room 1 is true then if sprinkler
for that room exists then that is also set true.
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org [mailto:
rules-users-bounces(a)lists.jboss.org] On Behalf Of
rules-users-request(a)lists.jboss.org
Sent: Thursday, June 10, 2010 4:57 AM
To: rules-users(a)lists.jboss.org
Subject: rules-users Digest, Vol 43, Issue 53
Send rules-users mailing list submissions to
rules-users(a)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(a)lists.jboss.org
You can reach the person managing the list at
rules-users-owner(a)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. Re: error with firing of rules and chainig rules (Giovanni Motta)
2. Re: depicting array in rules (Swindells, Thomas)
----------------------------------------------------------------------
Message: 1
Date: Thu, 10 Jun 2010 09:59:27 +0200
From: Giovanni Motta <mottagio(a)gmail.com>
Subject: Re: [rules-users] error with firing of rules and chainig
rules
To: Rules Users List <rules-users(a)lists.jboss.org>
Message-ID:
<AANLkTikzwm0qpIv6qDe4koF5NxxFezF3z7op4AIN7yGv(a)mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"
When you update your objects, do you notify the session of the change?
If you do that, you should not take care of salience. The objects insertion
order is not relevant (or, at least, marginally).
To notify the session of an object change, you should either put your
modifications inside a 'modify' block (see the docs) or let your java beans
include a 'PropertyChangeSupport' field (see dynamic facts).
In your sample, when the room gets the 'fire' status, the session should be
notified of the change, and the sprinkler rule will fire.
Regards
2010/6/9 Fnu Mahalakshmi <FMahalakshmi(a)nyx.com>
> Hi,
>
>
>
> If you have multiple rules where its important that rule 1 be fired on
the
> data first and then rule 2 how can we do this without specifying the
> salience factor?
>
> I do not want my rules to be dependant on each other as the data I am
> passing differs from each other.
>
> Ex:
>
> Room{
>
> Name, Id,
>
> Status,
>
> }
>
> Fire{
>
> Room,
>
> FireType}
>
>
>
> Sprinkler{
>
> Room,
>
> SprinklerType
>
> status}
>
>
>
>
>
> I pass all data above into my working memory.
>
> I have rules:
>
> Rule 1: ?if fire exists update room status to ?fire??
>
> Rule 2: ?if room has status ?fire? update sprinkler status to ?room
> number??
>
>
>
> Now when I pass my javabean objects: if theobject of type sprinkler gets
> processed first it will never get the room number even if actually the
room
> has status ?fire?
>
>
>
> If I specify salience feature then It will never work for my sprinkler
> objects and always be multichained.
>
> I don?t want chaining between my rules.
>
>
>
> Any suggestions???
>
> Thank you
>
> M
>
> ------------------------------
>
> *Please consider the environment before printing this email.*
>
> *Visit our website at
http://www.nyse.com
>
*****************************************************************************
>
> Note: The information contained in this message and any attachment to it
is
> privileged, confidential and protected from disclosure. If the reader of
> this message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you
are
> hereby notified that any dissemination, distribution or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, please notify the sender immediately by replying
to
> the message, and please delete it from your system. Thank you. NYSE
> Euronext. *
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)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/20100610/b3bb985...
------------------------------
Message: 2
Date: Thu, 10 Jun 2010 09:56:34 +0100
From: "Swindells, Thomas" <TSwindells(a)nds.com>
Subject: Re: [rules-users] depicting array in rules
To: Rules Users List <rules-users(a)lists.jboss.org>
Message-ID:
<DAC86F5F3B84F14088F0DB16092558CA0855AE88EA(a)UKMA1.UK.NDS.COM>
Content-Type: text/plain; charset="us-ascii"
Generally the advice when using drools is that if you are wanting to use an
array (or other type of collection) then you should probably be normalising
your data and putting the values of the collection into the working memory
as their own object (pretend that drools is a relational database and follow
the same rules as you would defining database tables and rows). Sometimes
you can't do this because of constraints on the environment you are work
within but in your case you I think you have two options:
Each room conceptually has its own sprinkler therefore each Sprinkler
object contains a single room field.
If a Sprinkler has the concept of operating over multiple rooms then have a
Sprinkler object containing its ID and status, then have multiple
SprinklerHeadLocation objects containing a reference to the Sprinkler and a
single room each.
Rule " if fire in room start sprinkler if room has sprinkler"
No-loop true
when
Fire($room : room)
SprinklerHeadLocation(room == $room, $sprinklerId : sprinklerId)
$sprinkler : Sprinkler(sprinklerId == $sprinklerId, status == false)??
then
modify($sprinkler){
setStatus(true)
};
End
Thomas
From: rules-users-bounces(a)lists.jboss.org [mailto:
rules-users-bounces(a)lists.jboss.org] On Behalf Of Esteban Aliverti
Sent: 09 June 2010 20:28
To: Rules Users List
Subject: Re: [rules-users] depicting array in rules
One way could be:
when
Fire($room : room)
$sprinkler : Sprinkler(room contains $room)
Room (this == $room, someField == "SomeValue")
then
modify($sprinkler){
setStatus(true)
};
End
If you dont have the Room as a Fact Type, then:
when
Fire($room : room)
$sprinkler : Sprinkler(room contains $room)
Room (someField == "SomeValue")from $room
then
modify($sprinkler){
setStatus(true)
};
End
I'm not 100% sure about this, but at least you can start from here
Best
2010/6/9 Fnu Mahalakshmi <FMahalakshmi@nyx.com<mailto:FMahalakshmi@nyx.com
>>
Hi,
Is there any way I can represent an array of values in my rules??
I want to do this:
Fire{
Room,
Status}
Sprinkler{
Object [] Room = new Room[]{new Room(),new room()}
Status
}
Room{
Name,
Number}
Rule " if fire in room start sprinkler if room has sprinkler"
No-loop true
when
Fire($room : room)
$sprinkler : Sprinkler( room == $room) # how can I search through the
array of room values here???????
then
modify($sprinkler){
setStatus(true)
};
End
Any Idea if that is possible to implement in rules???
I could do it with adding different instances of sprinkler and rooms. But I
want to minimize the amount of repetition in data stored and loaded into the
working memory.
Any idea??
Thank you,
M
________________________________
Please consider the environment before printing this email.
Visit our website at
http://www.nyse.com
*****************************************************************************
Note: The information contained in this message and any attachment to it is
privileged, confidential and protected from disclosure. If the reader of
this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, you are
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify the sender immediately by replying to
the message, and please delete it from your system. Thank you. NYSE
Euronext.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you
have received this message in error, please immediately notify the
postmaster(a)nds.com and delete it from your system as well as any copies.
The content of e-mails as well as traffic data may be monitored by NDS for
employment and security purposes. To protect the environment please do not
print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18
4EX, United Kingdom. A company registered in England and Wales. Registered
no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://lists.jboss.org/pipermail/rules-users/attachments/20100610/60ef3b0...
------------------------------
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
End of rules-users Digest, Vol 43, Issue 53
*******************************************
Please consider the environment before printing this email.
Visit our website at
http://www.nyse.com
****************************************************
Note: The information contained in this message and any attachment to it
is privileged, confidential and protected from disclosure. If the reader of
this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, you are
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited. If you have received this
communication in error, please notify the sender immediately by replying to
the message, and please delete it from your system. Thank you. NYSE
Euronext.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users