流口水在dinam上产生过滤器
新的JBoss流口水:)
我正在研究一个POC,其中有一个或多个过滤器存在的规则。我正在使用模板动态生成该规则。
template header
effectiveDate
expirationDate
rule
totalPriceValue
package test.template;
import test.domain.ProductDiscountRequest;
template "value discount template"
rule "Value discount on customer_@{row.rowNumber}"
date-effective "@{effectiveDate}"
date-expires "@{expirationDate}"
when
requestObject : ProductDiscountRequest(@{rule} && totalPrice > @{totalPriceValue});
then
requestObject.addDiscount(5.0d);
end
end template
该模板具有正确的输入,生成了一个规则,例如
package test.template;
import test.domain.ProductDiscountRequest;
rule "Value discount on customer_0"
date-effective "25-Jun-2022 16:00"
date-expires "26-Jun-2030 8:00"
when
requestObject : ProductDiscountRequest(customer == 'TestCustomer' && totalPrice > 30);
then
requestObject.addDiscount(5.0d);
end
有多个过滤器,也可以组合它们,因此 customer =='testCustomer'也可以是 customer =='testCustOustomer' && CustGroup ==“ TestGroup” 等。 我看到3个解决方案:
- 在代码中生成过滤零件,仅插入它
- 创建每个过滤器数量的不同规则(1个过滤器的1个规则,1个过滤器的1个规则等)
- 将过滤器发送到模板并将其直接生成
我尝试有些事情,但是我无法让#3上班。假设有一个过滤器列表,我该如何迭代它并将其连接到完整状态?
我对其他想法持开放态度,以使其变得更好。
New with JBoss Drools :)
I'm working on a PoC where there's a rule where one or multiple filters can exist. I'm using a template to generate that rule dynamically.
template header
effectiveDate
expirationDate
rule
totalPriceValue
package test.template;
import test.domain.ProductDiscountRequest;
template "value discount template"
rule "Value discount on customer_@{row.rowNumber}"
date-effective "@{effectiveDate}"
date-expires "@{expirationDate}"
when
requestObject : ProductDiscountRequest(@{rule} && totalPrice > @{totalPriceValue});
then
requestObject.addDiscount(5.0d);
end
end template
This template, with the correct input, generates a rule like
package test.template;
import test.domain.ProductDiscountRequest;
rule "Value discount on customer_0"
date-effective "25-Jun-2022 16:00"
date-expires "26-Jun-2030 8:00"
when
requestObject : ProductDiscountRequest(customer == 'TestCustomer' && totalPrice > 30);
then
requestObject.addDiscount(5.0d);
end
There are multiple filters available and they can also be combined, so customer == 'TestCustomer' can also be customer == 'TestCustomer' && custGroup == "TestGroup" and so forth.
I see 3 solutions:
- Generate the filtering part in the code and only insert it
- Create distinct rules per number of filters (1 rule for 1 filter, 1 rule for 2 filters etc)
- Send the filters to the template and generate it there directly
I tried some things but I couldn't get #3 to work. Supposing that there's a list of filters, how do I iterate over it and concatenate it to a full condition?
I'm open to other ideas to make this better.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论