Rule Builder > Managing Decision Tables > Exporting and Importing Decision Tables > Importing

You can import data from an external data source to a decision table using the following formats and facilities:

Table 12.4   Decision Table Import Formats
Format 
Description 
XML  Import following a proprietary format (for example, to import a file that was previously exported using the Export File menu). Use the File>Import File menu to import such a file. 
CSV  Import data following the CSV format as the contents of a decision table. The data represented in CSV must follow a documented protocol. The structure of the decision table is not imported and must pre-exist before importing data, and the data must follow the structure of the decision table. 
External tool  For example, Microsoft Excel. You can import some data into the decision table by selecting tabular data in an external tool and pasting it into a decision table. The data that is imported must follow the structure defined by the table. 
JRules API  You can also populate a decision table using the API. 

The CSV Protocol

Importing CSV data to a prestructured decision table follows a predefined protocol. The CSV data is mapped according to the number of columns and subcolumns of the decision table. The hierarchical structure of the table is formed according to empty or twin values.

Importing Data

Here is a example of importing data using the CSV protocol. The CSV file contains the following data, and the predefined structure of the decision table is shown in Figure 12.74 with the data imported.

18,   Silver,    10,   20,   1
, Gold, 20, 30, 2
, Platinum, 30, 40, 3
25, Platinum, 40, 50, 4
35, Gold, 50, 60, 5

There are two empty values in the first column of the CSV file, so the value 18 will get three partition items as children, as you can see in the resulting decision table. The Revenues column requires two parameters, so two columns from the CSV file are mapped to this column.

images/cvsexample.gif

Figure 12.74    Sample Data Imported in CSV Protocol
Extended Protocol

In the previous example, only data were imported. An extended protocol allows you to change the default predicates for numeric and date values.

Here is an example of the extended protocol, with the result of the import shown in Figure 12.75.

<=18,     Silver,        10,   20,   1
, Gold;Platinum, ]20, 30[, 2
, Platinum, 30, 40, 3
[19..34], Platinum, ]40, 50], 4
>=35, !=Gold, >50, , 5

images/extended_import_doc.gif

Figure 12.75    Sample Extended Protocol Imported in CSV Protocol

Note
In the CSV data, if, instead of empty values under the 18, 18 was duplicated, the result of the import would be the same.

Populating a Decision Table by API

The interface ilog.rules.dt.model.provider.IlrDTDataProvider provides a way to populate a decision table model from your data. For this purpose, the structure of the decision table must be defined with the Rule Builder. Then you must implement this interface on the data.

An IlrDTDataProvider is hierarchically structured. As in the CSV import protocol, this hierarchical structure defines how partition items are created and organized. For easy implementation of IlrDTDataProvider, you can derive IlrDTAbstractDataProviderTableModel which is an abstract class to map the decision table model to a classic table model.

Using the example in The CSV Protocol, when the import process requests the data from the interface, the definition of the Revenues column requires two parameters to be grouped to define the min and max values.

See the Java API Reference Manual for further details on IlrDTDataProvider.

See Also

Decision Table / Tree Predicates | Decision Table / Tree Supported Data Types | The CSV Protocol


Customer Support | Copyright © 1987-2004 ILOG S.A. All rights reserved. Legal terms. PREVIOUS   NEXT