第7章 Example decisions in Red Hat Decision Manager for an IDE
Red Hat Decision Manager provides example decisions distributed as Java classes that you can import into your integrated development environment (IDE). You can use these examples to better understand decision engine capabilities or use them as a reference for the decisions that you define in your own Red Hat Decision Manager projects.
The following example decision sets are some of the examples available in Red Hat Decision Manager:
- Hello World example: Demonstrates basic rule execution and use of debug output
- State example: Demonstrates forward chaining and conflict resolution through rule salience and agenda groups
- Fibonacci example: Demonstrates recursion and conflict resolution through rule salience
- Banking example: Demonstrates pattern matching, basic sorting, and calculation
- Pet Store example: Demonstrates rule agenda groups, global variables, callbacks, and GUI integration
- Sudoku example: Demonstrates complex pattern matching, problem solving, callbacks, and GUI integration
- House of Doom example: Demonstrates backward chaining and recursion
For optimization examples provided with Red Hat Business Optimizer, see Getting started with Red Hat Business Optimizer.
7.1. Importing and executing Red Hat Decision Manager example decisions in an IDE
You can import Red Hat Decision Manager example decisions into your integrated development environment (IDE) and execute them to explore how the rules and code function. You can use these examples to better understand decision engine capabilities or use them as a reference for the decisions that you define in your own Red Hat Decision Manager projects.
Prerequisites
- Java 8 or later is installed.
- Maven 3.5.x or later is installed.
- An IDE is installed, such as Red Hat JBoss Developer Studio.
Procedure
-
Download and unzip the Red Hat Decision Manager 7.3.0 Source Distribution from the Red Hat Customer Portal to a temporary directory, such as
/rhdm-7.3.0-sources
. -
Open your IDE and select File
Import Maven Existing Maven Projects, or the equivalent option for importing a Maven project. -
Click Browse, navigate to
~/rhdm-7.3.0-sources/src/drools-$VERSION/drools-examples
(or, for the Conway’s Game of Life example,~/rhdm-7.3.0-sources/src/droolsjbpm-integration-$VERSION/droolsjbpm-integration-examples
), and import the project. -
Navigate to the example package that you want to run and find the Java class with the
main
method. Right-click the Java class and select Run As
Java Application to run the example. To run all examples through a basic user interface, run the
DroolsExamplesApp.java
class (or, for Conway’s Game of Life, theDroolsJbpmIntegrationExamplesApp.java
class) in theorg.drools.examples
main class.図7.1 Interface for all examples in drools-examples (DroolsExamplesApp.java)
図7.2 Interface for all examples in droolsjbpm-integration-examples (DroolsJbpmIntegrationExamplesApp.java)