Transformation Properties

A transformation has the following properties:

General Tab

The General tab contains the following properties:

Property

Description

Name

Name of the transformation. Make sure you type understandable names in order to easily identify them in selection lists

Comment

Additional information about the transformation used to explain the script

Transformation Script Tab

The Transformation Script tab contains the following properties:

Name

Definition

CopyObject

Duplicates an existing object and set a source for the duplicated object.

Parameters:
  • source: object to duplicate

  • tag [optional]: identifier

Returns: A copy of the new object

SetSource

Sets the source object of a generated object. It is recommended to always set the source object to keep track of the origin of a generated object.

Parameters:
  • source: source object

  • target: target object

  • tag [optional]: identifier

Returns:

GetSource

Retrieves the source object of a generated object.

Parameters:
  • target: target object

  • tag [optional]: identifier

Returns: Source object

GetTarget

Retrieves the target object of a source object.

Parameters:
  • source: source object

  • tag [optional]: identifier

Returns: Target object

Since a source object can be transformed and have several targets, you may have problems identifying the origin of an object, especially in the merge dialog box. The following mechanism is used to help identify the origin of an object:
  • If the source object is transformed into a single object, the transformation is used as an internal identifier of the target object.
  • If the source object is transformed into several objects, you can define a specific tag to identify the result of transformation. You should use only alphanumeric characters, and we recommend that you use a "stable" value such as a stereotype, which will not be modified during repetitive generations.

For example, OOM1 contains the class Customer, to which you apply a transformation script to create an EJB. Two new classes are created from the source class, one for the home interface, and one for the remote interface. In the transformation script, you should assign a tag "home" for the home interface, and "remote" for the remote interface. The tag is displayed between <> signs in the Version Info tab of an object, beside the source object.

In the following example, the tag mechanism is used to identify the classes attached to a component:

 'setting tag for all classes attached to component  
 for each Clss in myComponent.Classes
  if clss <> obj then 
   trfm.SetSource obj,Clss," GenatedFromEJB"+ obj.name +"target" +Clss.Name
   For each ope in clss.Operations    
     if Ope.Name = Clss.Code Then 'then it is a constructor _Bean operation
      trfm.SetSource obj,Ope," GenatedFromEJB"+ obj.name +"target" +Ope.Name
     end if 
     if Ope.Name = Clss.Name Then 'then it is a constructor operation
      trfm.SetSource obj,Ope," GenatedFromEJB"+ obj.name +"target" +Ope.Name
     end if 
     if Ope.name = "equals" Then 'then it is an equals operation and should be tagged
      trfm.SetSource obj,Ope," GenatedFromEJB"+ obj.name +"target" +Ope.Name
     end if
   next
   end if  
 next

Transformation scripts do not require as many checks as standard scripts, which require that you verify the content of a model in order to avoid errors, because transformations are always implemented in a temporary model where there is no existing object. The temporary model is 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 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, so that when you update a model (regenerate) in which these kind of transformations have been executed, the transformations can be re-executed in the source model in order to maintain an equality between the source and the target model.

For example, CDM1 contains an entity A. You generate an OOM from CDM1 and class B is created. You apply some transformations to class B in OOM1 in order to create class C. When you re-generate CDM1 and update OOM1, class B will be generated from entity A but class C is missing in the generated model, and shows 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.

Global Script and Dependencies Tabs

The Global Script tab provides access to definitions shared by all VBScript functions defined in the profile, and the Dependencies tab lists the transformation profiles in which the transformation is used.