Accessing the Metamodel with GTL

The Generation Template Language (GTL) uses templates to generate files. A template is a piece of code defined on a given PowerDesigner metaclass and the metaclasses that inherit from this class. It can be used in different contexts for text and code generation.

These templates can be considered as metamodel extensions as they are special kinds of metamodel class attributes. You can define as many templates as needed for any given metaclass using the following syntax:

<metamodel-classname> / <template-name>

Templates are inherited by all the descendants of the metaclass they are defined for, and so can be used to share template code between metaclasses with a common ancestor. For example, if you define a template for the BaseObjects abstract class, all the classes linked via generalization links to this class inherit from this template.

The GTL uses macros such as foreach_item, for iterating over object collections. The template specified inside the block is translated over all the objects contained in the specified collection. The metamodel provides useful information about the collections of the metaclass on which you define a template containing an iteration macro.

The following calculated attributes are metamodel extensions specific to GTL:

Metaclass

Attributes

PdCommon.BaseObject

  • isSelected (boolean) - True if the object is part of the selection in the generation dialog

  • isShorctut (boolean) - True if the object was accessed by dereferencing a shortcut

PdCommon.BaseModel

  • GenOptions (struct) - Gives access to user-defined generation options

PdOOM.*

  • ActualComment (string) - Cleaned–up comment (with /**, /*, */ and // removed)

PdOOM.Association

  • RoleAMinMultiplicity (string)

  • RoleAMaxMultiplicity (string)

  • RoleBMinMultiplicity (string)

  • RoleBMaxMultiplicity (string)

PdOOM.Attribute

  • MinMultiplicity (string)

  • MaxMultiplicity (string)

  • Overridden (boolean)

  • DataTypeModifierPrefix (string)

  • DataTypeModifierSuffix (string)

  • @<tag> [Java-specific] (string) - Javadoc@<tag> extended attribute with additional formatting

PdOOM.Class

  • MinCardinality (string)

  • MaxCardinality (string)

  • SimpleTypeAttribute [XML-specific]

  • @<tag> [Java-specific] (string) - Javadoc@<tag> extended attribute with additional formatting

PdOOM.Interface

  • @<tag> [Java-specific] (string) - Javadoc@<tag> extended attribute with additional formatting

PdOOM.Operation

  • DeclaringInterface (object)

  • GetSetAttribute (object)

  • Overridden (boolean)

  • ReturnTypeModifierPrefix (string)

  • ReturnTypeModifierSuffix (string)

  • @<tag> [Java-specific] (string) - Javadoc@<tag> extended attribute with additional formatting (especially for @throws, @exception, @params)

PdOOM.Parameter

  • DataTypeModifierPrefix (string)

  • DataTypeModifierSuffix (string)

The following calculated collections are metamodel extensions specific to the GTL:

Metaclass name

Collection name

PdCommon.BaseModel

Generated <metaclass-name>List - Collection of all objects of type <metaclass-name> that are part of the selection in the generation dialog

PdCommon. BaseClassifierMapping

SourceLinks

PdCommon. BaseAssociationMapping

SourceLinks