< Previous | Next >

Task 1: Creating a BOM entry

You import a Java™ project, and create a rule project and a business object model (BOM).

About this task

In this tutorial, you follow a bottom-up approach to creating a vocabulary in Rule Designer. This means that you use existing application objects as the basis for your vocabulary. For this purpose, we have provided a Java project that models car rental concepts.

You do the following:

  • Import the Java project to be used as the execution object model.
  • Create a rule project that references the XOM.
  • Create a business object model (BOM) entry in the rule project and verbalize it by default.
Note:

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

You start by importing the Java project into your Eclipse workspace:

Procedure

  1. Open the Samples Console in the en_US (American English) locale (see Running samples from the Samples Console).
  2. Import the Java project:

    You use this Java project as the XOM, which serves as the basis of the BOM in rule editing.

    To store and organize the BOM and rule artifacts, you need to create a rule project.

    1. Switch to the Java perspective.
    2. On the File menu, click Import.
    3. In the Import wizard, open the General folder, select Existing Projects into Workspace, and then click Next.
    4. On the next page of the Import wizard, click Browse and select carrental-xom from the shared directory:

      <InstallDir>/studio/tutorials/shared

    5. Make sure that Copy projects into workspace is checked, and click Finish.

      The carrental-xom project appears in the Package Explorer view.

  3. Create the rule project:
    1. On the File menu, click New  > Project.
    2. In the New Project wizard, select Rule Project, and then click Next.
    3. Under Decision Service Rule Projects, select Main Rule Project, and then click Next.
    4. In the Project name field, type vocabulary-rules, and then click Next.
    5. On the Main Rule Project References page, click Finish without defining any references. Click Yes to open the Rule perspective.

      The main rule project vocabulary-rules now appears in the Rule Explorer view. You can see that it contains a rules directory for rule artifacts, a bom directory for BOM entries, and directories for deployment, queries, resources, and templates.

    In this tutorial, you write the following rules:

    Action rule Loyalty.AwardLoyalty

    if
       the duration of the rental agreement is more than 20
    then
       make it true that the customer of the rental agreement is loyalty program member;

    Action rule Eligibility.UnderAge

    if 
       the age of the customer of the rental agreement is less than 18
    then
       make it true that the rental agreement is rejected; 
       display the message "The rental agreement is rejected";

    Action rule BranchInfo

    if 
      the state of the branch is one of { "Massachusetts" , "New Hampshire" }
    then
      display the message "The branch is in Massachusetts or New Hampshire" ;

    Now you import the XOM in the main rule project.

  4. Import XOM:
    1. Select the vocabulary-rules project in the Rule Explorer view.
    2. In the Decision Service Map, click Import XOM.
    3. In the Import XOM wizard, make sure Java execution object model is selected and click OK.
    4. In the Java Execution Object Model wizard, select carental-xom and click OK.

    Now you create a BOM entry and verbalize the elements of the vocabulary that are required to make these rules. Verbalizing is the process of associating terms and phrases with elements of the BOM.

  5. Create the BOM entry:
    1. In the Rule Explorer view, right-click the rule project vocabulary-rules, and click New  > BOM Entry.
    2. In the New BOM Entry wizard, leave the default name model in the Name field, select Create a BOM entry from a XOM, and then click Next.
    3. On the BOM Entry page, click Browse XOM.
    4. In the Browse XOM dialog, select the Java project platform:carrental-xom, and then click OK.

      The Select classes field displays the carrental package.

    5. In the Select classes field, open the carrental package and select the classes Customer and RentalAgreement.
    6. Make sure the option Load getters and setters as attributes is selected, and then click Next.
    7. On the BOM Verbalization page, make sure the options Getters, Setters, and Static References are selected, and then click Finish.
    8. In the Rule Explorer view, expand vocabulary-rules > bom, and then double-click model.

      The Outline view and the BOM Editor show the BOM model.

      The BOM contains warnings, that you can see in the Problems view:

      BOM entry warnings
    The classes you added to the BOM entry include references to classes that are not in the BOM entry. While you do not need to verbalize all the members of these classes, the BOM entry still needs to include them. You fix this problem in the next task of the tutorial.

    Before you do so, take a minute to look at the default verbalization of the classes in the BOM entry.

  6. Look at the default verbalization:
    1. In the BOM Editor, expand the carrental package and double-click the class Customer.

      On the Class page, in the Class Verbalization section, you can see the verbalization of this class as the business term customer.

    2. In the Members section of the Class page, double-click the attribute firstName.

      On the Member page, in the Member Verbalization section, you can view the verbalization of this attribute as the navigation phrase {first name} of {this}.

    3. On the Window menu, click Show View  > Vocabulary.

      In the Vocabulary view, you can look at all your vocabulary elements.

      Vocabulary view

Results

In the next task, you fix the warnings by updating the BOM entry to include the missing classes, and verbalize new elements.

< Previous | Next >