Inside parentheses, the getTimelineDescriptor calls need an object.
Without parentheses, the implied object is this. But 5.2.0 did not
implement "free form expressions" fully.
-W
2011/11/29 Hezi Stern <hezis(a)delegatecom.com>:
Hi all,
I encountered the following strange inconsistent behavior with the eclipse
IDE and the Drools compiler.
I have the following test rule which should fire if a specific time
condition is present. The time condition is evaluated by a function called
getTimelineDescriptor() which is imported using import function.
rule "ScheduleTime: request for explicit time arrived"
when
ConditionMatrix(descriptors.times.timeline contains
getTimelineDescriptor(EButtonID.TIME_SPECIFIC) ||
descriptors.times.timeline contains
getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME) ||
descriptors.times.timeline contains
getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME),
$srcAlt:
srcWorkingAlternative,
)
then
//something...
end
the IDE indicates an error on the conditionMatrix line with the following
description:
Multiple markers at this line
- [ERR 101] Line 123:77 no viable alternative at input '(' in rule
"ScheduleTime: request for explicit time arrived" in pattern ConditionMatrix
- [ERR 102] Line 123:103 mismatched input '||' expecting 'then' in rule
"ScheduleTime: request for explicit time arrived"
- [ERR 101] Line 123:101 no viable alternative at input ')' in rule
"ScheduleTime: request for explicit time arrived" in pattern
getTimelineDescriptor
BUT it compiles ok and runs properly.
When I wrap the function with brackets (as I thought it should be) like this
rule "ScheduleTime: request for explicit time arrived"
when
ConditionMatrix(descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.TIME_SPECIFIC)) ||
descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME)) ||
descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME)),
$srcAlt:
srcWorkingAlternative,
)
then
//something...
end
the IDE shows no error but the compilation fails with the following error:
16:19:14,734 [ERROR] [LoggerStream]: Unable to Analyse Expression
descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.TIME_SPECIFIC)) ||
descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.DYNAMIC_ABSOLUTE_TIME)) ||
descriptors.times.timeline contains
(getTimelineDescriptor(EButtonID.DYNAMIC_RELATIVE_TIME)):
[Error: unable to resolve method using strict-mode:
com.delegatecom.rules.ConditionMatrix.contains(com.delegatecom.nlp.api.TimelineDescriptor)]
[Near : {... tors.times.timeline contains (getTimelineDescripto ....}]
I am using Drools 5.2 with Helios (Eclipse).
Any ideas why this is so? Although I have a working option it is impossible
to maintain code when there are error indications.
Thanks,
Hezi
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users