< Previous | Next >

Task 3: Authoring rules

You can now author rules using the vocabulary created at the beginning of the tutorial.

When developing a rule project, the developer writes the initial rules, designs rule templates, and organizes the folders used to manage the rules. Later, the business user writes and edits these rules in a web environment, though a developer might be asked to write more complex rules.

In this task, you first create an action rule, and then import the rules already prepared for you. In Rule Designer, you use the completion menu to write the following action rule that is based on the vocabulary that you created:

if
  the amount of 'the loan' is more than 1,000,000
then
   add "The loan cannot exceed 1,000,000" to the messages of 'the loan';
   reject 'the loan' ;

Time This task should take you about 15 to 30 minutes to complete.

Step 1: Create an action rule

The first rule that you are going to write rejects the loan if the requested amount is greater than 1,000,000.

To create an action rule:

  1. In Rule Designer, in the Author part of the Rule Project Map, click Add action rule.
    Tip: You can also right-click the validation package in the Rule Explorer and click New > Action Rule.
  2. In the Package field, type validation (or click Browse to select it) and in the Name field, name the rule maximum amount.
    New Action Rule wizard
  3. Click Finish.

    The Intellirule editor opens.

Step 2: Complete the action rule

You now use the code completion mechanisms of the Intellirule Editor to help you create the rule.

To complete the action rule:

  1. In the Intellirule editor, type if, and then press the space bar. The Content Assist box opens:
    Using the Content Assist box

    Select terms and phrases from the Content Assist box to build the following expression:

    the amount of 'the loan' is more than 1,000,000
  2. On the next line, type then, press the space bar, and then press Ctrl+Shift+space bar to activate the Tree Completer.
  3. In the Tree Completer box, type message in the field at the top to display only terms and phrases about messages:
    Using the Tree Completer box
  4. Double-click add <a string> to the messages of <a loan> to insert it, then use the Content Assist box to finish building the following expression:
    add "The loan cannot exceed 1,000,000" to the messages of 'the loan' ;
    Important:

    You must include a semicolon (;) at the end of the line.

  5. Press Esc after entering the semicolon, if you are still in the Content Assist box.
  6. Press Enter to create a new line, type a space, and write the following statement using the Content Assist box:
    reject 'the loan' ;
  7. Press Ctrl+Shift+F to format the rule.

    Your rule should now be:

    if
      the amount of 'the loan' is more than 1,000,000
    then
       add "The loan cannot exceed 1,000,000" to the messages of 'the loan';
       reject 'the loan' ;
  8. Save your work and close the Intellirule editor.

    For more information on using the rule editors, see Working with action rules.

Step 3: Import remaining rules

To complete the policy, you must add the rules that determine whether a borrower is eligible for a loan. For this tutorial, you import the eligibility rules into your rule project.

To import the remaining rules:

  1. Click File > Import.
  2. In the Import wizard, select General > File System, and click Next.
  3. In the From directory field, click Browse and select <InstallDir>/gettingstarted/DecisionServer/answer/miniloan-rules, and then click OK.
    Note:

    Ignore the message There are no resources currently selected for import. This is an Eclipse message prompting you to carry out the action you are about to perform.

  4. The miniloan-rules folder opens in one of the panes in the Import wizard. Expand the folder to miniloan-rules/rules and select the check box beside eligibility.
  5. Select the eligibility folder and make sure eligibility is highlighted, then clear the .rulepackage check box.
    Clearing .rulepackage
  6. In the Into folder field, click Browse, select my rule project, and then click OK.
  7. Select the Overwrite existing resources without warning option:
    Selecting Overwrite existing resources without warning
  8. Click Finish.

    The eligibility rules are added to your project in the Rule Explorer.

Step 4: View the imported rules

To view the rules that you imported:

  1. In the Rule Explorer, double-click the eligibility rules, and take a moment to look at them:
    minimum credit score

    Rejects the loan if the credit score is too low.

    minimum income

    Rejects the loan if the income is too low for the yearly repayments.

    repayment and score

    In a decision table, rejects the loan based on various values of the debt-to-income ratio and credit score.

    You use decision tables to represent rules that share conditions and actions. Each row in a decision table represents a rule. By placing your cursor over the number of a row, you can view the text of the corresponding rule as hover help.

    Note:

    Rows with no actions display a message warning you about invalid or incomplete rows. You can ignore these warnings because the only purpose of these rows is to fill gaps in the table. These rows are ignored when you run the project.

  2. Double-click the rules/miniloan ruleflow in the Rule Explorer to open it.
  3. In the Ruleflow Editor, double-click the eligibility task.
  4. In the Properties view, click the Rule Selection tab, and expand the eligibility package.
    Rules contained in the eligibility task

    By default, all the rules participate when the task is executed by the rule engine.

  5. Close the Ruleflow Editor.

You have created rules and defined the flow to execute them. You have used ruleset parameters as data to be processed by the ruleset. In the next task, you create an Excel file in which you enter scenarios to test your rules.

< Previous | Next >