drools 规则从地图中获取值
如何在阻塞时获取流水中的特定值。
我正在寻找类似的东西,但它不起作用:
我已将哈希图插入工作内存并尝试在当
$expiry_date:HashMap(get("CREDIT_CARD_EXPIRATION_DATE"));
eval(ageInDays($expiry_date)>10) ;
我遇到以下错误时检索它
[42,37]: [ERR 101] Line 42:37 no viable alternative at input '"CREDIT_CARD_EXPIRATION_DATE"' in rule "Rule1" in pattern HashMap
How to get the perticular value in the drools when block.
I am looking for something like this but its not working:
I have inserted Hashmap into Working memory and trying to retrieve it in When
$expiry_date:HashMap(get("CREDIT_CARD_EXPIRATION_DATE"));
eval(ageInDays($expiry_date)>10) ;
I get below error
[42,37]: [ERR 101] Line 42:37 no viable alternative at input '"CREDIT_CARD_EXPIRATION_DATE"' in rule "Rule1" in pattern HashMap
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于映射/列表/数组,您可以使用 [] 语法来访问元素。另外,如果您使用 Drools 5.3+,则 evals 现在基本上无关紧要。
使用 Drools 5.1/5.2,您可以执行以下操作:
For maps/lists/arrays, you can use [] syntax to access elements. Also, if you are using Drools 5.3+, evals are basically irrelevant now.
With Drools 5.1/5.2, you could do:
通常插入更多类型的对象比仅仅插入哈希映射更好。您能否解释一下您尝试处理的信息以及为什么选择插入
hashmap
而不是类型化对象
?我很确定你可以这样做:
我没有测试它,但如果你不能插入更多类型的事实,你应该朝那个方向看。
干杯
Usually its better to insert more typed objects than just a hash map. Can you explain the information that are you trying to process and why do you choose to insert a
hashmap
instead of atyped object
?I'm pretty sure that you can do something like:
I didn't test it but you should look in that direction if you can't insert more typed facts.
Cheers