Drools decision table, “mismatched input '>' in rule ”

好久不见. 提交于 2020-07-06 20:37:27

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!