SimpleRulesEngine Core
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Component created
Component changed
Component body
Simple Rules Engine Core
This module contains the functionality and hooks for a programmer to embed a Decision Support tool having a small set of user managed expert rules into their custom Drupal 7 application. This is the core module of the suite which currently consists of the following separate modules.
- Simple Rules Engine Core this module
- Simple Rules Engine UI a module that provides a user interface into the core
- Simple Rules Engine Demo a module that demonstrates creation of a decision support application
Requirements
- Drupal 7.x
- PHP 5.x
- MySQL 5.x
Simple Rules Engine Core
This contains the hooks for a programmer to embed a decision support system into their application.
Key Concepts
There are two tiers of configurable expressions in the system. Each has its own syntax.
User Level Rule Expressions
The top tier rules are intentionally restricted to operate only on boolean measures. This type of expression is more accessible to non-technical subject matter experts and is simpler to verify for correctness. A rule is considered triggered if its trigger criteria evaluates to a True result. The functions supported in the rule trigger criteria expression include the following.
- AnyFlagTrue takes a collection of flags and evaluates to True if any of them are True.
- AllFlagsTrue takes a collection of flags and evaluates to True only if all of them are True.
- AllFlagsFalse takes a collection of flags and evaluates to True only if all of them are False.
- AllFlagsNull takes a collection of flags and evaluates to True only if all of them are Null.
A top level rule which is triggered is considered to have a True value. Top level rules can reference other top level rules and flags.
The user level rules are maintained in the simplerulesengine_rule database table.
Measure Level Expressions
Measures can have scalar values or be collections of values. The only measure that a user level rule will process is one that returns a boolean value. The boolean measures are sometimes called "flags" for convenience.
Flags can have any of the following three values:
- Null to indicate that no values is known.
- False to indicate that value is known as False.
- True to indicate that no values is known as True.
All measures can have the value Null if no value is known. The expression syntax for measures is rich with arbitrary logic and arithmetic support.
A measure expression can reference other measure expressions but never a top level rule expression.
The measure expressions are maintained in the simplerulesengine_measure database table.
Recommended Rulebase Name Prefixes
Its always a good idea to have a convention for naming your rules; that convention will be highly influenced by your specific context. The following are some basic prefixes that seem to work well.
- IS_ for boolean values where subject is of a particular kind (True) or is not of a particular kind (False)
- HAS_ for boolean values where subject has something (True) or does not have something (False)
- GIVE_ for boolean values where something is given (True) or not given (False)
Consider meaningful suffixes for your names too. For example, an input that has a persons weight might be called WEIGHT_KG to indicate its purpose and the units employed. Don't be bullied into being lax, naming consistency is not the mark of a small mind.
Built-in Tests
Go to the YOURSITE/simplerulesengine/runtests
URL.
Contributing
This suite has been created by SAN Business Consultants for use by Drupal developers in their open source projects. Please contact Frank or Andrew at SAN Business Consultants if you would like to contribute to this project. Thanks!