Chapter 4 Managing Profiles


Creating a generated file

The Generated Files category contains file entries. These entries define the files that will be generated for a given metaclass or for the instances of a metaclass with a selected stereotype or criterion.

You use the GTL to define a generated file. You can define generated file entries for any metaclass, however, only the files defined for objects belonging to a model or a package collection will be generated. Sub-objects, like attributes, columns, or parameters do not support file generation, however it can interesting to see the piece of code generated for these sub-objects in their Preview tab.

You can identify the model or package collections in the PowerDesigner metamodel.

For more information on the PowerDesigner metamodel, see the "PowerDesigner Public Metamodel" chapter.

For more information on the GTL syntax, see the "Generation Reference Guide" chapter.

If an extended model definition complementing the generation of an object language contains a generated file name identical to a generated file name defined in the object language, then the generated file defined in the extended model definition will replace the generated file in the object language.

Generated file properties

In the previous version of PowerDesigner, you had to define a template corresponding to the file type to generate. Now, you can directly edit the template of the file to generate in the generated file property page.

Each generated file has the following properties:

Property Description
Name Name of the generated file entry in the resource editor
File Name Name of the file that will be generated, it can contain variables
Encoding Format of the generated file, PowerDesigner supports several formats. You can use the Ellipsis button to display the Text Output Encoding Format dialog box in which you can select a format in a list. In this dialog box, the Abort on Character Loss check box allows you stop generation if it causes the loss of characters
Comment Additional information about the generated file
Use Package hierarchy as file path Indicates that the package hierarchy should be used to generate the hierarchy of file directories
Generated file template (text zone) Template of the file to generate. You can open an editor using the Edit With tool, and if you are using templates, you can use the Browser tool to display the definition of this template. You can use the Browse tool to find all templates of the same name (see section Creating a template)

If the File Name box is empty there is no file generated. However, it can be very useful because it allows you to preview the content of the file before generation. You can use the Preview tab of the corresponding object at any time for this purpose.

If the File Name box contains a '.' (dot) character there is no file generated either but it allows you to use the Preview tab, as explained above, with the addition of syntax color highlighting. You can add the extensions after the dot character to use the language editor of your choice (example: .dtd for XML).

Steps To define a generated file:

  1. Right-click a metaclass in the Profile category and select New→Generated File.

    or

    Right-click a stereotype or a criterion in a metaclass and select New→Generated File.

    A new file entry is created under the selected category.
  2. Type a name in the Name box.
  3. Type the template of the name for the file to be generated in the File Name box.
  4. Select an encoding format.
  5. <optional but very useful> Type a comment in the Comment box in order to explain what the generated file will contain.
  6. Select the Use Package Hierarchy as File Path checkbox if you want to preserve the package hierarchy.
  7. Type the definition of the generated file in the text zone.
  8. Click Apply.

 


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