Plant Project Database - Operations with Schema Mapping and Mapping Add-in panel


Operations with Schema Mapping  

Creating New Mapping

Before creation of mapping ECSchema should be opened in advance. To create new mapping perform below operations.


.

Opening Mapping

To open an existing mapping for ECSchema do the following steps:

→ It is also possible to remove a mapping by selecting it in the list and clicking the "Remove" button

Note: A schema doesn't need to be opened in advance. The appropriate schema will be opened automatically while opening the mapping.

Saving a Mapping

To save a mapping select "Database Mapping > Save..." menu item or right click on the schema in tree and choose "Save Mapping" from the context menu. If a mapping file already exists it will be overridden, if not an new mapping file will be created

Closing a Mapping

To close an opened mapping select "Database Mapping > Close" or right click on the schema in the ClassEditor navigation tree and chose "Close Mapping" from the context menu.

Support of referenced schemas

In practice sometimes an APPlugin may work with two or more schemas. One schema may have base classes shared among several applications and the second can reference the first schema and contain derived classes with additional properties. The mapping file can contain mappings for all working schemas. The schema that references others will be considered as master. To allow the mapping of classes of any referenced schema it is sufficient to open it in the ClassEditor. After that it is possible to perform all operations with its classes like with classes of master schema.

Mapping storage

To locate mappings the Plant Poject Database Mapping Extension uses the ECSCHEMA_PATH environment variable. The variable contains a list of folders where ECSchemas are located. The mapping plug-in searches these folders for existing mapping files. All mappings for a schema are located in a subfolder of the schema folder. The subfolder has the following name pattern:

<FullSchemaName>_mapping

Example: PlantProjectSchema.08.11_mapping

The folder contains all mappings of all application for that schema. The name pattern for a mapping file is the following:

<FullSchemaName>_<AppName>.<MappingMajorVersion>.<MappingMinorVersion>.mapping.xml

Example: PlantProjectSchema.08.11_Autoplant_PIW.01.00.mapping.xml

Plant Project Database Mapping Add-in panel

After a mapping is opened or created the Plant Project Database Mapping Extension panel is displayed on the right of the ClassEditor. It consists of two tabs (see Fig.6). The first tab is "Summary". It contains overall information about the mapping and provides some statistics. The second tab is "Class Mapping" or "Relationship Mapping". The name depends on what has previously been selected: class or relationship. It provides overall information about the currently selected class mapping and property mapping.

Summary tab

The Summary tab contains overall information about the whole schema mapping and has the following sections:

Export Summary: When clicking the Export Summary button a summary is saved in a RichText file.

Edit Database Structure:  Opens a tool that allows loading and editing the Plant Project Database structure. For more information about database structure and operations with it see Database Structure.

Class and Relationship Mapping tab

Under this tab the overall information about the selected class or relationships mapping (on the top) and the selected property (on the bottom) is displayed. The class related part contains the following sections:

From the class mapping tab it is possible to activate or deactivate a mapping, add a new mapping, edit and remove a mapping. For more information see Class Mapping.

The property related panel contains more detailed information about the selected property. As for a class it is possible to activate or deactivate a mapping, add a new mapping, edit and delete a property mapping. For more detail see Property Mapping. The information of a property has the following sections:

Database Structure

In order to simplify the process of creating a mapping and provide the necessary validation a mapping file contains a model of the application database structure (only structure without data). If an application uses several databases then all of them should be included in the mapping file. A mapping doesn't contain the complete information about a database, but it contains the most significant information for generating the proper statements for reading and writing objects.

Database structure is stored in provider independent format. It is possible to load structure using several providers:

5.1 Loading database structure

The database structure is necessary to perform any editing on the mapping. After creation of a new mapping it should be loaded. The operation includes the following steps:

Browsing the Database Structure

The loaded database is displayed in the Database Structure Editor dialog box. The dialog box has two parts: The Navigation pane (on the left) and the Details pane (on the right). For a selected database item the detailed information is displayed in the details pane.
The navigation pane allows to navigation over all main items of the database:

Editing the Database Structure

The Database Editor also supports the editing of a database structure (creation of new database, editing tables and columns, indeces and keys). By default this feature is disabled. To enable it you need to add an option in the Class Editor configuration file (ECClassEditor.exe.config):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
...
   <appSettings>
   ...
      <add key="IsDBStructureEditable" value="True" />
   ...
   </appSettings>
</configuration>

Note: the ECClassEditor.exe.config file is located underneath the Program Files folder and you need administrator rights in order to make changes to it