Storing temp results in eval block
by cfili
Hi,
I have just started using Drools 4.0 and I am very pleased so far. I do
have one question regarding storage of a result from within an eval block.
For example if I have the following eval in my rule:
eval((value1 /value2) > 0.5)
Is there a way to store the result of value1/value2 in a temp variable so
that it can be accessed in the "then" part of my rule? I want to avoid
recomputing the result again in the then section.
Thanks.
--
View this message in context: http://www.nabble.com/Storing-temp-results-in-eval-block-tf4225783.html#a...
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 3 months
collect return random order
by Manukyan, Sergey
Folks,
When using collect on List of items with some filter (criteria), I need
to have result in the same order as it was received:
F.e. I have a list of suppliers :
List() : Supplier("FIRST", Status.ACTIVE), Supplier("SECOND",
Status.INACTIVE), Supplier("THIRD", Status.INACTIVE)
And I need to find first INACTIVE supplier, so it must be SECOND
supplier.
So doing the following :
When
$l : List() // list of suppliers
$inactive_supp : ArrayList() from collect Supplier(status ==
Status.INACTIVE) from $l
Then
System.out.println($l); // prints FIRST, SECOND, THIRD
System.out.println($inactive_supp); // prints THIRD, SECOND ....
Instead of SECOND , THIRD
So I am getting THIRD supplier instead of SECOND as the result..
Please advise if it is a bug .., or there is another way of doing
that...
Thanks,
-Sergey
**********************
** LEGAL DISCLAIMER **
**********************
This E-mail message and any attachments may contain
legally privileged, confidential or proprietary
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of
this message to the intended recipient(s), you are
hereby notified that any dissemination, distribution
or copying of this E-mail message is strictly
prohibited. If you have received this message in
error, please immediately notify the sender and
delete this E-mail message from your computer.
17 years, 3 months
NoClassDefFoundError for
by Barfield Steve
Jesse/Fernando/anybody
Do you know if this problem has been resolved - I am getting the same
problem from a web service running on BEA weblogic
Regards, Steve Barfield, Developer
Application Services
FUJITSU SERVICES
Cavendish Road, Stevenage, Herts, SG1 2DY
* +44 (0) 870 234 8197 (Int: 7444 8197)
* +44 (0) 7867 828474
* <mailto:steve.barfield@uk.fujitsu.com
<mailto:steve.barfield@uk.fujitsu.com> >
Web: http://uk.fujitsu.com <http://uk.fujitsu.com/>
Fujitsu Services Limited, Registered in England no 96056, Registered
Office 22 Baker Street, London, W1U 3BW
This e-mail is only for the use of its intended recipient. Its contents
are subject to a duty of confidence and may be privileged. Fujitsu
Services does not guarantee that this e-mail has not been intercepted
and amended or that it is virus-free.
17 years, 3 months
How to catch Exceptions when firing rules
by Yang Song
Hi,
Anyone knows how to catch the exception when firing the rules?
I wrapped the session.fireAllRules() method using try...catch, however it
doesn't work: when someone wrote bad code in the rule's action part, the
Exception will be thrown and printed to the stderr, and this will make the
rule engine stop working -- the try...catch outside doesn't help anything.
If the exception thrown from the rule's action part can be caught
externally, the system can be protected from interrupting Exception.
try {
_log.debug("Firing rules in : " + getName());
session.fireAllRules();
} catch (Exception e) {
_log.info("Error when firing rules: ", e);
}
Thanks,
Yang
17 years, 3 months
Problems with Global Date Object
by Brian Enderle
I would like to create a new Date object representing the current date and use
that as a global. I have tried the following:
(in Java code)
setGlobal("todaysDate", new Date());
(in rules file)
global java.utils.Date todaysDate;
rule "LevelTwo: Associate birth date must be before today"
when
Associate(birthDt <= todaysDate)
then
System.out.println("Birth Date must be before today");
end
with this code I get the following error:
Error creating bean with name 'ruleBase' defined in class path resource
[spring-beans.xml]: Invocation of init method failed; nested exception is
org.drools.rule.InvalidRulePackage: org.drools.compiler.GlobalError@b51c29
Caused by: org.drools.rule.InvalidRulePackage:
org.drools.compiler.GlobalError@b51c29
at org.drools.rule.Package.checkValidity(Package.java:408)
at org.drools.common.AbstractRuleBase.addPackage
(AbstractRuleBase.java:288)
at com.sample.RuleBaseBeanFactory.afterPropertiesSet
(RuleBaseBeanFactory.java:63)
etc...
I have also tried to set a constant date with the date format that I found in
the Drools docs (dd-MMM-yyyy) like such:
statefulSession.setGlobal("todaysDate", "10-Jul-1974");
and I get the same error message.
The rule does work correctly when I hard code a value in place of todaysDate
within the rule so I know the rule works (but obviously that is not an option).
What is the proper way to set a Date global? Is it possible this is a bug?
Thanks in advance,
Brian Enderle
17 years, 3 months
Programmatically get packages/snapshot list from JBRMS
by Erin
Hi guys,
The application we're developing requires that we be able to
programmatically get a list of all the Snapshots currently deployed on the
JBRMS.
The requirement is kinda like this -
(i) User A creates several rule packages and deploys snapshots of them
through the JBRMS.
(ii )User B, utilizing our application, should get a listing of all the
rules currently available from JBRMS (categorized in some manner) and choose
which rules should be executed.
(iii) Whenver User A, updates/deploys a package, it should reflect in User
B's application.
Does the JBRMS currently support this, along with some means of
categorization? If not, what would you suggest as the best way to emulate
this feature? (We're adamant on using JBRMS, it's too good!).
Thanks in advance (And apologies too, if the question is dumb :o)
-erin
17 years, 3 months
Friendly reminder: Drools Puzzle, Round 2. Already 7 solutions...
by Dr. Gernot Starke
Just as a friendly reminder: Tell all your friends and colleagues,
spread word in your blogs... about this cool-contest!!
btw.: I received already seven (7) cute solutions) - some even in
different programming languages. We still don't have
a Ruby solutions, and your friends from the Erlang/Haskell/PHP
department might join in :-)
Have a nice weekend,
Gernot
==== repeated message follows: =====================
Hi JBoss-Drools-folks,
round 2 of our (not-already) famous (enough) puzzle contest just
opened. Until September 14th you
can send your solutions to droolspuzzle(a)gmail.com
The riddle itself has been posted in the JBoss-Drools-Blog
http://blog.athico.com/2007/08/drools-puzzle-round-2-familiy-puzzle.html
For you non-bloggers:
=====================================
Difficulty level: Settler
* Three men, Abel, Locker and Snyder are married to Edith, Doris
and Luisa, but not necessarily in this order.
* Each couple has one son.
* The sons are called Albert, Henry and Victor.
* Snyder is nor married to Luisa, neither is he Henry's father.
* Edit is not married to Locker and not Albert's mother.
* If Alberts father is either Locker or Snyder, then Luisa is
Victor's mother.
* If Luisa is married to Locker, then Doris is not Albert's mother.
Who is married to whom and what are their sons called?
Taken from the German book "Denken als Spiel" by Willy Hochkeppel,
1973 (Thinking as a Game).
=====================================
Rules of the Contest:
http://blog.athico.com/2007/08/drools-puzzles.html
We're looking forward to your contributions -
let the rules rule...
greetings from Cologne,
Gernot
Dr. Gernot Starke
Doing IT Right
---
Willi-Lauf Allee 43, D-50858 Köln
gs(a)gernotstarke.de,
+49 (0) 177 - 728 2570
http://www.gernotstarke.de
Blog: http://it-and-more.blogspot.com
17 years, 3 months
String evaluation
by Saleem Lakhani
Hi,
Can we write something like this in Drools 3.0 ?
[when]The Roof is not NA=Object(roof != "" )
where roof is some String object.
Saleem Lakhani
17 years, 3 months
Data Driven Object Models and BRMS validation
by Knapp, Barry
Question:
What is the best way to customize the validation in the BRMS? Is there
a callout method that exists in JBoss Rules already to override the
current validator with a custom validator?
Reason:
I have a data driven object models and my users create rules in decision
tables.
I will have a decision table column header such as
<Attribute> equals <value>
and the user will enter a value in the cell for the 3 parameters
DRIVER, age, 23
The java mapping for the condition column would be like:
eval($1.isHashmapValueEqual("$2", "$3"))
After parsing the decision table, the DRL would look like this
DRIVER.isHashmapValueEqual("age", "23");
In this scenario, I do not have a DRIVER class until the rule is parsed
and I create a proxy DRIVER class to use for rules execution. This
proxy class generation is performed on the execution side on application
startup and not on the management side. The management side never has a
DRIVER to validate the rule against.
____________________________________________________
Barry Knapp
Barry.Knapp(a)RailInc.com <mailto:Barry.Knapp@RailInc.com>
919.651.5039
MSN Messenger barry25(a)hotmail.com <mailto:barry25@hotmail.com>
17 years, 3 months