Transformations (Profile)

Transformations define sets of actions to modify objects either before or after a model generation or on request. Transformations are commonly grouped together in transformation profiles.

Transformations can be used to:
  • Implement Model Driven Architecture (MDA), which uses UML modeling to describe an application at different levels of detail. PowerDesigner allows you to create an initial platform-independent model (PIM) (modeling the basic business logic and functionality) and refine it progressively in different models containing increasing levels of implementation and technology-dependent information through to a platform-specific model (PSM). You can define transformations that will generate a more refined version of a model, based on the desired target platform, and changes made to the PIM can be cascaded down to the generated models.
  • Apply design patterns to your model objects.
  • Modify objects for a special purpose. For example, you can create a transformation in an OOM that converts <<control>> classes into components.
  • Modify objects in a reversible way for round-trip engineering. For example, if you generate a PDM from an OOM in order to create O/R mappings, and the source OOM contains components, you can pre-transform components into classes for easy mapping to PDM tables. When you update the source OOM from the generated PDM, you can use a post-transformation to recreate the components from the classes.
Transformations can be invoked:
  • On demand, by selecting Tools > Apply Transformations.
  • Before or after model generation (see Core Features Guide > Linking and Synchronizing Models > Generating Models and Model Objects).
  • Via a user-defined menu command (see Menus (Profile)).
  1. Right-click a metaclass or stereotype, and select New > Transformation.
  2. Enter an appropriate Name and, optionally, a Comment to explain its purpose.
  3. On the Transformation Script tab, enter a VBscript to perform the transformation.
    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 Tools > Apply Transformations to create the domains in the existing model.
  4. [optional] Review the Global Script tab (see Global Script (Profile)), which provides access to definitions shared by all VBscript functions defined in the profile, and the Dependencies tab, which lists the transformation profiles in which the transformation is used.