< Previous | Next >

Task 1: Designing the main rule project in the decision service

You create a vocabulary to write business rules. You use Rule Designer to create the vocabulary from the object model in the Miniloan application.

About this task

As a developer, you want to create a business rule vocabulary that business users can use to write and edit rules. The vocabulary must consist of terms that are familiar to the business user. The process of creating a vocabulary is called verbalization.

You create a business object model (BOM) that is based on an object model in a Java™ project. The following diagram shows how the classes and members of the BOM relate to the vocabulary that is used by the business users.

Diagram shows the design of the business object model.

Step 1: Starting Rule Designer and importing the getting started projects

About this task

You can access the Samples Console from Rule Designer. The Samples Console contains the getting started projects.

Rule Designer is an Eclipse development environment for business rule applications. You can develop both rule projects and Java projects in this environment.

The rule project that you import for this tutorial is available in only American English (en_US). You must start Rule Designer in American English to use the rule project. When you start the Samples Console from the Windows Start menu, Rule Designer is displayed by default in American English.

Procedure

  1. From the Start menu, click All Programs > <package_group> > Sample Server > Samples Console (en_US). If necessary, close the Eclipse welcome page to view the Samples Console. In the file path, package_group refers to the package group specified in IBM® Installation Manager during installation. The default package group is IBM Operational Decision Manager V8.9.0.

    The Workspace Launcher window shows your default workspace. If the workspace is not empty, switch to an empty workspace.

  2. If you want to create a workspace, change the name of the workspace in the Workspace Launcher, and click OK.
    Tip: If you do not see the Workspace Launcher window when you start Rule Designer, you can change the workspace in the editor by clicking File > Switch Workspace.
  3. Close the Welcome view and restore the perspective. The Samples Console perspective opens on the Samples and Tutorials view, which contains the samples and tutorials to discover the components in Operational Decision Manager. You can view instructions and import projects for the samples and tutorials.
  4. Under Getting Started, expand Decision Server, and under start, click Import projects.

    Rule Designer imports the projects for the getting started tutorial, and switches to the Rule perspective "".

Results

The Rule perspective contains various views that you learn about in this tutorial, such as the Rule Explorer view and the Decision Service Map view.

The Rule Explorer view now contains the miniloan-server-webapp and miniloan-xom projects:

miniloan-server
From this project, you retrieve the hardcoded rules for the Miniloan web application. Inspect the rules in the validateWithJava method of the miniloan-server-webapp/src/miniloanweb/MiniloanBean.java class to understand the rules that Miniloan uses to assess loan requests.
miniloan-xom

This Java project contains the Miniloan application. The miniloan-xom contains the miniloan package that contains the Borrower and the Loan Java classes.

Notice the Rule Project Map tab. When you work with a decision service, the Rule Project Map tab shows the Decision Service Map, which contains the different steps for making and deploying a decision service. You can use the Decision Service Map to guide you through the decision service process. If the Decision Service Map view is not displayed, click Window > Show View > Rule Project Map to open it.

The following image shows the Rule Project Map tab.

Image shows the Rule Project Map tab
Note: You can ignore the warnings that are displayed about the project.

Step 2: Creating the main rule project for the decision service

About this task

In Rule Designer, you store the business logic of your application in a decision service. A decision service is organized into a main rule project and optional standard rule projects to split the logic of your business into several parts. Each rule project can contain rule artifacts, a business object model (BOM), a vocabulary, and a reference to the execution object model (XOM). In a rule project, you can manage, build, and debug the items that comprise the business logic of your application.

In this tutorial, you create only a main rule project to simplify the logic of the application.

Procedure

  1. Ensure that you are in the Rule perspective "". To switch to the perspective, click Window > Open Perspective > Other > Rule, and then click OK.
  2. In the Decision Service Map view, click Create main rule project.
  3. Ensure that Main Rule Project is selected under Decision Service Rule Projects, and click Next.
  4. In the Project name field, type my decision service, and then click Finish.

    The Rule Explorer displays my decision service. The rule project contains empty folders. You use the rules and bom folders to store your rules and BOM.

Step 3: Importing the XOM into your rule project

About this task

You import an execution object model (XOM) from the Miniloan Java project.

Procedure

  1. In the Rule Explorer view, click my decision service.

    The Decision Service Map displays the steps to follow to design your rule project.

  2. In the Decision Service Map view, click Import XOM.
  3. In the Import XOM dialog, select Java execution object model and click OK.
  4. In the Projects tab, select miniloan-xom and click OK:
    Image shows the selection of miniloan-xom in the Java Execution Object Model.

Step 4: Creating the business object model

About this task

Before you can create and edit business rules, you must define a business object model (BOM). You can create a BOM manually, or create it automatically by parsing your execution object model (XOM).

