You'll have to separate the logic for determining that the item you
are looking for is in the list from the access to the first occurrence.
rule "find first 'car'"
when
$p1:Policy()
$carList: List( size > 0 )
from collect ( Vehicle( name == "car" )
from $p1.vehicleslist )
$first: Vehicle( ) from $carList.get( 0 )
then
System.out.println( $first );
end
-W
On 24/08/2012, salt <writemesaltworth(a)gmail.com> wrote:
Hi Laune,
Vehicles list contains the values name and qty and the values are
car,10
jeep,20
lorry,30
car,30
Below is my implementation for that scenario which i have asked.
rule "HelloWorld_13"
salience 65523
when
$p1:Policy()
$trandet:Vehicle(name in ("CAR")) from $p1.vehicleslist
then
System.out.println($trandet.getQty());
end
The result for the above rule is
30
10
but i need 10 alone which is at the top of that list.. is that possible.?
and when googling found that if we use salience along with 'from' its
possible..
Please share your thoughts on the above.
Thanks
Salt
--
View this message in context:
http://drools.46999.n3.nabble.com/Getting-Latest-Matching-Fact-tp4019345p...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users