Chapter 4 Managing Profiles


Creating a transformation

When you create a transformation, you have to define the transformation function in the Transformation Script tab. The Global Script tab is also available and allows you to reuse functions and sub-procedures.

By default, the Transformation Script tab displays the following script:

Sub %Transformation%(obj, trfm)

Where obj is the object in the model for which the script is being executed; and trfm is an internal transformation object that serves to access a set of helper functions in the script.

For more information on the helper functions, see the "Script helper methods for transformations" section.

Script checks

The transformation script does not require as much checks as standard scripts. In a standard script, you have to verify the content of a model in order to avoid errors. For example, a script that creates and renames a component from a class must contain a check that verifies if the component does not exist already in the model.

These checks are not required in a transformation script because transformations are always implemented in a temporary model where there is no existing object. This temporary model will then be merged with the generation target model if the preserve modification option is selected during update.

If you create a transformation using an existing script, you can remove these controls.

Internal transformation object

Internal transformation objects do not appear in the PowerDesigner interface. They are created as temporary objects passed to the script so that the user can access the helper functions and also to record the execution of a sequence of transformations in order to be able to execute them later.

Internal transformation objects are preserved when the transformations are used by the Apply Transformations feature or in a menu. This is because when you update a model (regenerate) in which these kind of transformations have been executed, the transformations need to be re-executed in the source model in order to maintain an equality between the source and the target model.

For example, CDM1 contains entity A, you generate an OOM from CDM1 and class B is created. You apply some transformations to class B in OOM1, which creates class C. You then wish to re-generate CDM1 and update OOM1: class B will be generated from entity A but class C is missing in the generated model, and this would show up as a difference in the merge dialog box. However, thanks to the internal transformation objects, the transformations which were executed in the generated OOM are re-executed and you obtain class C and the models to be merged are more similar than before.

Steps To create a transformation:

  1. Right-click a metaclass, a stereotype or a criterion and select New→Transformation.

    A transformation is created.
  2. Type a name in the Name box.
  3. (optional) Type a comment in the Comment box.
  4. Type the script in the Transformation Script tab.
  5. Click Apply.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.