Re: [rules-users] Reuse of rule
by Küng Sabrina
Yes, sorry. I will try the extends and get back with a clearer question.
Thanks.
________________________________
From: Küng Sabrina
Sent: Mittwoch 1 Jun 2011 13:22
To: 'rules-users(a)lists.jboss.org'
Subject: RE: Reuse of rule
Thanks for your input. I am looking forward to the plugin.
How can I use a rule in the if-part (or as precondition) of another rule? Is that possible without using a ruleflow?
________________________________
From: Küng Sabrina
Sent: Montag 30 Mai 2011 13:52
To: 'rules-users(a)lists.jboss.org'
Subject: Reuse of rule
Hello
How can I write a rule, that can be used in several other packages resp. rulesets without copying the code?
14 years, 8 months
newbie question: forming event pairs
by Wouter De Borger
Hi all,
I'm new to drools and I have the following problem:
A stream of Start and Stop events comes into the engine.
The start and stop events should be paired and transformed into ranged
events.
Each start event should be paired to the first next stop event that is not
part of a pair already, with precedence for the last start event that came
in.
The problem is comparable to what a parser would do to match nested braces.
A sequence of the form
1: Start
2: Start
3: Start
4: End
5: Start
6: End
7: End
8: End
should form the following pairs
3-4
5-6
2-7
1-8
I checked the documentation but I still have two problems:
1. how can I find the next stop event (or previous start)
2. how can I make sure the pairs are formed innermost first?
Thanks in advance,
Wouter
14 years, 8 months
Building
by హరీష్ చౌదరి కూకట్ల
Hello EveryOne,
I am new to drools and I have couple of questions.
1. How to build group of .drl files as a package and load it into the
session.
2. Is there a way to see what rules are loaded into the session
programatically
Thank you very much,
Harish Kukatla.
14 years, 8 months
Drools 5.2.0.Final released
by Geoffrey De Smet
The Drools community is happy to announce the release of *Drools
5.2.0.Final*.
This includes:
* Drools Expert (rule engine)
* Drools Fusion (CEP: complex event processing)
* Drools Planner (planning optimization)
* Guvnor (BRMS web application)
* Drools IDE (Eclipse plugin)
Read the release announcement:
http://blog.athico.com/2011/06/drools-52-released.html
--
With kind regards,
The Drools team
14 years, 8 months
Drools' use of hashCode
by M. H.
Hi all,
I have encountered a situation I don't quite understand, I would be happy to
have some explanations about it. This is my first post here and I'm quite
new to all this so don't be afraid to go back to basics if I'm missing
something:
I have 3 classes :
public class Child
{
private Date time;
+get
+set
+constructor
}
public class Father
{
private Child child;
private int value;
+get
+set
+constructor
public void setTime(Date d)
{
child.setTime(d);
}
}
public class GdFather
{
private Father father;
+get
+set
+constructor
}
then 2 rules :
rule "1"
when
$father : Father(value==1)
then
$father.setTime(new Date(2));
$father.setValue(0);
update($father);
end
rule "2"
when
$father : Father()
$GdFather : GdFather(father==$father)
then
System.out.println($father);
end
////////////////////////////////////////
I didn't change the identity assert behavior, I insert a father and the
corresponding GdFather in the workingMemory, and all seems to work OK.
The issue occurs when I override the hashCode function in the Father class :
if I use this definition :
@Override
public int hashCode()
{
return child.getTime().hashCode();
}
then rule 2 is not fired after modification of the father, and is not either
if I change the function to return child.hashCode() with a Child hashCode
returning time.hashCode().
This also happens with a properly overriden equals function, and both Drools
5.1.1 and 5.2.0.CR1.
What I don't understand is why is it using the overriden hashCode function
with an identity assert behavior? What is it used for? And it looks like it
is using the overriden hashCode, but not equals, is that correct, and if so,
why?
How can I get the second rule to fire and have a custom hashCode() ?
Thank you in advance for your answers,
M.H.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-use-of-hashCode-tp3090419p309041...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
the condition starts with "-" in DSL mapping
by James Gu
Hi,
I am using guvnor-5.2.0.CR1-jboss-as-5.1. I found a bug in DSL mapping.
This is the DSL items.
[when]There is an TestObject=TestObject()
[when]-startDate is before {date}=startDate>DateUtils.parseDate("{date}")
[when]-endDate is after {date}=endDate>DateUtils.parseDate("{date}")
I created a business rule added these three lines in order. I clicked "view
source" and get this result. The second condition is not in the right place.
rule "test121"
dialect "mvel"
when
TestObject( startDate>DateUtils.parseDate("01/01/2009",
endDate>DateUtils.parseDate("01/01/2008") ) )
then
end
This is what I expected. I guess guvnor is looking for the first ")" and add
the condition (start with "-") before it. Actually it should look for the
last ")" and add the condition before it.
rule "test121"
dialect "mvel"
when
TestObject( startDate>DateUtils.parseDate("01/01/2009") ,
endDate>DateUtils.parseDate("01/01/2008") )
then
end
This problem also exists in drools-5.1.1-guvnor. It will be great if it can
be fixed soon.
Thanks,
James
--
View this message in context: http://drools.46999.n3.nabble.com/the-condition-starts-with-in-DSL-mappin...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
Avoid evaluation of expensive LHS terms
by Joe Ammann
Stumbled over this today in a specific case, but my question is about a
general practice (I'm quite new to Drools, 5.2.0.M2 btw). I have a
knowledge session with a fair amount of facts (0.5 Mio) and mostly
simple rules. One rule has a LHS expression that I know will be
expensive to execute, in the example that I encountered this it looks like:
rule "Count facts"
when
all : Number() from accumulate (s : X(), count(s))
blacklisted : Number() from accumulate (s : X(status ==
X.BLACKLISTED), count(s))
....
then
....
end
I want to execute this rule only after other rules have already executed
(and changed the status of most of the X facts). There's quite a number
of X facts (~200'000). Most of them have their status modified during
execution of other rules. If I run the rule base without the above
rules, performance is perfect, some tens of seconds. If I activate the
rule, execution never finishes (I stop it after a few minutes, never saw
it finished).
I *THINK* (correct me if I'm wrong) what happens is that especially the
second expression of the LHS gets executes over and over again whenever
one of the facts is modified by one of the other rules. Makes sense, but
I nevertheless want to try to avoid it.
Until now I tried unsuccessfully:
- "protect" the rule with a guard fact as the first expression, which is
inserted only late in the processing
- move the rule to another ruleflow-group (or agenda-group) and activate
it only at the end of the processing
- use the rule in a second independent knowledge base and session, and
insert the facts once the first has finished
I'm perfectly aware that I could solve this specific problem of counting
facts with different techniques, but my question is more general (as the
subject says). Because I have other cases where (as a last resort) I
need to go to a database or online service to get the required
information. It seems that others have similar problems
(http://drools.46999.n3.nabble.com/Short-circuiting-evaluations-on-LHS-td5...).
But in my experience, that technique ("protecting" the expensive pattern
in the LHS with a cheap one that evaluates to false until you really
need the expensive one) does not work. I get the impression that
(contrary to popular experience that a "false" value in an AND sequence
terminates the whole sequence) the drools LHS are processed differently.
Am I missing something really stupid?!
--
CU, Joe
14 years, 8 months
usage of @startTimestamp
by Lavoisier Farias
Hi everybody,
I am delepoing an application using Drools to correlate events from a
network management system. Can anyone recommend me a good tutorial which
teaches how to use real time clock ? I am using the book of Michal Bali,
which is very good indeed. The book examples uses the following code:
clock.advanceTime(*xx seconds*, TimeUnit.SECONDS);
However, I would like to use the property of an event called *startTime *and
*endTime *which means the time on which the event starts and the time the
event finishes. I know there is the property @startTimestamp mentioned at
the book. But, where can I find more examples of usage of @startTimestamp in
rule files ?
Best Regards,
*
Lavoisier José Leite Farias*
Skype: lavoisierfarias
Twitter: http://twitter.com/LavoisierFarias
14 years, 8 months