declare variable
by fakhfakh ismail
Hello,
first sorry for my bad english.
I want to declare a variable of type List
rule "userrole"
when
$user1: User (userid1: userId)
$user2: User (userId == userid1)
then
List L = new ArrayList();
if (L.contains($user1.getname())== false)
{
L.add($user1.getname());
System.out.println("hello");
}
end
the problem is everytime the List don't save all element every execution the variable list is intialised as empty is there other place to declare List?
(I try after when but error of parsing)
---------------------------------
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
18 years, 8 months
From v 3.0.6 to 4.0.0
by Chris Woodrow
Hi everyone,
I am new to this mailing list, I've had a quick look at archives and didn't
find anything ont this subject but sorry if this has allready been
underlined.
Here is my problem, while I was doing some test on v3.0.6, 4.0.0 came out,
so I started to migrate on the new version. Then I found out an unexpecteed
behavior on the 4.0.0.
I have been compiling both with Java 5 and running whith Java 1.5.0_11. And
I used versions with dependencies on both tests.
I have made an exemple for you to make it as clear as possible, here is the
rule :
---------------------------------------------------------------------------------------
package rules
rule "TwoCheeses"
when
$cheese1 : Cheese();
$cheese2 : Cheese();
then
System.out.println($cheese1);
System.out.println($cheese2);
System.out.println("TwoCheeses");
end
---------------------------------------------------------------------------------------
When I run it on V3.0.6, with this code :
---------------------------------------------------------------------------------------
package rules;
import java.io.InputStreamReader;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.WorkingMemory;
import org.drools.compiler.PackageBuilder;
public class Cheese {
public static void main(String[] args) throws Exception{
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(new InputStreamReader(
Cheese.class.getResourceAsStream("rule.drl")));
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(builder.getPackage());
WorkingMemory workingMemory = ruleBase.newWorkingMemory();
Cheese cheese = new Cheese();
workingMemory.assertObject(cheese);
workingMemory.fireAllRules();
}
}
---------------------------------------------------------------------------------------
The rule doesn't fire, which is normal AMHA since only one Cheese object is
asserted to the WM
When I run it on V4.0.0, whith this code :
---------------------------------------------------------------------------------------
package rules;
import java.io.InputStreamReader;
import org.drools.RuleBase;
import org.drools.RuleBaseFactory;
import org.drools.StatefulSession;
import org.drools.compiler.PackageBuilder;
public class Cheese {
public static void main(String[] args) throws Exception{
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(new InputStreamReader(
Cheese.class.getResourceAsStream("rule.drl")));
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(builder.getPackage());
StatefulSession statefulSession = ruleBase.newStatefulSession();
Cheese cheese = new Cheese();
statefulSession.assertObject(cheese);
statefulSession.fireAllRules();
}
}
---------------------------------------------------------------------------------------
Now the rule fires and $cheese1 $cheese2 have the same reference.
I have been searching in all docs, this modification of behavior doesn't
seem to be expected, has anyone noticed this?
Thanks for your help.
Chris
18 years, 8 months
M2 release DSL support is partial?
by Sikkandar Nawabjan
Mark,
The DSL is enabled completely or partially(engine level).
(ie) can we use the Eclipse(plugin) to create and test dsl?
since we tested M2 with eclipse and it seems the Rules are not =
acticvated when using DSL.
Our rules are very complex and we required such a Guy support to =
configure DSL and it is almost not possible to use text editor to write =
dsl/.
Please let me know about the DSL feauture that were added in this =
release
Thanks and Regs,
Basha
18 years, 8 months
Using the Rule Flow Builder GUI
by Shahad Ahmed
I've been playing with the new Ruleflow stuff in 4.0MR2 - which is cool -
and it's raised a couple of questions and observations that I hope other
users can answer.
1. Is there a way of specifying a constraint(s) on a Split node. I can
see the Split node type property can be given an AND value, but there seems
to be no way of specifying which output connections(s) should be traversed
after the split. I quick peek at the source code did reveal that the core
ruleflow stuff seems to have constraint attributes in the split node
implementation, so is this still a "Todo", or is there a way of
specifying constraints in 4.0MR2 release?
2. Am I correct in assuming that a rule can only ever belong to a single
RuleFlowGroup node (i.e. ruleset), as the rules in a RuleFlowGroup seem to
be specified by a rules (single) ruleflowgroup attribute? It appears that if
you want to reuse a rule in another RuleFlowGroup node in the ruleflow then
you have to redefine a copy of the rule and give it a different
ruleflowgroup attribute. However, if a rule could belong to several ruleflow
groups then you could reuse a rule in other RuleFlowGroup nodes in the
same ruleflow, or even in a different ruleflow. In some the applications
I've developed with commercial rules engines, it's common to have a number
of ruleflows that implement different parts of a system, but where all the
rules are defined against a common model, thus allowing some reuse of rules.
3. The Eclipse GUI ruleflow builder doesn't seem to allow loops in the flow.
It may sound a bit perverse, but is there any reason why loops should not
allowed (assuming the rule modeler is aware of the potential of infinite
loops etc)? I've implemented applications with commercial rules engines,
where looping in the ruleflow has proved useful. As I said, it may sound
perverse, but several commercial rules engines are getting to the point
where the ruleflow tools are essentially Business Process Management Systems
(BPMS). These systems mix rules and process control flow, such as split
conditions, looping and much more, to define applications within a single
framework, but that's a whole different topic.
Thanks
Shahad
18 years, 8 months
repeat result
by fakhfakh ismail
hello,
first sorry for my bad english,
is there a soluttion to avoid the repeating result?
when I execute my programme
I get solution repeat more then one:
alain ne peut pas executer cette activite
alain ne peut pas executer cette activite
alain ne peut pas executer cette activite
alain ne peut pas executer cette activite
thank u for your help
Ismail
---------------------------------
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
18 years, 8 months
Re: [drools-dev] async stuff
by Mark Proctor
np I took a simplified approach in the end, but I think it should
capture the main use cases.
Mark
Greg Barton wrote:
> I haven't gotten the chance to look at it yet, but I
> will. Sorry I dropped the ball on that. It's been a
> craaaaaazy year. :)
>
> --- Mark Proctor <mproctor(a)codehaus.org> wrote:
>
>
>> Greg,
>>
>> Did you checkout what I did with the async apis in
>> 4.0 MR2, happy I got
>> the balance and implementation right?
>>
>> Mark
>>
>>
>>
>>
> ---------------------------------------------------------------------
>
>> To unsubscribe from this list please visit:
>>
>> http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>
>
>
> ____________________________________________________________________________________Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
> http://new.toolbar.yahoo.com/toolbar/features/mail/index.php
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
18 years, 8 months
change "assert" to "insert"
by Mark Proctor
We have been getting querries with regards to jdk assert collision and
jboss rules assert, for this reason we are thinking of changing it to
insert for 4.0. Further to that its causing language integrations issues
for us as we expand pluggeable dialects. For this reason we are thinking
of chaning assert to insert, this would be an api change and a language
level change. I'd thought I'd throw this out to the community before we
do it. This of course breaks backwards compatability.
Mark
18 years, 8 months
How to handle priority in a rule
by Maxime
Hello,
I'm trying to find how to manage priority within a rule. Let me explain
the problem. I'll try to be as clear as possible but bear with me since
I am new to rules.
We have two objects, the Product is the object I'm trying to price and
the object Price is the one that knows all the prices. Both products and
prices have fields amount and length. Product amount is initialized to
0 and prices are going to determine the product amount depending on its
length.
Let's see an example :
Product : P -> length = 5, amount = 0
Price : P1 -> length = 1, amount = 50
Price : P2 -> length = 3, amount = 100
With this configuration, after asserting the 3 objects to the WM, the
amount field of Product P should have a value of 200 ( 1*100 + 2*50)
because the price with the greatest length should be favored over the
other ones.
Here is the rule I made :
rule "Price Product rule using price length"
when
$s : Product (length > 0)
$price : Price($length: length)
then
$s.setAmount($s.getAmount() + $price.getAmount());
$s.setLength($s.getLength() - $length.intValue());
modify($s);
end
This is obviously wrong because it always takes the first asserted price
object. I don't know how to make a rule which would take the amount of
the price object with the greatest length in priority.
Any help would be very much appreciated.
Cheers,
Max
18 years, 8 months
(no subject)
by vijay
Hi all,
I need an help can anyone help please. this is to check the list using drools
i have 2 list in a bean as its variables and using set method im assigning them certain values i need to perform equal ,greater and lesser check on this list elemnts using drools. do any one has any idea how to do it .
anyone help please!!!
Thanks
Vijay
"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world"
-- Albert Einstien
18 years, 8 months
(no subject)
by lucio@asteriski.com
---------------------------------
Lucio Piccoli
Director
Asterisk-i Pty Ltd
Software Design-Develop-Deploy
www.asteriski.com
18 years, 8 months