The E2E Flat File Definition Importer allows to import flat file definitions enabling the parsing and composing of flat files with delimited or fixed width fields. The importer uses this existing documentation and generates all necessary classes in the UML model. The only requirement for these flat file definitions is that the records and its attributes are described in a table or column oriented text file.

For more details on using these classes and the Flat File adapter refer to the description of the Flat File Adapter.

Start the import of flat file definitions by selecting Import > Flat File Definition from the E2E Model Compiler menu.
On the Flat File Importer dialog, select the appropriate settings for the import as described in the following sections.

Flat File Definition Import Dialog

First, select the flat file definition by clicking  as displayed in the picture.
Navigate to the flat file definition and select it.
The importer reads the flat file definition and enables all options on the dialog to specify the format of the definitions and the records of the flat file that will be processed by the service.

The dialog window is split into four sections.

The first section defines the name of the import package and the name of the class and the record class, which will represent flat file records. These classes and another class representing the flat file itself will be generated by the importer.
It is possible to select only a range of data lines of the flat file definitions to import different classes from the same definition file.
The second section Split Flat File Definitions by defines the column delimiter of the flat file definitions. After choosing the correct setting, the identified fields are shown in the table at the bottom of the dialog window. The values should be clearly separated in columns. Otherwise, choose another delimiter.
The third section defines the type of the flat file itself. Select, if it is a fixed width or separated file. If it is separated, the correct delimiter has to be chosen.
 
The fields identified in the flat file definitions are shown in the table at the bottom of the dialog window, the fourth section of the dialog window. The field specifications are separated by columns.

Composition of the Field Specification Table

The field specification table is composed as follows:

ElementDescription
Line NumberThe first column shows the line number of the flat file definition file.
Bridge TypeThe Bridge Type can be selected for each field. The importer will assign the selected Bridge base type to each attribute of the generated flat file record class.
Column SpecificationAssign some pre-defined E2E parameters to specify the content of the column.

Bridge Type

In the third column, the Bridge Type can be selected for each field. The importer will assign the selected Bridge base type to each attribute of the generated flat file record class. By default, all attributes are defined as String. Choose one of the following base types by clicking the field for each data line:

Column Specification

In the next step, the content of the remaining columns needs to be assigned to some pre-defined E2E parameters defining the content of a column.

Clicking the header of each column with the right mouse button will open a context menu providing all possible parameters. Depending whether the flat file contains fixed width or delimited fields, the available parameters for each field can be selected as shown in the table below. Each parameter can only be selected once except for the parameters Additional Info and Ignore.
ParameterDescriptionFixed Length (FIX) / Delimited (DEL)
NameThe data of this column contains the name of the attribute, which will be added to the flat file record class.FIX / DEL
DescriptionThe data of this column contains the description of the attribute, which will be added to the documentation field of the class attribute.FIX / DEL
Additional InfoThe data of this column will be appended to the documentation field of the class attribute. If defined more than once, each additional info will be shown in a separated line. This parameter can be selected several times.FIX / DEL
IgnoreThis column will not be imported. You may ignore more than one columns. Ignored columns are displayed in orange.FIX / DEL
OffsetThis column contains the position within a flat file record where the field begins. The position counting starts at position zero. This information is stored in the tagged value offset of each class attribute.FIX
LengthThis column contains the length of the field in number of characters. This information is stored in the tagged value externalLength of each class attribute.FIX
All columns need to be assigned to a parameter. Otherwise, the OK button of the dialog remains disabled. If all settings are done, click OK to start the import.
If your parameter definitions are violating constraints (e.g. if you're omitting the length parameter), you'll get a warning like the one on the left. You can Ignore the warning and continue with importing the flat file, accepting that some information will be lost during the import. To return to the flat file definition import dialog click Review.
The flat file definitions can be imported into either an existing or a new UML model. See sections
  • Importing Flat File Definitions into an Existing UML Model and
  • Importing Flat File Definitions into a New UML Model.
If the import process shows warnings, refer to Warnings during the Import of Flat File Definitions.The import process may also be canceled clicking Cancel.

Importing Flat File Definitions into an Existing UML Model

Wanting to import a flat file definition into an existing UML model, proceed as follows.

Select the UML model, in which the flat file definition should be imported. The uml source path of the current Builder project will be suggested.Select an XMI file and click OK.
After a few seconds, the chosen target XMI file will be loaded.
The imported types will be stored in the package Data / <Import Package Name>.

You need to save the UML model to persist the imported entities and packages.

Importing Flat File Definitions into a New UML Model

Wanting to import a flat file definition into a new UML model, proceed as follows.

 
Choose the directory, in which the new XMI file should be stored. The uml source path of the current Builder project will be suggested.
Furthermore, a file name derived from the selected class name will be suggested in the File Name field. Modify the file name according your needs and and click OK.
 
If the file already exists, you will be asked whether you want to overwrite it.

After a few seconds, the new UML model will be opened in MagicDraw.
 
The imported types will be stored in the package Data / <Import Package Name>.
New UML models that are created by the Importer are not based on the Bridge template and can be used as module. Alternatively, you may want to import such models into another UML model that is based on this template later.

Generated Classes of the Flat File Definition Importer

The Importer generates two classes. One with the settings for the flat file, having the stereotype <<Flat File>> . The other class represents the flat file records and has the stereotype <<Flat File Record>> . Between these two classes, a directed association is generated by default. The association end belonging to the record definition is adorned with the stereotype <<E2E Attribute>> and a multiplicity. For more details, refer to the description of the Flat File Adapter in the Reference Guide.

The settings made in the Importer are cached. If you open the Importer again, all the settings of the last import are shown again. For importing an additional class from the same flat file definition file, change the name of the class in the first section of the dialog and define a divergent range of data lines.

If you want to overwrite an existing class by repeating the import with the same class name, delete the imported package in the containment tree of the UML model first. Otherwise, the attributes and tagged values of the new and the old class will be mixed.

The settings of the Importer are cached, as long MagicDraw is open.

  • No labels