|
Declarative rules
|
|
|
when “condition” then “consequence”
|
|
|
Facts
|
Domain model objects used by Drools to evaluate conditions and execute consequences
|
|
Can be loaded from a database
|
|
|
Stated: Provided to rules engine by the caller
|
|
|
Inferred: calculated based on the stated facts
|
|
|
Does persist: May be long lived
|
|
|
Working memory
|
|
|
Holds objects acted upon by business rules
|
|
|
Does not persist. Only lives while needed
|
|
|
Developer asserts 'facts' into 'working memory' and then tells engine to run rules. As the engine runs rules on the 'facts' in working memory the effect may result that the 'facts' change. The engine will run the rules again until no rules left to run.
|
|
|
LHS conditional elements
|
|
|
A list of constraints on facts (LHS)
|
|
|
Pattern: A pattern is zero or more constraints with optional binding.
|
|
|
RHS actions/consequences
|
|
|
An action executed by this rule if facts with the list of constraints are found in the working memory (RHS).
|
|
|
Business Central web interface
|
|
|
Technical rule editor - creates .drl file
|
|
|
Guided rule editor - creates .brl file
|
|
|
Decision table editor
|
|
|
DSL (Domain-Specific Language) natural language extensions
|
|
|
JBDS Drools perspective, rule resource wizard
|
|
|
Individual rule - creates .drl file
|
|
|
Rule package - creates .drl file
|
|
|
DSL (Domain-Specific Language) natural language extensions
|
|
|
Decision table
|
|
|
Spreadsheet or .csv file imported into JBDS project, or JBoss BRMS repository
|
|
|
In Business Central web interface
|
|
|
Red Hat Training
|
|
|
Authoring Rules for Red Hat JBoss BRMS - Student Workbook
|
|
Remember:
|
Rules are not called directly, and do not call other rules directly. Rules operate in response to facts only and are fired by the rule engine.
|
|
update(object, handle) or update(object)
|
|
|
Tell the engine that an object has changed
|
|
|
However if property change listeners are provided to the JavaBeans that are inserted into the engine, it is possible to avoid the need to call update when the object changes.
|
|
|
insert(new Something())
|
|
|
Place a new object into the working memory
|
|
|
retract(handle)
|
|
|
Removes an object from working memory (delete)
|
|
|
insertLogical(new Something())
|
|
|
Same as insert except that object retracted when no more facts to support truth of firing rule
|
|
Might be:
|
|
|
single field
|
|
|
inline "eval"
|
|
|
constraint group (several field constraints tied together)
|
|
|
Connected using symbols:
|
|
|
'
|
Comma
|
|
&&
|
Represents and. All patterns match.
|
|
||
|
Represents or. Either pattern matches.
|
|
Operators are typically mathematical
|
|
|
==
|
Equal to
|
|
>
|
Greater than
|
|
<
|
Less than
|
|
>=
|
Greater than or equal to
|
|
<=
|
Less than or equal to
|
|
What is forward chaining?
|
|
|
Can be described logically as repeated application of modus ponens (the when, then statements). Forward chaining is a popular implementation strategy for expert systems, business and production rule systems.
|
|
|
As a rule fires, it can change the objects in working memory.
|
|
|
Some rules should fire before others
|
|
|
Forward chaining is in the rule engines to decide which rules to fire in which order
|
|
|
Recursive: rules are executed when the LHS conditions are met. The actions may change facts, causing new rules to be fired.
|
|
|
Important to understand. Understanding forward chaining will help get the most out of the rule engine
|
|
Latin name of a very old and common form of propositional logic
|
|
"P implies Q; P is asserted to be true, so therefore Q must be true."
|
|
Consequence or action required
|
|
|
Sctions to be executed by the rule.
|
|
|
Never use use imperative or conditional code on RHS
|
|
|
Must be atomic
|
|
|
"when this, then do this," not "when this, maybe do this or this."
|
|
|
Typical actions
|
|
|
update
|
Indicates that an object has changed and rules may need to be reconsidered.
|
|
insert
|
inserts a new object in working memory
|
|
insertLogical
|
inserts a new object, but the object is automatically retracted when there are no more facts to support the truth of the rule.
|
|
retract
|
removes an object from working memory (delete)
|
Note to self :) I would like to colour code the boxes based on the following themes: Structural concepts Declarative rule concepts Definitions and Methods
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.