## Map Tool application

Map Tool (MapTool) application is used to extend UML class model with information about mapping between database and class structures. It also is used to generate source files.
The unit of work withing MapTool is project file, wich contains the next information

- Generator template - main template (*.gen file)
- Filter template - template used to calculate filter expression
- Filter codes - text file, 1st line contains comma-delimited list of all possible filter codes. Must be consistent with filter template.
- UML url identifies the source where UML model is loaded from. Supported url formats are

- XMI:filename1[,filename2,...]
  Model will be loaded from the XML file filename1exported from such UML tools like Rational Rose or Enterprise Architect. MapTool supports XMI version 1.1 format. Model can be exported into several files (for example each package has it's own file) - in such case use comma-delimited list of filenames.
- EAREPO:username/password@database
  Model will be loaded from Enterprise Architect repository located on Oracle database.

- Package - default package after model loading
- Repository url identifies the location of mapping repository. Supported url formats are

- ORA:username/password@database
- FILE:filename

- Oracle connection and ODBC connection. MapTool allowes to provide two different mapping schemas, one for Oracle database and another one for ODBC connection.

To map class you have to assign table (view) to the class and for each class attribute assign correspondent column from that view (use drag-and-drop). After work is done don't forget to save your mapping. Finally you can generate source file for your class or whole package.

## Object-to-Database mapping

There are different ways to represent class structure in UML. Also there are many object mapping approaches. MapTools uses the next assumtions about class model and mapping methods

1. Classes are mapped to the tables or views.

- Each class has primary key - one or several attributes used to uniquely identify the object. Class primary key must be associated with primary key of the table this class is mapped to.
- Class can not be directly mapped to the combination of tables (joins, unions...), you have to provide a view to map such class.

2. Attributes of simple types (integer, string, float, boolean, etc.) are represented as class attributes in the class mode

- Simple attributes are mapped one-to-one (attribute - to - column)
- Data type conversion is responcibility of generator template or/and database engine used to serialize classes in the generated source files.

3. Attributes of object types (pointer to object, object) are represented as association between classes.

- Role on the opposite association end has such attribute name and cardinality "1" or "0..1".
- Mapping must be provided for each element of the target class primary key.

4. Attribute of collection types (list of objects) are represented as associations between classes.

- Role on the opposite association end has attrtibute's name and cardinality like "0..*", "1..*", "*".
- There are no direct association between collection and tables/columns. Instead of that mapping is represaned as set of query statements -

- Select statement
- Add statement
- Delete statement

5. Attribute of enumeration type are represented as association between classes.

- Target class has <<enumeration>> stereotype
- Role on the target end of association has attribute's name and cardinality "1" or "0..1".
- Attributes of enumerator type are mapped one-to-one (attribute - to - column)

6. Attribute of set type (arrays of simple types) are represented as association between classes

- Target class has <<enumeration>> stereotype.
- Role on the target end of association has attribute's name and cardinality "0..*" or "1..*" or "*".
- Sets can be mapped in two different ways

- Bit mask. Table column contains integer/string value. Each bit/char of the value represents particular element in the set.
- Column set. Each possible element in the set is represented by a table column. Not null/not zero value means correspondent element is presented in the set.