Chapter 6. Example projects and business assets in Decision Central
Decision Central contains example projects with example business assets that you can use as a reference for the rules or other assets that you create in your own Red Hat Decision Manager projects. Each sample project is designed differently to demonstrate decision management or business optimization assets and logic in Red Hat Decision Manager.
The following example projects are available in Decision Central:
- Mortgages: (Decision management) Example loan approval process using decision assets. Determines loan eligibility based on applicant data and qualifications.
- Employee_Rostering: (Business optimization) Example employee rostering optimization using decision and solver assets. Assigns employees to shifts based on skills.
- OptaCloud: (Business optimization) Example resource allocation optimization using decision and solver assets. Assigns processes to computers with limited resources.
6.1. Accessing example projects and business assets in Decision Central Copy linkLink copied to clipboard!
You can use the example projects in Decision Central to explore example business assets as a reference for the rules or other assets that you create in your own Red Hat Decision Manager projects.
Prerequisites
- Decision Central is installed and running. For installation options, see Planning a Red Hat Decision Manager installation.
Procedure
In Decision Central, go to Menu
Design Projects and click Try Samples. If a project already exists, click the three vertical dots in the upper-right corner of the Projects page and click Try Samples.
- Review the descriptions for each sample project to determine which project you want to explore. Each sample project is designed differently to demonstrate decision management or business optimization assets and logic in Red Hat Decision Manager.
- Select one or more sample projects and click Ok to add the projects to your space.
- In the Projects page of your space, select one of the new example projects to view the example assets for that project.
- Select each example asset to explore how the project is designed to achieve the specified goal or workflow.
In the upper-right corner of the project Assets page, click Build to build the sample project or Deploy to build the project and then deploy it to Decision Server.
To review project deployment details (if applicable), go to Menu
Deploy Execution Servers.
6.2. Executing rules Copy linkLink copied to clipboard!
After you identify example rules or create your own rules in Decision Central, you can build and deploy the associated project and execute rules locally or on Decision Server to test the rules.
Prerequisites
- Decision Central and Decision Server are installed and running. For installation options, see Planning a Red Hat Decision Manager installation.
Procedure
-
In Decision Central, go to Menu
Design Projects and click the project name. In the upper-right corner of the project Assets page, click Deploy to build the project and deploy it to Decision Server. If the build fails, address any problems described in the Alerts panel at the bottom of the screen.
For more information about deploying projects, see Packaging and deploying a Red Hat Decision Manager project.
Create a Maven or Java project outside of Decision Central, if not created already, that you can use for executing rules locally or that you can use as a client application for executing rules on Decision Server. The project must contain a
pom.xmlfile and any other required components for executing the project resources.For example test projects, see "Other methods for creating and executing DRL rules".
Open the
pom.xmlfile of your test project or client application and add the following dependencies, if not added already:-
kie-ci: Enables your client application to load Decision Central project data locally usingReleaseId -
kie-server-client: Enables your client application to interact remotely with assets on Decision Server -
slf4j: (Optional) Enables your client application to use Simple Logging Facade for Java (SLF4J) to return debug logging information after you interact with Decision Server
Example dependencies for Red Hat Decision Manager 7.2 in a client application
pom.xmlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow For available versions of these artifacts, search the group ID and artifact ID in the Nexus Repository Manager online.
NoteInstead of specifying a Red Hat Decision Manager
<version>for individual dependencies, consider adding the Red Hat Business Automation bill of materials (BOM) dependency to your projectpom.xmlfile. The Red Hat Business Automation BOM applies to both Red Hat Decision Manager and Red Hat Process Automation Manager. When you add the BOM files, the correct versions of transitive dependencies from the provided Maven repositories are included in the project.Example BOM dependency:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For more information about the Red Hat Business Automation BOM, see What is the mapping between Red Hat Decision Manager and the Maven library version?.
-
Ensure that the dependencies for artifacts containing model classes are defined in the client application
pom.xmlfile exactly as they appear in thepom.xmlfile of the deployed project. If dependencies for model classes differ between the client application and your projects, execution errors can occur.To access the project
pom.xmlfile in Decision Central, select any existing asset in the project and then in the Project Explorer menu on the left side of the screen, click the Customize View gear icon and select Repository Viewpom.xml. For example, the following
Personclass dependency appears in both the client and deployed projectpom.xmlfiles:<dependency> <groupId>com.sample</groupId> <artifactId>Person</artifactId> <version>1.0.0</version> </dependency>
<dependency> <groupId>com.sample</groupId> <artifactId>Person</artifactId> <version>1.0.0</version> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you added the
slf4jdependency to the client applicationpom.xmlfile for debug logging, create asimplelogger.propertiesfile on the relevant classpath (for example, insrc/main/resources/META-INFin Maven) with the following content:org.slf4j.simpleLogger.defaultLogLevel=debug
org.slf4j.simpleLogger.defaultLogLevel=debugCopy to Clipboard Copied! Toggle word wrap Toggle overflow In your client application, create a
.javamain class containing the necessary imports and amain()method to load the KIE base, insert facts, and execute the rules.For example, a
Personobject in a project contains getter and setter methods to set and retrieve the first name, last name, hourly rate, and the wage of a person. The followingWagerule in a project calculates the wage and hourly rate values and displays a message based on the result:Copy to Clipboard Copied! Toggle word wrap Toggle overflow To test this rule locally outside of Decision Server (if desired), configure the
.javaclass to import KIE services, a KIE container, and a KIE session, and then use themain()method to fire all rules against a defined fact model:Executing rules locally
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To test this rule on Decision Server, configure the
.javaclass with the imports and rule execution information similarly to the local example, and additionally specify KIE services configuration and KIE services client details:Executing rules on Decision Server
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the configured
.javaclass from your project directory. You can run the file in your development platform (such as Red Hat JBoss Developer Studio) or in the command line.Example Maven execution (within project directory):
mvn clean install exec:java -Dexec.mainClass="com.sample.app.RulesTest"
mvn clean install exec:java -Dexec.mainClass="com.sample.app.RulesTest"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example Java execution (within project directory)
javac -classpath "./$DEPENDENCIES/*:." RulesTest.java java -classpath "./$DEPENDENCIES/*:." RulesTest
javac -classpath "./$DEPENDENCIES/*:." RulesTest.java java -classpath "./$DEPENDENCIES/*:." RulesTestCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Review the rule execution status in the command line and in the server log. If any rules do not execute as expected, review the configured rules in the project and the main class configuration to validate the data provided.