You use Rule Designer to parse the Java classes in the XOM and create the BOM from their methods and properties. Then, you can write rules that use the verbalized terms that are contained in the BOM.

Procedure

  1. In the Decision Service Map view, click Create BOM.
    Tip: You can also right-click the bom folder in the Rule Explorer and click New > BOM Entry.
  2. In the New BOM Entry wizard, in the Name field, enter miniloan.
  3. Ensure that Create a BOM entry from a XOM is selected, and then click Next.
  4. In the Choose a XOM entry field, click Browse XOM, select platform:/miniloan-xom, and then click OK.
  5. Under Select classes, select the miniloan package. Selecting the package selects all the classes in the package.
    Image shows the miniloan package in the BOM Entry dialog.
    The miniloan package contains the Borrower and Loan classes.
  6. Click Next.
  7. On the BOM Verbalization page, select the All Methods check box. The All Methods check box ensures that all the methods are verbalized in addition to the elements already selected.
    Selecting the All Methods check box.
  8. Click Finish.
  9. In the Rule Explorer, open the bom folder and double-click miniloan.

    In the BOM Editor, expand the miniloan entry:

    Image shows the expanded miniloan BOM entry.

    In your BOM, you now have two classes that are equivalent to the classes in the XOM: Borrower and Loan.

  10. Double-click the Loan class to open it in the BOM editor.

    All Java members and methods are converted and assigned a default verbalization.

  11. In the Members section, double-click addToMessages(String).

    The BOM editor switches to the Member tab. In the Member Verbalization section, you can see that the verbalization of this method is add a string to the messages of a loan:

    Image shows the method verbalization in the Member Verbalization section

    The verbalization is also used in the Rule Editor.

  12. Close the miniloan tab to close the BOM Editor:
    Image shows how to close the BOM Editor.

Step 5: Defining a decision operation

About this task

A ruleset is an executable package that includes rule artifacts and other elements. It contains a set of rules that can be run by the rule engine. You must define the contents of the ruleset and the parameters that allow the client application to exchange information with the ruleset. A decision operation includes all the settings that are needed to define the contents of the ruleset and its parameters.

Procedure

  1. In the Decision Service Map view, click Add decision operation.
  2. In the New Decision Operation wizard, in the Name field, type my operation.
  3. Click Next.
  4. Ensure my decision service is selected in the source rule project dialog, and then click Finish.
  5. In the Decision Service Map view, click Go to operation map.
  6. Select my decision service > deployment > my operation.dop, and click OK.
    Image shows the my decision service folder.

Results

The operation map opens.

Image shows the operation map.

Step 6: Designing the operation signature

About this task

Client applications interact with a ruleset by using input and output parameters. These parameters are defined in the signature of a decision operation. They are equivalent to Java method parameters. They are references that you can use when you write rules.

To enable a decision to be made on the status of a loan, you create ruleset parameters for the borrower and the loan:

  • The borrower is an IN parameter. The value of the IN parameter is provided as input to the ruleset on execution.

  • The loan is an IN_OUT parameter. The value of the IN_OUT parameter is provided as input to the ruleset on execution, and can be modified by the ruleset and provided as output when execution completes.

Procedure

  1. In the Operation Map view, click Add variable set.
  2. In the New Variable Set wizard, in the Name field, type my parameters.
  3. Click Finish.
  4. Define the borrower parameter:
    1. Click Add. A new row is displayed with default values.
    2. In the Name column, type borrower.
    3. In the Type column, click the ... button, and then double-click the Borrower type in the Matching types box.

      The miniloan.Borrower type is displayed in the Type column.

    4. In the Verbalization column, enter the borrower.
  5. Define the loan parameter:
    1. Click Add.
    2. In the Name column, type loan.
    3. In the Type column, click the ... button, and then double-click the Loan type in the Matching types box.

      The miniloan.Loan type is displayed in the Type column.

    4. In the Verbalization column, enter the loan.
    5. Save your work.

      Your variable set is shown as follows:

      Image shows the variable set.
    6. Close the my parameters variable set editor.
  6. In the Operation Map view, click Bind variables.
  7. Expand my parameters in the Eligible variables part of the Decision Operation Signature editor:
    Image shows eligible variables.
    1. Drag borrower to the input parameters.
    2. Drag loan to the input-output parameters.

    The decision operation signature is displayed as follows:

    Image shows the parameters for the decision operation signature.
  8. Save your work, and close the my operation editor.

What to do next

You now have a rule project with a vocabulary, a variable set, and a decision operation with a signature. The design of your rule project is complete. Before you can write the business rules in Rule Designer, you must orchestrate how your rules are run. In the next task, you use a ruleflow to specify the order in which the rules are run.

< Previous | Next >