I think you misunderstand how rules work.
All Facts inserted into working memory will be compared to all patterns in
all rules; and where a match is found an activation recorded (i.e. LHS
runs).
So the following would group all products of type (if you insert
DelieveryList's into WM and set the type for each list you only need the one
rule):-
rule"group by type"
when
$d : DelieveryList ( $t : productType )
$p : Product( type == $t )
then
$d.add($p)
end
You don't need to "iterate" with rules; simply add all the objects to WM.
Cheers,
Mike
_____
From: KinG CD [mailto:kingcd8@hotmail.com]
Sent: 12 March 2008 19:07
To: Anstis, Michael (M.)
Subject: RE: Can I use drools to solve my problem?
Actually I was able to get near to that, but thank you very much, it cleared
my mind. My problem still is to group things. So I have a list of products
and I want to group them by type. So I want to create N lists for N types,
each list with every product of a certain type.
e.g
Product
-type
-name
-id
=======
productList{product1, product2, product3,...,productN}
I want a rule that
rule"group by type"
when
iterate the List and generate a productListbyType grouping all
products of typeN
then
deliveryList.add(productListbyType)
remove each product from the main List(i dont think i really nedd
that)
end
and loop in that rule until list is 'cleared'(all products have been sent to
their right lists.
sorry for bothering you, but i really searched for that and did not found. I
could iterate the list with the from collect bu i dont know how to use an
"abstract" type, how to iterate for all kind of types. we can have N types.
thank you very much.
_____
Subject: RE: Can I use drools to solve my problem?
Date: Mon, 10 Mar 2008 10:21:45 +0000
From: manstis1(a)ford.com
To: rules-users(a)lists.jboss.org
CC: kingcd8(a)hotmail.com
In my opinion it will be much easier if you insert individual Orders and
Products
Here's a hurriedly put together example to help you think in terms of rules
(I have no experience of your problem domain so this might be laughably
wrong):-
Global ArrayList branch1;
rule "Delievery split - Branch 1"
when
$p : Product( $b : branch = "Branch 1" )
$o : Order( products contains $p )
then
OrderDelievery od = new OrderDelievery($o, $p, $b);
insert(od);
end
rule "Consolidate delieveries"
when
$od : OrderDelievery( branch = "Branch 1" )
then
branch1.add($od);
end
Or you could just retrieve the OrderDelievery objects from WM at the end.
Drools can definately achieve what you want. If you can solve the problem
with hard-coded rules you can solve it with Drools.
Good luck,
Mike
_____
From: KinG CD [mailto:kingcd8@hotmail.com]
Sent: 07 March 2008 17:08
To: Anstis, Michael (M.)
Subject: RE: Can I use drools to solve my problem?
alright. I was trying not to boder you.
My companie is developing a billing software for a e-commerce site. So we
have an Order and we have to transform it into deliveries. So each Order has
many products and I have to filter it and define X deliveries(i call it
'delivery split'). There are filters like disponibility(in how many days it
will be ok), brach(in what city is the product), type(if it is a kit,
ticket...),...
I tried many ways and i really think that drools isn't the best tool for my
problem. The point is that mi boos dont want to use the hard code for define
the deliveries. He wats drolls to do everything. So i tried inserting the
the order in the WM, and using 'rom' chained with 'collect' i could
iterate
and set a list based in some rules, but how can i create lists based on the
branch. how can i group in Y different lists the Z different products i
have.
I also inserted each product manually and tried to manipulate each one. But
the point is that the rules should be interdependent but i was not able to
do it.
the resume is that i want to take the order and set N deliveries based on
interdependent rules. i would like to do almost everything with drools not
using the hard code.
Sorry for the English, thanj you very much for the help, i'm a little lost.
ect: FW: Can I use drools to solve my problem?
Date: Fri, 7 Mar 2008 15:45:22 +0000
From: manstis1(a)ford.com
To: rules-users(a)lists.jboss.org
CC: kingcd8(a)hotmail.com
Posted to forum for a wider audience.
I think you will need to be more specific with your use case.
With kind regards,
Mike
-----Original Message-----
From: kingcd8(a)hotmail.com [mailto:kingcd8@hotmail.com]
Sent: 07 March 2008 15:35
To: Anstis, Michael (M.)
Subject: Can I use drools to solve my problem?
I have a list of products and want to divide this list in other lists
applying the rules, than i want to apply the same rules to this new lists.
So I keep dividing them until no rules are applicable anymore.
Thank you
_____
Encontre o que você procura com mais eficiência! Instale já a Barra de
Ferramentas com Windows Desktop Search! É GRÁTIS!
<
http://www.windowslive.com.br/>
_____
Encontre o que você procura com mais eficiência! Instale já a Barra de
Ferramentas com Windows Desktop Search! É GRÁTIS!
<
http://www.windowslive.com.br>