Loading Relational Models from the Command Line

Section - Using Transformation Programs as Command Line Utilities

Relational models can be loaded into the TM repository from the command line if required.

Step 1

Choose Start | Programs | Transformation Manager | Command Prompt from the Windows taskbar.  The command prompt window which opens has the relevant environment variables (such as CLASSPATH) correctly set for working with either TM Design Tool or the Test Tool.

Step 2

Use a text editor to edit the Loader.config file, located in the tm directory of the TM installation, to configure the destination repository. This file contains a set of key-value pairs, and the following need to be set:

repository_driver = <driver class>

where <driver class> is the same entry as used in the Driver field to connect to a Repository.

repository_url = <jdbc url>

where <jdbc url> is the same entry as used in the URL field to connect to the repository.

repository_username = <user>

where <user> is the same entry as used in the User field to connect to the repository.

repository_password = <password>

where <password> is the same entry as used in the Password field to connect to the repository.

repository_type = <database type>

where <database type> is Oracle, Sybase, SQLServer or Access.  This must be set correctly because database-specific queries need to be executed. See also Connecting to a Repository.

The Loader.config file contains sample entries for all supported databases, so the appropriate lines need to be uncommented and all other lines commented. To specify the model which is to be imported, the following additional entries are also required (some example driver and URL values for an Oracle database are shown):

model_driver = oracle.jdbc.driver.OracleDriver
model_url = jdbc:oracle:thin:@hostname:1521:ORCL
model_username = <user>
model_password = <password>
model_name = <model_name>

The <user> and <password> are the ones required for access to the database that contains the model that is to be imported into TM.  <model_name> is the name by which the model will be identified in the TM repository.


Loader.config also contains the following lines:

#RELATIONSHIP NAMIMG CONVENTION
use_dest_element_name_in_rel = no
use_column_names_in_rel = no

These are used for relational models, and they determine the naming convention used for forward and inverse relationships in the repository.

The default value of no for use_dest_element_name_in_rel means that the name of the constraint in the model is used as the forward relationship name;  if this setting is changed to yes, then the destination element name is used as the forward relationship name.

For example, a foreign key constraint called book_fk which links the book_id column in the author table to the primary key id column in the book table, will have the relationship names in the TM repository shown  below:
 

use_dest_element_name_in_rel

Forward Relationship name

Inverse Relationship name

no book_fk ibook_fk
yes book ibook


The value of use_column_names_in_rel should always be no unless use_dest_element_name_in_rel is set to yes.

It should be set to yes when you want to use column names from the origin to distinguish between relationships, usually when an element has more than one relationship with the same name.  This happens when a table has more than one foreign key constraint referencing the same primary key table.  Relationship names are distinguished by the addition of the relevant foreign key column name to the end of the relationship name.

When this setting is no, then distinguishing characters from the relevant foreign key constraint name are appended to the relationship name.

Step 3

Copy the Loader.config file into the directory where the import command is to be executed.


Step 4

Import the model with the following command:

java com.prismt.transform.designtime.loader.LoadOracle

to import an Oracle model into the repository.  Change the last part of the command as appropriate to load other types of models:

...loader.LoadSybase
...loader.LoadSqlServer


Troubleshooting

Ensure that the URLs and drivers are specified correctly for the repository and the model.  Remember that the last part of the command name (the Java class you run) refers to the model type you want to load, not to the repository type; so you will use the ...LoadOracle command to load a model from an Oracle database regardless of the type of database your repository is stored in.