Mapping xml
This first mapping is used to pair database types and Sar-K internal types. It is validated by the following xsd file:
src/main/xsd/Mappings.xsd
A mapping file is required in input definition files. You can find a list of those files in the template_resources/mappings Sar-K source code directory or zipped in the same directory of SarK.jar file. This directory contains a list of those default mappings that depends on the specific database that has to be used. Current supported mapping list includes:
- DB2: Db2ToUmlMapping.xml
- MsSQL: MsSqlToUmlDataTypeMapping.xml
- MySQL: MySqlToUmlDataTypeMapping.xml
- Oracle: OracleToUmlMapping.xml
- PostgreSQL: PostgreSQLToUmlMapping.xml
- MS Access: MsAccessSQLToUmlMapping.xml
This list reflects the database types we have produced a template from. These mappings can be customized when required: we suggest you to copy them into your project directory and to modify them instead of changing the global ones.
The syntax of these XML is very easy, let’s put a sample:
<?xml version="1.0" encoding="UTF-8"?> <mappings name="MySQL"> <mapping> <from>BIT</from> <to>Datatype::Boolean</to> </mapping> <mapping> <from>TINYINT</from> <to>Datatype::Integer8bit</to> </mapping> <mapping> <from>SMALLINT</from> <to>Datatype::Integer16bit</to> </mapping> ... </mappings>
Each mapping entry must be composed of one "from" and one "to" field. In the "from" field there must be the name of the database field that has to be mapped. In the "to" field there is the Sar-K internal data type name. This name is a label that Sar-K uses internally when acquiring an input or when producing an output. For a detailed definition of Sar-K internal data types, please refer to the specific section.
A similar mapping file is used when generating the source code. In this case the mapping goes form the Sar-K internal reperesentation to the desired language. Currently there is only one mapping used from the available template, that is UmlDataTypeToJavaMapping.xml. This file maps form the Sar-K internal representation to the Java language output.
