Task 1: Creating a ruleflow

You create a ruleflow and define its structure.

About this task

You start by importing the ruleflow tutorial project, and running it to view its output without a ruleflow. Then, you add a ruleflow to the project and define its structure.

Step 1: Importing and running the ruleflow tutorial

Before adding the ruleflow, you must import the start projects for the ruleflow tutorial.

Before you begin

If you have imported the answer projects for the tutorial, close or delete them before importing the start projects.

Procedure

  1. Open the Samples Console in the en-US (American English) locale (see Running samples from the Samples Console).
  2. In the Samples and Tutorials view, navigate to Rule Designer > Tutorials > Creating your first ruleflow > start, and then click Import projects.

    This selection imports the Java™ project carrental-xom and the rule project ruleflow-rules-start. You can view these projects in the Rule Explorer.

  3. On the Run menu, click Run Configurations.
  4. In the Run Configurations dialog, select Decision Operation > ruleflow-start-configuration, and then click Run.

Results

The Console view displays the output, which shows how the rule applies to customer Alice Boorman:

set price of standard offer for the Rental Agreement for Alice Boorman (Nov 19, 1992)
Add surcharge of 2 for PEI
Add surcharge of 25 for CDW [FullSize,Luxury,SportUtility,Minivan]
In Rhode Island state, customer must be 25 or more to rent a car

This customer cannot rent a car because of age restrictions in the state of Rhode Island. However, the rules still compute prices for the customer. In this tutorial, you create a ruleflow that only applies the pricing rules if the customer passes the eligibility rules.

Step 2: Creating a new ruleflow

You can now add the ruleflow to a new rule project package.

Procedure

  1. Make sure that you are in the Rule perspective. To open it, go to the Window menu, and then click Open Perspective  > Other > Rule.
  2. In the Rule Explorer, select the rule project ruleflow-rules-start, and then clickNew Rule Package button New Rule Package on the New Rule Project Item toolbar.
  3. Create a package named flow, and then click Finish.
  4. Click New Ruleflow button New Ruleflow on the toolbar.
  5. In the New Ruleflow wizard, enter the following details:
    • In the Package field, make sure that the value is flow.
    • In the Name field, type carreservation.
  6. Click Finish.

Results

By default, the ruleflow opens in the New Ruleflow Editor. You must now define the ruleflow structure on the Diagram page of this editor.
Tip: If you want to use the legacy editor, right-click the ruleflow in the Rule Explorer and click Open With > Legacy Ruleflow Editor.

Step 3: Defining the ruleflow structure

You define a ruleflow structure by adding ruleflow elements to the ruleflow and defining the relationship between them. The ruleflow that you create in this tutorial has a start node, an end node, and two rule tasks with transitions between them.

Procedure

  1. In the Ruleflow Editor palette, click Start node button Create a start node, and then click inside the Diagram page.

    The ruleflow diagram now includes a start node.

  2. In the Ruleflow Editor palette, click Rule task button Create a rule task, and then click inside the ruleflow diagram.
  3. 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 eligibility in the Label field.
  4. In the same way that you created the eligibility rule task, add another rule task named pricing to the ruleflow diagram.
  5. In the Ruleflow Editor palette, click End node button Create an end node, and then click inside the Diagram page.

    You can have more than one end node in a ruleflow.

  6. Create transitions between the elements in the order they were added:
    1. In the Ruleflow Editor palette, click Transition button Create a transition. You can now create multiple transitions in the diagram.
    2. Click the start node, and then click the eligibility rule task.
    3. Click the eligibility rule task, and then click the pricing rule task.
    4. Click the pricing rule task, and then click the end node.
    5. To disable the transition creation mode in the Ruleflow Editor palette, click Transition button Create a transition again.
  7. To adjust the ruleflow diagram layout, go to the Ruleflow Editor toolbar and click Layout All Nodes button Layout All Nodes.

Results

The ruleflow now has the following structure.

Diagram of the ruleflow at this stage

The warning icons indicate that you must define the rule tasks.

What to do next

In the next task, you define the eligibility rule task.