New bee writing rules
by miro
I have a n object which has a method which returns java.util.Map .
Is it easy to implement a rule which calls the gettter method on this object
for the map and get the value for a specified key and check condition on
that value ?
Example
class MyObject {
private Map properties;
public Map getProperties(){
return properties;
}
public void setProperties(Map aMap){
this.properties=aMap;
}
Now the rule I need is
MyObject aObject= new MyObject();
return (
aObject.getPorperties().get("price").toString.equals("aproperty"))
}
Can this code be easily implemented in a drl file and what is with the
eval ?
--
View this message in context: http://www.nabble.com/New-bee-writing-rules-tf3488367.html#a9740856
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 8 months
Drools fact counts...
by Jim Majure
I have what I think is a very simple rule to implement, but I can't find a way to do it without "cheating" by using an eval/function. Here's the basic rule in English:
Reject a claim if it contains a treatment that has already been claimed more than 70 times
in the same calendar month.
In other words, I need to count the number of instances of the treatment that have already been paid.
Assume for the sake of this discussion, my facts are instances of the Treatment class.
If I replace "70" with, say, "2" in this rule I could do this:
rule
when
Treatment(id=="t1", status=="pending")
Treatment(id=="t1", status=="paid")
Treatment(id=="t1", status=="paid")
then
assert ( new Rejection("reason"));
end
Unfortunately, I can't simply replace "70" with "2", and using the same strategy to check for 70 instances doesn't seem quite right.
Am I missing something very simple here? Are there standard strategies to deal with this type of rule?
17 years, 8 months
ismail_info2005@yahoo.fr
by fakhfaki@loria.fr
hello,
I want to deploy the jsr-94 specific in the rule engine JBoss Rules
the problem I didn't find the specification for drools I find it for Jess
Please I need your help
Best regard
Ismail
17 years, 8 months
comparisons on Java primitive wrapper class types
by wasabifan
In creating a list of rules, I noticed when adding facts to my working memory
it may cause errors if Integer or Long values are null (as they are
attempting to do comparisons on null objects...even if other conditions
previously listed in that particular rule eliminate this fact from that
particular conflicting rule), however, I have not noticed this behavior for
null String objects. Is this the expected behavior, or should they be
defaulting to 0 in the comparisons (much like I am assuming the Strings must
be defaulting to empty Strings)?
Thanks for any clarification. I am using 3.1M1 if that is relevant as well.
Bryan
--
View this message in context: http://www.nabble.com/comparisons-on-Java-primitive-wrapper-class-types-t...
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 8 months
Problem with \" while compiling DRL
by D'Inca Cedric
Hi everyone,
I am currently experimentating troubles compiling a DRL file with a \" character in it.
I used a XLS decision table that, once compiled, gave me a DRL. The following lines are extracted from it.
#From row number: 14
rule "Exemple 1 2006 10 10_14"
salience 65522
when
Ctx:MyObject()
eval(Ctx.GetPrp("TEST").getValue().equals("GER"))
then
Ctx.SetPrp("TRUC").setValue("test char \" test");
end
#From row number: 15
The problem is that when compiled, an error is generated
Unknown:0-1 mismatched token: [@0,0,0='<no text>',<-1>,0:-1]; expecting type 'end'
If I modify the decision table to put
Ctx.SetPrp("TRUC").setValue("test char " test");
The result is the same
Unknown:0-1 mismatched token: [@0,0,0='<no text>',<-1>,0:-1]; expecting type 'end'
So it means that \" is not understood, however, if I put \z, I get the following error:
Rule compilation error Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\)
Where it is written that \" should be understood.
Any idea?
Greetings,
Cédric D'INCA
17 years, 8 months
Help: How to implement drools to validate a large volume of data ?
by Milinda Jayakody
Hi
I want to validate a large volume of data using drools. But I found that when i asserted a large no of objects to the working memory it results an out of memory error. Can anyone help me how to implement drools efficiently to validate a large no of facts?
Thank You
---------------------------------
Sucker-punch spam with award-winning protection.
Try the free Yahoo! Mail Beta.
17 years, 8 months
Struggling with Rule syntax - please help...
by jdepaul
I'm having trouble figuring out syntax for my rules - could someone please
steer me in the right direction - it's been a frustrating few days and no
luck. I need to check existence of various attributes from the
SHIPMENT_MOVE fact against a list of values (same list) I fetch from the
DB...
Get $valuesList from a DAO - then...
If SHIPMENT_MOVE.customer_code = "abc" and SHIPMENT_MOVE.reference_code
exists in $valuesList
OR
SHIPMENT_MOVE.customer_code = "abc" and SHIPMENT_MOVE.shipping_code exists
in $valuesList
OR
SHIPMENT_MOVE.customer_code = "abc" and SHIPMENT_MOVE.partner_code exists in
$valuesList
I have the following rule working fine:
$shipment SHIPMENT_MOVE(customer_code = "abc")
LookupTableResult ( resultValue == 1 ) from lookupDAO.getLookup(...)
But I'm having real problems with writing a rule like this:
when
SHIPMENT_MOVE(customer_code == "abc", $list contains ship_code) OR
SHIPMENT_MOVE(customer_code == "abc", $list contains deliver_code) OR
SHIPMENT_MOVE(customer_code == "abc", $list contains port_code)
Your guidance will be appreciated -
Thanks,
James
P.S.
I'm using Drools 3.1.0M1
--
View this message in context: http://www.nabble.com/Struggling-with-Rule-syntax---please-help...-tf3408...
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 8 months
Changing rules at runtime
by Carlos Henriquez
Hi all.
I'm new in this list and I have a year working with rules (integrated with
Spring). We are using drools 2.5 despite is legacy.
We want to change rules at runtime without redeploying the whole
application. I tried with the ruleAdministrator, deregistering the rule
source and registering again but I had a problem creating the
RuleExecutionSet with the createRuleExecutionSet method from
LocalRuleExecutionSetProvider. It didn't see any of my class and I got a
"unable to find class XXX" RuleExecutionSetCreateException every time I
tried to create a rule set from a file.
What I don't understand is how does Spring load all my rules the first time?
I don't know if I have to set som classpath manually and if I do, where?
I'll appreciate all the help you could give me.
Bye.
--
Carlos Henriquez
+58-416-839.94.28
17 years, 8 months
Performance with 'eval'
by Diego Manilla Suárez
Hi. I need to implement some sort of 'adviser' or 'recommender' system,
and I'm considering JBoss Rules to do the task. It would be an adviser
for choosing which car to buy, for example. Imagine: 'I want a car which
is all-wheel-drive, and I would like it in green, but I don't mind if
it's in another color'. The user can choose how important is each
feature for him, or if it's mandatory (in the previous example, the
'all-wheel-drive' requirement is mandatory, while the color it's not).
So, I would have all the car catalog in the working memory permanently
(class Car), and I would assert a buyer (class Buyer), and I would like
to get the cars that best match the user requirements and wishes. I had
outlined something like this (pseudocode):
################
rule "CarRecommendation"
when
buyer : Buyer()
car : Car (feature1=mandatoryRequirement1,
feature2=mandatoryRequirement2, ...)
eval (carUserCompatibilityLevel(car, buyer) >
COMPATIBILITY_THRESHOLD)
then
buyer.getRecommendedCars().add(car);
end
function int carUserCompatibilityLevel(Car car, Buyer buyer) {
return [compatibility level based on car suitableness to user
preferences];
}
################
My main question is if I'm forced to use an 'eval' element in order to
get what I want. I'm afraid I need to use it, and I'm concerned about
the performance since the WorkingMemory will hold up to 10 million
'cars' (well, they aren't really cars, the car-buyer thing it's just an
example for the sake of simplicity), and the docs clearly state that
evals are not nearly as efficient as field constraints (memory usage is
not a concern in this moment).
Since the 'car' catalog is so large, I wish I could get the cars with
the highest compatibility levels first and stop when I reach, for
example, 50 recommended cars (I would add something like 'if
buyer.getRecommendedCars().size() > CAR_LIMIT retract(buyer)' to the
consequence), and so I would't have the need for a
COMPATIBILITY_THRESHOLD. I don't know if that's even possible.
I'm new to this kind of programming and any tip would be appreciated,
even if it involves to totally change the approach (i. e., not using a
rule engine for the task). Just any clue that points me in the right
direction.
Thanks in advance
17 years, 8 months