drools

OptaPlanner's Drools rules don't fire with Spring Boot's devtools on the classpath so the score is zero

江枫思渺然 提交于 2019-12-21 05:30:09
问题 I got optaplanner working correctly with drools rules. "Suddenly", after some change I did, Optaplanner does not put my facts in the drools kSession anymore. I put some logging, and I see that optaplanner calls the getProblemFacts() method on my Solution, and this method returns a list with size > 0. I wrote a DRL rule to simply count the facts and log these counts (This rule is unit tested, and works well when I put the objects in the ksession myself). I am also convinced that optaplanner

Drools Fusion support for persistent, long running events

浪尽此生 提交于 2019-12-21 05:00:12
问题 I was considering using Drools Fusion to implement the following exemplary rules: if customer bought two same products within a year, she gets third for free for spending more than 200 USD in at most three consecutive transactions customer gets a discount when the customer is inactive for more than a year a reminder is generated a supervisor is notified when a single order is greater than an average order value within last six monhts ...and so on, these are just examples from the top of my

Drools: storing rules in database

女生的网名这么多〃 提交于 2019-12-20 08:52:31
问题 Currently I store all rules files on the file system (there are lots of versions of them) and load the different versions of them into memory at startup. I would like to change to storing my drools files in a database and was wondering if there is any solution or addon to Drools which facilitates this or should I craft my own? Thanks. 回答1: Yes, it can be done. All you need is the ability to get InputStream .In my case I use my own JPA class RulePackage to persist rule source as byte[], but

Validation in drools

笑着哭i 提交于 2019-12-20 05:45:10
问题 This is the second part of my drools validation question. First part has been already answered and proposed solutions has been implemented in my code. First Part This is my java class structure public class Person { List<PersonAddress> personAddress; List<FinanceDetails> financeDetails; } public enum AddressStatus { CURRENT, PREVIOUS; } public enum AddressType { PHYSICAL, POSTAL; } public enum AddressUseType { HOME, OFFICE; } public class PersonAddress{ Address address; AddressType type

In eclipse it is showing value 1.8 is not a valid language level

痴心易碎 提交于 2019-12-19 03:45:12
问题 I am using drools project in eclipse luna, java 1.8, drools 5.4.0. When i am opening drools file it is showing value '1.8' is not a valid language level. what should i do? 回答1: Late answer but posting anyway hoping it'll help someone. Drop down the compliance level to Java7: Project Properties> Java Compiler and Tick "Enable Project specific settings" Select compiler compliance level to 1.7. If your project is faceted may need to drop down the facet version as well. Project Properties>

Drools 简单应用实例1

女生的网名这么多〃 提交于 2019-12-18 19:11:50
Drools是一个基于java的规则引擎,开源的,可以将复杂多变的规则从硬编码中解放出来,以规则脚本的形式存放在文件中,使得规则的变更不需要修正代码重启机器就可以立即在线上环境生效。 1、Drools语法 开始语法之前首先要了解一下drools的基本工作过程,通常而言我们使用一个接口来做事情,首先要穿进去参数,其次要获取到接口的实现执行完毕后的结果,而drools也是一样的,我们需要传递进去数据,用于规则的检查,调用外部接口,同时还可能需要获取到规则执行完毕后得到的结果。在drools中,这个传递数据进去的对象,术语叫 Fact对象。Fact对象是一个普通的java bean,规则中可以对当前的对象进行任何的读写操作,调用该对象提供的方法,当一个java bean插入到workingMemory中,规则使用的是原有对象的引用,规则通过对fact对象的读写,实现对应用数据的读写,对于其中的属性,需要提供getter setter访问器,规则中,可以动态的往当前workingMemory中插入删除新的fact对象。 规则文件可以使用 .drl文件,也可以是xml文件,这里我们使用drl文件。 规则语法: package :对一个规则文件而言,package是必须定义的,必须放在规则文件第一行。特别的是,package的名字是随意的,不必必须对应物理路径

Retrieving facts of a specific type from working memory

╄→гoц情女王★ 提交于 2019-12-18 04:54:16
问题 Instead of retrieving all facts i need to retrieve specific type of facts from working memory. i learnt that i can retrieve all the facts from working memory as below. drools.getWorkingMemory().getWorkingMemoryEntryPoint("Stream").getObjects(); Please provide some pointers to retrieve specific type of objects from working memory. 回答1: Instead of using the getObjects() method you could use a query. Queries are like rules without RHS: query "getObjectsOfClassA" $result: ClassA() end You can use

Drools 6: add rules to a running KieSession

删除回忆录丶 提交于 2019-12-18 03:46:52
问题 till now I couldn't figure out the best way (meaning with minimal overhead) to add rules to a running KieSession in Drools 6.0.0 AND still keeping my facts in KieSession. In Drools 5 the KSession was updated when KBase was changed, but the same seems not be true for Drools 6 since my rules are not created in the KieBase. Is there a way to do it without replacing whole KieModules or Jars in the KieFileSystem. I think there should be an easy way to it. Do you guys have an idea? Regards 回答1: Yes

How to achieve below objective in drools

筅森魡賤 提交于 2019-12-14 03:23:17
问题 I am trying to do below things. Plesse check. rule "new rule" salience -101 dialect "mvel" when $pricingLineItem : PricingLineItem( $ackId : ackId, $prefix : prefix ) $baseUpChargeConfig : BaseUpChargeConfig( $baseOptionId : baseOptionId, prefix == $prefix ) $pricingOptionType : PricingOptionType( ackId == $ackId, $optionId : optionId, $optionValue : optionValue ) $baseOptionConfig : BaseOptionConfig( bOptionValue == $optionValue, bOptionCode == $optionId ,id == $baseOptionId ) then

No DRL files found for the KieBase, using kmodule.xml

半腔热情 提交于 2019-12-14 03:17:25
问题 I'm developing a Maven project using java and Drools 6.2.0, and I'm trying to "bind" a certain DRL file to a KieBase through the kmodule.xml file, but I keep getting the error WARN org.drools.compiler.kie.builder.impl.AbstractKieModule - No files found for KieBase when running the project. I think I've configured everything the right way, as shown in the documentation (Chapter 4.2.2 - Overview - Build, Deploy, Utilize and Run - Building), but can't see where is my mistake. In this project, I