Chapter 4 Managing Profiles


Script helper methods for transformations

Transformation scripts have access to special helper methods via the internal transformation object. These methods are the following:

Name Definition Parameters Returns
CopyObject Duplicates an existing object and set a source for the duplicated object source: object to duplicate

tag*: text identifier for object
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 source: source object

target: target object

tag*: text identifier for object
GetSource Retrieves the source object of a generated object target: target object

tag*: text identifier for object
Source object
GetTarget Retrieves the target object of a source object source: source object

tag*: text identifier for object
Target object

* optional tag used to improve generation history, see following paragraph

Generation history

The generation history mechanism used to retrieve the ID of the source object in order to identify the origin of a target object and display it in the Version Info tab. This was possible because there was a one-to-one mapping between source and target objects.

Now that a source object can be transformed and have several targets, you may have problems to identify 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 Then the transformation is used as an internal identifier of the target object.

If the source object is transformed into several objects Then you can define a specific tag to identify the result of transformation. This tag is a user-selected value that should only use alphanumeric characters. It is recommended to use a "stable" value, that is, a value not likely to be modified during repetitive generations, like a stereotype for example. For example, OOM1 contains class Customer, you apply a transformation script to this object 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, you use the tag mechanism 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

 


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