Mapping Objects by Script

You can use scripting to map objects from heterogeneous models.

You create or reuse a mapping for an object using the following method on the DataSource object and on the ClassifierMap object: CreateMapping(ByVal Object As BaseObject) As BaseObject.

Example

Given the following example where an OOM (oom1) contains a class (class_1) with two attributes (att1 and att2) and a PDM (pdm1) contains a table (table_1) with two columns (col1 and col2). To map the OOM class and attributes to the PDM table and columns, you have to do the following:

  • Create a data source in the OOM

set ds = oom1.datasources.createnew
  • Add the PDM as source for the data source

ds.AddSource pdm1
  • Create a mapping for class_1 and set this mapping as the default for class_1 (current data source being the default)

set map1 = ds.CreateMapping(class_1)
  • Add table_1 as source for class_1

map1.AddSource table_1
  • Add a mapping for att1

set attmap1 = map1.CreateMapping(att1)
  • Set col1 as source for att1

attmap1.AddSource col1
  • Add a mapping for att2

set attmap2 = map1.CreateMapping(att2)
  • Set col2 as source for att2

attmap.AddSource col2

You can also get the mapping of an object using the following method on the DataSource object and on the ClassifierMap object: GetMapping(ByVal Object As BaseObject) As BaseObject.

  • Get the mapping of class_1

Set mymap = ds.GetMapping (class_1)
  • Get the mapping of att1

Set mymap = map1.GetMapping (att1)

For more information about objects mapping, see Core Features Guide > Linking and Synchronizing Models > Object Mappings.