drools

ruleflow-group vs agenda-group in Drools 6.5

假如想象 提交于 2019-12-11 01:53:41
问题 I am trying to create two independent groups of rules in Drools 6.5 and I can't figure out what's the usecase for the ruleflow-group and agenda-group strategies. They both seem similar. 回答1: Reading the documentation ... 2.6.4. RuleFowGroup and AgendaGroups are merged These two groups have been merged and now RuleFlowGroup's behave the same as AgendaGroups. The get methods have been left, for deprecation reasons, but both return the same underlying data. When jBPM activates a group it now

Drool rules using cron expression?

纵饮孤独 提交于 2019-12-11 01:17:35
问题 I have one requirement that i want to fire rule only for weekdays.i have some rule like smoke, temperature, motion.can you suggest me how i can make rule as per my requirement.please provide me some example. Is there any better way to fire rules based on time other then cron? 回答1: You can fire rule on weekdays or weekends , same requirement i have faced , found some solution. you just fallow steps: DRL File: package com.javacodegeeks.drools; import java.text.DateFormat; import java.text

Test Event expiration in Drools Fusion CEP

风流意气都作罢 提交于 2019-12-11 01:06:39
问题 Ciao, I have tested in several ways, but I'm still unable to test and verify the Event expiration mechanism in Drools Fusion, so I'm looking for some little guidance, please? I've read the manual and I'm interested in this feature: In other words, one an event is inserted into the working memory, it is possible for the engine to find out when an event can no longer match other facts and automatically retract it, releasing its associated resources. I'm using the Drools IDE in Eclipse, 5.4.0

Guvnor rules encoding

时间秒杀一切 提交于 2019-12-11 00:43:30
问题 I have a Drools decision table in Excel, and some of the strings used in rules have "Á" characters. When I build rules package in Guvnor from this decision table, I get wrong characters in rules source. For instance, in spreadsheet -> Área de Lazer|POR, in built drl file -> �rea de Lazer|POR Is there any way Guvnor can be tuned to support UTF-8 in this case? Had anyone faced similar issue? Thanks @Geoffrey De Smet Hi, I have added following code to ExcelParser.java: WorkbookSettings ws = new

Drools Queries. How are they evaluated and executed?

喜欢而已 提交于 2019-12-10 22:08:14
问题 I am evaluating Drools 6 in a proof of concept application. I am either misunderstanding how the queries in Drools work or I have not implemented something properly. Could someone explain this behavior to me: I have a rule that is supposed to act on validated records like this: rule "Patient Intake: Valid new Patients without a Medical History require a Review" ruleflow-group "Patient Intake" when $patient : Patient( status == PatientStatus.NEW ) not Invalid( value == $patient ) then modify(

`Unable to find class` error in Drools

微笑、不失礼 提交于 2019-12-10 21:34:23
问题 I'm trying to define a very simple function in Drools as below: import java.util.List; function int sumLengths(List<String> strings) { int counter = 0; for (String s : strings) counter += s.length(); return counter; } but it gives me error: Exception in thread "main" java.lang.RuntimeException: [ function sumLengths (line:5): Unable to resolve type List<String> while building function. java.lang.ClassNotFoundException: Unable to find class 'List<String>' ] any idea? 回答1: Perhaps it is an

开源规则引擎 Drools 学习笔记 之 -- 1 cannot be cast to org.drools.compiler.kie.builder.impl.InternalKieModule

China☆狼群 提交于 2019-12-10 21:02:51
直接进入正题 我们在使用开源规则引擎 Drools 的时候, 启动的时候可能会抛出如下异常: Caused by: java.lang.ClassCastException: cn.com.chengzi.drools.domain.cofing.DroolsAutoConfiguration$1 cannot be cast to org.drools.compiler.kie.builder.impl.InternalKieModule at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:184) at org.drools.compiler.kie.builder.impl.KieServicesImpl.newKieContainer(KieServicesImpl.java:172) at cn.com.chengzi.drools.domain.cofing.DroolsAutoConfiguration.kieContainer(DroolsAutoConfiguration.java:57) at cn.com.chengzi.drools.domain.cofing.DroolsAutoConfiguration$

How to define constant in jboss drools?

我是研究僧i 提交于 2019-12-10 20:39:39
问题 All I want to know that how to define contant variable in jboss drools rule. So, Admin has to change only one place to modify the configurable value. Thanks. 回答1: You´re able to define global variables within a rule. This variable can be filled via Java like this: public void init() { StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession(); String string = "foo"; // setGlobal 'string' as 'var' in rule ksession.setGlobal("var", string); } In the rule, this global can be

drools -规则语法

淺唱寂寞╮ 提交于 2019-12-10 18:24:55
文章结构 1. 基础api 2. FACT对象 3. 规则 4. 函数 1. 基础api 在 Drools 当中,规则的编译与运行要通过Drools 提供的各种API 来实现,这些API 总体来讲可以分为三类:规则编译、规则收集和规则的执行。完成这些工作的API 主要有KnowledgeBuilder、KnowledgeBase、StatefulKnowledgeSession、StatelessKnowledgeSession、、等,它们起到了对规则文件进行收集、编译、查错、插入fact、设置global、执行规则或规则流等作用 1.1 KnowledgeBuilder KnowledgeBuilder 在业务代码当中收集已经编写好的规则, 然后对这些规则文件进行编译, 最终产生一批编译好的规则包(KnowledgePackage)给其它的应用程序使用。KnowledgeBuilder 在编译规则的时候可以通过其提供的hasErrors()方法得到编译规则过程中发现规则是否有错误,如果有的话通过其提供的getErrors()方法将错误打印出来,以帮助我们找到规则当中的错误信息。 1.2 KnowledgeBase KnowledgeBase 是 Drools 提供的用来收集应用当中知识(knowledge)定义的知识库对象,在一个KnowledgeBase 当中可以包含普通的规则

小明历险记:规则引擎drools教程一

被刻印的时光 ゝ 提交于 2019-12-10 18:13:32
小明是一家互联网公司的软件工程师,他们公司为了吸引新用户经常会搞活动,小明常常为了做活动加班加点很烦躁,这不今天呀又来了一个活动需求,我们大家一起帮他看看。 小明的烦恼 活动规则是根据用户购买订单的金额给用户送相应的积分,购买的越多送的积分越多,用户可以使用积分来兑换相应的商品,我们这次活动的力度很大,肯定会吸引很多的用户参加,产品经理小王兴高采烈唾液横飞的对小明讲到。小明心想,又tm来这套,这次需求又要变更多少次呢?表面上还的配合,说赶紧把规则给我们吧,早点开发早点上线,小王说这次需求老简单啦,估计你们两个小时就搞定了,不信你看需求文档。 用户购买的金额和对应送多少积分的规则如下: 100元以下, 不加分 100元-500元 加100分 500元-1000元 加500分 1000元 以上 加1000分 小明一看,这需求果然简单呀,作为一个工作了两三年的程序员来讲,这不就是小case,半天搞定,送积分的心代码如下: public void execute() throws Exception { List<Order> orderList = getInitData(); for (int i=0; i<orderList.size(); i++){ Order order = orderList.get(i); if (order.getAmout() <= 100){