In this example, which is created in an extension attached to a CDM under the
DataItem metaclass, the script tests to see whether the
data item has a list of values defined and, if this is the case (and a
domain with this same list of values does not already exist in the CDM),
creates a new domain with the list of
values:
Sub %Transformation%(obj, trfm)
Dim list
list = obj.ListOfValues
if not list = "" then
output "transforming " & cstr(obj)
' Check if such a domain already exist
Dim domn, found
found = false
for each domn in obj.Model.Domains
if domn.ListOfValues = list then
found = true
end if
next
' Create a new domain
if not found then
set domn = obj.Model.Domains.CreateNew()
domn.SetNameAndCode obj.Name, obj.Code
domn.ListOfValues = list
end if
end if
End Sub
This
transformation can be added to a transformation profile as a:
- Pre-generation transformation - The transformation is called from
the Generation Options dialog. The domains are created temporarily
in the CDM before generation and then are generated to the target
model (for example, to a PDM).
- Post-generation transformation - The transformation can be called
from the Generation Options dialog (for a CDM-CDM generation). The
domains are created in the target CDM after generation.
Alternatively, the transformation can be called at any time by
selecting to create the domains in the existing model.