Task 2: Orchestrating the rules

You create a ruleflow to set the sequence in which the rules run.

About this task

The ruleflow provides a way to set the order in which the rule engine processes rules. In Rule Designer, you use a ruleflow to orchestrate rules.

Diagram shows the use of a ruleflow to orchestrate rules.

Step 1: Creating rule packages

Before you define a ruleflow, you must organize your rules into packages that contain related rules. In this step, you create two rule packages, and then define the ruleflow for the packages.

Procedure

  1. In the Operation Map of Rule Designer, click Add rule package.
    Tip: You can also right-click the my decision service/rules folder in the Rule Explorer and click New > Rule Package.
  2. In the New Rule Package wizard, enter validation in the Package field, and then click Finish.

    The validation rule is added to my decision service.

  3. Repeat steps 1 and 2 to create an eligibility rule package.

Results

Your rule project now contains two rule packages in which you can store rules:

Image shows the new rule packages in the Rule Explorer

Step 2: Creating the ruleflow diagram

You design a ruleflow that creates a logical connection between the validation and eligibility rule packages. A ruleflow is a diagram that consists of several rule tasks that are connected by logical links. A ruleflow shows the sequence for running business rules.

Procedure

  1. In the Operation Map view, click Add ruleflow.
    You can also right-click the my decision service/rules folder in the Rule Explorer and click New > Ruleflow.
  2. In the New Ruleflow wizard, ensure that the Source folder field is set to /my decision service/rules, and that the Package field is empty.
  3. In the Name field, enter miniloan.
  4. Click Finish.
    The ruleflow editor opens. You now construct a ruleflow in which you specify how tasks are related. In other words, how, when, and under what conditions rules are run.
    Tip: By default, the ruleflow opens in the New Ruleflow Editor. If you want to use the legacy editor, right-click the ruleflow in the Rule Explorer and click Open With > Legacy Ruleflow Editor. For the differences between the editors, see Comparing ruleflow editors.
  5. Click Create a start node "", and then click in the ruleflow editing window.
  6. Click Create an end node "", and then click in the ruleflow editing window.

    You now have a start node and an end node for your ruleflow.

Step 3: Defining rule tasks

You create rule tasks in the ruleflow diagram, and then you create the transitions between the packages.

Procedure

  1. In the Ruleflow Editor palette, click Create a rule task Rule task button, and then click inside the ruleflow diagram.
  2. Make sure that the new rule task is still selected. In the Properties view on the Rule Task page, give the rule task a name by typing validation in the ID field.
  3. Select the validation rule task in the ruleflow diagram, and in the Properties view, click Rule Selection, and then click Edit.
  4. In the Select Rules dialog, select the validation rule package. Use the arrow to move the package to the panel on the side, and then click OK.

    All the rules in the validation rule package are now in the rule task.

  5. In the Properties view, click Rule Task, and then select Fastpath for Algorithm if it is not already selected.
  6. In the same way that you created the validation rule task, add another rule task named eligibility that uses the eligibility rule package.
  7. Click Create a transition "" and create the following transitions (shown as arrows) by clicking the first item, and then clicking the second item:
    1. Connect the start node to the validation task.
    2. Connect the validation task to the eligibility task.
    3. Connect the eligibility task to the end node.
    4. Connect the validation task to the end node.
  8. Click Layout All Nodes "" to format the ruleflow diagram.
  9. Click Create a transition "" again to release the transition tool.
  10. Save your work.

    The ruleflow diagram shows errors on transitions to indicate that conditions are missing:

    Image shows errors in the ruleflow.

Step 4: Defining the main transition

You set a transition condition so that the rules in the eligibility package are run only when data is validated.

Procedure

  1. Click the transition from validation to eligibility.

    The Properties view opens and shows the condition for this transition.

    Tip: If you cannot see the Properties view, click Window > Show View > Properties to open the Properties view.
  2. In the Properties view, enter data approved in the Label field.
  3. Ensure that Use BAL for transition condition is selected.
    The Business Action Language (BAL) is the language in which you write your conditions.
  4. Click in the text area, and then press Space to display the Content Assist box. Double-click the items to form the following statement: 'the loan' is approved
    Tip: You can also enter the statement directly in the text area.

    The Properties view looks as follows:

    Image shows the condition page in the properties view.

    The transition from validation to the end node is automatically set to else.

  5. Save the changes.

    Your ruleflow now looks like the following diagram:

    Ruleflow diagram

Step 5: Defining the final action

You define a final action to display a message in the console that indicates the status of the loan at the end of a rule run.

Procedure

  1. Click the end node.
  2. In the Properties view, in the Final Action section, ensure Use BAL for action is selected.
  3. Click in the text area, and press Space to display the Content Assist box. Enter the following final action:

    print the approval status of 'the loan' ;

    You must add a semicolon (;) to the end of the line.

  4. Save your work and close the ruleflow editor.

Step 6: Binding the ruleflow

To use the ruleflow at run time, you must bind the ruleflow to the decision operation.

Procedure

  1. In the Operation Map view, click Bind ruleflow.
  2. In Decision Operation Overview, select Use main ruleflow in the Ruleflow section.
  3. Click <choose a ruleflow> and select my decision service/rules/miniloan.
  4. Click OK.
  5. Save your work and close the decision operation editor.

What to do next

You now have a ruleflow for your rule project. In the next task, you write an action rule.