Samples > Rule Team Server Authoring Extensions > How to Create and Populate Decision Tables in Rule Team Server

This sample shows how to create a decision table in Rule Team Server by copying an existing decision table. The values used to populate the decision table model come from a customized data provider object.

This sample comes with the following providers:

Key Features

Key features of this sample include:

Installing this Sample

To install this sample:

  1. In the Samples Console, locate the teamserver > servercopydecisiontable sample.
  2. Check that the Samples Server is started.
  3. For information on how to start and stop the Samples Server, see Stopping and Restarting the Samples Server from the Samples Console.
  4. Execute the build command.
  5. This command builds the application that creates the target project, copies the sample decision tables into it, and populates them with data.

Running this Sample

This sample can only be opened and run in the Samples Console.

To run this sample:

  1. In the Samples Console, locate the teamserver > servercopydecisiontable sample.
  2. Check that the Samples Server is started.
  3. For information on how to start and stop the Samples Server, see Stopping and Restarting the Samples Server from the Samples Console.
  4. Execute the run command.
  5. This command creates the target project, creates the environment for the decision tables (security, dependencies, categories, parameters), selects the decision tables to be copied to the target project, and populates them. The environment and decision tables that are created are dependent on the arguments that are passed.

Source Files

This sample is located in <InstallDir>/teamserver/samples/servercopydecisiontable. It contains the following files:

public static IlrDTDataProvider createFileDataProvider (...)
public static IlrDTDataProvider createJDBCDataProvider (...)
public static IlrDTDataProvider createDataProvider (...)

Highlights

The highlights of this sample are described in the following sections.

Deleting Decision Tables in a Project

The following arguments are used to delete decision tables:

Decision tables belonging to the passed packages (see the rootfolders argument above) are selected and then deleted. They are selected using the IlrSession.findElements(IlrDefaultSearchCriteria searchCriteria) API. To delete the decision tables, we used the element IlrSession.deleteElement(IlrElementHandle).

Copying Decision Tables from a Source Project to a Target Project

The following arguments are used to copy decision tables:

Each decision table belonging to the folders (and subfolders) that are passed as arguments is selected using the IlrSession.findElements(IlrDefaultSearchCriteria searchCriteria) API. They are then copied to the target project.

The copy process is carried out in several stages:

Populating a Decision Table

The following arguments are used to populate decision tables:

Populating decision tables is carried out in several stages:

File configuration
# FILE PROVIDER FORMAT csv:PATH_TO_THE_FILE/SHEET_NAME/
COLUMN_SEPARATOR computation/bankruptcyScore=csv:data/input/bankruptcyScore.data/
The bankruptcyScore decision table located in the computation folder is populated from a comma-separated csv file.
# EXCEL PROVIDER FORMAT xl:PATH_TO_THE_FILE/SHEET_NAME
 eligibility/grade=xl:///./data/input/grade.xls/sheet
The gradedecision table located in the eligibility folder is populated from an Excel spreadsheet named sheet.
# DATABASE PROVIDER FORMAT jdbc:PATH_TO_THE_FILE_DB_CONFIGURATION/QUERY computation/
salary2score=jdbc:./data/input/derby.properties/SELECT * FROM DATATABLE
The salary2score table located in the computation folder is populated from the database query.
The derby.properties file provides all the data for the database connection.
Cells are populated in the following formats:

Rebuilding this Sample

To rebuild this sample to restore it to its original state:

  1. Open the Samples Console.
  2. Execute the build command to compile the code.

Related Concepts

Using the Rule Team Server API

Related Tasks

Working With Decision Tables

Related Samples and Tutorials

How to Populate a Decision Table from a Data Source