drools-fusion

Generate drools drl file by using java

安稳与你 提交于 2021-02-11 12:49:47
问题 I m trying to create the drools drl file using java programmatically by following method. I can able to create the below simple rules by simple rule by java program. rule "Demo_testing" when $employee : EmployeeModel( department contains "Accounts" ) then // And this in one working fine for me, but i need get the employee information from list. Like $employee : EmployeeModel( department contains "Accounts", role = "manager" ) from $employeeList I found the list on descriptor available in

How to return the value from Cosequence of drl file to java

谁说胖子不能爱 提交于 2021-02-05 07:54:08
问题 If rule matches then i am executing the java function in consequence of drl and i want that result of function in consequence to be returned back to the function which calls to execute the drl. 回答1: You need to make sure that the side effect of the rule is passed back to the caller. How you do this depends on your particular rule set and the objects you pass into it. One solution, for example, might be to change a value on an object you have in working memory. rule "Example rule changing a

Drools rule fire only for inserted event

点点圈 提交于 2020-01-25 08:59:08
问题 I have a multiple uses with each a sensor that sends pedometer data. I have a rule file that based on the macAddress, fires the rule: declare Steps @role(event) end declare User @role(fact) end rule "MAC" when User( $mac: macAddress ) from entry-point "entrySteps" then end rule "ACC STEPS RULE" extends "MAC" when accumulate( Steps( $s : steps , macAddress == $mac ) over window:time( 1h ) from entry-point "entrySteps"; $fst: min( $s ), $lst: max( $s ); $lst - $fst < 50 ) then System.out

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

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

How to describe this complex scene by cep?

喜夏-厌秋 提交于 2019-12-13 08:10:26
问题 This is my Event schema EventA (FieldA string, FieldB string, FiledC string) EventB (FieldD string, FieldE string) I want the query like: devide events into group window, group EventA by FieldA, FieldB ,group EventB by FieldE If events occured in this order: EventA -> EventA -> EventA -> EventB -> EventB ,and distinct( EventA.FieldC ) >= 3 ,and every EventB.FieldE equals every EventA.FieldB (join part),then generate a correlate event. The problem is that:the count of EventA (3) is for the

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

Drools Fusion support for persistent, long running events

六月ゝ 毕业季﹏ 提交于 2019-12-03 16:37:18
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 head All these rules can be easily expressed using Drools Fusion. However after creating a prototype and

Retrieving facts of a specific type from working memory

戏子无情 提交于 2019-11-29 07:09:45
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. 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 all the power of DRL language inside your queries to create really complex matching patterns. You can even