After doing some more tinkering, it doesn't seem I can reference
anything in the accumulate conditional unless it comes from the pattern
or init section of that accumulate conditional. I can not reference
globals or pattern bound variables from the rule (outside of accumulate)
or I get a duplicate parameter exception. What am I doing wrong? If I
haven't set this up incorrectly, I have to think this is a defect.
Thanks,
Eric
On Wed, 2007-11-28 at 09:43 -0500, Eric Miles wrote:
All,
I have a rule that I'm trying to run against, but I'm getting a
duplicate parameter error that doesn't make much sense to me. Here is
the rule:
rule "Daily Core Hours"
ruleflow-group "maxiflex-messages"
when
ScheduleDay($day: day, $schedIn: timeIn, $schedOut: timeOut)
not SmartTimeMessage(message == ("Core hours for day " + ($day + 1) +
" have not been met"))
Integer(intValue > 0 && intValue < ($schedOut - $schedIn))
from accumulate( SmartTimeLine(tito.day == $day, $timeOut:
tito.timeOut, $timeIn: tito.timeIn),
init( int total = 0; ),
action( total += calculateTime($schedIn,
$schedOut, (Integer)$timeIn, (Integer)$timeOut); ),
reverse( total -= calculateTime($schedIn,
$schedOut, (Integer)$timeIn, (Integer)$timeOut); ),
result( total ) )
then
SmartTimeMessage message = new SmartTimeMessage();
message.setType(SmartTimeMessageType.WARNING);
message.setMessage("Core hours for day " + ($day + 1) + " have not
been met");
insert(message);
end
function int calculateTime(int schedIn, int schedOut, int timeIn, int
timeOut) {
int beginTime = 0, endTime = 0;
if(timeIn < schedIn) {
beginTime = schedIn;
} else {
beginTime = timeIn;
}
if(timeOut > schedOut) {
endTime = schedOut;
} else {
endTime = timeOut;
}
return (endTime - beginTime);
}
The following is the error:
org.drools.rule.InvalidRulePackage: Rule Compilation error : [Rule
name=Daily Core Hours, agendaGroup=MAIN, salience=0, no-loop=false]
com/kronos/webta/service/smarttime/rules/Rule_Daily_Core_Hours_0.java
(32:1301) : Duplicate parameter $schedOut
com/kronos/webta/service/smarttime/rules/Rule_Daily_Core_Hours_0.java
(32:1330) : Duplicate parameter $schedIn
com/kronos/webta/service/smarttime/rules/Rule_Daily_Core_Hours_0.java
(41:1735) : Duplicate parameter $schedOut
com/kronos/webta/service/smarttime/rules/Rule_Daily_Core_Hours_0.java
(41:1764) : Duplicate parameter $schedIn
com/kronos/webta/service/smarttime/rules/Rule_Daily_Core_Hours_0.java
(51:2330) : Duplicate parameter $schedOut
com/kronos/webta/service/smarttime/rules/Rule_Daily_Core_Hours_0.java
(51:2359) : Duplicate parameter $schedIn
com/kronos/webta/service/smarttime/rules/Rule_Daily_Core_Hours_0.java
(58:2738) : Duplicate parameter $schedOut
com/kronos/webta/service/smarttime/rules/Rule_Daily_Core_Hours_0.java
(58:2767) : Duplicate parameter $schedIn
at org.drools.rule.Package.checkValidity(Package.java:424)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:364)
at
com.kronos.webta.service.smarttime.rules.maxiflex.FlowTest.setUpBeforeClass(FlowTest.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.junit.internal.runners.ClassRoadie.runBefores(ClassRoadie.java:49)
at
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:36)
at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Any help with this? Thanks in advance!
Eric
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users