问题
I'm creating an decision table using Drools and having trouble with the greater than character ('>'). I saw on the drools documentation that you could use '>' and '<' but I seem to get something wrong.
The column is (I don't have enough reputation yet to post images):
- |CONDITION|
- | | (empty cell)
- |duration >|
- |Duration|
- |50|
- |200|
The thing is that the architecture doesn't allow me to get the full object. I can only have some fields from the RemoteObject
.
So the thing I can do is:
Integer duration = getRemoteObjectDuration();
kSession.insert(duration);
kSession.fireAllRules();
Which results in:
[6,2]: [ERR 102] Line 6:2 mismatched input '>' in rule "RuleTable_11"
[14,2]: [ERR 102] Line 14:2 mismatched input '>' in rule "RuleTable_12"
[0,0]: Parser returned a null Package
I could create a dummy object containing my field, but there must be something better to do. Does anyone have an idea about this?
回答1:
To match an Integer you can use a rule like
rule findInt
when
Integer( $iv: intValue > 42 )
then
System.out.println( "got an Integer > 42: " + $iv );
end
and, consequently, a spreadsheet column according to
CONDITION
Integer
intValue >
- ... -
42
This is, of course, doomed to fail when you have several Integer objects floating around in working memory, not being able to identify what is what.
For your predicament I'd create a shadow object for holding all fields of the remote object rather than wrap the fields individually.
回答2:
Thanks to laune's comment, I finally made it work, but I had to create a custom object only containing the field I needed and I wrote the name of this new class below CONDITION.
来源:https://stackoverflow.com/questions/31785747/drools-decision-table-mismatched-input-in-rule