Re: [rules-users] Define a time event
by Christine
> Hi everyone,
> For example:
> when Time(hour==22,minute==0) Lamp(status==1)
> then
> Console.Writeline("It's late,turn off the light and go to bed")
> where time is a class that return the current hour;
Claudio, this would probably work if you fire the rules every hour or
every minute or every time your Time object changes. Just having the rules
sitting in your rulebase doesn't mean they get executed.
Christine
16 years, 7 months
Re: [rules-users] Date arithmetic in âÂÂwhenâ session
by Christine
>
> I tried this approach, but I get compilation errors for tokens '-' and '+'
> I
> get similar errors for any arithmetic symbols (*, + or -)
>
> What is the right way to add or subtract or multiply with in "when"
> session?
I don't know why the example doesn't work. Try this:
rule "ITR Discard"
when
req : LowFareRequest(
$reqTime : requestedDeparture.time)
itr : AirItinerary( discarded == false )
flight : Flight(
departure.time <
($reqTime / 3600000 + 2),
departure.time >
($reqTime / 3600000 - 4))
then
System.out.println("discard true");
end
Christine
16 years, 7 months
Newbie question / NoSuchMethodError error
by Cabou, Carl
Greetings,
I'm new to Drools and I've written a decision table based rule using excel.
The rule validates ok and I've deployed my package fine.
I've written a piece of code to test my rules, I want to set the calculatedRate to 125 when I get selected field equal to "0 - 50" :
...
StatelessSession statelessSession = rb.newStatelessSession(); Data data=new Data(); data.setSelected("0 - 50"); statelessSession.execute(data); // set private Integer field ...
When I run the code I get a exeption :
java.lang.NoSuchMethodError: java.lang.Integer.valueOf(I)Ljava/lang/Integer;
I don't understand why Drools tries to convert to Integer something which is already Integer !!!!
-----------
Here is the rules code.
rule "setCalculateRate_11"
salience 65525
when
Data(selected == "0 - 50")
then
object.setCalculatedRate(125);
end
Does anybody has an idea ??
Regards,
Carl.
16 years, 7 months
Date arithmetic in “when” session
by sridhar123
I am trying to subtract hours from date and compare with another date with
in "when" section, subtracting any value from date giving me compilation
errors. Only the way i could achive this writing drl file as:
dialect "java"
// Rule: Flight.departure – 2 hours < LowFareRequest.departure
// > Flight.departure + 4 hours
// then set AirItinerary.discarded = true
rule "ITR Discard"
when
$req : LowFareRequest()
$itr : AirItinerary( discarded == false )
$flight : Flight()
then
if((($flight.getDeparture().getTime() - 2 * 3600000)
< $req.getRequestedDeparture().getTime())
&&
($req.getRequestedDeparture().getTime()
> $flight.getDeparture().getTime() + 4 * 3600000))
System.out.println("discard true");
else
System.out.println("discard false");
end
I am new user to drools, executing if with in then session nullifies when
clause.
how else i can do the above?
TIA
--
View this message in context: http://www.nabble.com/Date-arithmetic-in-%E2%80%9Cwhen%E2%80%9D-session-t...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months
Define a time event
by Claudio Rainoldi
Hi everyone,
i'm using drools in .net version. I'd want that at a certain hour a rule has
to be fired.
For example:
when Time(hour==22,minute==0) Lamp(status==1)
then
Console.Writeline("It's late,turn off the light and go to bed")
where time is a class that return the current hour;
I've tried this code but nothing happens at 22.00.
Is there any solution, or i have to use an external class timer and execute
fireAllrules command for the hour that i'm interesting for?
Please,can somebody help me??
Cla
16 years, 7 months
Accumulate x No-loop
by Alessandro Lazarotti
Hi
When I use accumulate and update, no-loop is ignored and the rule is
recursive.
Why?
The Rule:
rule "Nota final das questoes"
no-loop true
when
questionarioResposta : QuestionarioResposta()
$result : Number() from
accumulate(QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)
from questionarioResposta.getQuestoesResposta(),
sum($nota * (Double)$peso))
$resultFinal : Number() from
accumulate(QuestaoResposta($nota:nota,$peso:questao.questaoPeso.peso)
from questionarioResposta.getQuestoesResposta(),
sum( $peso ))
then
System.out.println($result.doubleValue() / $resultFinal.doubleValue());
questionarioResposta.setNotaFinal($result.doubleValue() /
$resultFinal.doubleValue());
update( questionarioResposta );
end
16 years, 7 months
String range compares
by Steve Olson
We've hit a situation where the business users would like to specifiy some
facts that have a range check (a 'between' type operation) on fixed length
strings, that are usually short (6 characters or less). Simple example -
given a range of 'ABC' to 'ABM', this range would match all the character
strings 'ABC', 'ABD', ..., 'ABM'. We quickly discovered the '<' and '>'
operators don't work with strings, and are wondering if others have solved
this problem other ways. Searches have shown some discussions about being
able to build something like a custom StringEvaluator that does support '<'
and '>', but we haven't seen enough to know what would be the best path. If
anyone has suggestions, other than using eval() for all such checks, I'd
appreciate any info.
Thanks in advance...
--
View this message in context: http://www.nabble.com/String-range-compares-tp17085898p17085898.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 7 months
Advanced Course on Drools
by Christie, Blair
I am looking around for a course on jboss rules to take.
Is there any recommendations?
Blair
16 years, 7 months
facthandle iterator
by Christine
Hi All,
I thought this:
public void retractFacts() {
Iterator iter = workingMemory.iterateFactHandles();
while (iter.hasNext()) {
FactHandle handle = iter.next();
workingMemory.retract(handle);
}
}
would retract all facts, but in fact I get a compilation error because
iter.next is an object, not a factHandle. How do I retract facts using an
iterator iterating all facts?
kind regards
Christine
16 years, 7 months