Customizing SAP PowerDesigner 16.5 Guide
Customizing SAP PowerDesigner 16.5 Guide
The following types of resource files, based on or extending the PowerDesigner public metamodel are provided:
● Definition file: customize the metamodel to define the objects available for a specific DBMS or language:
○ DBMS definition files (.xdb) - define a specific DBMS in the PDM (see DBMS Definition Files [page 140]).
○ Process, object, and XML language definition files (.xpl, .xol, and .xsl) – define a specific language in the
BPM, OOM, or XSM (see Object, Process, and XML Language Definition Files [page 129]).
● Extension files (.xem) – extend the standard definitions of target languages to, for example, specify a
persistence framework or server in an OOM. You can create or attach one or more XEMs to a model (see
Extension Files [page 18]).
● Report templates (.rtp) - specify the structure of a report. Editable within the Report Template Editor (see
Core Features Guide > Storing, Sharing and Reporting on Models > Reports).
● Report language files (.xrl) – translate the headings and other standard text in a report (see Translating
Reports with Report Language Files [page 312]).
● Impact and lineage analysis rule sets (.rul) - specify the rules defined for generating impact and lineage
analyses (see Core Features Guide > Linking and Synchronizing Models > Impact and Lineage Analysis).
● Object permission profiles (.ppf) - customize the PowerDesigner interface to hide models, objects, and
properties (see Core Features Guide > Administering PowerDesigner > Customizing the PowerDesigner
Interface > Using Profiles to Control the PowerDesigner Interface).
● User profiles (.upf) - store preferences for model options, general options, display preferences, etc (see Core
Features Guide > Modeling with PowerDesigner > Customizing Your Modeling Environment > User Profiles).
● Model category sets (.mcc) - customize the New Model dialog to guide model creation (see Core Features
Guide > Administering PowerDesigner > Customizing the PowerDesigner Interface > Customizing the New
Model Dialog).
● Conversion tables (.csv) - define conversions between the name and code of an object (see Core Features
Guide > Modeling with PowerDesigner > Objects > Naming Conventions).
You can review all the available resource files from the lists of resource files, available by selecting Tools
Resources <type> .
Tool Description
New - Creates a new resource file using an existing file as a model (see Creating and Copying Re
source Files [page 14]).
Path - Specifies the directories that PowerDesigenr should search to populate the list (see Specifying
Directories to Search for Resource Files [page 15]).
Check In - [if the repository is installed] Checks the selected resource file into the repository. For in
formation about storing your resource files in the repository, see Core Features Guide > Administer
ing PowerDesigner > Deploying an Enterprise Glossary and Library.
Update from Repository - [if the repository is installed] Checks out a version of the selected file from
the repository to your local machine.
Compare with Repository - [if the repository is installed] Compares the selected file with a resource
file stored in the repository.
When working with a BPM, PDM, OOM, or XSM, you can open the definition file that controls the objects available
in your model in the Resource Editor for viewing and editing. You can also open and edit any extension files
currently attached to or embedded in your model or access the appropriate list of resource files and open any
PowerDesigner resource file.
To open any extension file currently attached to your model, double-click its entry inside the Extensions category
in the Browser.
To open any other resource file, select Tools Resources <Type > to open the relevant resource file list,
select a file in the list, and then click the Properties tool.
In each case, the file opens in the Resource Editor, in which you can review and edit the structure of the resource.
The left-hand pane shows a tree view of the entries contained within the resource file, and the right-hand pane
displays the properties of the currently-selected element:
Each entry is a part of the definition of a resource file, and entries are organized into logical categories. For
example, the Script category in a DBMS language file collects together all the entries relating to database
generation and reverse engineering.
You can drag and drop categories or entries in the tree view of the resource editor and also between two resource
editors of the same type (for example two XOL editors).
Note
Some resource files are delivered with "Not Certified" in their names. We will perform all possible validation
checks, but we do not maintain specific environments to fully certify these resource files. We will support them
by accepting bug reports and providing fixes as per standard policy, with the exception that there will be no
final environmental validation of the fix. You are invited to assist us by testing fixes and reporting any
continuing inconsistencies.
The tools at the top of the Resource Editor help you to navigate through and search in the resource file.
Back (Alt+Left) - Go to the previous visited entry or category. Click the down arrow to directly select
from your history.
Forward (Alt+Right) - Go to the next visited entry or category. Click the down arrow to directly select
from your history.
Lookup (Enter) - Go to the item named in the text box to the left of the tool. If more than one item is
found, they are listed in a results dialog and you should double-click on the desired item or select it
and click OK to go to it.
● [extension type] - select the type of extension to search, for example you can search only stereo
types
● Allow wildcard - Enables the use of the characters * to match any string and ? to match any sin
gle character. For example, type is* to retrieve all extensions called is....
● Match case - Search with case sensitivity.
Save (Ctrl+Shift+S) – Save the current resource file. Click the down arrow to save the current re
source file under a new name.
Note
To jump to the definition of a template from a reference in another template (see Templates (Profile) [page
101]) or other extension, place your cursor between the percent signs and press F12. If an extension overrides
another item, right-click it and select Go to super-definition to go to the overriden item.
You can add items in the resource editor by right-click a category or an entry in the tree view.
Add items... Opens a selection dialog box to allow you select one or more of the predefined metamo
del categories or entries to add to the present node. You cannot edit the names of these
items but you can change their comments and values by selecting their node.
Restore Comment Restores the default comment for the selected category or entry.
Restore value Restores the default value for the selected entry.
Note
You can rename a category or an entry directly from the resource file tree by selecting it and pressing the F2
key.
If you make changes to a resource file and then click OK to close the resource editor without having clicked the
Save tool, the changes are saved in memory, the editor is closed and you return to the list of resource files. When
you click Close in the list of resource files, a confirmation box is displayed asking you if you really want to save the
modified resource file. If you click Yes, the changes are saved in the resource file itself. If you click No, the changes
are kept in memory until you close the PowerDesigner session.
The next time you open any model that uses the customized resource file, the model will take modifications into
account. However, if you have previously modified the same options directly in the model, the values in the
resource file do not change these options.
Resource files can be shared and referenced by multiple models or copied to and embedded in a single model.
Any modifications that you make to a shared resource are available to all models using the resource, while
modifications to an embedded resource are available only to the model in which it is embedded. Embedded
resource files are saved as part of their model and not as a separate file.
The File Name field displays the location of the resource file you are modifying is defined. This field is empty if the
resource file is embedded.
You can create a new resource file in the appropriate resource file list. To create a copy of an existing resource file,
select it in the Copy from field of the New... dialog.
Context
Caution
Since each resource file has a unique id, you should only copy resource files within PowerDesigner, and not in
Windows Explorer.
Procedure
1. Select Tools Resources <Type> to open the appropriate resource file list.
2. Click the New tool, enter a name for the new file and select an existing file to copy. Select the <Default
template> item to create a minimally completed resource file.
3. Click OK to create the new resource file, and then specify a filename and click Save to open it in the Resource
Editor.
Note
You can create an extension file directly in your model from the List of Extensions. For more information,
see Creating an Extension File [page 19].
Use the Path tool in the resource list toolbar to specify directories to search to populate the list. If you plan to
modify the standard resource files or create your own, you must store these files in a directory outside the
PowerDesigner installation directory.
Context
By default, only the directory inside the Program Files folder containing the standard resource files appears in
the list, but PowerDesigner does not allow you to save modifications there, and will propose an alternative location
if you try to do so, adding the selected directory to the list. You can add additional directories as necessary.
Note
If you have created or modified resource files inside Program Files before 16.5, when this rule was
introduced, your files may no longer be available as Windows Vista or Windows 7 actually store them in a virtual
mirror at, for example, C:\Users\<username>\AppData\Local\VirtualStore\Program Files\Sybase
\PowerDesigner 16\Resource Files\DBMS. To restore these files to your lists, optionally move them to a
more convenient path, and add their location to your list using the Path tool.
The first directory in the list is the default location, which is proposed whenever you save a file. The root of the
library belonging to your most recent repository connection is searched recursively before the directories in the
list (see Core Features Guide > Administering PowerDesigner > Deploying an Enterprise Glossary and Library), .
Note
In rare cases, when seeking resource files to resolve broken references in models, the directories in the list are
scanned in order, and the first matching instance of the required resource is used.
You can select two resource files and compare them to highlight the differences between them.
Procedure
1. Select Tools Resources <Type> to open the appropriate resource file list.
2. Select the first resource file you want to compare in the list, and then click the Compare tool to open a
selection dialog.
The selected file is displayed in the second comparison field.
If the resource file you want to compare is not in the list, click the Select Path tool and browse to its directory.
4. Click OK to open the Compare... dialog, which allows you to review all the differences between the files.
For detailed information about this window, see Core Features Guide > Modeling with PowerDesigner >
Comparing and Merging Models.
5. Review the differences and then click Close to close the comparison window and return to the list.
Procedure
1. Select Tools Resources <Type> to open the appropriate resource file list.
2. Select the resource file in which you want to make merge changes in the list, and then click the Merge tool to
open a selection dialog.
The selected file is displayed in the To field.
3. Select the resource file from which you want to merge in the From field.
If the resource file you want to merge is not in the list, click the Select Path tool and browse to its directory.
Extension files have an .xem extension and are located in <install_dir>/Resource Files/Extended
Model Definitions.
Lists of extension files by model type are available by selecting Tools Resources Extensions <model
type> . For information about the tools available in resource file lists, see PowerDesigner Resource Files [page
9].
Note
Extensions, such as the Excel Import extension, which can be attached to any model type, are available in the
list at Tools Resources Extensions All Model Types .
● Generation - used to develop or complement the default PowerDesigner object generation (for BPM, OOM,
and XSM models) or for separate generation. For more information, see Generation Category [page 134].
● Profile - used for extending the metaclasses in the PowerDesigner metamodel. You can:
○ Object generations - to define mappings between different modules in the PowerDesigner metamodel
for model-to-model generation.
○ XML imports - to define mappings between an XML schema and a PowerDesigner module to import
XML files as models.
Note
Since you can attach several resource files to a model (for example, a target language and one or more
extension files) you can create conflicts, where multiple extensions with identical names (for example, two
different stereotype definitions) are defined on the same metaclass in separate resource files. In case of such
conflicts, the extension file extension usually prevails. When two XEMs are in conflict, priority is given to the one
highest in the List of Extensions.
You can create an extension file directly in your model or from the appropriate list of extension files.
Context
Note
Extensions, such as the Excel Import extension, which can be attached to any model type, can only be created
from the All Model Types extension list. For information about creating an extension file from a list of extension
files, see Creating and Copying Resource Files [page 14].
Procedure
1. Open your model, and then select Model Extensions to open the List of Extensions.
2. Click the Add a Row tool and enter a name for the new extension file.
3. Click the Properties tool to open the new extension file in the Resource Editor, and create any appropriate
extensions.
4. When you have finished, click OK to save your changes and return to the List of Extensions.
The new XEM is initially embedded in your model, and cannot be shared with any other model. For information
about exporting your extensions and making them available for sharing, see Exporting an Embedded
Extension File for Sharing [page 21].
Extensions can be stored in *.xem files that you can attach to one or more models. You can attach one or more
extension files to a model at creation time by clicking the Select Extensions button on the New Model dialog. You
can subsequently attach extension files to your model at any time from the List of Extensions.
Procedure
1. Select Model Extensions to open the List of Extensions, which contains extensions attached to the
model.
2. Click the Attach an Extension tool to open the Select Extensions dialog.
3. Review the different sorts of extensions available by clicking the sub-tabs and select one or more to attach to
your model.
By default, PowerDesigner creates a link in the model to the specified file. To copy the contents of the
extension file and save it in your model file, click the Embed Resource in Model button in the toolbar.
Embedding a file in this way enables you to make changes specific to your model without affecting any other
models that reference the shared resource.
4. Click OK to return to the List of Extensions.
Extension files listed in grey are attached to the model, while those in black are embedded in the model.
If you export an XEM created in a model, it becomes available in the List of Extensions, and can be shared with
other models. When you export an XEM, the original remains embedded in the model.
Procedure
1. Select Model Extensions to open the List of Extensions, which contains extensions attached to the
model.
2. Select an embedded extension in the list and click the Export an Extension tool.
3. Enter a name and select a directory to which to save the extension file and click Save.
Note
For the extension to be available for attaching to other models, you must save it to a directory that is listed
by the Path tool in the appropriate extension list (see Specifying Directories to Search for Resource Files
[page 15]).
Property Description
Name / Code Specify the name and code of the extension file, which must be unique in a model.
File Name [read-only] Specifies the path to the extension file. If the XEM has been copied to your
model, this field is empty.
Family / Subfamily Restricts the availability of the XEM to a particular target family and subfamily. For exam
ple, when an XEM has the family Java, it is available only for use with targets in the Java
object language family. EJB 2.0 is a sub-family of Java.
Auto-attach Specifies that the XEM will be automatically attached to new models with a target belong
ing to the specified family.
Category Groups XEMs by type for generation and in the Select Extensions dialog. Extensions having
the same category cannot be generated simultaneously. If you do not specify a category,
the XEM is displayed in the General Purpose category and is treated as a generation target.
Enable Trace Mode Lets you preview the templates used during generation (see Templates (Profile) [page
101]). Before starting the generation, click the Preview page of the relevant object, and
click the Refresh tool to display the templates.
When you double-click on a trace line from the Preview page, the Resource Editor opens to
the corresponding template definition.
Complement lan [BPM, OOM, XSM extensions] Specifies that any generated files (seeGenerated Files (Pro
guage generation file) [page 102]) that you define in the extension will be generated when you select
Language Generate... in addition to the files that are generated by default. If you give
a generated file in your extension the same name as one defined in the language definition
file (see Object, Process, and XML Language Definition Files [page 129]), then the file in
your extension will override the one in the language definition file.
To enable an independent generation of files, you must deselect this option, select the
Enable selection in file generation option for at least one metaclass (see Metaclasses (Pro
file) [page 39]), and add at least one generated file to the metaclass (see Generating
Your Files in a Standard or Extended Generation [page 106]).
Note
SAP® PowerBuilder® does not support XEMs for complementary generation.
● Generation - Contains Generation commands, options, and tasks to define and activate a generation process
(see Generation Category [page 134]).
● Transformation Profile - Groups transformations for application at model generation time or on demand (see
Transformations (Profile) [page 109]).
In this example, we will quickly add a new attribute directly from the property sheet of an object. PowerDesigner
will manage the creation of the extension file and creation of all the necessary extensions.
Procedure
1. Click on the Property Sheet Menu button at the bottom-left of the property sheet, to the right of the More/
Less button, and select New Attribute.
2. In the New Attribute dialog, enter Latency in the Name field, select String for the data type.
3. Click the ellipsis button to the right of the List of values field, enter the following list of predefined values, and
then click OK:
○ Batch
○ Real-Time
○ Scheduled
4. [optional] Select Scheduled in the Default value field.
5. [optional] Click Next to specify the property sheet page where you want the new attribute to appear. Here,
we'll leave the default, so its inserted on the General tab.
In this example, we will recreate the Robustness extension file delivered with PowerDesigner to extend the OOM
communication diagram to enable robustness analysis. Robustness diagrams sit between use case and sequence
diagram analysis, and allow you to bridge the gap between what the system has to do, and how it is actually going
to accomplish it.
Context
In order to support the robustness diagram, we will need to define new objects by applying stereotypes to a
metaclass, specify custom tools and symbols for them, as well as defining custom checks for instance links and
producing a file to output a description of messages exchanged between objects.
Creating the robustness extensions will enable us to verify use cases like the following, which represents a basic
Web transaction:
A customer wants to know the value of his stocks in order to decide to sell or not, and sends a stock value query
from his Internet Browser, which is transferred from his browser to the database server via the application server.
The first step in defining extensions, is to create an extension file (.xem) to keep them in:
Procedure
1. Create or open an OOM and select Model Extensions to open the list of extensions attached to the
model.
2. Click the Add a Row tool to create a new extension file, and then click the Properties tool to open it in the
Resource Editor.
For detailed information about creating extension files, see Creating an Extension File [page 19].
To implement robustness analysis in PowerDesigner, we need to create three new types of objects (boundary,
entity, and control objects), which we will define in the Profile category by extending the UMLObject metaclass
through stereotypes.
Procedure
1. Right-click the Profile category and select Add Metaclasses to open the Metaclass Selection dialog.
2. Select UMLObject on the PdOOM tab and click OK to add this metaclass to the extension file.
Note
Click the Find in Metamodel Objects Help tool to the right of the Name field (or click Ctrl+F1) to obtain
information about this metaclass and see where it is situated in the PowerDesigner metamodel.
Entity Entity objects represent stored data like a database, database [Link]
tables, or any kind of transient object such as a search result.
Control Control objects are used to control boundary and entity objects, [Link]
and represent transfer of information.
We will specify diagram symbols for each of our new robustness diagram objects by adding custom symbols to
our new stereotypes.
Procedure
1. Right-click Boundary stereotype and select New Custom Symbol to create a custom symbol under the
stereotype.
2. Click the Modify button to open the Symbol Format dialog, and select the Custom Shape tab.
3. Select the Enable custom shape check box, and select Boundary Object in the Shape name list.
4. Click OK to complete the definition of the custom symbol and return to the Resource Editor.
5. Repeat these steps for the other stereotypes:
We will now create three custom checks on the instance links that will connect the various robustness objects.
These checks, which are written in VB, do not prevent users from creating diagrams not supported by the
robustness methodology, but define rules that will be verified when you check your model.
Procedure
1. Right-click the Profile category, select Add Metaclasses to open the Metaclass Selection dialog, select
InstanceLink on the PdOOM tab and click OK to add it to the extension file.
2. Right-click the InstanceLink category and select New Custom Check to create a check under the
metaclass.
Field Value
Comment This check verifies if actors are linked to boundary objects. Linking
actors to control or entity objects is not allowed in the robustness
analysis.
Help message This check ensures that actors only communicate with boundary objects.
4. Select the Check Script tab and enter the following script in the text field:
Function %Check%(link)
' Default return is True
%Check% = True
Note
For more information on VBS, see Scripting PowerDesigner [page 330].
6. Repeat these steps to create a second check by entering the following values:
Field Value
Help message This check ensures that an instance link is not defined between two
boundary objects.
Output message The following links between boundary objects are incorrect:
7. Repeat these steps to create a third check by entering the following values:
Field Value
Help Message This check ensures that entity objects are accessed only from
control objects.
We are going to generate a textual description of the messages in the diagram, giving for each message, the
names of the sender, message, and receiver. To do so, we will need to define PowerDesigner Generation Template
Language (GTL) templates to extract the information and a generated file to contain and display the extracted
information.
Context
To generate this textual description, we will need to extract information from the Message metaclass (to extract
the message sequence number, name, sender, and receiver) and the CommunicationDiagram (to gather all the
messages from each diagram and sort them)
1. Right-click the Profile category, select Add Metaclasses to open the Metaclass Selection dialog, select
CommunicationDiagram and Message on the PdOOM tab and click OK to add them to the extension file.
2. Right-click the Message category and select New Template to create a template under the metaclass.
3. Enter description in the Name field, and then enter the following GTL code in the text area:
The first line of the template initializes the _tabs variable, and the foreach_part macro calculates an
appropriate amount of indentation by looping through each sequence number, and adding 3 spaces whenever
a dot is found. The last line uses this variable to indent, format, and display information extracted for each
message.
4. Right-click the CommunicationDiagram category and select New Template to create a template
under the metaclass.
5. Enter compareCbMsgSymbols in the Name field, and then enter the following GTL code in the text area:
This template resolves to a boolean value to determine if one message number is greater than another, and
the result will be used in a second template.
6. Right-click the CommunicationDiagram category and select New Template to create a second
template, enter description in the Name field, and then enter the following GTL code in the text area:
The first line of this template generate the title of the scenario from the name of the communication diagram.
Then the .foreach_item macro loops on each message symbol, and calls on the other templates to format
and output the message information.
Having created templates to extract information about the messages in the model, we need to create a generated
file to contain and display them on the Preview tab of the diagram property sheet. We will define the file on the
BasePackage metaclass, which is the common class for all packages and models, and will have it loop through all
the communication diagrams in the model to evaluate the template description defined on the
CommunicationDiagram metaclass.
Procedure
1. Right-click the Profile category, select Add Metaclasses to open the Metaclass Selection dialog, click the
Modify Metaclass Filter tool, select Show Abstract Modeling Metaclasses, and click the PdCommon
tab.
2. Select BasePackage and click OK to add it to the extension file.
3. Right-click the BasePackage category and select New Generated File to create a file under the
metaclass.
Field Value
Encoding ANSI
.foreach_item(CollaborationDiagrams)
%description%
.next(\n\n)
6. Click Apply to save your changes, and then OK to close the resource editor.
7. Click OK to close the List of Extensions.
For detailed information about creating generated files, see Generated Files (Profile) [page 102].
To test the extensions we have created, we will create a small robustness diagram to analyze our use case.
Procedure
1. Right-click your model node in the Browser, and select New Communication Diagram .
In addition to the standard Toolbox, a custom toolbox is provided with tools you have defined to create
boundary, control, and entity objects.
2. Drag the Customer actor from the Actors category in the Browser into the diagram to create a shortcut. Then
create one each of the boundary, control and entity objects, and name them Internet Browser,
Application Server, and Database Server respectively.
3. Use the Instance Link tool in the standard Toolbox to connect the Customer to the Internet Browser to the
Application Server, to the Database Server.
4. Create the following messages on the Messages tabs of the instance links property sheets:
Metaclasses are defined in the PowerDesigner metamodel and provide the basis for your extensions. You add a
metaclass to the Profile category when you want to extend it in some way by modifying its behavior, adding new
properties, changing its property sheet or symbol, or even excluding it from your models.
Context
You can either make extensions to an existing type of object or create an entirely new kind of modeling object by
adding the ExtendedObject, ExtendedSubObject or ExtendedLink metaclass (see Extended Objects, Sub-
Objects, and Links (Profile) [page 42]).
In the following example, the FederationController is an entirely new type of object created by adding the
ExtendedObject metaclass and defining a stereotype on it. Various specializations of the Table metaclass are
defined through criteria and stereotypes:
For example, a table bearing the FederatedTable stereotype, and for which
the SecureTable criteria evaluates to true, would display the
SecurityLevel, EncryptionKey, and ExternalLogin attributes, while a
table bearing the PriorityTable stereotype, and for which both the
SecureTable and Replicated criteria evaluate to true, would display these
attributes and, additionally, the ReplicationPath and Availability at
tributes.
Procedure
○ All metaclasses
○ Concrete metaclasses - for object types that can be created in a model, such as Class or Interface.
○ Abstract metaclasses -which are never instantiated but are used to define common extensions. For
example, add the Classifier metaclass to your profile to define extensions that will be inherited by both
classes and interfaces.
Note
For information about viewing and navigating among metaclasses in the metamodel, see The
PowerDesigner Public Metamodel [page 364].
Property Description
Name [read-only] Specifies the name of the metaclass. Click the button to the right of this
field to open the Metamodel Objects Help for the metaclass.
Parent [read-only] Specifies the parent of the metaclass. Click the button to the right of this
field to go to the parent. If the parent is not present in the profile, a message invites
you to add it.
Code naming con [concrete metaclasses in target files] Specifies the default format to initialize the
vention name to code conversion script for instances of the metaclass. The following formats
are available:
○ firstLowerWord - First word in lowercase, then other first letters of other words
in uppercase
○ FirstUpperChar - First character of all words in uppercase
○ lower_case - All words in lowercase and separated by an underscore
○ UPPER_CASE - All words in uppercase and separated by an underscore
For more information on conversion scripts and naming conventions, see Core Fea
tures Guide > Modeling with PowerDesigner > Objects > Naming Conventions.
Illegal characters [concrete metaclasses in target files] Specifies a list of illegal characters that may not
be used in code generation for the metaclass. The list must be placed between double
quotes, for example:
"/!=<>""'()"
When working with an OOM, this object-specific list overrides any values specified in
the IllegalChar property for the object language (see Settings Category: Object
Language [page 132]).
Enable selection in Specifies that instances of the metaclass can be selected to generate files from on the
file generation Selection tab of the Generation dialog in an extended generation (see Generating Your
Files in a Standard or Extended Generation [page 106]).
Exclude from model [concrete metaclasses only] Prevents the creation of instances of the metaclass and
removes all references to the metaclass from the menus, Toolbox, property sheets
and so on, to simplify the interface. For example, if you do not use business rules, se
lect this check box for the BusinessRule metaclass to hide them in your models.
When several resource files are attached to a model, the metaclass is excluded if at
least one file excludes it and the others do not explicitly enable it. For models that al
ready have instances of this metaclass, the objects will be preserved but it will not be
possible to create new ones.
Comment Documents the reason for the presence of the metaclass in this profile.
Context
● Extended objects – define new types of objects that can be created anywhere.
● Extended sub-objects – define new types of child objects that can only be created in the property sheet of
their parent via an extended composition (see Extended Collections and Compositions (Profile) [page 60]).
● Extended links – define new types of links between objects.
Procedure
1. Right-click the Profile category, select Add Metaclasses, and click the PdCommon sub-tab in the dialog to
display the list of objects common to all models.
2. Select one or more of ExtendedLink, ExtendedSubObject, and ExtendedObject and click OK to add
them to your profile.
Note
To make the tools for creating extended objects and extended links available in the Toolbox of models
other than the free model, you must add them via the customization dialog available at Tools
Customize Menus and Tools .
3. [optional] To create your own object add a stereotype (see Stereotypes (Profile) [page 44] and define
appropriate extensions under the stereotype. To have your object appear in the PowerDesigner interface as a
standard metaclass, with its own tool, Browser category and model list, select Use as metaclass in the
stereotype definition (see Creating New Metaclasses with Stereotypes [page 46]).
4. Click Apply to save the changes.
Stereotypes subclassify metaclasses so that extensions are applied to objects only if they bear the stereotype.
Stereotypes can be promoted to the status of metaclasses with a specific list, Browser category and custom
symbol and Toolbox tool.
Context
Note
You can define more than one stereotype for a given metaclass, but you can only apply a single stereotype to
each instance. Like other extensions, stereotypes support inheritance, so extensions to a parent stereotype are
inherited by child stereotypes.
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Stereotype .
2. Enter the following properties as appropriate:
Property Description
Name Specifies the internal name of the stereotype, which is used for scripting.
Label Specifies the display name of the stereotype, which will appear in the PowerDesigner inter
face.
Parent Specifies a parent stereotype of the stereotype. You can select a stereotype defined in the
same metaclass or in a parent metaclass. Click the Properties button to go to the parent
stereotype in the tree and display its properties.
Abstract Specifies that the stereotype cannot be applied to metaclass instances. The stereotype
will not appear in the stereotype list in the object property sheet, and can only be used as a
parent of other child stereotypes. Disables the Use as metaclass property.
Use as meta Promotes the stereotype to the same status as standard PowerDesigner metaclasses, to
class give it its own list of objects, Browser category, and its own tab in multi-pane selection
boxes such as those used for generation (see Creating New Metaclasses with Stereotypes
[page 46]).
No Symbol [available when Use as metaclass is selected] Specifies that instances of the stereotyped
metaclass cannot be displayed in a diagram and are visible only in the Browser. Disables
the Toolbox custom tool.
Icon Specifies an icon for stereotyped instances of the metaclass. Click the tools to the right of
this field in order to browse for .cur or .ico files.
Note
The icon is used to identify objects in the Browser and elsewhere in the interface, but
not as a diagram symbol. To specify a custom diagram symbol, see Custom Symbols
(Profile) [page 85].
Toolbox cus [available for objects supporting symbols] Specifies a Toolbox tool to enable you to create
tom tool objects in a diagram. If you do not select this option, users are only able to create objects
bearing the stereotype from the Browser or Model menu. Custom tools appear in a sepa
rate Toolbox group named after the resource file in which they are defined.
Note
If you have not specified an icon, the tool will use a hammer icon by default.
Plural label [available when Use as metaclass is selected] Specifies the plural form of the display name
that will appear in the PowerDesigner interface.
Default name [available when Use as metaclass or Toolbox Custom Tool is selected] Specifies a default
name for objects created. A counter will be automatically appended to the name specified
to generate unique names.
A default name can be useful when designing for a target language or application with
strict naming conventions. Note that the default name does not prevail over model naming
conventions, so if a name is not correct it is automatically modified.
You can use stereotypes to create new kinds of objects that behave like standard PowerDesigner metaclasses or
to have objects with identical names but different stereotypes in the same namespace (a metaclass stereotype
creates a sub-namespace in the current metaclass).
Context
For examples, see Creating New Types of Objects with Stereotypes [page 25].
Note
Stereotypes defined on sub-objects (such as table columns or entity attributes), cannot be promoted to
metaclass status.
1. Create a stereotype under the metaclass on which you want to base your new metaclass. If the new object
type does not share characteristics with an existing metaclass, then use the ExtendedObject metaclass.
Note
If the ExtendedObject or other metaclass is not visible, add it by right-clicking the Profile category, and
selecting Add Metaclass (see Metaclasses (Profile) [page 39]).
○ A separate list in the Model menu after the parent metaclass list (and the parent metaclass list will not
display objects with the metaclass stereotype). Objects created in the new list bear the new metaclass
stereotype by default. If you change the stereotype, the object will be removed from the list the next time
it is opened.
○ A separate Browser folder and command under New, when you right-click the model or a package.
○ Property sheet titles based on the metaclass label.
○ Its own tab in multi-pane selection boxes such as those used for generation.
5. [optional: DBMS definition files] Add the new object to the Script/Objects and define appropriate SQL
statements to enable its generation and reverse-engineering (see Defining Generation and Reverse-
Engineering of New Metaclasses [page 154]).
Criteria subclassify metaclasses so that extensions are applied to objects only if they satisfy conditions. You can
test an object instance against multiple criteria, and for sub-criteria, its condition and any conditions specified by
its parents must be met for its extensions to be applied to the instance.
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Criterion .
2. Enter the following properties as appropriate:
Property Description
Condition Specifies the condition which instances must meet in order to access the criterion exten
sions. You can use any expressions valid for the PowerDesigner GTL .if macro (see .if
Macro [page 302]). You can reference any extended attributes defined at the metaclass
level in the condition, but not those defined under the criterion itself.
For example, in a PDM, you can customize the symbols of fact tables by creating a crite
rion that will test the type of the table using the following condition:
(%DimensionalType% == "1")
Parent Specifies the parent criterion of the criterion. To move the criterion to under another pa
rent, select the parent in the list. Click the Properties tool to open the parent and view its
properties.
Extended attributes define additional metadata to capture for object instances. You can specify a default value,
allow users to freely enter numeric, string, or other types of data (or select objects), provide an open or closed list
of possible values, or calculate a value.
Context
Note
Extended attributes are listed on a generic Extended Attributes tab in the object property sheet, unless you
insert them into forms (see Forms (Profile) [page 68]). If all the extended attributes are allocated to forms,
the generic page will not be displayed.
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Extended
Attribute .
2. Specify the following properties as appropriate:
Property Description
Name Specifies the internal name of the attribute, which can be used for scripting.
Label Specifies the display name of the attribute, which will appear in the PowerDesigner inter
face.
Data type Specifies the form of the data to be held by the extended attribute. You can choose from:
Select the Validate check box to the right of the list to enforce validation of the values en
tered for the attribute.
To create your own data type, click the Create Extended Attribute Type tool to the right of
the field (see Creating an Extended Attribute Type [page 55]).
Computed Specifies that the extended attribute is calculated from other values using VBScript on
the Get Method Script, Set Method Script, and Global Script tabs, or via an aggregation
specified on the Definition tab. When you select this checkbox, you must choose between:
Default value [if not computed] Specifies a default value for the attribute. You can specify the value in
any of the following ways:
Template [if not computed] Specifies that the value of the attribute is to be evaluated as a GTL
template at generation time. For example, if the value of the attribute is set to %Code%, it
will be generated as the value of the code attribute of the relevant object.
By default (when this checkbox is not selected), the attribute is evaluated literally, and a
value of %Code% will be generated as the string %Code%.
List of values Specifies a list of possible values for the attribute in one of the following ways:
.collection([Link], %Generated%==true)
For more complex filtering, use the foreach_item macro (see .foreach_item Macro
[page 297]):
.foreach_item ([Link])
.if %Generated%
.// (or more complex criteria)
%ObjectID%
.endif
.next (\n)
If the attribute is based on an extended attribute type (see Creating an Extended Attribute
Type [page 55]), this field is unavailable since the values of the extended attribute type
will be used.
Complete Specifies that all possible values for the attribute are defined in the List of values, and that
the user may not enter any other value.
Edit method [if not Complete] Specifies a method to override the default action associated with the
tool to the right of the field.
This method is often used to apply a filter defined in the List of values field in the object
picker. In the following example, only tables with the Generated attribute set to true will
be available for selection:
Sub %Method%(obj)
Dim Mdl
Set Mdl = [Link]
Dim Sel
Set Sel = [Link]
[Link]
End If
End Sub
Icon Set Specifies a set of icons to display on object symbols in place of extended attribute values
(see Specifying Icons for Attribute Values [page 56]).
Text format [for Text data types only] Specifies the language contained within the text attribute. If
you select any value other than plain Text, then an editor toolbar and (where appropri
ate) syntax coloring are provided in the associated form fields.
Object type / [for Object data types only] Specify the type of the object that the attribute contains (for
stereotype / In example, User, Table, Class) and, optionally a stereotype that objects of this type must
verse collection bear to be selectable.
name
If the computed option is not selectd, you can also specify the name under which the
links to the object will be listed on the Dependencies tab of the target object.
An extended collection with the same name as the extended attribute, which handles
these links, is automatically created for all non-computed extended attributes of the Ob
ject type, and is deleted when you delete the extended attribute, change its type, or select
the Computed checkbox.
Physical option [for [Physical Option] data types only] Specifies the physical option with which the attrib
ute is associated. Click the ellipsis to the right of this field to select a physical option. For
more information, see Adding DBMS Physical Options to Your Forms [page 232].
Unit [for aggregated metric calculated attributes] Specifies the currency unit to apply to the
metric.
You can create extended attributes whose values depend on the values of other attributes. These can be read-
only or read and write.
The following scripts provide a means for reading and writing the value from the standard Name attribute into a
calculated extended attribute:
The following scripts read the value of the computed FileGroup extended attribute from the filegroup
physical option, and write back to the physical attribute:
The following script reads the value of the name of the database associated with the PDM into the read-only
Database extended attribute defined on the table metaclass:
[none]
Function %Get%(obj)
%Get% =
[Link]("[Link]"
)
End Function
The following script evaluates the value of the Number attribute of a table to set the boolean BigTable extended
attribute:
[none]
Function %Get%(obj)
%Get% = [Link]("Number") >
99999
End Function
Function %Get%(obj)
Dim value
If [Link]("Number") >
99999 then
value = true
Else
value = false
End if
%Get% = value
End Function
The following script evaluates the value of the Number attribute of a table to set a text TableSize extended
attribute:
[none]
Function %Get%(obj)
Dim value
If [Link]("Number") <
10000 then
value = "Small"
ElseIf (([Link]("Number")
> 9999) and
([Link]("Number") < 100000))
then
value = "Medium"
ElseIf (([Link]("Number")
> 99999) and
([Link]("Number") <
1000000)) then
value = "Large"
Else
value = "Very Large"
End if
%Get% = value
End Function
You can create extended attribute types to define the data type and authorized values of extended attributes.
Creating extended attribute types allows you to reuse the same list of values for several extended attributes
without having to write code.
Procedure
1. Right-click the Profile\Shared category and select New Extended Attribute Type .
2. Enter the appropriate properties, including a list of values and a default value.
The new shared type is available to any extended attribute in the Data Type field. You can also define a list of
values for a given extended attribute directly in this field (see Extended Attributes (Profile) [page 49]).
You can specify icons to display on object symbols in place of extended attribute values by creating an attribute
icon set with individual attribute value icons for each possible value.
Procedure
A new icon set is created at Profile Shared Attribute Icon Sets initialized with the possible values and
an empty icon which matches any value for which another icon has not been defined (=*).
Note
By default, the Filter operator field is set to =, and each icon matches exactly one possible value. To have a
single icon match multiple values, use the Between or another operator together with a suitable Filter
value. For example, in an icon set paired with a progress attribute for which the user can enter any value
between 0 and 100% progress, you could use three icons:
○ Not Started - = 0
○ In Progress - Between 1,99
○ Completed - = 100
6. If appropriate, add the attribute to a form (see Forms (Profile) [page 68]), to enable users to modify its
value.
7. Click OK to save your changes and return to the model.
8. To enable the display of the icon on your object symbol, select Tools Display Preferences , select your
object type, and click the Advanced button to add your attribute to the symbol. For detailed information about
working with display preferences, see Core Features Guide > Modeling with PowerDesigner > Diagrams,
Matrices, and Symbols > Display Preferences.
Your attribute is now displayed on object symbols. In the following example, the Employee entity is In
Progress, while the Customer entity is Completed:
Specify the [Object] data type to allow users to select another object as the value of the attribute. You must
specify an Object type (metaclass) to link to, and can optionally specify an Object stereotype to filter the objects
available for selection and an Inverse collection name, which will be displayed on the Dependencies tab on the
referenced object property sheet.
For example, under the Table metaclass, I create an extended attribute called Owner, select [Object] in the Data
type field, and User in the Object type field. I name the inverse collection Tables owned. When I set the Owner
property of a table, the table will be listed on the Dependencies tab of the user property sheet, under the inverse
collection name of Tables owned.
Aggregated metrics are extended attribues that contain values calculated by aggregating other values from other
objects. For example, if EAM business functions are linked to multiple systems that support them, and an annual
cost is specified for each system, you could create an aggregated metric for business functions that will calculate
the total annual costs.
Context
Procedure
Property Description
Function Specifies how the aggregated values will be calculated. You can choose from:
Attributes Lists the numeric attributes available for aggregation in the metaclass itself. Select
one or more attributes to include them in the calculation.
Collections Specifies the paths to other metaclassess that will provide values to the aggregated
metric. To specify a path:
You can specify as many paths and measures as necessary, and all will be aggregated
together.
3. [optional] Add your aggregated metric to a property sheet (see Forms (Profile) [page 68]).
4. Click Apply to save your changes, or OK to return to your model.
In this example, extended attributes have been added to the application, database, and system metaclasses,
and the Total Annual Cost aggregated metric defined on the system aggregates these values:
Extended collections define the possibility to associate an object instance with a group of other objects of the
specified type. Extended compositions define a parent-child connection between an object instance and a group
of sub-objects derived from the ExtendedSubObject metaclass.
Context
For extended collections, the association between the parent and child objects is relatively weak, so that if you
copy or move the parent object, the related objects are not copied or moved, but the connection is maintained
(using shortcuts if necessary). For example, you could associate documents containing use case specifications
with the different packages of a model by creating an extended collection under the Package metaclass and
specifying FileObject as the target metaclass.
For extended compositions, the association is stronger. Sub-objects can only be created within the parent object
and are moved, copied, and/or deleted along with their parent.
The collection or composition is displayed as a new tab in the object instance property sheet. The property sheets
of objects referenced in a collection show the object instance owning the collection on their Dependencies tab.
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Extended
Collection or Extended Composition.
Note
If you define the collection or composition under a stereotype or criterion, its tab is displayed only if the
metaclass instance bears the stereotype or meets the criterion.
Property Description
Label Specifies the display name of the collection, which will appear as the name of the tab asso
ciated with the collection in the parent object property sheet.
Inverse Name [extended collection only] Specifies the name to appear in the Dependencies tab of the tar
get metaclass. If you do not enter a value, an inverse name is automatically generated.
Target Type Specifies the metaclass whose instances will appear in the collection.
For extended collections, the list displays only metaclasses that can be directly instanti
ated in the current model or package, such as classes or tables, and not sub-objects such
as class attributes or table columns. Click the Select a Metaclass tool to the right of this
field to choose a metaclass from another type of model.
For extended compositions, only the ExtendedSubObject is available, and you must spec
ify a stereotype for it.
Target Stereo [required for extended compositions] Specifies a stereotype to filter the target type. You
type can select an existing stereotype from the list or click the Create tool to the right of this
field to create a new one.
List Columns Specifies the property columns that will be displayed by default in the parent object prop
erty sheet tab associated with the collection. Click the Customize Default Columns tool to
the right of this field to add or remove columns.
Note
When you open a model containing extended collections or compositions and associate it with a resource
file that does not support them, the collections are still visible in the different property sheets in order to let
you delete objects in the collections no longer supported.
Calculated collections define a read-only connection between an object instance and a group of other objects of
the specified type. The collection displays as a sub-tab on the Dependencies tab of the object property sheet. The
logic of the collection is defined using VBScript.
Context
For example, in an OOM, you may need to create a list of sequence diagrams using an operation, and can create a
calculated collection on the operation metaclass that retrieves this information. In a BPM, you could create a
calculated collection on the process metaclass that lists the CDM entities created from data associated with the
process.
You can loop on calculated collections with GTL (see Accessing Collections of Sub-Objects or Related Objects
[page 273]) You can use calculated collections to fine-tune impact analysis to better evaluate the impact of a
change. For example, in a model where columns and domains can diverge, you can create a calculated collection
on the domain metaclass that lists all the columns that use the domain and have the same data type.
Note
Calculated collections, unlike extended collections (see Extended Collections and Compositions (Profile) [page
60]) cannot be modified by the user.
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Calculated
Collection .
2. Enter the following properties as appropriate:
Name Specifies the name of the calculated collection for use in scripts.
Label Specifies the display name of the collection, which will appear as the name of the tab
associated with the collection in the parent object property sheet.
Target Type Specifies the metaclass whose instances will appear in the collection. The list displays
only metaclasses that can be directly instantiated in the current model or package,
such as classes or tables, and not sub-objects such as class attributes or table col
umns.
Click the Select a Metaclass tool to the right of this field to choose a metaclass from
another type of model.
Target Stereotype [optional] Specifies a stereotype to filter the target type. You can select an existing
stereotype from the list or enter a new one.
List Columns Specifies the columns displayed by default on the collection property sheet tab.
3. Click the Calculated Collection Script tab and enter a script that will calculate which objects will form the
collection.
The following script recreates the list on the Outgoing References sub-tab on a table's Dependencies tab:
Note
You can reuse functions on the Global Script tab (see Global Script (Profile) [page 128]) but you should be
aware that if you declare global variables they will not be reinitialized each time the collection is calculated,
and will keep their value until you modify the resource file, or the PowerDesigner session ends. This may
cause errors, especially when variables reference objects that can be modified or deleted. Make sure you
reinitialize the global variable if you do not want to keep the value from a previous run.
Dependency matrices allow you to review and create links between any kind of objects. You specify one metaclass
for the matrix rows, and the same or another metaclass for the columns. The contents of the cells are then
calculated from a collection or link object.
Context
For example, you could create dependency matrices that show links between:
Procedure
1. Right-click the Profile category and select Add Dependency Matrix to add the DependencyMatrix metaclass
to the profile and create a stereotype under it, in which you will define the matrix properties.
2. On the General tab, enter a name for the matrix (for example Table Owners Matrix) along with a label and
plural label for use in the PowerDesigner interface, as well as a default name for the matrices that users will
create based on this definition.
3. Click the Definition tab to specify the rows and columns of your matrix and how they are associated using the
following properties.
Property Description
Rows Specifies the object type with which to populate your matrix rows.
Columns Specifies the object type with which to populate your matrix columns. Click the Select
Metaclass button to the right of the list to select a metaclass from another model type.
Matrix Cells Specifies how the rows and columns of your matrix will be associated. You must specify a
Dependency from the list, which includes all the collections and links available to the ob
ject.
Click the Create button to the right of the list to create a new extended collection (see Ex
tended Collections and Compositions (Profile) [page 60]) connecting your objects, or the
Advanced button to specify a complex dependency path (see Specifying Advanced De
pendencies [page 67]).
For certain dependencies, the Object type on which the dependency is based will be dis
played, and you can select an Object attribute to display in the matrix cells along with the
No value symbol, which is displayed if that attribute is not set in any particular instance.
You can now create instances of the matrix in your model as follows:
Note
For information about using dependency matrices, see Core Features Guide > Modeling with
PowerDesigner > Diagrams, Matrices, and Symbols > Dependency Matrices.
You can examine dependencies between two types of objects that are not directly associated with each other,
using the Dependency Path Definition dialog, which is accessible by clicking the Advanced button on the Definition
tab, and which allows you to specify a path passing through as many intermediate linking objects as necessary.
Property Description
Name Specifies a name for the dependency path. By default, this field is populated with the origin
and destination object types.
Dependency Specifies the dependency for this step in the path. The list is populated with all the possible
dependencies for the previous object type.
Object Type Specifies the specific object type that is linked to the previous object type by the selected
dependency. This field is autopopulated if only one object type is available through the se
lected dependency.
In the following example, a path is identified between business functions and roles, by passing from the business
function through the processes it contains, to the role linked to it by a role association:
Forms present standard and extended attributes and collections as property sheet tabs or can be used to create
dialog boxes launched from menus or property sheet buttons.
Context
Note
Unless you add them to a form, extended attributes are listed alphabetically on the Extended Attributes tab of
the object's property sheet. By creating your own form, you can make these attributes more visible and easy to
use, by organizing them logically, grouping related ones, and emphasizing those that are most important. If you
associate all of your extended attributes with a form, the Extended Attributes tab is not displayed.
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Form .
Note
If you define a property tab under a stereotype or criterion, it is displayed only when the metaclass instance
bears the stereotype or meets the criterion.
Property Description
Name Specifies the internal name of the form, which can be used for scripting.
Label Specifies the display name of the form, which will display in the tab of the property tab or in
the title bar of the dialog box.
Help file Enables the display of a Help button and specifies an action that will be performed when the
button is clicked or F1 is pressed when in the context of the form.
The action can be the display of a help file (.hlp, .chm or .html), and can specify a specific
topic. For instance:
C:\PD1500\[Link] 26204
If no help file extension is found, the string will be treated as a shell command to execute. For
instance, you could instruct PowerDesigner to open a simple text file:
[Link] C:\Temp\[Link]
Type Specifies the kind of form. You can choose from the following:
○ Dialog Box – creates a dialog box that can be launched from a menu or via a form button
○ Property Tab – creates a new tab in the property sheet of the metaclass, stereotype or
criterion
○ Replace <<standard> > Tab – replaces a standard tab in the property sheet of the met
aclass, stereotype or criterion. If your form is empty, it will be filled with the standard con
trols from the tab that you are replacing.
Add to fa [property tabs only] Specifies that the tab is displayed by default in the object property sheet.
vorite tabs
3. Insert controls as necessary in your form using the toolbar on the Form tab (see Adding Extended Attributes
and Other Controls to Your Form [page 70]).
4. Click the Preview button to review the layout of your form and, when satisfied, click Apply to save your
changes.
You insert controls into your form using the tools in the Form tab toolbar. You can reorder controls in the form
control tree by dragging and dropping them. To place a control inside a container control (group box or horizontal
or vertical layout), drop it onto the container. For example, if you want the extended attributes GUID, InputGUID,
and OutputGUID to be displayed in a GUI group box, you should create a group box, name it GUI and drag and
drop all three extended attributes under the GUI group box.
Tool Description
Add Attribute / Collection – opens a selection box in which you select standard or extended attrib
utes or collections belonging to the metaclass to insert into the form. If you do not enter a label,
the attribute or collection name is used as its form label. If you have entered a comment, it is dis
played as a tooltip.
The type of control associated with an attribute depends on its type: booleans are associated with
check boxes, lists with combo boxes, text fields with multi-line edit boxes, and so on. Collections
are displayed as standard grids with all the appropriate tools.
Add Group Box - inserts a group box, intended to contain other controls within a named box.
Add Tab Window - inserts a sub-tab layout, in which each child control appears, by default, in its
own sub-tab. To place multiple controls on a single sub-tab, use a horizontal or vertical layout.
Add Horizontal / Vertical Layout - inserts a horizontal or vertical layout. To arrange controls to dis
play side by side, drag them onto a horizontal layout in the list. To arrange attributes to display one
under the other, drag them onto a vertical layout in the list. Vertical and horizontal layouts are of
ten used together to provide columns of controls.
Include Another Form - inserts a form defined on this or another metaclass in the present form
(see Example: Including a Form in a Form [page 79]).
Add Method Push Button - opens a selection box in which you select one or more methods belong
ing to the metaclass to associate with the form via buttons. Clicking the button invokes the
method. If you do not enter a label, the method name is used as the button label. If you have en
tered a comment, it is displayed as a tooltip.
Add Edit / Multi-Line Edit Field [dialog boxes only] inserts an edit or multi-line edit field.
Add Combo Box / List Box / Check Box [dialog boxes only] - inserts a combo box, list box, or check
box.
Add Text / Separator Line / Spacer - inserts the appropriate decorative control. The separator line
is vertical when its parent control is a vertical layout.
Property Definition
Name Internal name of the control. This name must be unique within the form. The name can be
used in scripts to get and set dialog box control values (see Example: Opening a Dialog Box
from a Menu [page 99]).
Label Specifies a label for the control on the form. If this field is left blank, the name of the control is
used. If you enter a space, then no label is displayed. You can insert line breaks with \n.
To create keyboard shortcuts to navigate among controls, prefix the letter that will serve as
the shortcut with an ampersand. If you do not specify a shortcut key, PowerDesigner will
choose one by default. To display an ampersand in a label, you must escape it with a second
ampersand (for example: &Johnson && Son will display as Johnson & Son.
Attribute [included forms] Specifies the object on which the form to be included is defined. The list is
populated with all attributes of type object and the following objects:
Form name [included forms] Specifies the name of the form that will be included. You can:
Indentation [container controls] Specifies the space in pixels between the left margin of the container
(form, group box, or horizontal or vertical layout) and the beginning of the labels of its child
controls.
Label space [container controls] Specifies the space in pixels reserved for displaying the labels of child
controls between the indentation of the container and the control fields.
To align controls with the controls in a previous container, enter a negative value. For exam
ple, if you have two group boxes, and want all controls in both to be aligned identically, set an
appropriate indentation in the first group box and set the indentation of the second group
box to -1.
If a child control label is larger than the specified value, the label space property is ignored; to
display this label, you need to type a number of pixels greater than 50.
Show control as [group boxes] Use the first control contained within the group box as its label.
label
Show Hidden At [extended attributes] Displays controls that are not valid for a particular form (because they
tribute do not bear the relevant stereotype, or do not meet the criteria) as greyed. If this option is
not set, irrelevant options are hidden.
Value [dialog box entry fields] Specifies a default value for the control. For extended attributes, de
fault values must be specified in the attribute's properties (see Extended Attributes (Profile)
[page 49]).
List of Values [combo and list boxes] Specifies a list of possible values for the control. For extended attrib
utes, lists of values must be specified in the attribute's properties (see Extended Attributes
(Profile) [page 49]).
Exclusive [combo boxes] Specifies that only the values defined in the List of values can be entered in
the combo box.
Minimum Size Specifies the minimum width (in characters) to which the control may be reduced when the
(chars) window is resized.
Minimum Line Specifies the minimum number of lines to which a multiline control may be reduced when the
Number window is resized.
Horizontal / Ver Specifies that the control may be resized horizontally or, for multiline controls, vertically,
tical Resize when the property sheet or dialog is resized.
Read-Only [included forms and dialog box entry fields] Specifies that the control is read-only, and will be
greyed in the form.
Left Text [booleans] Places the label text to the left of the checkbox.
Display [booleans and methods] Specifies the form in which the boolean options or method button
are displayed.
For booleans, you can choose between a check box or vertical or horizontal radio buttons,
while for methods, you can choose from a range of standard icons or Text, which prints the
text specified in the Label field on the button.
Width/ Height [spacers] Specify the width and height, in pixels, of the spacer.
In this example, we will give instructions for creating each of the most common controls for presenting attributes
on your forms.
The following form contains many of the most commonly-used controls for presenting attributes in your forms:
Control Requires
Single-line text Select the String, Password (masks entered values), or Float, Hex, or Integer data
type for your attribute.
Read-only Select any data type, check the Computed and Read only (Get method) options and enter
the necessary script to calculate the value that will be displayed.
Multi-line rich text Select the Text data type and the RTF text format. You can select a number of other text
formats to display various types of code or plain text.
Checkbox Select the Boolean data type. Use the Default value field to specify whether the checkbox
should be selected or not by default.
Radio Buttons Select any appropriate data type, enter a list of values, and select the Complete option.
When adding your attribute to the form, select either horizontal or vertical radio buttons
from the Display option.
File, Date, or Color Select the File, Date, or Color data type.
Picker
Choose value from Select any appropriate data type and enter a list of values to allow the user to select a
list or Enter or value from the list or enter their own value. Select the Complete option to force the user
choose value to select from the list.
Choose object Select the Object data type and then select an object type and optionally an object ster
eotype (see Linking Objects Through Extended Attributes [page 58]).
In this example, we will create a new property tab for the EAM Person metaclass to display extended attributes we
define to store personal information.
Procedure
1. Create a new extension file (see Creating an Extension File [page 19]) in an EAM, add the Person metaclass
(see Metaclasses (Profile) [page 39]), and define five extended attributes (see Extended Attributes (Profile)
[page 49]) to contain home contact details:
3. Click OK to add the attributes to the form, and arrange them in a group box, using horizontal layouts to align
them neatly. Here, I'm using the Label field to overide the default name of the attribute in the form for brevity:
In this example, we will replace the General tab of the EAM Person metaclass by a form which includes properties
from the person and from the site to which she is assigned by including a form defined on the Site metaclass as a
read-only control in a form defined on the Person metaclass.
Context
This example builds on the extension file created in Example: Creating a Property Sheet Tab [page 76].
Procedure
1. Add the Site metaclass and create a form called Site Address. Select Property Tab from the Type list
and unselect the Add to favorite tabs option (as we do not want this form, which duplicates standard site
properties displayed in site property sheets).
2. Populate the form with standard attributes to display the complete address of the site:
In this example, we will add a button to a property sheet tab, to open a dialog box, allowing you to enter additional
personal details for a person.
Context
This example builds on the extension file developed in Example: Including a Form in a Form [page 79].
Procedure
1. Open the Personal Details form under the Person metaclass, and select Dialog Box in the Type field,
to transform it from a property sheet tab into an independent dialog:
Sub %Method%(obj)
' Show custom dialog for advanced extended attributes
Dim dlg
Set dlg = [Link]("%CurrentTargetCode%.Personal Details")
If not dlg is Nothing Then
[Link]()
End If
End Sub
3. Select the Contact Details form, and click the Add Method Push Button tool, select the
ShowPersonalDetails method, and then click OK to add it to the form. Here, I use a horizontal layout and
spacer to align the button with the right edge of the form:
Custom symbols modify the appearance of object symbols in diagrams along with the content displayed on them.
You can choose to enforce certain aspects of the symbol format and content, while allowing users some liberty to
change others.
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Custom Symbol .
Note
If you customize the line style and arrows of a link symbol (such as a PDM reference), your styles will
override those selected in the Display Preferences dialog, and may cause confusion and inconsistency in
the model. To ensure coherence in a model governed by a notation, select Notation for the Style and
Arrows properties on the Line Style tab.
For more information on the Symbol Format dialog (including the custom symbol options that let you control
the default format options for the symbol, and whether users can edit them, on a per-tab basis) see Core
Features Guide > Modeling with PowerDesigner > Diagrams, Matrices, and Symbols > Symbols > Symbol
Format Properties.
3. Click OK to return to the resource editor and view your changes in the Preview field.
4. Click Apply to save your changes.
Custom checks define additional rules to validate the content of your models. The logic of the check is defined
using VBScript. Custom checks appear alongside standard checks in the Check Model dialog.
Context
Custom checks appear with standard model checks in the Check Model Parameters dialog (see Core Features
Guide > Modeling with PowerDesigner > Objects > Checking Models).
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Custom Check .
2. Enter the following properties as appropriate:
Parameter Description
Name Specifies the name of the custom check, which is displayed under the selected
object category in the Check Model Parameters dialog. This name is also used
(concatenated) in the check function name to uniquely identify it.
Help Message Specifies text to display in the message box that opens when the user right-
clicks the check and selects Help.
Output message Specifies text to display in the Output window during check execution.
Default severity Specifies whether the check is designated by default as an error (major problem
that stops generation) or a warning (minor problem or just recommendation).
Execute the check by de Specifies that the check is selected by default in the Check Model Parameters
fault dialog.
Enable automatic correc Specifies that an autofix is available for the check (see Example: PDM Autofix
tion [page 89]).
3. Click the Check Script tab and enter your script (see Example: PDM Custom Check [page 89]. You can
access shared library functions and static attributes defined for reuse in the resource file from the Global
Script tab (see Global Script (Profile) [page 128]).
All custom checks defined in any resource files attached to the model are merged and all the functions for all
the custom checks are appended to build one single script. You custom checks are displayed in the Check
Model Parameters dialog box alongside the standard model checks. If there are errors in your custom check
scripts, the user will be prompted with the following options:
○ Ignore- Skip the problematic script and continue with the other checks.
○ Ignore All - Skip this and any future scripts with problems and continue with the other checks.
○ Abort - Stop the model checking.
○ Debug - Stop the model checking and open the Resource Editor on the script line with the problem.
You enter the script of the custom check in the Check Script tab using VBScript. In this example, we will write a
script to verify that SAP® IQ indexes of type HG, HNG, CMP, or LF are not linked with columns with a data type of
VARCHAR with a length higher than 255.
The script is initialized with the following line, which must not be altered:
Function %Check%(obj)
At run-time the variable %Check% is replaced by concatenating the names of the resource file, metaclass, any
stereotypes or criteria, and the name of the check itself from the General tab, with any spaces replaced by an
underscore. The parameter obj contains the object being checked.
We begin by defining a certain number of variables after the default function definition:
Next, we enter the function body, which starts by setting the %Check% to true (meaning that the object passes the
test) and then iterates over each of the columns associated with the index and tests their datatype. If a column
has a varchar longer than 255, the script outputs a message and sets the check to false (the object fails the test:
%Check%= True
position = InStr([Link],"(")
if position <> 0 then
DT_col = left([Link], position -1)
else
DT_col = [Link]
end if
if ucase(DT_col) = "VARCHAR" and [Link] > 255 then
output "Table " & [Link] & " Column " & [Link] & " : Data type is
not compatible with Index " & [Link] & " type " & [Link]
%Check% = False
end if
For more information about using VBScript in PowerDesigner, see Scripting PowerDesigner [page 330].
If the custom check you have defined supports an automatic correction, you enter its script on the Autofix Script
tab using VBScript. In this example, we will write a script to fix an IQ index linked with columns with an invalid data
type.
The script is initialized with the following line, which must not be altered:
We begin by defining a certain number of variables after the default function definition:
Next, we enter the function body, which starts by setting the %Fix% to false (meaning that it does nothing) and
then iterates over each of the columns associated with the index and tests their datatype. If a column has a
varchar longer than 255, the script outputs a message, deletes the column from the collection of columns
associated with the index, and sets the fix to true (it has made a correction):
%Fix% = False
If [Link] = "LF" or [Link] = "HG" or [Link] = "CMP" or [Link] ="HNG" Then
For Each c In [Link]
Set col = [Link]
position = InStr([Link],"(")
If position <> 0 Then
DT_col = Left([Link], position -1)
Else
DT_col = [Link]
End If
If (Ucase(DT_col) = "VARCHAR") And ([Link] > 255) Then
outmsg = "Automatic correction has removed column " & [Link] & " from index."
[Link]
%Fix% = True
End If
Next
End If
Event handlers define validation rules or other scripts to run when an event occurs on an object. The logic of the
event handler is defined using VBScript. Criteria do not support event handlers.
Procedure
1. Right-click a metaclass or stereotype in the Profile category and select New Event Handler to open a
selection box, listing the available types of event handlers:
CanCreate Implements a validation rule to prevent objects from being created in an invalid
context. For example, in a BPM for ebXML, a process with a Business Transactions
stereotype can only be created under a process with a Binary Collaboration stereo
type. The script of the CanCreate event handler associated with the Business
Transaction process stereotype is the following:
Function %CanCreate%(parent)
if parent is Nothing or
[Link](PdBpm.Cls_Process) then
%CanCreate% = False
else
%CanCreate% = True
end if
End Function
If the event handler returns True on a stereotype, then you can use the custom tool
to create the stereotyped object and the stereotype is available in the Stereotype
list on the object property sheet. If it returns True on a metaclass, then you can
create the object from the Toolbox, from the Browser or in a list.
Note
CanCreate event handlers are ignored during model import or reverse-engi
neering, since they could modify the model and make it diverge from the source.
Note
This event handler cannot prevent the deletion of an object.
Initialize Allows you to insert actions after the creation of an object with a predefined tem
plate. For example, in a BPM, a Business Transaction must be a composite process
with a predefined sub-graph. The script of the Initialize event handler associated
with the Business Transaction process stereotype contains all the functions
needed to create the sub-graph. The following script fragment is from the Initialize
event handler for a Business Transaction.
...
' Search for an existing requesting activity
symbol
Dim ReqSym
Set ReqSym = Nothing
If Not ReqBizAct is Nothing Then
If [Link] > 0 Then
Set ReqSym = [Link](0)
End If
End If
If the event handler returns True on a stereotype, then the initialization script will
be launched whenever the stereotype is assigned, either with a custom tool in the
Toolbox, or from the object property sheet. If it returns True on a metaclass, then it
will be launched when you create a new object from the Toolbox, from the Browser,
in a list or in a property sheet. If it returns true on a model, then it will be launched
when you assign a target (DBMS or object, process, or schema language) to the
model at creation time, when you change the target of the model, or when you at
tach an extension to the model.
Validate Validates changes to object properties or triggers cascade updates when you
change tabs or click OK or Apply in an object property sheet. You can define an er
ror message to appear when the condition is not satisfied by filling the message
variable and setting the %Validate% variable to False.
In this example, the event handler verifies that a comment is added to the definition
of an object:
CanLinkKind [link objects] Validates the kind and stereotype of the objects that can be linked to
gether as the source and destination extremities when you create a link with a
Toolbox tool or modify link ends in a property sheet. The sourceStereotype and
destinationStereotype parameters are optional.
In this example, the source of the extended link must be a start object:
OnModelOpen, OnMo [models] Run immediately after a model is opened, saved, or closed.
delSave, and OnModel
Close
OnNewFromTemplate [models] Runs immediately after a model or a project is created from a model or
project template.
GetObjectLabel, Se Allow you to override the standard label displayed on symbols and in the Browser.
tObjectLabel, GetOb For example, the following script prefaces the displayed name of an object with
jectTooltip CORE: if the boolean extended attribute Core is selected:
Function %GetObjectLabel%(obj)
If [Link]("Core") = true then
%GetObjectLabel% = "CORE: " & [Link]
Else
%GetObjectLabel% = [Link]
End if
End Function
GetEstimatedSize [PDM only] Runs when the Estimate Database Size mechanic is called (see Modify
ing the Estimate Database Size Mechanism [page 223]).
You can set a default value for most object properties via an Initialize event handler.
Procedure
1. Add the appropriate metaclass to your profile (see Metaclasses (Profile) [page 39]), and create an event
handler of type Initialize under it.
obj.<PropertyName> = <Value>
For example, the following script sets the stereotype of a CDM inheritance to MyInheritance and its
Generate children property to the value of Inherit only primary attributes:
Function %Initialize%(obj)
[Link] = "MyInheritance"
[Link] = False
%Initialize% = True
End Function
Methods are written in VBScript and perform actions on objects when they are invoked by other extensions, such
as menu items or form buttons.
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Method .
2. Enter the following properties as appropriate:
Property Description
3. Click the Method Script tab, and enter the VBscript. If appropriate, you can reuse functions on the Global
Script tab.
For more information on defining a script and using the Global Script tab, see Example: PDM Custom Check
[page 89] and Global Script (Profile) [page 128].
The following example, created under the Class metaclass, converts classes into interfaces by copying basic
class properties and operations, deleting the class (to avoid namespace problems), and creating the new
interface.
Sub %Mthd%(obj)
' Convert class to interface
Note
This script does not deal with other class properties, or with interface display, but a method can be used to
launch a custom dialog box to ask for end-user input before performing its action (see Example: Opening a
Dialog Box from a Menu [page 99]).
Menus specify commands to appear in the standard PowerDesigner File, Tools, and Help menus or in contextual
menus.
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Menu .
2. Enter the following properties as appropriate:
Property Description
Name Specifies the internal name of the menu. This name will not appear in the menu
Location [model and diagram only] Specifies where the menu will be displayed. You can choose
between:
Menus created on other metaclasses are only available on the contextual menu, and do
not display a Location field.
3. Use the tools on the Menu sub-tab to create the items in your menu:
Tool Function
Add Command - Opens a selection dialog listing methods (see Methods (Profile) [page 96]) and
transformations (see Transformations (Profile) [page 109]) defined in the current metaclass and
its parents to add to the menu as commands. Select one or more and click OK.
MenuEntry (Method/TransformationName)
You can modify the MenuEntry (and define a shortcut key by adding an ampersand before the
shortkey letter) but you must not edit the Method/TransformationName.
Note
If you modify the name of a method or transformation, you must update any commands using
the method or transformation by hand, because the name is not automatically synchronized.
You can use the Replace in Items tool to locate and update these commands.
You can reorder items in the menu tree by dragging and dropping them. To place an item inside a submenu
item, drop it onto the submenu.
Procedure
1. Create a new extension file (see Creating an Extension File [page 19]) in a PDM and add the Table metaclass
(see Metaclasses (Profile) [page 39]).
2. Right-click the Table metaclass and select New Form . Enter Export in the Name field, and select
Dialog Box from the Type list.
4. Right-click the Table metaclass and select New Method . Enter Export in the Name field, click the
Method Script tab and enter the following code:
Sub %Method%(obj)
' Exports an object to a file
' Create a dialog to input the export file name
Dim dlg
Set dlg = [Link]("%CurrentTargetCode%.Export")
If not dlg is Nothing Then
' Initialize filename control value
[Link] "Filename", "c:\temp\[Link]"
5. Right-click the Table metaclass and select New Menu . Enter Export in the Name field, and then click
the Add Command tool and select the Export method:
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category (or the Profile/Shared category, if
the template applies to all metaclasses) and select New Template .
2. Enter a name for the template. You should not use spaces in the name and, by convention, templates are
named in headless camelcase (for example myTemplate).
3. [optional] Enter a comment to explain the use of the template.
4. Enter GTL code (see Customizing Generation with GTL [page 271]) in the text box.
In this example, myTemplate is defined on the Class metaclass, and will generate the name of the class
followed by a list of its attributes:
Generated files assemble GTL templates for generation as files or for previewing on the object property sheet
Preview tab.
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Generated File .
Only objects, such as tables or classes, support file generation, but you can still create generated files for sub-
objects, such as columns and attributes, to preview code generated for them on their property sheet Preview
tab.
2. Enter the following properties as appropriate:
Property Description
Name Specifies a name for the generated file item in the resource editor.
If an extension attached to the model contains a generated file name identical to one
defined in the main resource file, then only the extension generated file will be gener
ated.
File Name Specifies the name of the file that will be generated. This field can contain GTL varia
bles. For example, to generate an XML file with the code of the object for its name, you
would enter %code%.xml.
If you leave this field empty, then no file will be generated, but you can view the code
produced in the object's Preview tab.
If this field contains a recognized extension, the code is displayed with the correspond
ing language editor and syntactic coloring.
Type Specifies the type of file to provide appropriate syntax coloring in the Preview window.
Encoding Specifies the encoding format for the file. Click the ellipsis tool to the right of the field to
choose an alternate encoding from the Text Output Encoding Format dialog, where you
can specify the following options:
Use package hier Specifies that the package hierarchy should be used to generate a hierarchy of file di
archy as file path rectories.
3. Enter GTL code (see Customizing Generation with GTL [page 271]) or the name of a template to populate the
file in the text zone.
In the following example, a generated file is defined for OOM classes. A file will be generated for each class in
the model with a name derived from the class %Name%, and containing the contents generated from the
%myTemplate% template (see Templates (Profile) [page 101]):
The file is immediately available as a sub-tab on the Preview tab of the object property sheet:
Templates contain GTL code used to generate text fragments from PowerDesigner property values, while
generated files are used to assemble templates for generation as files or for previewing on the object property
sheet Preview tab.
In this example, a generated file called Java Source is defined for classifiers. A file will be generated for each
classifier in the model with a name derived from the %sourceFilename% template specified in the File name field,
and containing the contents generated from the %source% template:
The referenced template, source, contains GTL code, including references to further templates called
%isSourceGenerated%, %sourceHeader%, %package%, and %imports%:
You can use generated files to extend the standard generation for objects from OOMs, BPMs, and XSMs or to
create a separate extended generation for any type of model. For extended generations, you can define a custom
menu command.
To extend the standard BPM, OOM, or XSM generation from the Resource Editor:
1. Select the Complement language generation property in the root of the extension file (see Extension File
Properties [page 21]) to have the extension file appear for selection on the Generation dialog Targets tab.
2. Define generated files as appropriate.
3. [optional] Define options in Generation\Options (see Example: Adding a Generation Option [page 135]) to
have them appear on the Generation dialog Options tab.
4. [optional] Define commands in Generation\Commands and reference these commands in tasks (see
Example: Adding a Generation Command and Task [page 136]) to have them appear on the Generation dialog
Tasks tab.
Alternatively, to define separate file generations apart from the standard language generation for a PDM or any
type of model and make them available via the Tools Extended Generation command
1. [OOM, BPM, and XSM only] Deselect the Complement language generation property in the root of the
extension file (see Extension File Properties [page 21]).
a. Create a method in Profile\Model with the name you want to give to your command, and enter the
following code (where extension is the code of the extension file):
Sub %Method%(obj)
End Sub
For more information about methods, see Methods (Profile) [page 96].
b. Create a menu in Profile\Model and select the Tools menu in the Location list (see Menus (Profile)
[page 97]).
c. Add the method to the menu using the Add Command tool:
Transformations define sets of actions to modify objects either before or after a model generation or on request.
Transformations are commonly grouped together in transformation profiles.
Context
● Implement Model Driven Architecture (MDA), which uses UML modeling to describe an application at different
levels of detail. PowerDesigner allows you to create an initial platform-independent model (PIM) (modeling the
basic business logic and functionality) and refine it progressively in different models containing increasing
levels of implementation and technology-dependent information through to a platform-specific model (PSM).
You can define transformations that will generate a more refined version of a model, based on the desired
target platform, and changes made to the PIM can be cascaded down to the generated models.
Transformations can be invoked on demand (select Tools Apply Transformations ), before or after model
generation (see Core Features Guide > Linking and Synchronizing Models > Generating Models and Model
Objects), or via a user-defined menu command (see Menus (Profile) [page 97]).
Procedure
1. Right-click a metaclass, stereotype, or criterion in the Profile category and select New Transformation .
2. Enter an appropriate Name and, optionally, a Comment to explain its purpose.
3. On the Transformation Script tab, enter a VBscript to perform the transformation.
In this example, which is created in an extension attached to a CDM under the DataItem metaclass, the script
tests to see whether the data item has a list of values defined and, if this is the case (and a domain with this
same list of values does not already exist in the CDM), creates a new domain with the list of values:
Dim list
list = [Link]
if not list = "" then
output "transforming " & cstr(obj)
End Sub
○ Pre-generation transformation - The transformation is called from the Generation Options dialog. The
domains are created temporarily in the CDM before generation and then are generated to the target
model (for example, to a PDM).
○ Post-generation transformation - The transformation can be called from the Generation Options dialog
(for a CDM-CDM generation). The domains are created in the target CDM after generation. Alternatively,
A transformation profile groups transformations together, and makes them available during model generation or
by selecting Tools Apply Transformations .
Procedure
1. [if the Transformation Profiles category is not present] Right-click the root node, select Add Items, select
Transformation Profiles, and click OK to create this folder.
2. Right click the Transformation Profiles folder, and select New to create a transformation profile.
3. Enter the following properties as appropriate:
Property Description
Name / Com Specify the name of the transformation profile and provide an explanation of what it is in
ment tended to do.
Model Type / [optional] Specify the type of model with which the transformation profile can be used dur
Family / Sub ing generation and (if the type supports a language definition file) the family and subfamily.
family If one or more of these fields is completed, the profile will only be displayed if the model to
be generated conforms to them. For example, if you define the transformation in a PDM or
PDM extension and specify Object-Oriented Model and Java, then the profile will only
be available when you select to generate the PDM into a Java OOM.
4. Click the Pre-generation tab and click the Add Transformations tool to add transformations to perform prior to
generation.
These transformations are executed before generation on the objects in your source model. If objects are
created by these transformations then they are automatically added to the list of objects to be generated. Any
changes to existing objects or new objects created by these transformations are reversed after generation, so
that your model returns to its previous state.
5. Click the Post-generation tab and click the Add Transformations tool to add transformations to perform after
generation. Transformations added on this tab are also made available to apply outside of the context of a
generation by selecting Tools Apply Transformations .
These transformations are executed on the objects generated in your target model.
6. Click Apply to save your changes.
Transformation scripts are written in VBScript using a certain number of special methods. Transformation scripts
do not require as many checks as standard scripts, because they are always implemented in a new, empty,
temporary model, which is merged with the generation target model.
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.
● CopyObject(source [,tag])
Duplicates an existing object, sets a source for the duplicated object, and returns a copy of the new object.
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.
● GetSource(target [,tag])
● GetTarget(source [,tag])
Internal transformation objects are preserved when the transformations are used via the Apply Transformations
or a custom menu command, so that they can be re-executed if you subsequently update (regenerate) the model.
For example, you generate a CDM entity A to an OOM class B and then apply a transformation to class B in order
to create class C. If you make changes to entity A and repeat the generation to update the OOM, class B is updated
and the transformation is automatically reapplied to update class C.
XML imports allow you to define mappings between an XML schema and the PowerDesigner metamodel (and any
extensions) to enable the import of XML files complying with the schema. You can specify initialization and post-
processing scripts to manage complexities in the import.
Context
For an overview of creating, deploying, and using XML imports, see Core Features Guide > Modeling with
PowerDesigner > Objects > Importing Objects from XML Files.
Procedure
1. [if the XML Imports category is not present] Right-click the root node, select Add Items, select XML
Imports, and click OK to create this folder.
2. Right click the XML Imports folder, and select New to create an XML import.
3. Enter the following properties as appropriate:
Property Description
Name Specifies the name of the import, which will be used as the name of the import command
under File Import .
First diagram Specifies the first diagram that should be initialized in the model created from the im
ported file.
Create default Specifies to create symbols for the imported objects in the diagram.
symbols
File extension Specifies the file extension that identifies XML documents that conform to the schema.
4. Click the Schema tab and click the Import tool to copy the schema, with any imports and includes resolved, to
the extension file for mapping.
Caution
If the selected schema is too permissive and allows for too many possible object hierarchies it may not be
possible to display it fully in the Mapping Editor. If you have an example XML data file to import, you can
import this in place of the schema by clicking the Import from Sample tool and PowerDesigner will deduce a
partial schema from it. Note that while a schema obtained in this way may successfully import the sample
data file, other documents based on the same schema may not be complete if they contain other types of
objects (or attributes or collections) that, though valid for the schema, were not in the first document.
You can click the View as Model tool to open the schema as an XML schema model.
You control how elements defined in an XML schema are imported by mapping them and their attributes,
compositions, and aggregations to objects in the PowerDesigner metamodel. The XML schema is analyzed and
presented as a list of metaclasses on the left side of the Mapping Editor and the PowerDesigner metamodel (and
any extensions) are displayed on the right side.
Context
Note
It is not necessary to map all metaclasses (or all their contents), but only those with which you want to work. If
the PowerDesigner metamodel does not contain appropriate metaclasses, attributes, compositions, or
aggregations to map against, you can create them dynamically here or save any existing mappings, close the
Mapping Editor, define or attach appropriate extensions, and then reopen the Mapping Editor to map to them.
Procedure
1. Drag and drop an external metaclass to a PowerDesigner metaclass to create an import mapping. Any
external attributes and collections are automatically mapped to PowerDesigner attributes with which they
share a name:
Note
If no suitable metaclass exists, to create and map to a new extended metaclass based on the
ExtendedObject metaclass, drag and drop the external metaclass onto the PowerDesigner metamodel
root.
2. Drag and drop additional attributes under the metaclass to PowerDesigner attributes with compatible data
types to create mappings for them. Attributes are contained in a folder under the metaclass and represent
individual properties such as Name, Size, DimensionalType, which have boolean, textual, numeric, or object
ID values:
PowerDesigner identifies sub-object metaclasses in the schema that are limited to a single instance and
displays a 1 overlay on their icons. Attributes under such metaclasses are treated as belonging to the parent
metaclass and can be mapped to attributes under the PowerDesigner object with which the parent is mapped:
3. Drag and drop external sub-object metaclasses (compositions) under the metaclass to PowerDesigner
compositions to create mappings between them:
Any attributes under the sub-object metaclass are automatically mapped to PowerDesigner attributes with
which they share a name. Map other sub-object attributes as necessary.
Note
In certain circumstances, it may be appropriate to map an external sub-object metaclass to a
PowerDesigner object metaclass, and so such mappings are also permitted.
4. Drag and drop external collections (aggregations) under the metaclass to PowerDesigner collections to
create mappings between them:
5. In certain schemas, it may be necessary to identify attributes as references and identifiers to link one
metaclass to another through aggregation:
a) Right-click an attribute and select Declare as Object Reference to specify that it acts as a pointer to
another object. Such attributes often have a type of GUID, Token, or NCName (PowerDesigner
automatically identifies attributes of type IDRef as references). A rounded arrow overlay is added to the
attribute icon:
c) The object reference attribute can now be mapped to a PowerDesigner attribute of type object (which
also bears a rounded arrow overlay):
6. [optional] Select a metaclass and enter an initialization or post-processing script to modify the objects at or
after creation (see Metamodel Mapping Properties [page 118]).
7. [optional] Click the target model (root node) to display the global list of mappings in the Mappings pane at the
bottom of the dialog and use the arrows at the bottom of the list to change the order in which objects are
imported to ensure that dependencies are respected.
Note
To control the order in which attributes, compositions, and aggregations are imported within objects,
select the target metaclass to display its mappings in the Mappings pane, and use the arrows at the bottom
of the lists on the Attribute Mappings, Collection Mappings, and Sub-Object Mappings sub-tabs.
Metamodel mappings are mappings between metamodel objects, which control how objects are imported or
generated. Metamodel mappings are sub-objects of the PowerDesigner metamodel object on which they are
defined.
To open a metamodel mapping property sheet, select the mapping from the list at the top of the Mapping Editor
Mappings pane or parent object property sheet Mapping tab and click the Properties tool.
The tabs available on a particular mapping property sheet depend on the objects being mapped. The General tab
contains the following properties:
Property Description
Source object Specifies the metamodel object being mapped to the target object.
Target object Specifies the metamodel object being mapped from the source object. This object is the pa
rent of the mapping itself.
Transformation [metaattribute mappings] Specifies a script to set the value of the attribute. In the following
script example, from an XML import, the notnullable attribute is imported to the Mandatory at
tribute and, because the sense of the attributes is reversed, the boolean value imported is set
to the opposite of the source value:
In the following example, from an object generation, the NumberID attribute is generated to
the Comment attribute and a text string is prepended to make clear the origin of the value:
● Initialization - Specifies a script to initialize the metaclass to be created. In the following example, the value of
the Stereotype attribute is set to SimpleType:
Sub %Initialize%(obj)
[Link] = "SimpleType"
End Sub
● Attribute Mappings - Lists the mappings of attributes under the metaclass. Select a mapping and click the
Properties tool to open its property sheet. To control the order in which attributes are created, in order to
respect dependencies between them, use the arrows at the bottom of the list.
● Collection Mappings - Lists the mappings of collections under the metaclass.
Sub %PostProcess%(obj)
' Copy code into name
[Link] = [Link]
End Sub
To view the properties of metaclasses, metaattributes, and metacollections displayed in the Mapping Editor,
double-click the object node in the Mapping Editor or right-click the node and selecting Properties.
Property Description
Parent [metaattributes and metacollections] Specifies the metaclass to which the metaobject be
longs.
Parent collec [sub-objects/compositions] Specifies the name of the composition collection that contains
tion the sub-objects under the parent object.
Name Specifies the name of the metaclass in the PowerDesigner metamodel or XML schema.
Identifier [metaattributes] Specifies that the attribute is used to identify the metaclass for referencing
by another metaclass.
Reference / [metaattributes and metacollections] Specifies that the attribute or collection is used to point
Reference path to another metaclass to form an aggregation.
Singleton [metaclasses] Specifies that only one instance of the metaclass is possible under each parent
object.
● Attributes - Lists the metaattributes belonging to the metaclass. Select an attribute in the list and click the
Properties tool to open its property sheet.
● Collections - Lists the metacollections belonging to the metaclass. Select a collection in the list and click the
Properties tool to open its property sheet.
Object generations allow you to define mappings between one PowerDesigner model type and another based on
the two metamodels (and any extensions) to enable the generation of one or more object types.
Context
For an overview of creating, deploying, and using object generations, see Core Features Guide > Linking and
Synchronizing Models > Generating Models and Model Objects > Generating Model Objects > Defining Advanced
Object Generations.
Procedure
1. [if the Object Generations category is not present] Right-click the root node, select Add Items, select
Object Generations, and click OK to create this folder.
2. Right click the Object Generations folder, and select New to create an object generation.
3. Enter the following properties as appropriate:
Property Description
Target model Specifies the type of model that will be created or updated by the generation.
type
Menu com Specifies the name of the command that will appear in the interface under Tools
mand name
Generate Objects . This field is initialized when you select a target model type.
4. [optional] Click the Source Extensions and/or Target Extensions tab and select extension files containing
extended attributes, collections, or metaclasses to reference in your mappings.
Attaching extension files in this way allow you to reuse previously defined extensions in your generations or to
share extensions between generations. You can also define extensions as appropriate under the Profile
category in the resource file containing the generation definition.
5. Click the Mappings button to define mappings from your source to target metaclasses in the Mapping Editor
(see Model-to-Model Generation Mappings [page 121]).
6. Click Apply to save your changes.
You control how metaclasses from one PowerDesigner model type will be generated to metaclasses in another
model type by mapping them and their attributes and collections in the Mapping Editor. Any extensions defined
for the source or target metamodels are displayed and available for mapping.
Context
Note
It is not necessary to map all metaclasses (or all their contents), but only those with which you want to work. If
the PowerDesigner metamodel does not contain appropriate metaclasses, attributes, compositions, or
aggregations to map against, you should save any existing mappings, close the Mapping Editor, define or
attach appropriate extensions, and then reopen the Mapping Editor to map to them.
Procedure
1. Drag and drop a metaclass from the source pane on the left to a metaclass in the Target pane on the right.
Any source attributes are automatically mapped to target attributes with which they share a name:
Note
By default, the Mapping Editor lists the standard attributes and collections of metaclasses, which are
displayed, by default, in object property sheets. To display all available properties, click the Filter Properties
tool, and select Show All Properties. You can also filter the tree by using the Filter Mappings and Filter
Objects tools.
Note
In certain circumstances, it may be appropriate to map a source sub-object metaclass to a target object
metaclass, and so such mappings are also permitted.
4. Drag and drop source collections (aggregations) under the metaclass to target collections to create mappings
between them:
5. [optional] Select a metaclass and enter an initialization or post-processing script to modify the objects at or
after creation (see Metamodel Mapping Properties [page 118]).
6. [optional] Click the target model (root node) to display the global list of mappings in the Mappings pane at the
bottom of the dialog and use the arrows at the bottom of the list to change the order in which objects are
generated to ensure that dependencies are respected.
Note
To control the order in which attributes, compositions, and aggregations are generated, select the target
metaclass to display its mappings in the Mappings pane, and use the arrows at the bottom of the lists on
the Attribute Mappings, Collection Mappings, and Sub-Object Mappings sub-tabs.
Datasets define paths through the PowerDesigner metamodel that will be used to extract data from models for
display in a PowerDesigner Web chart.
Context
A sample set of enterprise architecture model datasets (see Chart Examples [page 124]) is loaded by default in
your repository Library folder, and is also delivered as part of the EA Example files available at <install_dir/
Examples/EAExample> (see Enterprise Architecture Modeling > Planning Your Enterprise Architecture Initiative >
Example EA Model, Imports, and Charts).
1. [if the Dataset Definitions category is not present] Right-click the root node, select Add Items, select
Dataset Definitions, and click OK to create this folder.
2. Right click the Dataset Definitions folder, and select New to create a new entry.
3. Enter the following properties as appropriate on the General tab:
Property Description
Name Specifies the internal name of the dataset, which can be used for scripting.
Label Specifies the name that will be displayed to identify the dataset in the PowerDesigner
Web chart builder.
4. Click the Definition tab, and select the Source and Target metaclasses that you want to analyze, and then click
the Modify definition button.
For example, if you want to analyze the deployment of databases by site, select Site as the source and
Database as the target. To see the OS split for your hardware servers, without concern for sites, or any other
organizing dimension, select Model as the source and Hardware Server as the target.
5. Specify the query path that will be used to extract the data from you model, and then click Next.
The length and complexity of the path that you define is dependant on the way in which your model is
constructed. In our example, there are three levels of sites (region, country, and city), systems are located in a
city, and the database is associated within a system.
Example models and an extension file containing datasets to derive charts from them are provided with
PowerDesigner.
The following example charts are defined in the EA Charts extension file, which is loaded by default in your
repository library (and which is also delivered as part of the EA Example files available at <install_dir>/
Examples/EAExample).
Note
Chart datasets must be defined to be compatible with the structure of the models they will analyze. These
charts are based on the structure of the [Link] model (see Enterprise Architecture Modeling >
Planning Your Enterprise Architecture Initiative > Example EA Model, Imports, and Charts).
● Y Axis: ItCapex
● X Axis: L1 Business Function
The profile contains a global script, which you can use to store functions and variables to be reused in your scripts
defined for extensions.
For example, we could imagine writing a function for obtaining the data type of an item and reusing it in the scripts
for both the custom check and autofix examples (see Custom Checks (Profile) [page 87].
The new DataTypeBase function is entered on the Global Script tab as follows:
Function DataTypeBase(datatype)
Dim position
position = InStr(datatype, "(")
If position <> 0 Then
DataTypeBase = Ucase(Left(datatype, position -1))
Else
DataTypeBase = Ucase(datatype)
End If
End Function
The script for the check (see Example: PDM Custom Check [page 89] can be rewritten to call the function as
follows:
Function %Check%(obj)
Dim c 'temporary index column
Dim col 'temporary column
Dim position
%Check%= True
If [Link] = "LF" or [Link] = "HG" or [Link] = "CMP" or [Link] ="HNG" then
For Each c In [Link]
Set col = [Link]
If (DataTypeBase([Link]) = "VARCHAR") And ([Link] > 255) Then
Output "Table " & [Link] & " Column " & [Link] & " : Data type is
not compatible with Index " & [Link] & " type " & [Link]
%Check% = False
End If
Next
End If
End Function
Note
Variables defined on the Global Script tab are reinitialized each time they are referenced in another script.
Language definition files have an .xol, .xpl, or .xsl extension and are located in <install_dir>/Resource
Files. To view the list of languages, select Tools Resources Object Languages , Process Languages, or
XML Languages. For information about the tools available in resource file lists, see PowerDesigner Resource Files
[page 9].
Note
The PDM uses a different form of definition file (see DBMS Definition Files [page 140]), and other model types
do not have definition files but can be extended with extension files (see Extension Files [page 18]).
All target languages have the same basic category structure, but the detail and values of entries differs for each
language:
● Settings - contains data types, constants, namings, and events categories used to customize and manage
generation features. The types of items in this category differ depending on the type of resource file.
● Generation - contains generation commands, options, and task.
● Profile - contains extensions on metaclasses.
Property Description
Name / Code Specify the name and code of the language definition file.
File Name [read-only] Specifies the path to the language definition file. If the target language has
been copied to your model, this field is empty.
Version [read-only] Specifies the repository version if the resource is shared via the repository.
Family / Subfamily Specifies the family and subfamily of the language, which may enable certain non-default
features in the model. For example, object languages of the Java, XML, IDL and SAP® Pow
erBuilder® families support reverse engineering.
Enable Trace Mode Lets you preview the templates used during generation (see Templates (Profile) [page
101]). Before starting the generation, click the Preview page of the relevant object, and
click the Refresh tool to display the templates.
When you double-click on a trace line from the Preview page, the Resource Editor opens to
the corresponding template definition.
The Settings category contains the following items used to control the data types, constants, namings, and events
categories used to customize and manage BPM generation features:
● Implementation – [executable BPM only] Gathers options that influence the process implementation
possibilities. The following constants are defined by default:
○ LoopTypeList - This list defines the type of loop supported by the language. The value must be an integer
○ OperationTypeList - This list defines the type of operation supported by the language. An unsupported
operation type cannot be associated with a process. The value must be an integer
○ EnableEmissionCorrelation - enables the definition of a correlation for an emitted message
○ EnableProcessReuse - allows a process to be implemented by another process
○ AutomaticInvokeMode - indicates if the action type of a process implemented by an operation can be
automatically deducted from the operation type. You can specify:
○ EnableMessageOnFlow - indicates if a message format can be associated to a flow or not. The default
value is Yes
○ EnableMessageVariable - enables a variable object to store the whole content of a message format. In this
case, the message format objects will appear in the data type combo box of the variable
● Choreography - Gathers objects that allow the design of the graph of activities (start, end, decision,
synchronization, transition...) Contains the following constant values defined by default:
○ EnableMultipleStarts - When set to No, ensures that no more than one start is defined under a composite
process
○ EnableTopLevelChoreography - When set to No, ensures that no flow or choreography object (start, end,
decision...) is defined directly under the model or a package. These objects can be defined only under a
composite process
The Settings category contains the following items used to control the data types, constants, namings, and events
categories used to customize and manage OOM generation features:
● Data Types - Tables for mapping internal data types with object language data types. The following data types
values are defined by default:
○ BasicDataTypes – lists the most commonly-used data types. The Value column indicates the conceptual
data type used for CDM and PDM model generations.
○ ConceptualDataTypes – lists internal PowerDesigner data types. The Value column indicates the object
language data type used for CDM and PDM model generations.
○ AdditionalDataTypes – lists additional data types added to data type lists. Can be used to add or change
data types of your own. The Value column indicates the conceptual data type used for CDM and PDM
model generations.
○ DefaultDataType – specifies the default data type.
The Settings category contains the Data types category that shows a mapping of internal data types with XML
language data types.
● ConceptualDataTypes - The Value column indicates the XML language data type used for model generations.
Conceptual data types are the internal data types of PowerDesigner, and cannot be modified.
● XsmDataTypes- Data types for generations from the XML model.
The Generation category contains categories and entries to define and activate a generation process.
● Commands - contains generation commands, which can be executed at the end of the generation process,
after the generation of all files. Commands are written in GTL (see Customizing Generation with GTL [page
271]), and must be included within tasks to be evoked.
● Options – contains options, available on the Options tab of the Generation dialog, the values of which can be
tested by generation templates or commands. You can create options that take boolean, string, or list values.
The value of an option may be accessed in a template using the following syntax:
%[Link]%
In this example, we will add a generation option to the Java object language.
Procedure
1. Select Language Edit Current Object Language to open the Java resource file.
2. Expand the Generation category, and then right-click the Options category and select New:
3. Click OK to save your changes and return to the model. Then select Language Generate Java code to
open the Generation dialog, and click the Options tab. The new option is listed on the tab under its comment
(or its name, if no comment has been provided):
In this example, we will add a generation command and associated task to the Java object language
Procedure
1. Create a new OOM for Java, and then select Language Edit Current Object Language .
2. Expand the Generation category, and then right-click the Commands category and select New.
3. Name the command DoCommand and enter an appropriate template:
The language definition file Profile category can contain Stereotypes, Extended attributes, Methods and so on, to
extend the metaclasses defined in the PowerDesigner metamodel.
In object languages, the Shared/Extended Attribute Types category contains various attributes used to
control object language support within PowerDesigner. The Object Container variable specifies the default
container for implementing associations. This attribute has an editable list of possible values for each object
language, from which you can select a default value for your language. You can, if necessary, override this default
using the Default association container model option.
For detailed information about working with the Profile category, see Extension Files [page 18].
DBMS definition files have an .xdb extension and are located in <install_dir>/Resource Files/DBMS. To
view the list of DBMSs, select Tools Resources DBMS . For information about the tools available in
resource file lists, see PowerDesigner Resource Files [page 9].
You can consult or modify the DBMS definition file attached to your PDM in the Resource Editor by selecting
Database Edit current DBMS . When you select a category or an item in the left-hand pane, the name, value,
and related comment appear in the right side of the dialog box.
Caution
The resource files provided with PowerDesigner inside the Program Files folder cannot be modified directly.
To create a copy for editing, use the New tool on the resource file list, and save it in another location. To include
resource files from different locations for use in your models, use the Path tool on the resource file list.
● General - contains general information about the database, without any categories (see General Category
(DBMS) [page 155]). All items defined in the General category apply to all database objects.
● Script - used for generation and reverse engineering. Contains the following sub-categories:
○ SQL - contains the following sub-categories, each of which contains items whose values define general
syntax for the database:
○ Syntax - general parameters for SQL syntax (see Syntax Category (DBMS) [page 156])
○ Format - parameters for allowed characters (see Format Category (DBMS) [page 157])
○ File - header, footer and usage text items used during generation (see File Category (DBMS) [page
159])
○ Keywords - the list of SQL reserved words and functions (see Keywords Category (DBMS) [page
161])
○ Objects - contains commands to create, delete or modify all the objects in the database. Also includes
commands that define object behavior, defaults, necessary SQL queries, reverse engineering options,
and so on (see Script/Objects Category (DBMS) [page 163]).
○ Data Type - contains the list of valid data types for the specified DBMS and the corresponding types in
PowerDesigner (see Script/Data Type Category (DBMS) [page 219]).
○ Customize - Retrieves information from PowerDesigner Version 6 DBMS definition files. It is not used in
later versions.
● ODBC - present only if the DBMS does not support standard statements for generation. In this case the ODBC
category contains additional items necessary for live database connection generation .
● Transformation Profiles – contains group of transformations used during model generation when you need to
apply changes to objects in the source or target models (see Transformations (Profile) [page 109]).
● Profile - allows you to define extended attribute types and extended attributes for database objects (see
Profile Category (DBMS) [page 222]).
The following properties are available on the root of a DBMS definition file:
File Name [read only] Path and name of the DBMS file.
Family Used to classify a DBMS, and to establish a link between different database resource files. For
example, SAP® SQL Anywhere®, and SAP® Adaptive Server® Enterprise belong to the SQL
Server family.
Triggers are retained when you change target within the same family.
The DBMS Trigger templates, Trigger template items, and Procedure templates are accessible via the tabs in the
Resource Editor window. In addition, for Oracle, there is a tab for database package templates.
Templates for stored procedures are defined under the Procedure category in the DBMS tree view.
For more information, see Data Modeling > Building Data Models > Triggers and Procedures
PowerDesigner supports generation and reverse engineering of databases through scripts and live connections
via SQL statements and queries stored in the Script/Objects category. Generation and reverse-engineering of
scripts and generation to a live connection all use the same statements, while reverse-engineering from a live
connection uses separate queries.
● Generation/Update Database - Each model object selected is applied to the statements in the Script/
Objects category.
● Reverse engineering:
○ Script - PowerDesigner parses the script and identifies object creation statements by comparing them
with the statements in the Script/Objects category.
○ Live connection - PowerDesigner uses the queries in the Script/Objects category to retrieve
information from the database system tables. Each column of a query result set is associated with a
variable. The query header specifies the association between the columns of the resultset and the
variable. The values of the returned records are stored in these variables which are then committed as
object attributes.
PowerDesigner can generate a SQL script from a PDM to create or modify a database. The statements that
control script generation are available in the Script/Objects category.
When generating a SQL script, PowerDesigner takes each object to be created in turn, and applies the appropriate
Create or other statement to create or modify the object:
For example, in ASE 15.7, the Create statement in the Table category is the following:
This statement contains the parameters for creating the table together with its owner and physical options using
variables (see Variables for Tables and Views [page 237]) that extract the necessary information from the
object's properties. The %TABLDEFN% variable collects the Add items in the Column, PKey, Key, and Reference
categories, and the AddTableCheck item in the Table category.
Other statements in the object categories are used to customize the PowerDesigner interface and behavior
according to database features, such as Maxlen, Permission, EnableOwner, and AllowedADT.
You can extend script generation statements to complement generation using the extension statements. The
extension mechanism allows you to generate statements immediately before or after Create, Drop, and Modify
statements, and to retrieve these statements during reverse engineering.
Extension statements are written in GTL (see Customizing Generation with GTL [page 271]). During generation,
the statements and variables are evaluated and the result is added to the global script.
Note
We recommend that you avoid using GTL macros (other than .if) in generation scripts, as they may not be
resolvable when reverse engineering by script. Generating and reverse engineering via a live database
connection are not subject to this limitation.
The extension statement AfterCreate is defined in the Table category to complement the table Create
statement by adding partitions to the table if the value of the partition extended attribute requires it:
The .if macro evaluates variable %ExtTablePartition%, which is an extended attribute that contains the
number of table partitions. If the value is higher than 1, then %CreatePartition%, defined in the Table category,
will be generated as follows:
This item generates the statement for creating the number of table partitions specified in %ExtTablePartition
%.
The extension statement BeforeCreate is defined in the User category to create the login of a user before the
user Create statement is executed:
The automatically generated login will have the same name as the user, and its password. The BeforeCreate
statement is displayed before the user creation statement in the Preview:
You can also add BeforeModify and AfterModify statements to standard Modify statements.
Modify statements are executed to synchronize the database with the schema created in the PDM. By default, the
modify database feature does not take into account extended attributes when it compares changes performed in
the model from the last generation. You can bypass this rule by adding extended attributes in the
ModifiableAttributes list item. Extended attributes defined in this list will be taken into account in the merge
dialog box during database synchronization.
To detect that an extended attribute value has been modified you can use the following variables:
For example, you can verify that the value of the extended attribute ExtTablePartition has been modified
using the following GTL syntax:
If the extended attribute value was changed, an extended statement will be generated to update the database. In
the ASE syntax, the ModifyPartition extended statement is the following because in case of partition change
you need to delete the previous partition and then recreate it:
PowerDesigner can reverse engineer SQL scripts into a PDM. The statements that control script generation are
available in the Script/Objects category.
When reverse-engineering a SQL script into a PDM, PowerDesigner compares each statement in turn with all of
the Create statements defined in the DBMS definition file and when it finds a match, extracts all of the available
information to create or update PDM objects.
The statements used in script reverse engineering are the same as those for script generation (see Script
Generation [page 142]).
For example, in IQ v15.2, the Create statement in the Table category is the following:
This statement contains the parameters for creating the table together with its owner and physical options using
variables (see Variables for Tables and Views [page 237]) that extract the necessary information from the
object's properties.
If you are using the extension mechanism for script generation, you have to declare statements in the list item
ReversedStatements (one statement per line) for them to be properly reversed.
For example, the extension statement AfterCreate uses CreatePartition, which must be declared in
ReversedStatements to be properly reverse engineered:
PowerDesigner can generate or modify a database from a PDM to a live connection. The statements that control
live generation are available in the Script/Objects category, except when the DBMS does not support standard
SQL syntax. For example, MS Access, which needs VB scripts to create database objects, has special generation
statements defined in the ODBC category.
When generating to a live connection, PowerDesigner takes each object to be created in turn, and applies the
appropriate Create or other statement to create or modify the object.
The statements used in live generation are the same as those for script generation (see Script Generation [page
142]).
PowerDesigner can reverse engineer from a live database connection into a PDM. The queries that control live
reverse engineering are available in the Script/Objects category.
● SqlListQuery - Retrieves a list of available objects to populate the Database Reverse Engineering dialog.
This query is memory intensive, and should retrieve the smallest number of columns possible. If it is not
defined, then SqlAttrQuery will be used to populate the dialog.
● SqlAttrQuery - Retrieves the object attributes to be reverse-engineered. This query is not necessary if the
object has few attributes, and the SqlListQuery can retrieve all necessary information, as is the case for
tablespaces in SQL Anywhere.
● SqlOptsQuery - Retrieves the physical options to be reverse-engineered.
● SqlListChildrenQuery - Retrieves lists of child objects (such as columns of an index or key or joins of a
reference) to be reverse-engineered.
● SqlSysIndexQuery - Retrieves system indexes created by the database.
● SqlChckQuery - Retrieves object check constraints.
● SqlPermQuery - Retrieves object permissions.
Note
You can also create your own queries (see Creating Queries to Retrieve Additional Attributes [page 149]).
Each type of query has the same basic structure comprised of a comma-separated list of PowerDesigner
variables enclosed in curly braces { } followed by a select statement to extract values to populate these variables.
The values of the returned records are stored in these variables, which are then committed as object attribute
values.
For example, the SqlListQuery in the View category of Oracle 11g R1 extracts values for eight variables:
select
[Link],
v.view_name,
decode (v.view_type, 'XMLTYPE', 'XML', 'View'),
v.view_type,
v.oid_text,
v.superview_name,
decode (v.view_type, 'XMLTYPE', '%SqlXMLView.'||[Link]||v.view_name||'1%', ''),
decode (v.view_type, 'XMLTYPE', '%SqlXMLView.'||[Link]||v.view_name||'2%', '')
from sys.all_views v
[where [Link] = %.q:SCHEMA%]
● Name of variable - [required] can be any standard PDM variable (see PDM Variables and Macros [page 233]),
metamodel public name (see Navigating in the Metamodel [page 365]) or the name of an extended attribute
defined under the metaclass in the Profile (see Profile Category (DBMS) [page 222]).
● ID - [optional] the variable is part of the identifier.
● ... - [optional] the variable must be concatenated for all the lines returned by the SQL query that have the
same values for the ID columns. The ID and ... (ellipsis) keywords are mutually exclusive.
In this script, the identifier is defined as TABLE + ISKEY+ CONSTNAME through the use of the ID keyword:
In the resulting lines returned by the SQL script, the values of the fourth field are concatenated in the COLUMNS
field as long as these ID values are identical.
In the example, COLUMNS will contain the list of columns separated by commas, and PowerDesigner will process
the contents to remove the last comma.
In this example, when the SQL query returns the value 25 or 26, it is replaced by JAVA in the TYPE variable:
You can create queries to retrieve additional attributes. These attributes could be added to SqlAttrQuery, but
retrieving them in a separate query helps to avoid overloading that item. User-created queries are only called
during reverse-engineering if their names are added to the ReversedQueries item.
To create a new query in a category, right-click the category and select New Text Item . Enter an
appropriate name, and then add the name to the ReversedQueries item.
For example, in the Oracle family of DBMSs, SqlColnListQuery is defined in the View category:
select
[Link],
c.table_name,
c.column_name||', '
from
sys.all_tab_columns c
where 1 = 1
[and [Link]=%.q:OWNER%]
[and c.table_name=%.q:VIEW%]
order by
1, 2, c.column_id
This query retrieves view columns, and is enabled by adding it to ReversedQueries in the View category.
Note
Subqueries that are called with the EX keyword from within SqlAttrQuery or other queries (see Calling Sub-
Queries with the EX Keyword [page 149]) do not need to be added to ReversedQueries.
DBMS system tables may store information to be reversed in columns with LONG, BLOB, TEXT and other
incompatible data types, which PowerDesigner cannot directly concatenate into strings.
Context
You can bypass this limitation by using the EX keyword and creating user-defined queries and variables in the
existing reverse engineering queries with the syntax:
%[Link]%
select
[Link],
c.table_name,
c.constraint_name,
...
'global partition by range
(%SqlPartIndexDef.'||[Link]||i.index_name||'%)',
...
Note
Extended queries are not be added to the ReversedQueries item.
Procedure
1. A query is executed to evaluate variables in a set of string statements. If the EX keyword is present in the
query header, PowerDesigner searches for user-defined queries and variables to evaluate. You can create
user-defined queries in any live database reverse engineering query. Each query must have a unique name.
2. The execution of the user-defined query generates a resultset containing pairs of user-defined variable names
(without %) and variable value for each of the variables as needed. For example, in the following resultset, the
query returns 3 rows and 4 columns by row:
Variable 1 1 Variable 2 2
Variable 3 3 Variable 4 4
Variable 5 5 Variable 6 6
During reverse engineering, physical options are concatenated in a single string statement. However, when the
system tables of a database are partitioned (like in Oracle) or fragmented (like in Informix), the partitions/
fragments share the same logical attributes but their physical properties like storage specifications, are stored in
each partition/fragment of the database. The columns in the partitions/fragments have a data type (LONG) that
allows storing larger amount of unstructured binary information.
Since physical options in these columns cannot be concatenated in the string statement during reverse
engineering, SqlOptsQuery (Tables category in the DBMS) contains a call to a user-defined query that will
evaluate these physical options.
select
[Link],
[Link],
'%[Link]'||[Link]||'% %FragExpr'||[Link]||'% in %FragDbsp'||
[Link]||'% ',
[Link]
from
[Link] t,
[Link] f
where
[Link] = 0
and [Link]=[Link]
[ and [Link] = '%SCHEMA%']
[ and [Link]='%TABLE%']
After the execution of SqlOptsQuery, the user-defined query SqlFragQuery is executed to evaluate FragDbsp
n, FragExpr n, and FragSprt n. n stands for evalpos which defines fragment position in the fragmentation list.
n allows to assign unique names to variables, whatever the number of fragment defined in the table.
FragDbsp n, FragExpr n, and FragSprt n are user-defined variables that will be evaluated to recover
information concerning the physical options of fragments in the database:
Only the translation rules defined between brackets will be used during string concatenation: "FragSprt0", which
contains 0 ([Link]), will be replaced by " ", and "FragSprt1", which contains 1, will be replaced by ","
SqlFragQuery generates a numbered resultset containing as many pairs of user-defined variable name (without
%) and variable value as needed, if there are many variables to evaluate.
In Oracle 8i and later versions, you can create indexes based on functions and expressions that involve one or
more columns in the table being indexed. A function-based index precomputes the value of the function or
expression and stores it in the index. The function or the expression will replace the index column in the index
definition.
An index column with an expression is stored in system tables with a LONG data type that cannot be
concatenated in a string statement during reverse engineering.
To bypass this limitation, SqlListQuery (Index category in the DBMS) contains a call to the user-defined query
SqlExpression used to recover the index expression in a column with the LONG data type and concatenate this
value in a string statement (the following is a subset of SqlListQuery):
select
'%SCHEMA%',
i.table_name,
i.index_name,
decode(i.index_type, 'BITMAP', 'bitmap', ''),
decode(substr(c.column_name, 1, 6), 'SYS_NC', '%[Link]'||i.table_name||
i.index_name||c.column_position||'%', c.column_name)||' '||[Link]||', ',
c.column_position
from
user_indexes i,
user_ind_columns c
where
c.table_name=i.table_name
and c.index_name=i.index_name
[ and i.table_owner='%SCHEMA%']
[ and i.table_name='%TABLE%']
[ and i.index_name='%INDEX%']
The execution of SqlListQuery calls the execution of the user-defined query SqlExpression.
{VAR, VAL}
select
'Xpr'||table_name||index_name||column_position,
column_expression
from
all_ind_expressions
where 1=1
[ and table_owner='%SCHEMA%']
[ and table_name='%TABLE%']
The name of the user-defined variable is unique, it is the result of the concatenation of "Xpr", table name, index
name, and column position.
A qualifier allows the use of the object qualifier that is displayed in the dropdown list box in the upper left corner of
the Database Reverse Engineering dialog box. You use a qualifier to select which objects are to be reverse
engineered.
You can add a qualifier section when you customize your DBMS. This section must contain the following items:
● enable: YES/NO
● SqlListQuery (script) : this item contains the SQL query that is executed to retrieve the qualifier list.
You should not add a Header to this query
Yes Yes Qualifiers are available for selection. Select one as required. You can
also type the name of a qualifier. SqlListQuery is executed to fill the
qualifier list
No Only the default (All qualifiers) is selected. You can also type the
name of a qualifier
.[Link] :
select dbspace_name from sysfile
You can extend your DBMS to include new metaclasses that are not present in the standard PowerDesigner
metamodel. Many DBMSs contain such metaclasses, which are defined by creating a stereotype on an existing
metaclass, and you can also create your own. To include these objects in generation and reverse-engineering, you
must add them to the Script/Objects category, and define appropriate SQL statements and queries.
Procedure
1. Create a new metaclass in your DBMS definition file by defining a new stereotype on an existing metaclass
and selecting the Use as metaclass option (see Creating New Metaclasses with Stereotypes [page 46]).
2. Define appropriate extended attributes (see Extended Attributes (Profile) [page 49]) and other extensions as
appropriate to accurately define the nature of your object.
3. Right-click the Script/Objects category, select Add Items, select your new object in the list, and then click
OK to add it to the category.
4. Right-click the new object entry, and select Add Items to add the necessary script items to it. As a minimum,
to enable the generation and reverse engineering of the object, you must add the following items:
○ Create
○ Drop
○ AlterStatementList
○ SqlAttrQuery
○ SqlListQuery
5. Click OK to add these script items to your object, and enter the appropriate SQL statements and queries. You
will need to enter values for each of these items. For guidance on syntax, see Common Object Items [page
165].
6. [optional] To control the order in which this and other objects will be generated, use the Generation Order
item (see Script/Objects Category (DBMS) [page 163]).
You can specify scripts to be used before or after database generation or reverse engineering.
Procedure
1. Open the Profile folder. If there is no entry for Model, then right-click the Profile folder and select Add
Metaclasses.
2. On the PdPDM sub-tab, select Model and then click OK to add the Model item to the Profile folder.
3. Right-click the Model item, and select New Event Handler (see Event Handlers (Profile) [page 91]).
4. Select one or more of the following event handlers depending on where you want to add a script:
○ BeforeDatabaseGenerate
○ AfterDatabaseGenerate
○ BeforeDatabaseReverseEngineer
○ AfterDatabaseReverseEngineer
5. Click OK to add the selected event handlers to the Model item.
6. Select each of the event handlers in turn, click its Event Handler Script tab, and enter the desired script.
7. Click OK to confirm your changes and return to the model.
The General category is located directly beneath root, and contains high-level items that define the basic behavior
of the DBMS.
Item Description
EnableCheck Specifies whether the generation of check parameters is authorized. The following set
tings are available. If this item is set to No, no variables linked to check parameters will
be evaluated during generation and reverse-engineering.
EnableConstName Specifies whether constraint names are supported by the DBMS. If this item is set to
Yes, table and column constraint names are generated in addition to the constraints
themselves.
EnableIntegrity Specifies whether integrity constraints are supported by the DBMS. If this item is set to
Yes, primary, alternate, and foreign key check boxes are available for database genera
tion and modification
EnableMultiCheck Specifies whether the generation of multiple check parameters for tables and columns
is supported by the DBMS. If this item is set to Yes, multiple check parameters are gen
erated, with the first constraint concatenating all the validation business rules, and ad
ditional constraints generated for each constraint business rules attached to the ob
ject. If this item is set to No, all business rules (validation and constraint) are concaten
ated into a single constraint expression.
SchemaStereotype Specifies the user stereotype to be used to indicate a schema (object owner).
SqlSupport Specifies whether SQL syntax is supported by the DBMS. If this item is set to Yes, SQL
syntax is supported and the SQL Preview is available.
UniqConstName Specifies whether unique constraint names for objects are required by the DBMS. If
this item is set to Yes, all constraint names (including index names) must be unique in
the database. Otherwise constraint names must be unique only at the object level.
UserStereotype Specifies the user stereotype to be used to indicate a user (permissions grantee).
The SQL category is located in the Root Script category and contains sub-categories that define the SQL
syntax for the DBMS.
The Syntax category is located in the Root Script SQL category, and contains the following items that
define the DBMS-specific syntax:
Item Description
Example:
/* */
BlockTerminator Specifies the end of block character, which is used to end expressions for triggers and
stored procedures.
IdentifierDelimiter Specifies the identifier delimiter character. When the beginning and end delimiters are
different, they must be separated by a space character.
Example:
%%
Note that the same quote must be used in the check parameter tab to enclose reserved
words used as default.
SqlContinue Specifies the continuation character. Some databases require a continuation character
when a statement is longer than a single line. For the correct character, refer to your
DBMS documentation. This character is attached to each line just prior to the linefeed.
Terminator Specifies the end of statement character, which is used to terminate create table, view,
index, or the open/close database, and other statements.
UseBlockTerm Specifies the use of BlockTerminator. The following settings are available:
The Format category is located in the Root Script SQL category, and contains the following items that
define script formatting:
Item Description
AddQuote Specifies that object codes are systematically enquoted during the generation. The fol
lowing settings are available:
CaseSensitivityUsing Specifies if the case sensitivity for identifiers is managed using double quotes. Enable
Quote this option if the DBMS you are using needs double quotes to preserve the case of ob
ject codes.
DateTimeFormat / Specify the format for generating date and time test data to a script or live database
OdbcDateTimeFor connection.
mat / DateFormat /
● yyyy/yy, mm, dd - Years, months, and days.
OdbcDateFormat /
● HH, MM, SS - Hours, minutes, and seconds.
TimeFormat / OdbcTi
meFormat For example, you can define the following value for the DateTimeFormat item for SQL:
yy-mm-dd HH:MM.
EnableOwnerPrefix / Specifies that object codes can be prefixed by the object owner (%OWNER%), the data
EnableDtbsPrefix base name (%DBPREFIX%), or both (%QUALIFIER%). The following settings are availa
ble:
● Yes – enables the Owner Prefix and/or Database Prefix options in the Database
Generation dialog to require one or both prefixes for objects.
● No - The Owner Prefix and Database Prefix options are unavailable
Note
EnableOwnerPrefix enables the Ignore identifying owner model option for tables
and views.
IllegalChar [generation only] Specifies invalid characters for names. If there is an illegal character
in a Code, the code is set between quotes during generation.
Example:
+-*/!=<>'"()
If the name of the table is "SALES+PROFITS", the generated create statement will be:
Double quotes are placed around the table name to indicate that an invalid character is
used. During reverse engineering, any illegal character is considered as a separator un
less it is located within a quoted name.
LowerCaseOnly / Up When generating a script, all objects are generated in lowercase or uppercase inde
perCaseOnly pendently of the model Naming Conventions and the PDM codes. The following set
tings are available:
Note
These items are mutually exclusive. If both are enabled, the script is generated in
lowercase.
The File category is located in the Root Script SQL category, and contains the following items that define
script formatting:
Item Description
EnableMultiFile Specifies that multiple scripts are allowed. The following settings are available:
● Yes – enables the One File Only check box in the Generate database, Generate
Triggers and Procedures, and Modify Database parameters windows. If you dese
lect this option, a separate script is created for each table (named after the table,
and with the extension defined in the TableExt item), and a global script summa
rizes all the single table script items.
● The One File Only check box is unavailable, and a single script includes all the state
ments.
The file name of the global script is customizable in the File Name field of the genera
tion or modification windows and has the extension specified in the ScriptExt item.
The default name for the global script is CREBAS for database generation, CRETRG for
triggers and stored procedures generation, and ALTER for database modification.
Footer Specifies the text for the database generation script footer.
Header Specifies the text for the database generation script header.
ScriptExt Specifies the default script extension when you generate a database or modify a data
base for the first time.
Example:
sql
StartCommand Specifies the statement for executing a script. Used inside the header file of a multi-file
generation to call all the other generated files from the header file.
isql %NAMESCRIPT%
Corresponds to the %STARTCMD% variable (see PDM Variables and Macros [page
233]).
TableExt Specifies the extension of the scripts used to generate each table when the EnableMul
tiFile item is enabled and the "One File Only" check box is not selected in the Generate
or Modify windows.
Example:
sql
TrgFooter Specifies footer text for a triggers and procedures generation script.
TrgUsage1 [when using a single script] Specifies text to display in the Output window at the end of
trigger and procedure generation.
TrgUsage2 [when using multiple scripts] Specifies text to display in the Output window at the end
of trigger and procedure generation.
TriggerExt Specifies the main script extension when you generate triggers and stored procedures
for the first time.
Example:
trg
Usage1 [when using a single script] Specifies text to display in the Output window at the end of
database generation.
Usage2 [when using multiple scripts] Specifies text to display in the Output window at the end
of database generation.
The Keywords category is located in the Root Script SQL category, and contains the following items that
reserve keywords.
The lists of SQL functions and operators are used to populate the PowerDesigner SQL editor to propose lists of
available functions to help in entering SQL code.
Item Description
CharFunc Specifies a list of SQL functions to use with characters and strings.
Example:
char()
charindex()
char_length() etc
ConvertFunc Specifies a list of SQL functions to use when converting values between hex and integer
and handling strings.
Example:
convert()
hextoint()
inttohex() etc
Example:
dateadd()
datediff()
datename() etc
Example:
avg()
count()
max() etc
ListOperators Specifies a list of SQL operators to use when comparing values, boolean, and various
semantic operators.
Example:
=
!=
not like etc
Example:
abs()
acos()
asin() etc
OtherFunc Specifies a list of SQL functions to use when estimating, concatenating and SQL
checks.
Example:
db_id()
db_name()
host_id() etc
Reserved Default Specifies a list of keywords that may be used as default values. If a reserved word is
used as a default value, it will not be enquoted.
When you run this script, CURRENT DATE is recognized as a reserved default value.
ReservedWord Specifies a list of reserved keywords. If a reserved word is used as an object code, it is
enquoted during generation (using quotes only in DBMS Script SQL Syntax
Quote ).
The Objects category is located in the Root Script SQL category (and, possibly within Root ODBC
SQL ), and contains the following items that define the database objects that will be available in your model.
The following items are located in the Root Script Objects and Root ODBC Objects categories,
and apply to all objects:
● MaxConstLen - Specifies the maximum constraint name length supported by the target database for tables,
columns, primary and foreign keys. This value is used during model checking and returns an error if the code
exceeds the defined value. The constraint name is also truncated at generation time.
Note
PowerDesigner has a maximum length of 254 characters for constraint names. If your database supports
longer constraint names, you must define the constraint names to fit in 254 characters or less.
● EnableOption - Specifies that physical options are supported by the target DBMS for the model, tables,
indexes, alternate keys, and other objects and enables the display of the Options tab in object property
sheets. For more information, see Physical Options (DBMS) [page 228].
● GenerationOrder - Specifies the generation order of database objects. Drag and drop entries in the Ordered
List tab to adjust the order in which objects will be created.
The following items are available in various objects located in the Root Script Objects category.
Item Description
Add Specifies the statement required to add the object inside the creation statement of
another object.
AlterDBIgnored Specifies a list of attributes that should be ignored when performing a comparison
before launching an update database.
AlterStatementList Specifies a list of attributes which, when changed, should give rise to an alter state
ment. Each attribute in the list is mapped to the alter statement that should be
used.
BeforeCreate/ After Specify extended statements executed before or after the main Create, Drop or
Create / BeforeDrop / Af Modify statements (see Script Generation [page 142]).
terDrop / BeforeModify /
AfterModify
ConstName Specifies a constraint name template for the object. The template controls how the
name of the object will be generated.
The template applies to all the objects of this type for which you have not defined an
individual constraint name. The constraint name that will be applied to an object is
displayed in its property sheet.
● Table: CKT_%.U26:TABLE%
● Column: CKC_%.U17:COLUMN%_%.U8:TABLE%
● Primary Key: PK_%.U27:TABLE%
Create [generation and reverse] Specifies the statement required to create the object.
Example:
DefOptions Specifies default values for physical options (see Physical Options (DBMS) [page
228]) that will be applied to all objects. These values must respect SQL syntax.
Example:
in default_tablespace
EnableOwner Enables the definition of owners for the object. The object owner can differ from the
owner of the parent table. The following settings are available:
Note that, in the case of index owners, you must ensure that the Create statement
takes into account the table and index owner. For example, in Oracle 9i, the Create
statement of an index is the following:
Footer / Header Specify the object footer and header. The contents are inserted directly after or be
fore each create object statement.
MaxConstLen Specifies the maximum constraint name length supported for the object in the tar
get database, where this value differs from the default specified in MaxConstLen
(see .Script/Objects Category (DBMS) [page 163]).
MaxLen Specifies the maximum code length for an object. This value is used when checking
the model and produces an error if the code exceeds the defined value. The object
code is also truncated at generation time.
ModifiableAttributes Specifies a list of extended attributes that will be taken into account in the merge
dialog during database synchronization (see Script Generation [page 142]).
ExtTablePartition
Options Specifies physical options (see Physical Options (DBMS) [page 228]) available to
apply when creating an object.
in %s : category=tablespace
Permission Specifies a list of available permissions for the object. The first column is the SQL
name of permission (SELECT for example), and the second column is the short
name that is displayed in the title of grid columns.
SELECT / Sel
INSER / Ins
DELETE / Del
UPDATE / Upd
REFERENCES / Ref
ReversedQueries Specifies a list of additional attribute queries to be called during live database re
verse engineering (see Live Database Reverse Engineering [page 147]).
ReversedStatements Specifies a list of additional statements that will be reverse engineered (see Script
Reverse Engineering [page 145]).
SqlListQuery Specifies a SQL query for listing objects in the reverse engineering dialog. The query
is executed to fill header variables and create objects in memory.
{ OWNER, DIMENSION }
select [Link], d.dimension_name
from sys.all_dimensions d
where 1=1
[ and d.dimension_name=%.q:DIMENSION%]
[ and [Link]=%.q:SCHEMA%]
order by [Link], d.dimension_name
SqlOptsQuery Specifies a SQL query to retrieve physical options from objects reversed by
SqlListQuery. The result of the query will fill the variable %OPTIONS% and must
respect SQL syntax.
SqlPermQuery Specifies a SQL query to reverse engineer permissions granted on the object.
{ GRANTEE, PERMISSION}
select
u.user_name grantee, 'EXECUTE'
from sysuserperms u, sysprocedure s, sysprocperm p
where (s.proc_name = %.q:PROC% ) and
(s.proc_id = p.proc_id) and
(u.user_id = [Link])
Default Variable
In a column, if the type of the default variable is text or string, the query must retrieve the value of the default
variable between quotes. Most DBMS automatically add these quotes to the value of the default variable. If the
DBMS you are using does not add quotes automatically, you have to specify it in the different queries using the
default variable.
...
case(default) when '1' then '''' concat defaultvalue concat '''' when '5' then
'''' concat defaultvalue concat '''' else defaultvalue end,
...
The Table category is located in the Root Script Objects category, and can contain the following items
that define how tables are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for tables:
For a description of each of these common items, see Common Object Items [page
165].
AddTableCheck Specifies a statement for customizing the script to modify the table constraints within
an alter table statement.
AllowedADT Specifies a list of abstract data types on which a table can be based. This list popu
lates the Based On field of the table property sheet.
You can assign an abstract data type to a table, the table will use the properties of the
type and the type attributes become table columns.
OBJECT
AlterTable Footer Specifies a statement to be placed after alter table statements (and before the
terminator).
Example:
AlterTable Header Specifies a statement to be placed before alter table statements. You can place
an alter table header in your scripts to document or perform initialization logic.
Example:
DefineTable Check Specifies a statement for customizing the script of table constraints (checks) within a
create table statement.
Example:
check (%CONSTRAINT%)
DropTable Check Specifies a statement for dropping a table check in an alter table statement.
Example:
InsertIdentityOff Specifies a statement for enabling insertion of data into a table containing an identity
column.
InsertIdentityOn Specifies a statement for disabling insertion of data into a table containing an identity
column.
Rename [modify] Specifies a statement for renaming a table. If not specified, the modify data
base process drops the foreign key constraints, creates a new table with the new
name, inserts the rows from the old table in the new table, and creates the indexes
and constraints on the new table using temporary tables.
The %OLDTABL% variable is the code of the table before renaming, and the %NEW
TABL% variable is the new code.
SqlListRefr Tables Specifies a SQL query used to list the tables referenced by a table.
SqlListSchema Specifies a query used to retrieve registered schemas in the database. This item is
used with tables of XML type (a reference to an XML document stored in the data
base).
When you define an XML table, you need to retrieve the XML documents registered in
the database in order to assign one document to the table, this is done using the
SqlListSchema query.
SqlStatistics Specifies a SQL query to reverse engineer column and table statistics. See SqlStatis
tics in Column Category (DBMS) [page 173].
SqlXMLTable Specifies a sub-query used to improve the performance of SqlAttrQuery (see Com
mon Object Items [page 165]).
TableComment [generation and reverse] Specifies a statement for adding a table comment. If not
specified, the Comment check box in the Tables and Views tabs of the Database Gen
eration box is unavailable.
The %TABLE% variable is the name of the table defined in the List of Tables, or in the
table property sheet. The %COMMENT% variable is the comment defined in the Com
ment textbox of the table property sheet.
TypeList Specifies a list of types (for example, DBMS: relational, object, XML) for tables. This
list populates the Type list of the table property sheet.
UniqConstraint Name Specifies whether the same name for index and constraint name may be used in the
same table. The following settings are available:
● Yes – The table constraint and index names must be different, and this will be
tested during model checking
● No - The table constraint and index names can be identical
The Column category is located in the Root Script Objects category, and can contain the following items
that define how columns are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for columns:
● Add
● AfterCreate, AfterDrop, AfterModify
● BeforeCreate, BeforeDrop, BeforeModify
● ConstName
● Create, Drop
● Enable
● Maxlen, MaxConstLen
● ModifiableAttributes
● Options, DefOptions
● Permission
● ReversedQueries, ReversedStatements
● SqlAttrQuery, SqlListQuery, SqlOptsQuery, SqlPermQuery
For a description of each of these common items, see Common Object Items [page
165].
AddColnCheck Specifies a statement for customizing the script for modifying column constraints
within an alter table statement.
AlterTableAdd Default Specifies a statement for defining the default value of a column in an alter statement.
AltEnableAdd ColnChk Specifies if a column check constraint, built from the check parameters of the column,
can or cannot be added in a table using an alter table statement. The following
settings are available:
Example:
DefineColn Check Specifies a statement for customizing the script of column constraints (checks) within
a create table statement. This statement is called if the create, add, or alter state
ments contain %CONSTDEFN%.
Example:
DropColnChck Specifies a statement for dropping a column check in an alter table statement.
This statement is used in the database modification script when the check parame
ters have been removed on a column.
DropColnComp Specifies a statement for dropping a column computed expression in an alter table
statement.
DropDefault Constraint Specifies a statement for dropping a constraint linked to a column defined with a de
fault value
EnableBindRule Specifies whether business rules may be bound to columns for check parameters. The
following settings are available:
EnableDefault Specifies whether predefined default values are permitted. The following settings are
available:
● Yes - The default value (if defined) is generated for columns. It can be defined in
the check parameters for each column. The %DEFAULT% variable contains the
default value. The Default Value check box for columns must be selected in the
Tables & Views tabs of the Database Generation box
● No - The default value can not be generated, and the Default Value check box is
unavailable.
EnableDefault is enabled and the default value for the column employee function
EMPFUNC is Technical Engineer. The generated script is:
EnableIdentity Specifies whether the Identity keyword is supported. Identity columns are serial coun
ters maintained by the database (for example SQL Anywhere and Microsoft SQL
Server). The following settings are available:
● Yes - Enables the Identity check box in the column property sheet.
● No - The Identity check box is not available.
When the Identity check box is selected, the Identity keyword is generated in the
script after the column data type. An identity column is never null, and so the Manda
tory check box is automatically selected. PowerDesigner ensures that:
Note that, during generation, the %IDENTITY% variable contains the value "identity"
but you can easily change it, if needed, using the following syntax :
EnableNotNull WithDflt Specifies whether default values are assigned to columns containing Null values. The
following settings are available:
● Yes - The With Default check box is enabled in the column property sheet. When it
is selected, a default value is assigned to a column when a Null value is inserted.
● No - The With Default check box is not available.
ModifyColn Chck Specifies a statement for modifying a column check in an alter table statement.
This statement is used in the database modification script when the check parame
ters of a column have been modified in the table.
The %COLUMN% variable is the name of the column defined in the table property
sheet. The % CONSTRAINT % variable is the check constraint built from the new
check parameters.
ModifyColn Comp Specifies a statement for modifying a computed expression for a column in an alter
table.
ModifyColnDflt Specifies a statement for modifying a column default value in an alter table state
ment. This statement is used in the database modification script when the default
value of a column has been modified in the table.
The %COLUMN% variable is the name of the column defined in the table property
sheet. The %DEFAULT% variable is the new default value of the modified column.
ModifyColnNull Specifies a statement for modifying the null/not null status of a column in an alter
table statement.
ModifyColumn Specifies a statement for modifying a column. This is a different statement from the
alter table statement, and is used in the database modification script when the
column definition has been modified.
NullRequired Specifies the mandatory status of a column. This item is used with the NULLNOT
NULL column variable, which can take the "null", "not null" or empty values. For more
information, see Working with Null Values [page 179].
Rename Specifies a statement for renaming a column within an alter table statement.
SqlChckQuery Specifies a SQL query to reverse engineer column check parameters. The result must
conform to proper SQL syntax.
SqlStatistics Specifies a SQL query to reverse engineer column and table statistics.
[%ISLONGDTTP%?{ AverageLength }
select [%ISLONGDTTP%?[%ISSTRDTTP%?avg(char_length(%COLUMN
%)):avg(datalength(%COLUMN%))]:null] as average_length
from [%QUALIFIER%]%TABLE%
:{ NullValuesRate, DistinctValues, AverageLength }
select
[%ISMAND%?null:(count(*) - count(%COLUMN%)) * 100 / count(*)]
as null_values,
[%ISMAND%?null:count(distinct %COLUMN%)] as distinct_values,
[%ISVARDTTP%?[%ISSTRDTTP%?avg(char_length(%COLUMN
%)):avg(datalength(%COLUMN%))]:null] as average_length
from [%QUALIFIER%]%TABLE%]
The NullRequired item specifies the mandatory status of a column. This item is used with the NULLNOTNULL
column variable, which can take the "null", "not null" or empty values. The following combinations are available
"not null" is always generated whether NullRequired is set to True or False as shown in the following example:
● If NullRequired is set to True, "null" is generated. The NullRequired item should be used in ASE for example,
where nullability is a database option, and the "null" or "not null" keywords are required.
● If NullRequired is set to False, an empty string is generated. However, if a column attached to a mandatory
domain becomes non-mandatory, "null" will be generated.
In the following example, "null" is generated only for COLUMN_NULL3 because this column uses the
mandatory domain, the other columns generate an empty string:
The Index category is located in the Root Script Objects category, and can contain the following items
that define how indexes are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for indexes:
● Add
● AfterCreate, AfterDrop, AfterModify
● BeforeCreate, BeforeDrop, BeforeModify
● Create, Drop
● Enable, EnableOwner
● Header, Footer
● Maxlen
● ModifiableAttributes
● Options, DefOptions
● ReversedQueries
● ReversedStatements
● SqlAttrQuery, SqlListQuery, SqlOptsQuery
For a description of each of these common items, see Common Object Items [page
165].
Note
For information about using variables in the SqlListQuery to reverse-engineering
function-based indexes, see Live Database Reverse Engineering Function-based In
dex [page 152]
AddColIndex Specifies a statement for adding a column in the Create Index statement. This pa
rameter defines each column in the column list of the Create Index statement.
%COLUMN%[ %ASC%]
%COLUMN% is the code of the column defined in the column list of the table. %ASC
% is ASC (ascending order) or DESC (descending order) depending on the Sort radio
button state for the index column.
AlterIgnoreOrder Specifies that changes in the order of the collection should not provoke a modify data
base order.
Cluster Specifies the value to be assigned to the Cluster keyword. If this parameter is empty,
the default value of the %CLUSTER% variable is CLUSTER.
CreateBefore Key Controls the generation order of keys and indexes. The following settings are availa
ble:
Example (DB2):
Type2
EnableAscDesc Enables the Sort property in Index property sheets, which allows sorting in ascending
or descending order. The following settings are available:
● Yes – The Sort property is enabled for indexes, with Ascending selected by de
fault. The variable %ASC% is calculated, and the ASC or DESC keyword is gener
ated when creating or modifying the database
● No – Index sorting is not supported.
A primary key index is created on the TASK table, with the PRONUM column sorted in
ascending order and the TSKNAME column sorted in descending order:
EnableCluster Enables the creation of cluster indexes. The following settings are available:
EnableFunction Enables the creation of function-based indexes. The following settings are available:
CMP
HG
HNG
LF
WD
DATE
TIME
DTTM
MandIndexType Specifies whether the index type is mandatory for indexes. The following settings are
available:
MaxColIndex Specifies the maximum number of columns that may be included in an index. This
value is used during model checking.
SqlSysIndex Query Specifies a SQL query used to list system indexes created by the database. These in
dexes are excluded during reverse engineering.
UniqName Specifies whether index names must be unique within the global scope of the data
base. The following settings are available:
● Yes – Index names must be unique within the global scope of the database.
● No – Index names must be unique per object
The Pkey category is located in the Root Script Objects category, and can contain the following items that
define how primary keys are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for primary keys:
● Add
● ConstName
● Create, Drop
● Enable
● Options, DefOptions
● ReversedQueries
For a description of each of these common items, see Common Object Items [page
165].
PkAutoIndex Determines whether a Create Index statement is generated for every Primary key
statement. The following settings are available:
● Yes - Automatically generates a primary key index with the primary key state
ment. If you select the primary key check box under create index when generating
or modifying a database, the primary key check box of the create table will auto
matically be cleared, and vice versa.
● No - Primary key indexes are not automatically generated. Primary key and create
index check boxes can be selected at the same time.
UseSpPrimKey Specifies the use of the Sp_primarykey statement to generate primary keys. For a
database that supports the procedure to implement key definition, you can test the
value of the corresponding variable %USE_SP_PKEY% and choose between the crea
tion key in the table or launching a procedure. The following settings are available:
UseSpPrimKey = YES
Add entry of
The Key category is located in the Root Script Objects category, and can contain the following items that
define how keys are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for keys:
● Add
● AfterCreate, AfterDrop, AfterModify
● BeforeCreate, BeforeDrop, BeforeModify
● ConstName
● Create, Drop
● Enable
● MaxConstLen
● ModifiableAttributes
● Options, DefOptions
● ReversedQueries, ReversedStatements
● SqlAttrQuery, SqlListQuery, SqlOptsQuery
For a description of each of these common items, see Common Object Items [page
165].
AllowNullable Coln Specifies whether non-mandatory columns are permitted. The following settings are
available:
AlterIgnoreOrder Specifies that changes in the order of the collection should not provoke a modify data
base order.
SqlAkeyIndex Specifies a reverse-engineering query for obtaining the alternate key indexes of a ta
ble by live connection.
UniqConstAuto Index Determines whether a Create Index statement is generated for every key state
ment. The following settings are available:
● Yes - Automatically generates an alternate key index within the alternate key
statement. If you select the alternate key check box under create index when gen
erating or modifying a database, the alternate key check box of the create table
will automatically be cleared, and vice versa.
● No - Alternate key indexes are not automatically generated. Alternate key and cre
ate index check boxes can be selected at the same time.
The Reference category is located in the Root Script Objects category, and can contain the following
items that define how references are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for references:
● Add
● AfterCreate, AfterDrop, AfterModify
● BeforeCreate, BeforeDrop, BeforeModify
● ConstName
● Create, Drop
● Enable
● MaxConstLen
● ModifiableAttributes
● ReversedQueries, ReversedStatements
● SqlAttrQuery, SqlListQuery
For a description of each of these common items, see Common Object Items [page
165].
CheckOn Commit Specifies that referential integrity testing is performed only after the COMMIT. Con
tains the keyword used to specify a reference with the CheckOnCommit option.
Example:
CHECK ON COMMIT
DclDelIntegrity Specifies a list of declarative referential integrity constraints allowed for delete. The
list can contain any or all of the following values, which control the availability of the
relevant radio buttons on the Integrity tab of reference property sheets:
● RESTRICT
● CASCADE
● SET NULL
● SET DEFAULT
DclUpdIntegrity Specifies a list of declarative referential integrity constraints allowed for update. The
list can contain any or all of the following values, which control the availability of the
relevant radio buttons on the Integrity tab of reference property sheets:
● RESTRICT
● CASCADE
● SET NULL
● SET DEFAULT
DefineJoin Specifies a statement to define a join for a reference. This is another way of defining
the contents of the create reference statement, and corresponds to the %JOINS
% variable.
Usually the create script for a reference uses the %CKEYCOLUMNS% and %PKEY
COLUMNS% variables, which contain the lists of child and parent columns separated
by commas.
If you use %JOINS%, you can refer to each paired parent and child columns sepa
rately. A loop is executed on Join for each paired parent and child columns, allowing to
have a syntax mix of PK and FK.
P=%PK% F=%FK%
EnableChange JoinOr Specifies whether, when a reference is linked to a key as shown in the Joins tab of ref
der erence properties, the auto arrange join order check box and features are available.
The following settings are available:
● Yes - The join order can be established automatically, using the Auto arrange join
order check box. Selecting this check box sorts the list according to the key col
umn order. Clearing this check box allows manual sorting of the join order with the
move buttons.
● No - The auto arrange join order property is unavailable.
EnablefKey Name Specifies the foreign key role allowed during database generation. The following set
tings are available:
● Yes - The code of the reference is used as role for the foreign key.
● No - The foreign key role is not allowed.
FKAutoIndex Determines whether a Create Index statement is generated for every foreign key
statement. The following settings are available:
● Yes - Automatically generates a foreign key index with the foreign key statement.
If you select the foreign key check box under create index when generating or
modifying a database, the foreign key check box of the create table will automati
cally be cleared, and vice versa.
● No – Foreign key indexes are not automatically generated. Foreign key and create
index check boxes can be selected at the same time.
SqlListChildren Query Specifies a SQL query used to list the joins in a reference.
{CKEYCOLUMN, FKEYCOLUMN}
[%ISODBCUSER%?select
p.column_name, f.column_name
from sys.user_cons_columns f,
sys.all_cons_columns p
where [Link] = [Link]
and f.table_name=%.q:TABLE%
[ and [Link]=%.q:POWNER%]
and p.table_name=%.q:PARENT%
and f.constraint_name=%.q:FKCONSTRAINT%
and p.constraint_name=%.q:PKCONSTRAINT%
order by [Link]
:select p.column_name, f.column_name
from sys.all_cons_columns f,
sys.all_cons_columns p
where [Link] = [Link]
and [Link]=%.q:SCHEMA%
and f.table_name=%.q:TABLE%
[ and [Link]=%.q:POWNER%]
and p.table_name=%.q:PARENT%
and f.constraint_name=%.q:FKCONSTRAINT%
and p.constraint_name=%.q:PKCONSTRAINT%
order by [Link]]
UseSpFornKey Specifies the use of the Sp_foreignkey statement to generate a foreign key. The fol
lowing settings are available:
The View category is located in the Root Script Objects category, and can contain the following items that
define how views are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for views:
For a description of each of these common items, see Common Object Items [page
165].
EnableIndex Specifies a list of view types for which a view index is available.
MATERIALIZED
SqlListSchema Specifies a query used to retrieve registered schemas in the database. This item is
used with views of XML type (a reference to an XML document stored in the data
base).
When you define an XML view, you need to retrieve the XML documents registered in
the database in order to assign one document to the view, this is done using the
SqlListSchema query.
TypeList Specifies a list of types (for example, DBMS: relational, object, XML) for views. This
list populates the Type list of the view property sheet.
ViewCheck Specifies whether the With Check Option check box in the view property sheet is avail
able. If the check box is selected and the ViewCheck parameter is not empty, the
value of ViewCheck is generated at the end of the view select statement and before
the terminator.
ViewComment Specifies a statement for adding a view comment. If this parameter is empty, the
Comment check box in the Views groupbox in the Tables and Views tabs of the Gener
ate Database box is unavailable.
ViewStyle Specifies a view usage. The value defined is displayed in the Usage list of the view
property sheet.
materialized view
The Tablespace category is located in the Root Script Objects category, and can contain the following
items that define how tablespaces are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for tablespaces:
For a description of each of these common items, see Common Object Items [page
165].
The Storage category is located in the Root Script Objects category, and can contain the following items
that define how storages are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for storages:
For a description of each of these common items, see Common Object Items [page
165].
The Database category is located in the Root Script Objects category, and can contain the following items
that define how databases are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for databases:
For a description of each of these common items, see Common Object Items [page
165].
BeforeCreate Database Controls the order in which databases, tablespaces, and storages are generated. The
following settings are available:
● Yes – [default] Create Tablespace and Create Storage statements are generated
before the Create Database statement.
● No - Create Tablespace and Create Storage statements are generated after the
Create Database statement
CloseDatabase Specifies the command for closing the database. If this parameter is empty, the Data
base/Close option on the Options tab of the Generate Database box is unavailable.
EnableMany Databases Enables support for multiple databases in the same model.
OpenDatabase Specifies the command for opening the database. If this parameter is empty, the Da
tabase/Open option on the Options tab of the Generate Database box is unavailable.
use %DATABASE%
The %DATABASE% variable is the code of the database associated with the gener
ated model.
The Domain category is located in the Root Script Objects category, and can contain the following items
that define how domains are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for domains:
For a description of each of these common items, see Common Object Items [page
165].
EnableBindRule Specifies whether business rules may be bound to domains for check parameters.
The following settings are available:
This item is tested during column generation. If User-defined Type is selected for col
umns in the Generation dialog box, and EnableCheck is set to Yes for domains, then
the check parameters are not generated for columns, since the column is associated
with a domain with check parameters. When the checks on the column diverge from
those of the domain, the column checks are generated.
EnableDefault Specifies whether default values are generated. The following settings are available:
● Yes - Default values defined for domains are generated. The default value can be
defined in the check parameters. The %DEFAULT% variable contains the default
value
● No - Default values are not generated
SqlListDefault Query Specifies a SQL query to retrieve and list domain default values in the system tables
during reverse engineering.
Unbind Specifies the syntax for unbinding a business rule from a domain.
The Abstract Data Type category is located in the Root Script Objects category, and can contain the
following items that define how abstract data types are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for abstract data types:
For a description of each of these common items, see Common Object Items [page
165].
AllowedADT Specifies a list of abstract data types which can be used as data types for abstract
data types.
OBJECT
TABLE
VARRAY
Authorizations Specifies a list of those users able to invoke abstract data types.
EnableAdtOn Coln Specifies whether abstract data types are enabled for columns. The following settings
are available:
● Yes - Abstract Data Types are added to the list of column types provided they
have the valid type.
● No - Abstract Data Types are not allowed for columns.
EnableAdtOn Domn Specifies whether abstract data types are enabled for domains. The following settings
are available:
● Yes - Abstract Data Types are added to the list of domain types provided they
have the valid type
● No - Abstract Data Types are not allowed for domains
Install Specifies a statement for installing a Java class as an abstract data class (in ASA, ab
stract data types are installed and removed rather than created and deleted). This
item is equivalent to a create statement.
JavaData Specifies a list of available instantiation mechanisms for SQL Java abstract data
types.
Remove Specifies a statement for installing a Java class as an abstract data class.
The Abstract Data Types Attribute category is located in the Root Script Objects category, and can
contain the following items that define how abstract data type attributes are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for abstract data type attributes:
● Add
● AfterCreate, AfterDrop, AfterModify
● BeforeCreate, BeforeDrop, BeforeModify
● Create, Drop, Modify
● ModifiableAttributes
● ReversedQueries, ReversedStatements
● SqlListQuery
For a description of each of these common items, see Common Object Items [page
165].
AllowedADT Specifies a list of abstract data types which can be used as data types for abstract
data type attributes.
OBJECT
TABLE
VARRAY
If you select the type OBJECT for an abstract data type, an Attributes tab appears in
the abstract data type property sheet, allowing you to specify the attributes of the ob
ject data type.
The User category is located in the Root Script Objects category, and can contain the following items that
define how users are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for users:
For a description of each of these common items, see Common Object Items [page
165].
The Rule category is located in the Root Script Objects category, and can contain the following items that
define how rules are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for rules:
For a description of each of these common items, see Common Object Items [page
165].
ColnDefault Name Specifies the name of a default for a column. This item is used with DBMSs that do not
support check parameters on columns. When a column has a specific default value
defined in its check parameters, a name is created for this default value.
D_%.19:COLUMN%_%.8:TABLE%
The EMPFUNC column of the EMPLOYEE table has a default value of Technical
Engineer. The D_EMPFUNC_EMPLOYEE column default name is created:
ColnRuleName Specifies the name of a rule for a column. This item is used with DBMSs that do not
support check parameters on columns. When a column has a specific rule defined in
its check parameters, a name is created for this rule.
R_%.19:COLUMN%_%.8:TABLE%
The TEASPE column of the Team table has a list of values - Industry, Military, Nuclear,
Bank, Marketing - defined in its check parameters:
The R_TEASPE_TEAM rule name is created and associated with the TEASPE column:
MaxDefaultLen Specifies the maximum length that the DBMS supports for the name of the column
Default name
UddtDefault Name Specifies the name of a default for a user-defined data type. This item is used with
DBMSs that do not support check parameters on user-defined data types. When a
user-defined data type has a specific default value defined in its check parameters, a
name is created for this default value.
D_%.28:DOMAIN%
The FunctionList domain has a default value defined in its check parameters:
Technical Engineer. The following SQL script will generate a default name for that
default value:
UddtRuleName Specifies the name of a rule for a user-defined data type. This item is used with
DBMSs that do not support check parameters on user-defined data types. When a
user-defined data type has a specific rule defined in its check parameters, a name is
created for this rule.
R_%.28:DOMAIN%
The Domain_speciality domain has to belong to a set of values. This domain check
has been defined in a validation rule. The SQL script will generate the rule name fol
lowing the template defined in the item UddtRuleName:
The Procedure category is located in the Root Script Objects category, and can contain the following
items that define how procedures are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for procedures:
For a description of each of these common items, see Common Object Items [page
165].
CustomFunc Specifies the statement for creating a user-defined function, a form of procedure that
returns a value to the calling environment for use in queries and other SQL state
ments.
EnableFunc Specifies whether functions are allowed. Functions are forms of procedure that return
a value to the calling environment for use in queries and other SQL statements.
The Trigger category is located in the Root Script Objects category, and can contain the following items
that define how triggers are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for triggers:
For a description of each of these common items, see Common Object Items [page
165].
%TEMPLATE%_%.L:TABLE%
Event Specifies a list of trigger event attributes to populate the Event list on the Definition
tab of Trigger property sheets.
Example:
Delete
Insert
Update
Time Specifies a list of trigger time attributes to populate the Time list on the Definition tab
of Trigger property sheets.
Example:
Before
After
UniqName Specifies whether trigger names must be unique within the global scope of the data
base. The following settings are available:
● Yes – Trigger names must be unique within the global scope of the database.
● No – Trigger names must be unique per object
UseErrorMsg Table Specifies a macro for accessing trigger error messages from a message table in your
database.
Enables the use of the User-defined radio button on the Error Messages tab of the
Trigger Rebuild dialog box (see Data Modeling > Building Data Models > Triggers and
Procedures > Generating Triggers and Procedures > Creating User-Defined Error Mes
sages).
If an error number in the trigger script corresponds to an error number in the message
table, the default error message of the .ERROR macro is replaced your message.
begin
select @errno = %ERRNO%,
@errmsg = %MSGTXT%
from %MSGTAB%
where %MSGNO% = %ERRNO%
goto error
end
Where:
UseErrorMsg Text Specifies a macro for accessing trigger error messages from the trigger template defi
nition.
Enables the use of the Standard radio button on the Error Messages tab of the Trigger
Rebuild dialog box.
The error number and message defined in the template definition are used.
begin
select @errno = %ERRNO%,
@errmsg = %MSGTXT%
goto error
end
The DBMS Trigger category is located in the Root Script Objects category, and can contain the following
items that define how DBMS triggers are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for DBMS triggers:
For a description of each of these common items, see Common Object Items [page
165].
Events_scope Specifies a list of trigger event attributes to populate the Event list on the Definition
tab of Trigger property sheets for the selected scope, for example, schema, database,
server.
Scope Specifies a list of available scopes for the DBMS trigger. Each scope must have an as
sociated Events_scope item.
Time Specifies a list of trigger time attributes to populate the Time list on the Definition tab
of Trigger property sheets.
Example:
Before
After
The Join Index category is located in the Root Script Objects category, and can contain the following
items that define how join indexes are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for join indexes:
● Add
● AfterCreate, AfterDrop, AfterModify
● BeforeCreate, BeforeDrop, BeforeModify
● Create, Drop
● Enable, EnableOwner
● Header, Footer
● Maxlen
● ModifiableAttributes
● Options, DefOptions
● ReversedQueries, ReversedStatements
● SqlAttrQuery, SqlListQuery, SqlOptsQuery
For a description of each of these common items, see Common Object Items [page
165].
AddJoin Specifies the SQL statement used to define joins for join indexes.
Example:
Table1.coln1 = Table2.coln2
EnableJidxColn Enables support for attaching multiple columns to a join index. In Oracle 9i, this is
called a bitmap join index.
The Qualifier category is located in the Root Script Objects category, and can contain the following items
that define how qualifiers are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for qualifiers:
● Enable
● ReversedQueries
● SqlListQuery
For a description of each of these common items, see Common Object Items [page
165].
The Sequence category is located in the Root Script Objects category, and can contain the following
items that define how sequences are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for sequences:
For a description of each of these common items, see Common Object Items [page
165].
The Synonym category is located in the Root Script Objects category, and can contain the following items
that define how synonyms are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for synonyms:
● Create, Drop
● Enable, EnableSynonym
● Maxlen
● ReversedQueries
● SqlAttrQuery, SqlListQuery
For a description of each of these common items, see Common Object Items [page
165].
The Group category is located in the Root Script Objects category, and can contain the following items
that define how groups are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for groups:
For a description of each of these common items, see Common Object Items [page
165].
SqlListChildren Query Specifies a SQL query for listing the members of a group.
The Role category is located in the Root Script Objects category, and can contain the following items that
define how roles are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for roles:
For a description of each of these common items, see Common Object Items [page
165].
SqlListChildren Query Specifies a SQL query for listing the members of a group.
Unbind Specifies a command for removing a role from a user or another role.
The DB Package category is located in the Root Script Objects category, and can contain the following
items that define how database packages are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for database packages:
For a description of each of these common items, see Common Object Items [page
165].
CreateBody Specifies a template for defining the body of the database package. This statement is
used in the extension statement AfterCreate.
The following categories are located in the Root Script Objects category.
● DB Package Procedure
● DB Package Variable
● DB Package Type
● DB Package Cursor
● DB Package Exception
● DB Package Pragma
Each contains many of the following items that define how database packages are modeled for your DBMS.
[Common items] The following common object items may be defined for database packages:
● Add
● ReversedQueries
For a description of each of these common items, see Common Object Items [page
165].
DBProcedure Body [database package procedures only] Specifies a template for defining the body of the
package procedure in the Definition tab of its property sheet.
begin
end
ParameterTypes [database package procedures and cursors only] Specifies the available types for pro
cedures or cursors.
in
in nocopy
in out
in out nocopy
out
out nocopy
The Parameter category is located in the Root Script Objects category, and can contain the following
items that define how parameters are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for database packages:
● Add
● ReversedQueries
For a description of each of these common items, see Common Object Items [page
165].
The Privilege category is located in the Root Script Objects category, and can contain the following items
that define how privileges are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for privileges:
For a description of each of these common items, see Common Object Items [page
165].
RevokeInherited Allows you to revoke inherited privileges from groups and roles.
CREATE DATABASE
CREATE DEFAULT
CREATE PROCEDURE
CREATE TRIGGER
CREATE RULE
CREATE TABLE
CREATE VIEW
The Permission category is located in the Root Script Objects category, and can contain the following
items that define how permissions are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for permissions:
● Create, Drop
● Enable
● ReversedQueries
● SqlListQuery
For a description of each of these common items, see Common Object Items [page
165].
RevokeInherited Allows you to revoke inherited permissions from groups and roles.
cascade
The Default category is located in the Root Script Objects category, and can contain the following items
that define how defaults are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for defaults:
For a description of each of these common items, see Common Object Items [page
165].
Bind Specifies the command for binding a default object to a domain or a column.
If the domain or column use a default value directly typed in the Default list, then the
default value is declared in the column creation line:
Unbind Specifies the command for unbinding a default object from a domain or a column.
The Web Service and Web Operation categories are located in the Root Script Objects category, and can
contain the following items that define how web services and web operations are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for web services and web opera
tions:
For a description of each of these common items, see Common Object Items [page
165].
OperationType List [web operation only] Specifies a list of web service operation types.
query
update
storeXML
retrieveXML
call
RAW
HTML
XML
DISH
UniqName Specifies whether web service operation names must be unique in the database.
WebService Comment/ Specifies the syntax for adding a comment to web service or web service operation.
WebOperation Com
ment
The Web Parameter category is located in the Root Script Objects category, and can contain the
following items that define how web parameters are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for web parameters:
● Add
● Enable
For a description of each of these common items, see Common Object Items [page
165].
ParameterDttp List Specifies a list of data types that may be used as web service parameters.
The Result Column category are located in the Root Script Objects category, and can contain the
following items that define how web services and web operations are modeled for your DBMS.
Item Description
ResultColumn DttpList Specifies a list of data types that may be used for result columns.
The Dimension category is located in the Root Script Objects category, and can contain the following
items that define how dimensions are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for dimensions:
For a description of each of these common items, see Common Object Items [page
165].
AddAttr Hierarchy Specifies the syntax for defining a list of hierarchy attributes.
child of %DIMNATTRHIER%
hierarchy %DIMNHIER% (
%DIMNATTRHIERFIRST% %DIMNATTRHIERLIST%)
AddJoin Hierarchy Specifies the syntax for defining a list of joins for hierarchy attributes.
The Extended Object category is located in the Root Script Objects category, and can contain the
following items that define how extended objects are modeled for your DBMS.
Item Description
[Common items] The following common object items may be defined for extended objects:
For a description of each of these common items, see Common Object Items [page
165].
AlterStatement List Specifies a list of text items representing statements modifying the corresponding at
tributes
The Data Type category provides mappings to allow PowerDesigner to handle DBMS-specific data types
correctly.
AmcdAmcdType Lists mappings to convert from specialized data types (such as XML, IVL, MEDIA, etc) to
standard PowerDesigner data types. These mappings are used to help conversion from
one DBMS to another, when the new DBMS does not support one or more of these special
ized types. For example, if the XML data type is not supported, TXT is used.
AmcdDataType Lists mappings to convert from PowerDesigner (Internal) data types to DBMS (Physical
Model) data types.
These mappings are used during CDM to PDM generation and with the Change Current
DBMS command.
PhysDataType Lists mappings to convert from DBMS (Physical Model) data types to PowerDesigner
(Internal) data types.
These mappings are used during PDM to CDM generation and with the Change Current
DBMS command.
PhysDttpSize Lists the storage sizes of DBMS data types. These values are used when estimating the
size of a database.
OdbcPhysData Lists mappings to convert from live database (ODBC) data types to DBMS (Physical
Type Model) data types during database reverse engineering.
These mappings are used when data types are stored differently in the database (often
due to the inclusion of a default size) than in the DBMS notation.
PhysOdbcData Lists mappings of DBMS (Physical Model) data types to database (ODBC) data types for
Type use when updating and reverse engineering a database.
These mappings are used when data types that are functionally equivalent but different to
those specified in the PDM are found in an existing database to avoid the display of unnec
essary and irrelevant differences in the Merge dialog.
PhysLogADT Type Lists mappings to convert from DBMS (Physical Model) abstract data types to PowerDe
signer (Internal) abstract data types.
These mappings are used to populate the Type field and display the appropriate properties
in abstract data type property sheets and with the Change Current DBMS command.
● The Oracle 11g VARRAY abstract data type is converted to an Array for PowerDe
signer.
● The Oracle 11g SQLJ_OBJECT datatype is converted to a JavaObject for PowerDe
signer.
LogPhysADT Type Lists mappings to convert from PowerDesigner (Internal) abstract data types to DBMS
(Physical Model) abstract data types.
These mappings are used with the Change Current DBMS command.
● The PowerDesigner List abstract data type is converted to a TABLE for Oracle 11g.
● The PowerDesigner Object abstract data type is converted to an OBJECT for Oracle
11g.
AllowedADT Lists the abstract data types that may be used as types for columns and domains in the
DBMS.
● JAVA
HostDataType Lists mappings to convert from DBMS data types (Physical Model) to data types permitted
as procedure parameters (Trigger).
These mappings are used to populate the Data type field in ADT procedure parameter
property sheets
The Profile category is used to extend standard PowerDesigner objects. You can refine the definition, behavior,
and display of existing objects by creating extended attributes, stereotypes, criteria, forms, symbols, generated
files, etc, and add new objects by creating and stereotyping extended objects and sub-objects.
● your DBMS definition file - you should save a backup of this file before editing it.
● a separate extension file - which you attach to your model.
For detailed information about working with profiles, including adding extended attributes and objects, see
Extension Files [page 18].
Extended attributes can be taken into account during generation. Each extended attribute value can be used as a
variable that can be referenced in the scripts defined in the Script category.
Some DBMSs include predefined extended attributes. For example in PostgreSQL, domains include default
extended attributes used for the creation of user-defined data types.
You can create as many extended attributes as you need, for each DBMS supported object.
Example
For example, in DB2 UDB 7 OS/390, the extended attribute WhereNotNull allows you to add a clause enforcing
the uniqueness of index names if they are not null.
If the index name is unique, and if you set the type of the WhereNotNull extended attribute to True, the "where
not null" clause is inserted in the script.
select
tbcreator,
tbname,
name,
case indextype when '2' then 'type 2' else 'type 1' end,
case uniquerule when 'D' then '' else 'unique' end,
case uniquerule when 'P' then 'primary' when 'U' then 'unique' else '' end,
case clustering when 'Y' then 'cluster' else '' end,
case uniquerule when 'N' then 'TRUE' else 'FALSE' end
from
[Link]
where 1=1
[ and tbname=%.q:TABLE%]
[ and tbcreator=%.q:OWNER%]
[ and dbname=%.q:CATALOG%]
order by
1 ,2 ,3
By default, the Estimate Database Size mechanism uses standard algorithms to calculate the sizes of
tablespaces, tables, columns, and indexes and adds them together to provide an indication of the size that the
database will require. You can override the algorithm for one or more of these types of objects or include
additional objects in the calculation by adding the GetEstimatedSize event handler to the appropriate object in
the Profile category and entering a script to calculate its size.
1. Select Database Edit Current DBMS to open the DBMS definition file, and expand the profile category.
2. Right-click the metaclass for which you want to provide a script to calculate the object size, select New
Event Handler to open a selection dialog, select the GetEstimatedSize event handler, and then click OK to
add it under the metaclass.
3. Click the Event Handler Script tab in the right pane and enter appropriate code to calculate the size of your
chosen object.
In the following example, we look at extracts of a GetEstimatedSize event handler defined on the Table
metaclass to estimate the size of the database by calculating the size of each table as the total size of all its
columns plus the total size of all its indexes.
Note
For examples of the GetEstimatedSize event handler in use on the Table and other metaclasses, see the
SAP IQ v16 and HP Neoview R2.4 DBMS definition files.
In this first extract from the script, the GetEstimatedSize function opens and the size of each table is
obtained by looping through the size of each of its columns. The actual work of calculating the column size is
done by the line:
' Get table size and keep column size for future use
Dim ColSizes, TblSize, ColSize, C
Set ColSizes = CreateObject("[Link]")
TblSize = 0 ' May be changed to take into account table definition initial
size.
' Start browsing table columns and use event handler defined on column
metaclass (if it exists).
ColSize = [Link](message, false)
' Store column size in the map for future use in indexes.
[Link] C, ColSize
Next the size of the table indexes is calculated directly in the script without making a call to an event handler
on the Index metaclass, the line outputting index sizes is formatted and the size of the indexes added to the
total database size:
' Now calculate index sizes. Set up variables to store indexes sizes.
Dim X, XMsg, XDataSize
XMsg = ""
for each X in [Link]
XDataSize = 0
' Browsing index columns and get their size added in XDataSize
For each C in [Link]
XDataSize = XDataSize + [Link]([Link])
next
XDataSize = BlockSize * int([Link] * XDataSize / BlockSize)
' Format the display message in order to get size information in output
and result list.
XMsg = XMsg & CStr(XDataSize) & "|" & [Link] & vbCrLf
Finally the size information is formatted for output (see Formatting the Database Size Estimation Output
[page 226]). Each table is printed on a separate line in both the Output and Result List windows, and its total
size including all columns and indexes is given:
' set the global message to table size and all indexes (separate with
carriage return).
message = CStr(RawDataSize) & "||" & [Link] & vbCrLf & XMsg
%GetEstimatedSize% = RawDataSize
Once all the tables have been processed, PowerDesigner calculates and prints the total estimated size of the
database.
You can call a GetEstimatedSize event handler defined on another metaclass to use this size in your
calculation. For example, you may define GetEstimatedSize on the Table metaclass, and make a call to
GetEstimatedSize defined on the Column and Index metaclasses to use these sizes to calculate the total size
of the table.
The syntax of the function is as follows, where <message> is the name of your variable containing the results to
print:
GetEstimatedSize(<message>[,true|false])
In general, we recommend that you use the function in the folllowing form:
GetEstimatedSize(<message>, false)
The use of the false parameter (which is the default, but which is shown here for clarity) means that we call the
GetEstimatedSize event handler on the other metaclass, and use the default mechanism only if the event
handler is not available.
Setting the parameter to true will force the use of the default mechanism for calculating the size of objects (only
possible for tables, columns, and join indexes):
GetEstimatedSize(<message>, true)
You can format the output for your database size estimation. Sub-objects (such as columns and indexes)
contained in a table are offset, and you can print additional information after the total.
[<object-size>][:<compartment>]|[ObjectID][|<label>]
where:
For example, in the event handler defined on the Table metaclass (having calculated and stored the size of a
table, the size of all the columns of type LONG contained in the table, and the size of each index in the table), we
create a message variable to print this information. We begin by printing a line giving the size of a table:
We then add a line printing the total size of all the columns of type LONG in the table:
message = message & CStr(LongSize) & "||Columns of type LONG" & vbCrLf
We then add a line printing the size of each index in the table:
message = message & CStr(IndexSize) & "|" & [Link] & vbCrLf
In the event handler defined on the Tablespace metaclass (having calculated and stored the size of a
tablespace), we create a message variable to print this information after the database size calculation has been
printed.
We then add a line printing the size of each tablespace in the table
[...etc...]
[...etc...]
The ODBC category contains items for live database generation when the DBMS does not support the generation
statements defined in the Script category.
For example, data exchange between PowerDesigner and MSACCESS works with VB scripts and not SQL, this is
the reason why these statements are located in the ODBC category. You have to use a special program
([Link]) to convert these scripts into MSACCESS database objects.
For some DBMSs, additional options are used to specify how an object is optimized or stored in a database. In
PowerDesigner, these options are called physical options and are displayed on the Physical Options and Physical
Options (Common) tabs of object property sheets.
To appear on the Physical Options tab, an option must be defined in the Script\Objects\<object>\Options
item (see Common Object Items [page 165]). Default values can be stored in Options or in DefOptions. To
appear on the Physical Options (Common) tab (or any other property sheet tab), the physical option must,
additionally be associated with an extended attribute (see Adding DBMS Physical Options to Your Forms [page
232]).
During generation, the options selected in the model for each object are stored as a SQL string in the %OPTIONS
% variable, which must appear at the end of the Create statement of the object, and cannot be followed by
anything else. The following example uses the correct syntax:
create table
[%OPTIONS%]
During reverse engineering by script, the section of the SQL query determined as being the physical options is
stored in %OPTIONS%, and will then be parsed when required by an object property sheet.
During live database reverse engineering, the SqlOptsQuery SQL statement is executed to retrieve the physical
options which is stored in %OPTIONS% to be parsed when required by an object property sheet.
You can use PowerDesigner variables (see PDM Variables and Macros [page 233]) to set physical options for an
object. For example, in Oracle, you can set the following variable for a cluster to make the cluster take the same
name as the table.
Cluster %TABLE%
For information about setting physical options, see Data Modeling > Building Data Models > Physical
Implementation > Physical Options.
Simple physical options must contain a name, and may contain a %d, %s, or other variable to let the user specify
a value, and keywords to specify permitted values and defaults.
Simple physical options are specified on a single line using the following syntax:
Everything entered before the colon is generated in scripts. The <name> is required by PowerDesigner, but you
can place it between carets (<<name>>) if you need to exclude it from the final script. The %d or %s variables
require a numeric or string value, and you can also use a PowerDesigner variable or GTL snippet.
<Partition-name> %s <name>
You can insert a colon followed by comma-separated keywords to control your options:
category=<metac Allows the user to associate the object with an object of the specified kind. The following
lass> settings are available:
● tablespace
● storage
Note
In Oracle, the storage composite physical option is used as a template to define
all the storage values in a storage entry to avoid having to set values independently
each time you need to re-use them same values in a storage clause. For this rea
son, the Oracle physical option does not include the storage name (%s).
on %s : category=storage
{
dquoted=yes and Specifies that the value is enclosed in double or single quotes.
squoted=yes
multiple=yes Specifies that the option is displayed with a <*> suffix in the left pane of the Physical Op
tions tab and can be added to the right pane as many times as necessary. If the option is
selected in the right pane and you click the same option in the left pane to add it, a mes
sage box asks you if you want to reuse the selected option. If you click No, a second in
stance of the option is added to the right pane.
enabledbprefix= Specifies that the database name is inserted as a prefix (see tablespace options in DB2
yes OS/390).
prevmand=yes and Specifies that the previous or next physical option is required for the present option and
nextmand=yes that if the present option is added to the right pane, then the previous or next option is
also added.
Examples
<flashback_archive> %s <string>
Composite physical options are specified over multiple lines, and contain one or more dependent options. If you
add the composite option to the right pane of the Physical Options tab, all the dependant options are added with it.
If you add a dependant option, the composite option is added as well to contain it.
Everything entered before the colon is generated in scripts. The <name> is required by PowerDesigner, but you
can place it between carets (<<name>>) if you need to exclude it from the final script. The %d or %s variables
require a numeric or string value, and you can also use a PowerDesigner variable or GTL snippet.
composite=yes Specifies that the option is a composite option containing dependant options surround
by curly braces.
parenthesis=yes Specifies that the ensemble of dependant objects are contained between parentheses.
chldmand=yes Specifies that at least one of the dependant options must be set.
Examples
Many DBMSs use physical options as part of the definition of their objects. The most commonly-used physical
options are displayed on a form, Physical Options (Common), defined under the appropriate metaclass. You can
edit this form, or add physical options to your own forms.
Context
Note
PowerDesigner displays all of the available options for an object (defined at Script/Objects/<object>/
Options category) on the Physical Options tab (see Physical Options (DBMS) [page 228]).
For a physical option to be displayed in a form, it must be associated with an extended attribute with the type
physical option.
Procedure
1. Right-click the metaclass and select New Extended Attribute from Physical Options to open the Select
Physical Options dialog:
2. Select the physical option required and click OK to create an extended attribute associated with it.
3. Specify any other appropriate properties.
4. Select the form in which you want to insert the physical option and click the Add Attribute tool to insert it as a
control (see Adding Extended Attributes and Other Controls to Your Form [page 70]).
Results
Note
To change the physical option associated with an extended attribute, click the ellipsis to the right of the
Physical Options field in the Extended Attribute property sheet.
The SQL queries recorded in the DBMS definition file items make use of various PDM variables, which are written
between percent signs. These variables are replaced with values from your model when the scripts are generated,
and are evaluated to create PowerDesigner objects during reverse engineering.
For example, in the following query, the variable %TABLE% will be replaced by the code of the table being created:
Note
You can use these variables freely in your own queries, but you cannot change the method of their evaluation
(ie, %TABLE% can only ever evaluate to the code of the table). You can alternately, access any object properties
using GTL (see Customizing Generation with GTL [page 271]) and the public names available through the
PowerDesigner metamodel (see The PowerDesigner Public Metamodel [page 364]).
The evaluation of variables depends on the parameters and context. For example, the %COLUMN% variable cannot
be used in a Create Tablespace query, because it is only valid in a column context.
These variables can be used for all objects supporting these concepts:
Variable Comment
%OWNER% Generated code of User owning Object or its parent. You should not use this
variable for queries on objects listed in live database reverse dialog boxes, be
cause their owner is not defined yet
%OPTIONSEX% The parsed SQL text defining physical options of the object
%CONSTRAINT% Constraint SQL body of Object. Ex: (A <= 0) AND (A >= 10)
%CONSTDEFN% Column constraint definition. Ex: constraint C1 checks (A>=0) AND (A<=10)
%NAMEISCODE% True if the object (table, column, index) name and code are identical (AS 400
specific)
%TABLOWNER% The generated code of the user owning the parent table
You can use square brackets [ ] to test for the existence or value of a variable.
● Include optional strings and variables, or lists of strings and variables in the syntax of SQL statements:
[%<variable>%]
● Test the value of a variable and insert or reconsider a value depending of the result of the test: [%<variable>
%? <true> : <false>]
● Test the content of a variable [%<variable>%=<constant>? <true> : <false>]
[%<variable>%? <true> : Tests for the existence of the variable and allows conditional output.
<false>]
Generation: <true> is generated if <variable> exists and is not assigned
NO or FALSE. Otherwise, <false> is generated.
[%<variable>%=<constant>? Tests the value of the variable and allows conditional output.
<true> : <false>]
Generation: If <variable> equals <constant>, <true> is generated. Oth
erwise, <false> is generated.
[.Z: [<item1>] Specifies that the <items> do not have a significant order.
[<item2>]...]
Generation: .Z is ignored
Reverse: The <items> can be reversed in any order they are encountered.
[.O: [<item1>] Specifies that the <items> are synonyms, only one of which should be out
[<item2>]...]
put.
Reverse: The reverse parser must find one of the <items> to validate the
full statement.
Examples
● [%OPTIONS%]
If %OPTIONS% (physical options for the objects visible in the object property sheet) exists and is not assigned
NO or FALSE, it is generated to the value of %OPTIONS%.
● [default %DEFAULT%]
If the statement default 10 is found during reverse engineering, %DEFAULT% is assigned the value 10, but
the statement is not mandatory and reversing continues even if it is absent. In script generation, if %DEFAULT%
has a value of 10, it is generated as default 10 otherwise nothing is generated for the block.
If %MAND% is evaluated as true or contains a value other than False or NO, it is generated as not null.
Otherwise it is generated as null.
Because of the presence of the .Z variable, both of the following statements will be reversed correctly even
though the column attributes are not in the same order:
● [.O:[procedure][proc]]
This statement will generate procedure. During reverse engineering, the parser will match either procedure
or proc keywords.
● Note
A string between square brackets is always generated. For reverse engineering, placing a string between
square brackets means that it is optional and its absence will not cancel the reversing of the statement.
A script containing either create or create or replace will be correctly reversed because or replace is
optional.
You can specify a format for variable values. For example, you can force values to lowercase or uppercase,
truncate the length of values, or place values between quotes.
%[[?][-][<x>][.[-]<y>][<options>]:]<variable>%
Option Description
[-][<x>].[-]<y>[M] Extracts the first <y> characters or, for -<y>, the last <y> characters.
If <x> is specified, and <y> is lower than <x>, then blanks or zeros are added to
the right of the extracted characters to fill the width up to <x>. For -<x>, the
blanks or zeros are added to the left and the output is right-justified.
If the M option is appended, then the first <x> characters of the variable are dis
carded and the next <y> characters are output.
Template Output
(%.3:Name%) gives (abc)
(%.-3:Name%) gives (xyz)
(%10.3:Name%) gives (abc )
(%10.-3:Name%) gives (xyz )
(%-10.3:Name%) gives ( abc)
(%-10.-3:Name%) gives ( xyz)
(%10.3M:Name%) gives (jkl)
L[F], U[F], and c Converts the output to lowercase or uppercase. If F is specified, only the first
character is converted. c is equivalent to UF.
You can combine format codes. For example, the template (%12.3QMFU:Name%) applied to object
abcdefghijklmnopqrstuvwxyz generates ("Lmn").
PowerDesigner can use variables in the generation and reverse-engineering of tables and views.
Variable Comment
Variable Comment
%VIEWCHECK% Contains Keyword "with check option" if this option is selected in View
%SCRIPT% Complete view creation order. Ex: create view V1 as select * from T1
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of columns, domains, and
constraints. Parent table variables are also available.
Variable Comment
%PREVCOLN% Code of the previous column in the list of columns of the table
%NEXTCOLN% Code of the next column in the list of columns of the table
%NULLNOTNULL% Mandatory status of a column. This variable is always used with NullRequired
item, see Working with Null Values [page 179]
%PKEYCLUSTER% CLUSTER keyword for the primary key when it is defined on the same line
%AKEYCLUSTER% CLUSTER keyword for the alternate key when it is defined on the same line
%ISLONGDTTP% TRUE if the column datatype is a long datatype but not an image or a blob
Variable Comment
%DEFAULTNAME% Name of the default object associated with the domain (SQL Server specific)
Variable Comment
%MINMAX% SQL constraint associated with Min and max values. Ex: (C1 <= 0) AND (C1 >=
5)
%ISUPPERVAL% TRUE if the upper-case attribute of standard check has been selected
%ISLOWERVAL% TRUE if the lower-case attribute of standard check has been selected
%CASE% SQL constraint associated with cases (upper, lower, first word capital, etc)
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of indexes and index columns.
Variable Comment
%TABLE% Generated code of the parent of an index, can be a table or a query table (view)
%CIDXLIST% List of index columns with separator, on the same line. Example: A asc, B desc, C
asc
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of references and reference columns.
Variable Comment
%CHCKONCMMT% TRUE when check on commit is selected on Reference (ASA 6.0 specific)
Variable Comment
%HOSTCOLTYPE% Primary key column data type used in procedure declaration. For example:
without length
PowerDesigner can use variables in the generation and reverse-engineering of triggers and procedures.
Variable Comment
%ORDER% Order number of Trigger (in case DBMS support more than one trigger of one
type)
%TRGBODY% Trigger body (only for Oracle live database reverse engineering)
%TRGDESC% Trigger description (only for Oracle live database reverse engineering)
Variable Comment
%PROC% Generated code of Procedure (also available for trigger when Trigger is implemented with
a procedure)
Variable Comment
Variable Comment
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of tablespaces and storages.
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of abstract data types and their child
objects.
Variable Comment
%TYPE% Type of Abstract data type. It contains keywords like "array", "list", ...
The following variables are available for abstract data type attributes:
Variable Comment
The following variables are available for abstract data type procedures:
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of IQ join indexes.
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of objects for ASE and SQL Server.
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of objects during database
synchronization.
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of database packages and their child
objects.
Variable Comment
Variable Comment
Variable Comment
Variable Comment
Variable Comment
Variable Comment
Variable Comment
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of database security objects.
Variable Comment
%GRANTOPTION% Option for grant: with grant option / with admin option
%MEMBERS% List of members (users or roles) of a group or role separated by the delim
iter
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of Web services.
Variable Comment
Variable Comment
Variable Comment
Variable Comment
Variable Comment
PowerDesigner can use variables in the generation and reverse-engineering of extended objects.
Variable Comment
%EXTOBJECTDEFN% Complete body of the extended object definition. Contains definition of ex
tended collection listed in DefinitionContent DBMS item.
Variable Comment
%S% Allow to skip a word. The string is parsed for reverse but not generated
%D% Allow to skip a numeric value. The numeric value is parsed for reverse but not
generated
%A% Allow to skip all Text. The text is parsed for reverse but not generated
%SCHEMA% Variable representing a user login and the object belonging to this user in the da
tabase. You should use this variable for queries on objects listed in database re
verse dialog boxes, because their owner is not defined yet. Once the owner of an
object is defined, you can use SCHEMA or OWNER
%SIZE% Data type size of column or domain. Used for live database reverse, when the
length is not defined in the system tables
PowerDesigner can use variables in the generation of databases, triggers, and procedures.
Variable Comment
%NAMESCRIPT% Name of File script where SQL orders are going to be written
%DATASOURCE% Name of the data source associated with the generated script
%USE_SP_PKEY% Use stored procedure primary key to create primary keys (SQL Server specific)
%USE_SP_FKEY% Use stored procedure foreign key to create primary keys (SQL Server specific)
Repeat a statement for each alternate, foreign, or primary key column in a table.
Syntax
.AKCOLN("<statement>","<prefix>","<suffix>","<last_suffix>", "<condition>")
.FKCOLN("<statement>","<prefix>","<suffix>","<last_suffix>")
.PKCOLN("<statement>","<prefix>","<suffix>","<last_suffix>")
Argument Description
condition Alternate key code (if condition argument is left empty the macro returns a statement for
each alternate key in the table)
Example
Note
For columns, these macros only accept the %COLUMN% variable.
Syntax
.ALLCOL("<statement>","<prefix>","<suffix>","<last_suffix>")
Argument Description
Example
.ALLCOL("%COLUMN% %COLTYPE%","",",",";")
AU_ID char(12),
AU_LNAME varchar(40),
AU_FNAME varchar(40),
AU_BIOGRAPH long varchar,
AU_ADVANCE numeric(8,2),
AU_ADDRESS varchar(80),
CITY varchar(20),
STATE char(2),
POSTALCODE char(5),
AU_PHONE char(12);
Syntax
Argument Description
Example
Defines a variable and initializes its value if the test value is not null
Syntax
Argument Description
Example
%DEFAULT%
.DEFINEIF "%DEFAULT%" "_DEFLT"" "%DEFAULT%"
Add %COLUMN% %DATATYPE% %_DEFLT%
Handles errors.
Syntax
Argument Description
Example
Repeats a statement for each parent-to-child reference in the current table fulfilling a condition.
Syntax
.FOREACH_CHILD ("<condition>")
"<statement>"
.ENDFOR
Argument Description
Condition Selects
Example
.FOREACH_CHILD("DELETE RESTRICT")
-- Cannot delete parent "%PARENT%" if children still exist in "%CHILD%"
.ENDFOR
Repeats a statement for each column in the current table fulfilling a condition.
Syntax
.FOREACH_COLUMN ("<condition>")
"<statement>"
.ENDFOR
Argument Description
Condition Selects
NMFCOL Non-modifiable columns (columns that have Cannot Modify selected as a check parameter)
INCOLN Triggering columns (primary key columns, foreign key columns; and non-modifiable col
umns)
.FOREACH_COLUMN("NMFCOL")
-- "%COLUMN%" cannot be modified
.ENDFOR
Repeats a statement for each child-to-parent reference in the current table fulfilling a condition.
Syntax
.FOREACH_PARENT ("<condition>")
"<statement>"
.ENDFOR
Argument Description
.FOREACH_PARENT("FKCANTCHG")
-- Cannot modify parent code of "%PARENT%" in child "%CHILD%"
.ENDFOR
Repeats a statement for each primary key column, foreign key column, alternate key column, or non-modifiable
column in a table.
Syntax
.INCOLN("<statement>","<prefix>","<suffix>","<last_suffix>")
Argument Description
Example
.INCOLN("%COLUMN% %COLTYPE%","",",",";")
TITLE_ISBN char(12),
PUB_ID char(12);
Syntax
.JOIN("<statement>","<prefix>","<suffix>","<last_suffix>")
Argument Description
Example
.FOREACH_PARENT()
where .JOIN("%PK%=%FK%", " and", "", ";")
message 'Reference %REFR% links table %PARENT% to %CHILD%'
.ENDFOR
Note
For columns, the macro JOIN only accepts the variables %PK%, %AK%, and %FK%.
Repeats a statement for each non-modifiable column in a table. Non-modifiable columns have Cannot Modify
selected as a check parameter.
Syntax
.NMFCOL("<statement>","<prefix>","<suffix>","<last_suffix>")
Argument Description
Example
.NMFCOL("%COLUMN% %COLTYPE%","",",",";")
TITLE_ISBN char(12),
PUB_ID char(12);
Uses the client and/or server expression of a business rule in the trigger template, template item, trigger, and
procedure script.
Syntax
Example
In a trigger based on template AfterDeleteTrigger, you type the following macro in the Definition tab of the trigger:
.SERVEREXPRESSION(ACTIVITY_DATE_CONTROL)
● The Insert SQL/XML Macro tool opens a selection dialog box where you choose a global element from an XML
model. The XML model must be open in the workspace, mapped to a PDM, and have the SQL/XML extension
file attached. Click OK in the dialog box and the SQLXML macro is displayed in the definition code, with the
code of the XML model (optional) and the code of the global element.
● The Macros tool, where you select .SQLXML( ) in the list. The SQLXML macro is displayed empty in the
definition code. You must fill the parentheses with the code of an XML model (optional), followed by :: and the
code of a global element. The XML model, from which you choose a global element, must be open in the
workspace, mapped to a PDM, and have the SQL/XML extension file attached.
After generation, the SQLXML macro is replaced by the SQL/XML query of the global element.
Syntax
.SQLXML(CorporateMembership::DEPARTMENT)
When you launch a generation from a model, PowerDesigner generates a file for each instance of each metaclass
for which you have defined a generated file (see Generated Files (Profile) [page 102]) by evaluating the templates
it calls and resolving any variables.
GTL is object-oriented, supporting inheritance and polymorphism for reusability and maintainability, and provides
macros for testing variables and iterating through collections, etc.
A GTL template can contain text, macros, and variables, and can reference:
Note
Though GTL can be used to extend generation in a PDM, the standard generation is primarily defined using a
different mechanism (see Database Generation and Reverse Engineering [page 141]).
GTL templates are commonly used for generating files. If your template is going to be used in generation, it must
be referenced in a generated file.
Procedure
1. Open your language definition or extension file in the resource editor (see Opening Resource Files in the Editor
[page 10]).
2. If necessary, add a metaclass to the Profile category (see Metaclasses (Profile) [page 39]) and then right-click
it and select New Template (see Templates (Profile) [page 101]).
3. Enter helloWorld as the name of the template and enter the following code in the text box:
Hello World!
This template is being generated for the %Name% object.
4. Right-click the metaclass again, and select New Generated File (see Generated Files (Profile) [page
102]).
5. Enter myFile as the name of the generated file, and enter the following code in the text box to call your
template:
%helloWorld%
6. Click OK to save your changes in the resource file and return to your model.
7. Create an instance of the metaclass on which you defined the template and generated file, open its property
sheet, and click the Preview tab.
8. Select the myFile sub-tab to preview what would be generated for this object.
Object properties are referenced as variables and enclosed between percent signs: %<variable>%. Variable
names are case sensitive, and property names are, by convention, defined in CamelCase.
Example
Result:
Standard properties defined in the PowerDesigner public metamodel (see The PowerDesigner Public Metamodel
[page 364]) are referenced using their public names, which are written in CamelCase. You can infer public names
for many properties from their labels in object property sheets, but in case of doubt, click the Property Sheet
Menu button at the bottom of the property sheet and select Find in Metamodel Objects Help to review all available
properties for the object.
Extended attributes (see Extended Attributes (Profile) [page 49]) are referenced by their Name defined in the
resource editor.
%.D:MyExtAtt%
An OOM contains a collection of classes and classes contain collections of attributes and operations. To iterate
over a collection, use the .foreach_item macro.
Example
%Name% contains:
.foreach_item(Widgets)
\n\t%Name% (%Color% %Shape%)
.next
Result:
MyObject contains:
Widget1 (Red Triangle)
Widget2 (Yellow Square)
Widget3 (Green Circle)
Standard collections defined in the PowerDesigner public metamodel (see The PowerDesigner Public Metamodel
[page 364]) are referenced using their public names, which are written in CamelCase. You can infer public names
for many collections from their labels in object property sheet tabs, but in case of doubt, click the Property Sheet
Menu button at the bottom of the property sheet and select Find in Metamodel Objects Help to review all available
collections for the object.
Extended collections (see Extended Collections and Compositions (Profile) [page 60] and Calculated Collections
(Profile) [page 62]) are referenced by their Name.
You can use the following keywords to access information about a collection:
Name Description
IsEmpty (boolean) Returns True if the collection is empty, or false if it contains one or more mem
bers.
Count (integer) Returns the number of elements in the collection. You can use this keyword for de
fining criteria based on collection size, for example [Link]>=10.
Result:
You can change the formatting of variables by embedding formatting options in variable syntax. New lines and
tabs are specified using the \n and \t escape sequences respectively.
%[[-][<x>][.[-]<y>][<options>]:]<variable>%
Option Description
[-][<x>].[-]<y>[M] Extracts the first <y> characters or, for -<y>, the last <y> characters.
If <x> is specified, and <y> is lower than <x>, then blanks or zeros are added to
the right of the extracted characters to fill the width up to <x>. For -<x>, the
blanks or zeros are added to the left and the output is right-justified.
If the M option is appended, then the first <x> characters of the variable are dis
carded and the next <y> characters are output.
Template Output
(%.3:Name%) gives (abc)
(%.-3:Name%) gives (xyz)
(%10.3:Name%) gives (abc )
(%10.-3:Name%) gives (xyz )
(%-10.3:Name%) gives ( abc)
(%-10.-3:Name%) gives ( xyz)
(%10.3M:Name%) gives (jkl)
L[F], U[F], and c Converts the output to lowercase or uppercase. If F is specified, only the first
character is converted. c is equivalent to UF.
For example, the value of the Visibility attribute is stored internally as +, but is
displayed as public in the property sheet. The template %Visibility% gener
ates as +, but %.D:Visibility% generates as public.
Note
You can access extended attributes defined in another extension file by prefix
ing them with the .D option (see Extracting Object Properties [page 272]).
E [deprecated – use the ! power evaluation operator instead, see GTL Operators
[page 278]].
Examples
This file is generated for %.UQ:Name%. It has the form of a %.L:Color% %.L:Shape%.
This file is generated for "MYGADGET". It has the form of a red triangle.
%12.3QMFU:Name%
Result:
"Lmn"
The head and tail strings in a macro block are only generated when necessary. If the block returns nothing then
the head and tail strings do not appear, which can help to control the creation of new lines.
Example
The text and new lines in the head and tail of each .foreach_item loop are only printed if the collection is not
empty. When this template is applied to a class with attributes but no operations, the text // Operations and
the new lines specified before and after the operations list will not be printed:
class "%Code%" {
.foreach_item(Attributes, // Attributes\n,\n\n)
%DataType% %Code%
.if (%InitialValue%)
= %InitialValue%
.endif
.next(\n)
.foreach_item(Operations, // Operations\n,\n\n)
%ReturnType% %Code%(...)
.next(\n)
<Source>
}
Result:
<Source>
}
Note
To print a blank space between the curly brace and the string // Attributes, you must enclose the head
string in double-quotes:
.foreach_item(Attributes," // Attributes\n",\n)
Place text containing a variable between square brackets to have it appear only if the variable resolves to a non-
null value.
You can also use a form similar to C and Java ternary expressions to print a string if the variable is true or not null:
[<variable> ? <ifNotNull>]
You can optionally include a string to print if the variable is evaluated to false, null, or the empty string:
Examples
Result:
Attribute A1 =0;
Attribute A2 =100;
Attribute A3;
Attribute A4 =10;
Note
You can also test the nullity of variables with the .if macro (see .if Macro [page 302]). The following code
tests whether a Comment has been entered for the object and either prints the comment or a warning:
.if (%Comment%)
Documentation:
%Comment%
.else
!! No Documentation is defined for this table.
.endif(\n)
You can insert information such as your user name and the current date with global variables.
Name Description
%ActiveModel% (object) Returns the UID of the model. Use %[Link]% to obtain the
name of the model.
%PreviewMode% (boolean) Returns true in the Preview tab, false when generated to a file.
%CurrentDate% (string) Returns the current system date and time formatted using local settings.
Example
Result:
This file was generated from My Model by jsmith on Tuesday, November 06, 2012
4:06:41 PM.
GTL supports standard arithmetic and logical operators along with some advanced template operators.
The following standard arithmetical and logical operators are supported, where <x> and <y> can be numbers or
templates resolving to numbers:
Operator Description
= Assignment operator.
>= and <= Greater than or equal to and less than or equal to operators.
Template Results
Operator Description
%*<template> [(<P1,P2...>)]%
For information about template parameters, see Passing Parameters to a Template [page
286].
In the following example, a local variable is returned normally and in a dereferenced form:
.set_value(C, Code)
%C%
%*C%
Result:
Code
%Code%
! Power evaluation operator - Evaluates the results of the evaluation of the variable as a tem
plate.
In the following example, a local variable is returned normally and in a power-evaluated form:
.set_value(C, %%MyAttribute%%)
%C%
%!C%
Result:
%MyAttribute%
Red
%!!t%
This outputs the results of the evaluation of the evaluation of the evaluation of template t.
? Existence operator - Tests whether a template, local variable, or property is present, and re
turns false if it is not.
For example:
Result:
true
false
+ Visibility operator - Tests whether an object property is visible in the interface, and returns
false if it is not.
For example, to test if the Type field is displayed in the General tab of a database property
sheet in a DMM (meaning that a Replication Server® extension file is attached to the model),
enter the following:
%[Link]+%
The initial scope of a template is always the metaclass on which it is defined. All standard and extended attributes,
collections, and templates defined on the active object metaclass and its parents are visible, but only one object is
active at any given time.
Examples
The following template is applied to a package P1, which contains a class C1, which contains operations O1 and
O2, which each contain parameters P1 and P2. The scope changes, affecting the value of the %Name% variable, as
each collection is traversed. The Outer keyword is used to return temporarily to previous scopes:
%Name%
.foreach_item(Classes)
\n\t*%Name% in %[Link]%
.foreach_item(Operations)
\n\t*%Name% in %[Link]% in %[Link]%
.foreach_item(Parameters)
\n\t\t*%Name% in %[Link]% in %[Link]% in
%[Link]%
.next
.next
.next
Result:
P1
*C1 in P1
*O1 in C1 in P1
*P1 in O1 in C1 in P1
*P2 in O1 in C1 in P1
*O2 in C1 in P1
*P1 in O2 in C1 in P1
*P2 in O2 in C1 in P1
The Outer scope is restored when you leave a .foreach_item block. Nested scopes form a hierarchy that can
be viewed as a tree, with the top level scope being the root. Use Parent instead of Outer to climb above the
scope of the original object. For example, nothing will be output if the following template is applied to the param
eter P1:
Result:
P1 in O1 in C1
Shortcuts are dereferenced during translation, so that the scope of the target object replaces the scope of the
shortcut. This is different from VB Script where shortcut translation retrieves the shortcut itself. You can use the
%IsShortcut% variable to test whether an object is a shortcut, and the Shortcut keyword to access the
properties of the shortcut itself.
Template
In this example, the template is applied to an OOM package P1 containing two classes and two shortcuts to
classes in P2:
.foreach_item(Classes)
\n*Class %Code% [%IsShortcut% ? From package %[Link]% : Local Object]
.next
Result:
Note
If your model contains shortcuts to objects in another model that is not open, a dialog box invites you to open
the target model. You can use the .set_interactive_mode macro to change this behavior
(see .set_interactive_mode Macro [page 305]).
GTL supports a number of escape sequences to simplify the layout of your templates and generated files, and to
make reserved characters accessible.
\n New line. For examples of using new lines in macro blocks, see Controlling Line
Breaks in Head and Tail Strings [page 276].
\t Tab
\\ Backslash
%% Percent character.
You can call a template from a generated file or from another template by entering its name surrounded by
percentage signs. Object properties, collections, and local and global variables are called in the same way. At
generation time, a template call is replaced by the template content, which is then resolved to its final textual
value.
Examples:
Breaking templates into concise units and calling them at generation time helps with readability and reuse. For
example, you can define a commonly-used condition in one template and reference it in multiple other templates:
Example
.bool (%ContainerClassifier%!=null)
The %QualifiedCode% template calls the %isInner% template to test if the class is an inner class:
.if (%isInner%)
%[Link]%::%Code%
.else
%Code%
.endif
Result:
C2::C1
The %QualifiedCode% template is applied to the C1 class, which is an inner class to C2.
Templates are defined on a particular metaclass in a language definition file or extension and are inherited by and
available to the children of the metaclass. For example, a template defined on the Classifier metaclass is available
to templates or generated files defined on the Class and Interface metaclasses.
● Polymorphism - The choice of the template to be evaluated is made at translation-time. A template defined on
a classifier can access templates defined on its children (class, interface). In the following example, the
content of %definition% depends on whether a class or an interface is being processed:
● Template overriding - A template defined on a given metaclass can be overridden by a template of the same
name defined on a child class. In the following example the template defined on the Classifier metaclass is
overridden by the one defined on the Class metaclass:
You can view the overridden parent by right-clicking the child template and selecting Go to Super-Definition.
You can specify the use of the parent template by prefixing the template call with the :: qualifying operator.
For example: %Classifier::isAbstract%.
● Template overloading - You can overload your template definitions and test for different conditions.
Templates can also be defined under criteria (see Criteria (Profile) [page 47]) or stereotypes (see Stereotypes
(Profile) [page 44]), and the corresponding conditions are combined. At translation-time, each condition is
evaluated and the appropriate template (or, in the event of no match, the default template) is applied. For
example:
● Classifier: ● Classifier:
The Class and Interface metaclasses both inherit from the Classifier metaclass, and each will generate a
myFile and a myOtherFile.
The following template calls are possible in myLang/Classifier/myFile (which cannot access the templates in
myExtension):
%t% or myLang/Class/t
%myLang::t%
%Classifier::t% or myLang/Classifier/t
%myLang::Classifier::t%
The following template calls are possible in myExtension/Classifier/myOtherFile (which can access both
its own templates and those in myLang):
%t% or myExtension/Class/t
%myExtension::t%
%Classifier::t% or myExtension/Classifier/t
%myExtension::Classifier::t%
%myLang::t% or myLang/Class/t
%myLang::Class::t%
%myLang::Classifier::t% myLang/Classifier/t
Note
For an extension file to reach templates defined in a language definition file, the Complement language
generation property in the extension must be selected (see Extension File Properties [page 21]).
Parameter values cannot contain any % characters (you cannot pass a template), and are separated by commas.
They are retrieved in the template using local variables with the names @1, @2, ....
Examples
%myTemplate(fine,sunny,24,12)%
calls %myTemplate%:
The weather today is %@1% and %@2%, with a high of %@3% and a low of %@4%.
Result:
The weather today is fine and sunny, with a high of 24 and a low of 12.
.foreach_item(Attributes)
.if (%Visibility% == %@1%)
%DataType% %Code%
.endif
.next(\n)
The template %AttributeList% calls %Attributes% three times, passing a different visibility value each time
to loop over only the attributes that have this visibility:
// Protected
%attributes(#)%
// Private
%attributes(-)%
Result:
// Protected
int shape
// Private
int cost
int price
A template can call itself, but such a template should contain some kind of criteria or scope change to avoid an
infinite loop.
Example
Class C1 is inner to class C2, which is in turn inner to C3. The template %topContainerCode% tests whether the
present classifier is inner to another, and if so, calls itself on the container classifier to perfom the same test until
it reaches a classifier that is not inner, at which point it prints the code of the top container:
.if (%isInner%)
%[Link]%
.else
%Code%
.endif
Result:
C3
A number of calculated attributes and collections are provided as GTL-specific extensions to the metamodel.
[Link] ● 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
Note
Macro parameters can be delimited by double quotes, and this is required if the parameter value includes
commas, braces, leading or trailing blanks. The escape sequence for double quotes inside a parameter value is
\". When the macro parameters specify that a parameter is of type simple template, this means that it can
contain text, variables, and conditional blocks, but no macros. Parameters of type complex template can
additionally include macros.
○ .lowercase and .uppercase Macros [page 304] - change the case of a text block.
○ .convert_name and .convert_code Macros [page 293] - convert codes into names or names into codes.
○ .delete and .replace Macros [page 294] - perform operations on substrings.
○ .unique Macro [page 307] - filters redundant lines from a text block.
○ .block Macro [page 291] - adds a header and a footer to a text block.
● Generation command macros - for use when writing GTL in the context of the execution of a generation
command:
○ .set_object, .set_value, and .unset Macros [page 305] - create local objects or variables.
○ .comment and .// Macro [page 293] - inserts a comment in a template.
○ .object and .collection Macros [page 304] - returns a collection of objects based on the specified scope
and condition.
○ .object and .collection Macros [page 304] - return an object or collection based on the specified scope
and condition.
○ .bool Macro [page 292] - evaluates a condition.
○ .set_interactive_mode Macro [page 305] – defines whether the GTL execution must interact with the
user.
Example
.if %_JAVAC%
.execute_command (%_JAVAC%,%FileName%)
.else
.abort_command
.endif
For information about generation commands, see Generation Category [page 134].
This macro wraps a block of output with a header and/or a footer, if the output is not empty.
.block [(head)]
block-input
.endblock[(tail)]
Parameter Description
block-input Specifies the text to output between the head and tail.
This macro returns true or false depending on the value of the condition specified.
.bool (condition)
Parameter Description
Type: Condition
Example Result
Example
These macros change the current directory or create the specified path as part of a generation command.
.change_dir (path)
.create_path (path)
Parameter Description
Example Result
For information about generation commands, see Generation Category [page 134].
These macros are used to insert comments in a template. Lines starting with .// or .comment are ignored during
generation.
Example
These macros convert the object name to its code (or vice versa).
.convert_name (expression[,"separator"[,"delimiters"],case])
.convert_code (expression[,"separator"[,"delimiters"]])
Parameter Description
expression Specifies the text to be converted. For .convert_name, this is generally the %Name% variable
and may include a suffix or prefix.
separator [optional] Character generated each time a separator declared in delimiters is found in the
code. For example, "_" (underscore).
Type: Text
delimiters [optional] Specifies the different delimiters likely to exist in the input code or name, and
which will be replaced by separator. You can declare several separators, for example "_ "
and "-"
Type: Text
case [optional for .convert_name only] Specifies the case into which to convert the code. You
can choose between:
These macros delete or replace all instances of the given string in the text input.
.delete (string)
block-input
.enddelete
.replace (string,new-string)
block-input
.endreplace
Parameter Description
Type: Text
new-string [.replace only] Specifies the string with which to replace string.
Type: Text
block-input Specifies the text to be parsed for instances of the string to delete or replace.
Examples Result
.delete(Get) CustomerName
GetCustomerName
.enddelete
.replace(Get,Set) SetCustomerName
GetCustomerName
.endreplace
These macros are used to output errors and warnings during translation. Errors stop generation, while warnings
are purely informational and can be triggered when an inconsistency is detected while applying the template on a
particular object. The messages are displayed in both the object Preview tab and the Output window.
.error message
.warning message
Parameter Description
Example
This macro is launches executables as part of a generation command. If there is a failure for any reason
(executable not found or output sent to stderr), then command execution is stopped.
Parameter Description
Example
For information about generation commands, see Generation Category [page 134].
This macro is used to execute a VB script specified in a separate file as part of a generation command.
Parameter Description
script-parameter [optional] Passed to the script through the ScriptInputParameters global property.
.execute_vbscript(C:\samples\vbs\[Link], %username%)
The result of the script is available in the ScriptResult global property (see Manipulating Models, Collections,
and Objects (Scripting) [page 336]). The active object of the current translation scope can be accessed through
the ActiveSelection collection as [Link](0).
For information about generation commands, see Generation Category [page 134].
Parameter Description
head [optional] Specifies text to be generated before the output, unless the collection is empty.
Type: Text
tail [optional] Specifies text to be generated after the output, unless the collection is empty.
Type: Text
order [optional] Specifies the order in which the collection will be iterated in the format:
When the comparison evaluates to true, %Item1% will be placed after %Item2%. By de
fault, the collection is ordered alphabetically by name.
output Specifies the text to output for each item in the collection.
Type: Text
Note
If parameter values contain commas, braces, or leading or trailing blanks, they must be delimited with double-
quotes. To escape double-quotes inside a parameter value, use \".
Examples
Simple list:
.foreach_item(Attributes)
*%Code% (%DataType%)[ = %InitialValue%];
.next(\n)
Result:
Result:
Attributes:
*available (boolean) = true;
*actualCost (int);
*baseCost (int);
*color (String);
*height (int) = 10;
*width (int) = 5;
*name (int);
With filter:
.foreach_item(Attributes,,,%.1:Code%==a)
*%Code% (%DataType%)[ = %InitialValue%];
.next(\n)
Result:
Result:
*width (int) = 5;
*name (int);
*height (int) = 10;
*color (String);
*baseCost (int);
*available (boolean) = true;
*actualCost (int);
This macro iterates over the lines of the multiline block of text using the special %CurrentLine% local variable.
Parameter Description
head [optional] Specifies text to be generated before the output, unless there is no output.
Type: Text
tail [optional] Specifies text to be generated after the output, unless there is no output.
Type: Text
output Specifies the text to output for each line in the input.
Type: Text
Example
.foreach_line(%Comment%,"/**\n","\n*/")
* %CurrentLine%
.next("\n")
Result:
/**
* This is my comment.
* It is a Java style documentation comment.
* It spans several lines.
*/
This macro iterates over the parts of a string divided by a delimiter using the special %CurrentPart% local
variable.
Parameter Description
delimiter Specifies the sub-string that divides the input into parts. You can specify multiple charac
ters including ranges. For example [A-Z] specifies that any capital letter acts as a delim
iter.
By default, the delimiter is set to ' -_,\t' (space, dash, underscore, comma, or tab).
Note
The delimiter must be surrounded by single quotes if it contains a space.
Type: Text
head [optional] Specifies text to be generated before the output, unless there is no output.
Type: Text
tail [optional] Specifies text to be generated after the output, unless there is no output.
Type: Text
output Specifies the text to output for each part in the input.
Type: Text
For example:
Examples
.foreach_part (%Name%)
%.FU:CurrentPart%
.next
Result:
MyClass
Result:
tbl_my_class
.foreach_part (%Name%,[A-Z])
%.L:CurrentPart%
.next(-)
Result:
my-class
.if[not] condition
output
[(.elsif[not] condition
output)*]
[.else
output]
.endif [(tail)]
Parameter Description
If no operator and condition are specified, the condition evaluates to true unless the value
of the variable is false, null, or the empty string.
If variable and comparison are not integers, the operators perform a string comparison
that takes into account embedded numbers. For example:
You can chain conditions together using the and or or logical operators.
tail [optional] Specifies text to be generated after the output, unless the output is empty.
Type: Text
Examples
Simple test:
.if %Abstract%
This class is abstract.
.endif
Result (if the Abstract property is not selected and the Visibility property is set to Public):
This macro logs a message to the Output window Generation tab as part of a generation command.
.log message
Example
For information about generation commands, see Generation Category [page 134].
.lowercase
block-input
.endlowercase
.uppercase
block-input
.enduppercase
Parameter Description
Example Result
Applied to
.lowercase
%Comment%
.endlowercase This is my comment.
Produces:
this is my comment.
These macro return a single object OID or a collection of objects as a concatenation of semi-colon terminated
OIDs, and are generally used to create templates returning objects for use by other templates.
Parameter Description
Type: simple-template
Result:
C73C03B7-CD73-466A-B323-0B90B67E82FC
Result:
C73C03B7-CD73-466A-B323-0B90B67E82FC;77E3F55C-
CF24-440F-84E7-5AA7B3399C00;F369CD8C-0C16-4896-9C2D-0CD2F80D6980;00ADD959-0705-4061
-BF77-BB1914EDC018;
This macro is used to define if the GTL execution must interact with the user or not.
.set_interactive_mode(mode)
Parameter Description
mode Specifies the level of interaction required. You can choose between:
● im_Batch - Suppresses dialog boxes and always uses default values. For example, if
your model contains external shortcuts and the target model for the shortcuts is
closed, this mode will automatically open the model without user interaction.
● im_Dialog - Displays information and confirmation dialog boxes that require user in
teraction for the execution to keep running.
● im_Abort - Suppresses dialog boxes and aborts execution if a dialog is encountered.
These macros are used to define a local variable of object (local object) or value type or to unset them.
Parameter Description
scope [optional] Specifies the qualifying scope. If no scope is set, then the scope is the object
with the current scope. Use the this keyword to explicitly give a scope of the current ob
ject, or Parent to give a scope of the parent object.
name Specifies the name of the object or variable, which you can reference elsewhere in the
template in the form of %name%.
Type: Simple-template
Type: [<scope>.]<object-scope>]
mode [optional] Specifies the mode of creation. You can choose between:
● new - Forces the (re)-definition of the variable in the current scope. Recommended
when a variable with the same name may already be defined in a previous scope.
● update – [default] If a variable with the same name already exists, update the existing
variable. Otherwise define a new one.
● newifundef - Define the variable in the current scope if it has not been defined in an
outer scope. Otherwise do nothing.
unescape [.set_value only - optional] Specifies to interpret escaped characters such as \n in the
supplied value. By default, such characters are uninterpreted.
Examples:
Examples
.set_object(Attribute1, [Link])
.set_value(FirstAttributeCode, %[Link]%)
%FirstAttributeCode% (OID: %Attribute1%)
Result:
a1 (OID: 63442F85-48DF-42C8-92C1-0591F5D34525)
.set_value([Link], %Code%-%ObjectID%)
Result:
C1-40D8F396-EE29-4B7B-8C78-E5A0C5A23325
.set_value(i, 1, new)
%i?%
.unset(i)
%i?%
Result:
true
false
The first call to %i?% outputs true as the variable i is defined, and the second outputs false, because it has
been unset.
.set_value(oneline, "line1\nline2")
.set_value(twolines,"line3\nline4",, unescape)
%oneline%
%twolines%
Result:
line1\nline2
line3
line4
Note
You can use the dereferencing operator, * (see GTL Operators [page 278]), to convert the value of a variable
set with the .set_value macro to a template name. For example, the following code is equivalent to %Code%.:
.set_value(i, Code)
%*i%
This macro outputs a block in which each line of the text generated is unique, and is often used for calculating
imports, includes, typedefs, or forward declarations in languages such as Java, C++ or C#.
.unique
block-input
.endunique[(tail)]
Parameter Description
tail [optional] Specifies text to be generated after the output, unless the collection is empty.
Type: Text
Example
.unique
import [Link].*;
import [Link];
%imports%
.endunique
This macro is used to embed VBScript code inside a template as part of a generation command. The result of the
script is available as the ScriptResult array
.vbscript [(script-param-list)]
block-input
.endvbscript [(tail)]
Parameter Description
script-param-list Specifies the parameters to pass to the script through the ScriptInputArray table.
Type: Text
Type: Text
This simple script accepts the two words hello and world as input parameters, and returns them as a single
string with a space in between them:
.vbscript(hello, world)
ScriptResult = ScriptInputArray(0) + " " + ScriptInputArray(1)
.endvbscript
Result:
hello world
This script accepts an attribute code, reviews it against all the attribute codes in the current model, and appends
a 1 to it if it matches any other code:
.set_value(_code,%@1%,new)
.vbscript(%_code%)
Dim attrCode
attrCode = ScriptInputArray(0)
While (attrFound(attrCode))
attrCode = attrCode + "1"
Wend
Function attrFound(attrCode)
Dim found, attr
found = False
For Each attr in [Link](0).Attributes
If [Link] = attrCode Then
found = True
Exit For
End If
Next
ScriptResult = attrCode
.endvbscript
Note
The active object of the current translation scope is accessed as [Link](0) (see Manipu
lating Models, Collections, and Objects (Scripting) [page 336]).
For information about generation commands, see Generation Category [page 134].
Error messages stop the generation of the file in which errors have been found, these errors are displayed in the
Preview tab of the corresponding object property sheet.
target::catg-path full-template-name(line-number)
active-object-metaclass active-object-code):
error-type error-message
expecting .endif Add an .endif or .if (see .if Macro [page 302]).
expecting .end%s Add an appropriate .end to the macro block (for example,
see .unique Macro [page 307]).
.end%s with no matching .%s Add an appropriate .<macro> to the .end<macro> (for exam
ple, see .vbscript Macro [page 308]).
unknown macro Replace with a valid macro (see GTL Macro Reference [page
290]).
.execute_command incorrect syntax The correct syntax is displayed in the Preview tab, or in the
Output window (see .execute_command Macro [page 296]).
Change_dir incorrect syntax See .change_dir and .create_path Macros [page 293].
convert_name incorrect syntax See .convert_name and .convert_code Macros [page 293].
set_object incorrect syntax See .set_object, .set_value, and .unset Macros [page 305].
unresolved member: <member> Unknown member, null object member, or expecting a string
instead of an object (see Extracting Object Properties [page
null object
272]).
expecting object variable: <object>
no outer scope Invalid use of the Outer keyword (see Translation Scope
[page 281]).
VBScript execution error VB script error (see .vbscript Macro [page 308]).
Report language files have an .xrl extension and are stored in <install_dir>/Resource Files/Report
Languages. To view the list of report languages, select Tools Resources Report Languages . For
information about the tools available in resource file lists, see PowerDesigner Resource Files [page 9].
In the following example, Entity Card, Entity Description, and Entity Annotation are shown in English and French as
they will appear in the Report items pane:
The report language files use GTL templates (see Customizing Generation with GTL [page 271]) to factorize the
work of translation. Report Item Templates interact with your translations of the names of model objects and
Linguistic Variables (that handle syntactic peculiarities such as plural forms and definite articles) to automatically
generate all the textual elements in a report and dramatically reduce (by around 60%) the number of strings that
must be translated in order to render reports in a new language.
For example the French report title Liste des données de l'entité MyEntity is automatically generated
as follows:
○ %@Value% - resolves to the object type of the metaclass (see Object Attributes Category [page 323]),
données.
○ %[Link]% %%PARENT%% - resolves to the object type of the parent
metaclass, as generated by the OFTHECLSSNAME linguistic variable (see Profile/Linguistic Variables
Category [page 326]), l'entité.
○ %%PARENT%% - resolves to the name of the specific object (see Object Attributes Category [page 323]),
MyEntity.
You can review and edit report language files in the Resource Editor.
Procedure
1. Select Tools Resources Report Languages to open the List of Report Languages, which lists all the
available .xrl files:
2. Select a report language and click the Properties tool to open it in the Resource Editor.
You can open the .xrl file attached to a report open in the Report Editor by selecting Report Report
Properties , and clicking the Edit Current Language tool beside the Language list. You can change the
report language by selecting another language in the list.
For more information about the tools available in the List of Report Languages, see PowerDesigner Resource
Files [page 9].
You can translate reports and other text items used to generate PowerDesigner reports into a new language.
Procedure
1. Select Tools Resources Report Languages to open the List of Report Languages, which shows all the
available report language resource files.
2. Click the New tool, and enter the name that you want to appear in the List of Report Languages.
3. [optional] Select a report language in the Copy from list.
4. Click OK to open the new file in the Report Language Editor.
5. Open the Values Mapping category, and translate each of the keyword values (see Values Mapping Category
[page 316]).
6. Open the Profile Linguistic Variables category to create the grammar rules necessary for the correct
evaluation of the report item templates (see Profile/Linguistic Variables Category [page 326]).
7. Open the Profile Report Items Templates category, and translate the various templates (see Profile/
Report Item Templates Category [page 328]). As you translate, you may discover additional linguistic
variables that you should create.
8. Click the All Classes tab to view a sortable list of all the metaclasses available in the PowerDesigner
metamodel (see All Classes Tab [page 325]). Translate each of the metaclass names.
9. Click the All Attributes and Collections tab to view a sortable list of all the attributes and collections available in
the PowerDesigner metamodel (see All Attributes and Collections Tab [page 325]). Translate each of the
attribute and collection names.
10. Click the All Report Titles tab, and review the automatically generated report titles (see All Report Titles Tab
[page 322]). This tab may take several seconds to display.
11. Click the Save tool, and click OK to close the Report Language Editor. The report language file is now ready to
be attached to a report.
All report language files can be opened in the Resource Editor, and have the same basic category structure.
Property Description
The Values Mapping category contains a list of keywords values (such as Undefined, Yes, False, or None) for
object properties displayed in cards, checks, and lists. You must enter a translation in the Value column for each
keyword in the Name column:
Sub-category Description
Forms Contains a Standard mapping table for keywords of object properties in cards and
checks, which is available to all models. You have to provide translations for keywords
values in the Value column.
Lists Contains a Standard mapping table for keywords of object properties in lists, which is
available to all models. You have to provide translations for keywords values in the
Value column.
Example: True.
You can create new mapping tables containing keywords values specific to particular types of model objects.
You can override the values in the Standard mapping tables for a specific model object by creating a new mapping
table, and attaching it to the object.
Context
In the following example, the DisplayMap mapping table is used to override the Standard mapping table for PDM
columns to provide custom values for the Displayed property, which controls the display of the selected column in
the table symbol. This situation can be summarized as follows:
Name Value
TRUE Displayed
Procedure
2. Right-click the Lists category, select New Map Item to create a new list, and open its property sheet.
3. Enter DisplayMap in the Name field, enter the following values in the Value list, and click Apply:
The Report Titles category contains translations for all the possible report titles that appear in the Available Items
pane in the Report Editor, those that are generated with the Report Wizard, and other miscellaneous text items.
Sub-category Description
Common Objects Contains the text items available to all models. You must provide translations of these items
here.
Example: HTMLNext provides the text for the Next button in an HTML report.
Report Wizard Contains the report titles generated with the Report Wizard. You must provide translations
of these items here.
Example: Short description title provides the text for a short description section when you
generate a report with the Report Wizard.
[Models] Contain the report titles and other text items available to each model. These are automati
cally generated, but you can override the default values.
Example: DataTransformationTasks list provides the text for the data transformation tasks
list of a given transformation process in the Data Movement Model.
By default (with the exception of the Common Objects and Report Wizard sub-categories) these translations are
automatically generated from the templates in the Profile category (see Profile/Report Item Templates Category
Note
The All Report Titles tab (see All Report Titles Tab [page 322]) displays the same translations shown in this
category in a simple, sortable list form. You may find it more convenient to check and, where appropriate, to
override generated translations on this tab.
The HTML report Previous button is a common object available to all models, and located in the Common Objects
category. You must translate this text item manually along with the other items in this, and the Report Wizard
categories.
Procedure
The Report Titles tab lists all the report titles and other miscellaneous text items available in the Report Titles
category on the General tab, but the flat structure makes it more convenient to work with.
The Object Attributes category contains all the metaclasses, collections and attributes available in the
PowerDesigner metamodel, organized in tree form:
Sub-category Description
[Models] Contain text items for metaclasses, collections and attributes available to each
model, for which you must provide translations.
Example: Action provides the text for an attribute of a process in the Business
Process Model.
Common Objects Contains text items for metaclasses, collections and attributes available to all
models, for which you must provide translations.
For each item the name is given, and you must provide a translation in the Localized name field. This value is
retrieved by the templates you have specified in the Profile category to generate default report titles (see Report
Titles Category [page 319]).
For metaclasses only, the linguistic variables you have specified (see Profile/Linguistic Variables Category [page
326]) are listed along with the results of their application to the translations given in the Localized name field. If
necessary, you can override the automatically generated values by entering your own text in the Value column,
which will depress the User-Defined button to indicate that the value is no longer generated.
The All Classes tab lists all the metaclasses available in the Object Attributes category on the General tab but the
flat structure makes it more convenient to work with.
For each metaclass listed in the Name column, you must enter a translation in the Localized Name column. You
can sort the list to group similarly-named objects, and translate identical items together by selecting multiple
lines.
The All Attributes and Collections lists all the collections and attributes available in the Object Attributes category
on the General tab, but the flat structure makes it more convenient to work with.
The Linguistic Variables category contains templates, which specify grammar rules to help build the report item
templates.
Examples of grammar rules include the plural form of a noun, and the correct definite article that must precede a
noun (see Profile/Report Item Templates Category [page 328]).
Each linguistic variable and the result of its evaluation is displayed for each metaclass in the Object Attributes
category (see Object Attributes Category [page 323]).
The following are examples of grammar rules specified as linguistic variables to populate report item templates in
the French report language resource file:
● GENDER – Identifies as feminine a metaclass name %Value%, if it finishes with "e" and as masculine in all
other cases:
.if (%.-1:@Value% == e)
F
.else
M
.endif
● CLSSNAMES – Creates a plural by adding "x" to the end of the metaclass name %Value%, if it finishes with
"eau" or "au" and adds "s" in all other cases:
● THECLSSNAME – Inserts the definite article before the metaclass name %Value% by inserting " l' ", if it
begins with a vowel, "le" if it is masculine, and "la" if not:
● OFTHECLSSNAME – Inserts the preposition "de" plus the definite article before the metaclass name %Value
%,if it begins with a vowel or if it is feminine, otherwise "du".
● OFCLSSNAME – Inserts the preposition " d' " before the metaclass name %Value%,, if it begins with a vowel,
otherwise "de".
The Report Item Templates category contains a set of templates that, in conjunction with the translations that you
will provide for metaclass, attribute and collection names, are evaluated to automatically generate all the possible
report titles for report items (book, list, card etc.)
For example the template syntax for the list of sub-objects contained within a collection belonging to an object is
the following:
When this template is evaluated, the variable %@Value% is resolved to the value of the localized name for the
object, %ParentMetaClass.@Value% is resolved to the value of the localized name for the parent of the object,
and %%PARENT%% is resolved to the name for the parent of the object.
This template will be reused to create report titles for all the lists of sub-objects contained within a collection
belonging to an object.
Note
You cannot create or delete templates.
You can access and modify any PowerDesigner object using Java, VBScript, C#, or many other languages. In this
chapter, we focus primarily on writing VBScript to execute in PowerDesigner's Edit/Run Script dialog, but you can
also call add-ins from PowerDesigner menus (see Launching Scripts and Add-Ins from Menus [page 359]) or
script the PowerDesigner application via OLE automation (see OLE Automation and Add-Ins [page 353]).
The following script illustrates the basic syntax of VBScript applied to manipulating PowerDesigner models and
objects, including:
Note
VBScript can also be used to create custom checks, event handlers, transformations, and methods in an
extension file (see Extension Files [page 18]) and embedded in or called from GTL templates
(see .execute_vbscript Macro [page 296] and .vbscript Macro [page 308]).
The examples in this chapter are intended to introduce the basic concepts and techniques for controlling
PowerDesigner by script. For complete documentation of the PowerDesigner metamodel, select Help
Metamodel Objects Help . For full documentation of VBScript, see the Microsoft MSDN site .
You can run VBScript scripts in your PowerDesigner client by selecting Tools Execute Commands to open
the Edit/Run Script dialog. Output from the script is printed to the Output window.
Tools Description
● New [Ctrl+N] - Reinitializes the field by removing all the existing content.
● Open... [Ctrl+O] - Replaces the content of the field with the content of the selected file.
● Insert... [Ctrl+I] - Inserts the content of the selected file at the cursor.
● Save [Ctrl+S] - Saves the content of the field to the specified file.
● Save As... - Saves the content of the field to a new file.
● Select All [Ctrl+A] - Selects all the content of the field.
● Find... [Ctrl+F] - Opens a dialog to search for text in the field.
● Find Next... [F3] - Finds the next occurence of the searched for text.
● Find Previous... [Shift+F3] - Finds the previous occurence of the searched for text.
● Replace... [Ctrl+H] - Opens a dialog to replace text in the field.
● Go To Line... [Ctrl+G] - Opens a dialog to go to the specified line.
● Toggle Bookmark [Ctrl+F2] Inserts or removes a bookmark (a blue box) at the cursor posi
tion. Note that bookmarks are not printable and are lost if you refresh the tab
● Next Bookmark [F2] - Jumps to the next bookmark.
● Previous Bookmark [Shift+F2] - Jumps to the previous bookmark.
Edit With [Ctrl+E] - Opens the previewed code in an external editor. Click the down arrow to se
lect a particular editor or Choose Program to specify a new editor. Editors specified here are
added to the list of editors available at Tools General Options Editors .
Save [Ctrl+S] - Saves the content of the field to the specified file.
Cut [Ctrl+X], Copy [Ctrl+C], and Paste [Ctrl+V] - Perform the standard clipboard actions.
Undo [Ctrl+Z] and Redo [Ctrl+Y] - Move backward or forward through edits.
Multiple levels of Undo and Redo are supported but , if you run a script that modifies objects in
several models, you must use the Undo or Redo commands in each of the models called by the
script.
Run [F5] - Runs the script. Output is printed to the Output window.
If a compilation error occurs, a message box is displayed, a brief error description appears in
the dialog's Result pane, and the cursor is set at the error position.
You can catch errors using the On Error Resume Next statement, unless the script is called
in the im_Abort interactive mode (see .set_interactive_mode Macro [page 305]).
Find in Metamodel Objects Help [Ctrl+F1] - Opens the PowerDesigner metamodel objects help
file, which provides detailed information about all the attributes, collections, and methods avail
able for each metaclass.
PowerDesigner ships with a set of script samples, that you can use as a basis to create your own scripts, and
which are located in the VB Scripts folder of the PowerDesigner installation directory. These scripts are
intended to show you the range of tasks you can perform on PowerDesigner models using VBScript.
Caution
You should always make a backup copy of the sample script before making changes to it.
The following script browses any model, looping through any packages and listing the objects contained in them:
The following script creates a new OOM model, then creates a class with attributes and operations:
You can manipulate the contents of a model by creating or opening it and then descending from the model root
through collections of objects. A number of global properties, functions, and constants are available in any
context and provide entry points for your scripts.
The following global properties provide access to the Workspace and models it contains:
The following global functions are commonly used to create or open models and perform actions upon them:
● CreateModel() and OpenModel() - Create and open a model (see Creating and Opening Models (Scripting)
[page 337]).
● Output() - Prints text to the Script tab of PowerDesigner's Output window.
● IsKindOf() - Tests the metaclass of the object.
● ExecuteCommand() - Launches an external application
● EvaluateNamedPath() and MapToNamedPath() - Manage named paths in model files.
● BeginTransaction(), CancelTransaction(), and EndTransaction() - Start, cancel, and commit
transactions.
The following global constants provide information about the instance of PowerDesigner:
○ im_Batch [default] - Suppresses dialog boxes and always uses default values. For example, if your model
contains external shortcuts and the target model for the shortcuts is closed, this mode will automatically
open the model without user interaction.
○ im_Dialog - Displays information and confirmation dialog boxes that require user interaction for the
execution to keep running.
○ im_Abort - Suppresses dialog boxes and aborts execution if a dialog is encountered.
● ShowMode [OLE-specific] - Checks or changes the visibility status of the main application window. Returns
True if the application main window is visible and not minimized.
● Locked [OLE-specific] - When set to True, ensures that PowerDesigner continues to run even after an OLE
client disconnects.
For detailed information about all the global properties, constants, and functions, select Help MetaModel
Objects Help and navigate to Basic Elements.
This script creates a new OOM targeting the Analysis language, creates some classes in it, displays them in the
diagram, and then saves the model and closes it:
Dim NewModel
set NewModel = CreateModel(PdOOM.Cls_Model, "Language=Analysis|Diagram=ClassDiagram|
Copy")
If NewModel is Nothing then
msgbox "Failed to create UML Model", vbOkOnly, "Error" ' Display an error message
Else
output "The UML model has been created" ' Display a message in Output
[Link] "MyOOM", "MyOOM" 'Initialize model name and code
For idx = 1 to 12 'Create classes and display them
Set obj=[Link]()
[Link] "C" & idx, "C" & idx
Set sym=[Link] (obj)
Next
[Link](2)
[Link] "c:\temp\[Link]" ' Save the model
[Link] ' Close the model
Set NewModel = Nothing ' Release last reference to object to free memory
End If
Most metamodel navigation is performed by descending from the model root through collections of objects to
collections of sub-objects or associated objects. An OOM contains a collection of classes and classes contain
collections of attributes and operations. You can obtain information about and browse the members of a
collection through scripting, as well as adding, removing, and moving objects in the collection.
To browse the members of a collection, navigate to the parent object and then use a For each loop. This script
prints the names of all the tables in an open PDM:
Dim MyModel
Set MyModel=ActiveModel
For each t in [Link]
Output "* " & [Link]
Next
When you browse a collection, both full objects in the collection and any shortcuts will be retrieved.
Note
For information about accessing collections defined in extensions, see Creating and Accessing Extensions
(Scripting) [page 351].
● Compositions - contain objects that will be deleted if the parent is deleted. For example, the PdPDM/Tables
and PdPDM/Table/Columns collections are compositions.
● Aggregations - reference objects that will continue to exist if the parent is deleted. For example, the
PdCommon/NamedObject/AttachedRules collection (inherited by most objects) is an aggregation.
● Unordered collections - contain objects with no significant order. For example, the PdCDM/Entity/
Relationships collection is unordered.
● Ordered collections - contain objects where the user chooses the order. For example, the PdPDM/Table/
Columns collection is ordered.
● Read-only collections - can only be browsed. For example, the global Models collection (all open models) is
read-only.
● Creates a PDM,
● Creates objects in the model's Tables and BusinessRules unordered composition collections, and
● Adds some objects to table T1's AttachedRules ordered aggregation collection and then manipulates that
collection:
You can access and modify any PowerDesigner object and its properties by script. Objects include not only
standard design objects (such as tables, classes, processes, and columns), but also diagrams and symbols and
functional objects (such as a report or repository). An object belongs to a metaclass of the PowerDesigner
metamodel and inherits properties, collections and methods from its metaclass.
Root objects, such as models, are accessed using global properties and functions (see Manipulating Models,
Collections, and Objects (Scripting) [page 336]), while standard objects are accessed by browsing collections (see
Browsing and Modifying Collections (Scripting) [page 338]) or individually through the following methods:
● FindChildByName("Name",Kind[,OptionalParams]
● FindChildByCode("Code",Kind[,OptionalParams]
● FindChildByPath("Path",Kind[,OptionalParams]
Parameter Description
Name / Code / Path Specifies the name or code of, or the path to the object. For example, to find the column
Address in the table Customer in the package Sales from the context of the model
node, you could search by name Address or by path Sales/Customer/Address.
Kind Specifies the metaclass of the object to find in the form cls_<PublicName>. For exam
ple, to find a column, select cls_Column.
These metaclass ids are unique within their model library but, in cases such as packages,
which appear in multiple types of models, you must prefix the id with the name of the
module (PdOOM.cls_Package). When you create a model, you must use the module pre
fix (for example PdPDM.cls_Model).
● "Stereotype" - Specifies that the object to find must bear the specified stereotype.
● "LastFound" - Specifies to begin the search after this object. This parameter is used
when several objects have the same path value, and can be used to launch a find in a
while loop that uses the previous match as the last found parameter.
● CaseSensitive=y|n - [default: y] Specifies that the search is case sensitive.
● IncludeShortcuts - [default: n] Specifies that shortcuts can be found.
● UseCodeInPlaceOfName - [ByPath, default: n] Specifies that the object can be found
by its code (Default=n).
● PathSeparator - [ByPath, default= /, \, or ::)] Specifies the character to separate no
des in the path.
You can get standard attribute values using the dot notation ([Link]) or using the following
methods:
You can set attribute values using the dot notation ([Link]=value) or using the following methods:
Note
For information about getting and setting extended attribute values see Creating and Accessing Extensions
(Scripting) [page 351]
The following script opens a sample OOM, finds a class by name and a parameter by path, and then prints and
modifies some of their properties:
Dim MyModel, C, P
'Open model file
Set MyModel=OpenModel(EvaluateNamedPath("%_EXAMPLES%\" & "UML2 [Link]"))
'Obtain class and parameter
Set C=[Link]("OrderManager",cls_Class)
Set P=[Link]("SecurityManager/CheckPassword/
login",PdOOM.cls_Parameter)
You should generally create objects via the collection under the parent object using the CreateNew() method.
The CreateObject(<kind>) method is also available on model objects.
This script creates a class in an OOM, sets some of its properties, and then creates an attribute under the class, in
each case creating the objects inside collections:
Dim MyModel
Set MyModel = ActiveModel
Dim MyClass
' Create a class
Set MyClass = [Link]()
If MyClass is nothing Then
' Display an error message box
msgbox "Fail to create a class", vbOkOnly, "Error"
You can also create objects using the CreateObject(<kind>) method. This script creates a class inside an
OOM and sets some of its properties:
Dim MyModel
Set MyModel = ActiveModel
Dim MyClass
' Create a class
Set MyClass = [Link](cls_Class)
[Link] "Another Class", "Class2"
[Link] = "Created by CreateObject"
When creating a link object, you must define its extremities. This script creates two classes and joins them by an
association link:
Dim MyModel
Set MyModel = ActiveModel
Dim MyFirstClass, MySecondClass, MyAssociation
' Create classes
Set MyFirstClass = [Link]()
[Link] "Class1", "C1"
Set MySecondClass = [Link]()
[Link] "Class2", "C2"
' Create association
Set MyAssociation = [Link]()
[Link] = "A1"
' Define its extremities
Set MyAssociation.Object1 = MyFirstClass
Set MyAssociation.Object2 = MySecondClass
When you create an object, it will not appear in a diagram unless you use the AttachObject() or
AttachLinkObject() method. Symbols are objects in their own right that can be accessed via collections on the
parent object or diagram. You can position a symbol using the Position() method and change its format using
the LineWidth and other formatting attributes.
The following script creates an EAM and four architecture areas, aligns them in a square, and formats the top-left
area:
The following script creates a new CDM, populates it with entities and relationships, and then deletes entity E5
and relationship R8:
You can create a selection of objects using the CreateSelection() method. You can perform actions on the
selection such as changing properties or format or moving them to another package.
The following script creates a PDM, populates it with tables and then makes a selection of tables and moves them
into a package:
To add all the tables to the selection, use the AddObjects method:
[Link] MyModel,cls_table
[Link]([Link]("T6",cls_table))
You can access the current workspace using the ActiveWorkspace global property, open, save, and close
workspaces, and add folders and documents to it.
The following script constructs a simple folder structure in a workspace and adds and creates several models in it:
Option Explicit
' Close existing workspace and save it to Temp
Dim workspace, curentFolder
Set workspace = ActiveWorkspace
[Link] "%_EXAMPLES%\[Link]"
Output "Saving current workspace to ""Example directory :
"+EvaluateNamedPath("%_EXAMPLES%\[Link]")
[Link] "%_EXAMPLES%\[Link]"
[Link]
[Link] = "VBS WSP"
[Link] = "[Link]"
[Link] "%_EXAMPLES%\[Link]"
dim Item, subitem
for each Item in [Link]
If [Link](PdWsp.cls_WorkspaceFolder) Then
ShowFolder (item)
renameFolder item,"FolderToRename", "RenamedFolder"
deleteFolder item,"FolderToDelete"
curentFolder = item
ElsIf [Link](PdWsp.cls_WorkspaceModel) Then
ElsIf [Link](PdWsp.cls_WorkspaceFile) Then
End if
next
Dim subfolder
'insert folder in root
Set subfolder = [Link](PdWsp.cls_WorkspaceFolder)
[Link] = "Newfolder(VBS)"
'insert folder in root at pos 6
Set subfolder = [Link](5, PdWsp.cls_WorkspaceFolder)
[Link] = "Newfolder(VBS)insertedAtPos5"'
' add a new folder in this folder
Set subfolder = [Link](PdWsp.cls_WorkspaceFolder)
[Link] = "NewSubFolder(VBS)"
[Link] EvaluateNamedPath("%_EXAMPLES%\[Link]")
[Link] EvaluateNamedPath("%_EXAMPLES%\[Link]")
[Link] EvaluateNamedPath("%_EXAMPLES%\[Link]")
[Link] EvaluateNamedPath("%_EXAMPLES%\[Link]")
dim lastmodel
set lastmodel = [Link] (EvaluateNamedPath("%_EXAMPLES%
\[Link]"))
[Link]
[Link] = "Computers"
[Link]
'detaching model from workspace
[Link]
[Link] "%_EXAMPLES%\[Link]"
For more information about properties and methods available on the workspace, select Help MetaModel
Objects Help and navigate to Libraries/PdWSP/Workspace.
The following script acts on an OOM and creates a shortcut of the class C1 from package P1 in package P2:
The following script creates a shortcut of the class C1 from model O1 package P1 directly under model O2:
You can create data sources in a model and from there create mappings from source objects in other models to
objects in the first model using scripts.
The following script creates an OOM and a PDM, populates them with classes and tables, then creates a data
source in the OOM, associates the PDM with it and creates mappings:
For more information about objects mapping, see Core Features Guide > Linking and Synchronizing Models >
Object Mappings.
You can create a report, browse its contents, and generate it as HTML or RTF using scripting.
Dim model
Set model = ActiveModel
[Link]("MyReport")
To browse the reports in a model, use the Reports collection. For example:
Dim model
Set model = ActiveModel
For each m in [Link]
Output [Link]
Next
set m = ActiveModel
For each r in [Link]
filename = "C:\temp\" & [Link] & ".htm"
[Link] (filename)
Next
You can connect to the repository and check documents into and out of it by script and iterate on the latest
versions of repository documents through the RepositoryConnection object. You can manage repository
folders and branches and LDAP and SMTP servers and the repository password policy, but you cannot manipulate
repository users and groups.
The following script opens a repository connection, creates a new PDM and checks it in, and then loops over the
creation of tables, and further consolidations, before closing the connection:
Dim rc
Set rc = RepositoryConnection
[Link] "REPOSITORYNAME", "USER", "PW", "DBUSER", "DBPW"
Output "Before consolidation"
ListChildren rc
Dim NewModel
Set NewModel = CreateModel(PdPDM.Cls_Model, "|Language=SYASIQ1540")
[Link] = "My PDM"
[Link] rc
For i = 1 to 5
For j = 1 to 5
[Link]()
Next
[Link]
Next
Output "After consolidation"
ListChildren rc
[Link]
Sub ListChildren(rc)
For each c in [Link]
Output [Link] & "(Modified: " & [Link] & ")"
Next
End Sub
For detailed information about the members, collections, and methods available for scripting the repository,
select Help MetaModel Objects Help and navigate to Libraries/PdRMG.
You can generate a PDM as a SQL script or directly to a live database connection using the
GenerateDatabase() method. You can generate test data with the GenerateTestData() method.
The following script fragment opens an example PDM and then calls procedures to generate various scripts:
Sub GenerateDatabaseScripts(m)
Dim opts
Set opts = [Link]()
InteractiveMode = im_Batch ' Avoid displaying generation window
[Link] = False ' Force sql script generation rather than ODBC
[Link] = GenDir
[Link] = "[Link]"
[Link] ' Launch the Generate Database feature
End Sub
To generate to a live database connection, you would connect to the database (using the ConnectToDatabase()
method) and then set the GenerateODBC property to true.
Note
For more information about the generation options, select Help MetaModel Objects Help and navigate to
Libraries/PdPDM/BasePhysicalPackageOptions.
This procedure modifies the model by adding a new column to each table:
Sub ModifyModel(m)
dim pTable, pCol
For each pTable in [Link]
Set pCol = [Link]()
[Link] "az" & [Link], "AZ" & [Link]
[Link] = False
Next
End Sub
Sub GenerateAlterScripts(m)
Dim pOpts
Set pOpts = [Link]()
InteractiveMode = im_Batch ' Avoid displaying generate window
' set generation options using model package options
[Link] = False ' Force sql script generation rather than ODBC
[Link] = GenDir
[Link] = 0 'force already saved apm as source
[Link] = GenDir & "[Link]"
[Link] = "[Link]"
[Link] ' Launch the Modify Database feature
End Sub
Sub GenerateTestDataScript(m)
Dim pOpts
Set pOpts = [Link]()
InteractiveMode = im_Batch ' Avoid displaying generate window
' set generation options using model package options
[Link] = False ' Force sql script generation rather than
ODBC
[Link] = False
[Link] = GenDir
[Link] = "[Link]"
[Link] ' Launch the Generate Test Data feature
End Sub
You can connect to a database using the ConnectToDatabase() method, and reverse engineer the schema to a
PDM using ReverseDatabase().
To connect to a database via a user or system data source, define a constant in the form
"ODBC:datasourcename" . For example:
To use a data source file, define a constant with the full path to the DSN file. For example:
This script creates a new PDM, connects to a database via a system data source, sets reverse options and
reverses all objects to the PDM:
You can create extensions by script to define additional properties, new metaclasses, forms, and any other type of
extension to the standard metamodel.
The following example creates an EAM, then creates an extension inside it, defines a new type of object called
tablet derived from the MobileDevice metaclass, and creates an extended attribute and new custom form for
it:
You can get and set extended attribute values using the following methods:
● GetExtendedAttribute("[Link]")
● GetExtendedAttributeText("[Link]")
● SetExtendedAttribute "[Link]" "value"
● SetExtendedAttributeText "[Link]" "value"
You can access collections defined in an extension using the following methods:
You can explore the structure of the PowerDesigner metamodel as a standalone model or starting from object
instances in your model.
For general information about accessing and navigating in the metamodel, see The PowerDesigner Public
Metamodel [page 364]. Metaclasses (such as CheckModelInternalMessage and FileReportItem) that are
not accessible by script are visible in [Link], but bear the <<notScriptable>> stereotype and are not
listed in the Metamodel Object Help file.
You can access metaclasses, metaattributes, and metacollections by iterating over collections descending from
the MetaModel root or individually through the following methods:
The following script traverses the metamodel by library and lists each concrete class:
The following script locates the BaseClass root and shows the first two levels of inheritance under it:
The following script obtains a table in a PDM, and then shows the metaclass of which the object is an instance, the
parent metaclass and metalibrary to the metaclass, and all the attributes and collections that are available on that
metaclass:
Dim object
Set object = [Link]("myTable",cls_Table)
Output "Object: " + [Link]
Dim metaclass
Set metaclass = [Link]
Output "Metaclass: " + [Link]
Output "Parent: " + [Link]
Output "Metalibrary: " + [Link]
Output "Attributes:"
For each attr in [Link]
Output " - " + [Link]
Next
Output "Collections:"
For each coll in [Link]
Output " - " + [Link]
Next
OLE Automation provides a way to communicate with PowerDesigner from another application using the COM
architecture. You can write a program using any language that supports COM, such as Word or Excel macros, VB,
C++, or [Link] can create executables that call PowerDesigner or add-ins that are called by
PowerDesigner.
VBScript programs that run from within PowerDesigner and OLE Automation programs are very similar, but OLE
requires you to work through a PowerDesigner application object, and to use stronger typing. You must:
● Create an instance of the PowerDesigner Application object and release it when your script terminates:
Dim PD As [Link]
Set PD = CreateObject("[Link]")
'Enter script here
'Once script is finished, release PD object
Set PD = Nothing
If PowerDesigner is currently running, this instance will be used; otherwise a new instance will be launched. If
you do not specify a version number, the most recent version is used. To specify a specific version, use the
syntax:
Set PD = CreateObject("[Link]")
[Link]
● Specify object types whenever possible. For example, instead of simply using Dim cls, you should use:
If your model contains shortcuts, we recommend that you use the following syntax to avoid runtime errors
when the target model is closed:
● Adapt the object class ID syntax to the language when you create object. For VBScript, VBA and VB and other
languages that support enumeration defined outside a class, you can use the syntax:
For C# and [Link], you can use the following syntax (where PdOOM_Classes is the name of the
enumeration):
For other languages such as JavaScript or PowerBuilder, you have to define constants that represent the
objects you want to create. For a complete list of class ID constants, see file [Link] in the
PowerDesigner OLE Automation directory.
● Add references to the object type libraries you need to use. For example, in a VBA editor, select Tools
References :
'* Purpose: This script displays the number of classes defined in an OOM in the
output window.
Option Explicit
' Main function
Sub VBTest()
' Defined the PowerDesigner Application object
Dim PD As [Link]
' Get the PowerDesigner Application object
Set PD = CreateObject("[Link]")
' Get the current active model
Dim model As [Link]
Set model = [Link]
If model Is Nothing Then
MsgBox "There is no current model."
ElsIf Not [Link](PdOOM.cls_Model) Then
MsgBox "The current model is not an OOM model."
Else
' Display the number of classes
Dim nbClass
nbClass = [Link]
[Link] "The model '" + [Link] + "' contains " + CStr(nbClass) + " classes."
' Create a new OOM
Dim model2 As [Link]
Set model2 = [Link](PdOOM.cls_Model)
If Not model2 Is Nothing Then
' Copy the author name
[Link] = [Link]
' Display a message in the output window
[Link] "Successfully created the model '" + [Link] + "'."
Else
MsgBox "Cannot create an OOM."
End If
End If
' Release the PowerDesigner Application object
OLE Automation samples for different languages are provided in the OLE Automation directory within your
PowerDesigner installation directory.
To operate as a PowerDesigner add-in, the ActiveX add-in must implement the IPDAddIn interface, which defines
the following methods, invoked by PowerDesigner to dialog with menus and execute the commands defined by
the add-in:
For example:
<Menu>
<Popup Caption="&Perforce">
<Command Name="CheckIn" Caption="Check &In"/>
<Separator/>
<Command Name="CheckOut" Caption="Check &Out"/>
</POPUP>
</MENU>
Note
To use your add-in, save it to the Add-ins directory beneath your PowerDesigner installation directory and
enable it through the PowerDesigner General Options window (see Core Features Guide > Modeling with
PowerDesigner > Customizing Your Modeling Environment > General Options > Add-Ins).
The following illustration helps you understand the XML file structure:
Note
The DTD is available at PD_installdir\Add-ins\[Link].
● A Shared element - which defines the menus that are always available and their associated methods, along
with a GlobalScript attribute, which can contain a global script for shared functions.
● One or more Metaclass elements - which define commands and menus for a specific metaclass, identified by
its public name prefixed by its Type Library public name.
● Menus contains Menu elements that specify a location, which can be one of:
○ A Command element - whose Name must be equal to the name of a Method, and whose Caption defines
the name of the command that appears in the menu.
○ A Separator element - which indicates that you want to insert a line in the menu.
○ A Popup element - which defines a sub-menu item that may in turn contain commands, separators, and
popups.
● Methods contains Method elements, which define the methods used in the menus, and which are defined by
a name and a VBScript. A method defined under a metaclass has the current object as a parameter.
Inheritance is taken into account, so that a menu defined on the metaclass [Link] will be
available on [Link].
The following example defines two menu items for the Perforce repository and the methods that are called by
them:
Note
To use your add-in, save it to the Add-ins directory beneath your PowerDesigner installation directory and
enable it through the PowerDesigner General Options window (see Core Features Guide > Modeling with
PowerDesigner > Customizing Your Modeling Environment > General Options > Add-Ins).
You can extend PowerDesigner menus to add commands to call scripts defined in resource files or externally and
to launch executables and ActiveX add-ins. XML add-ins can be used to group and organize multiple commands.
You can extend the File, Tools, and Help menus, and the contextual menus available on objects in the Browser and
diagrams.
● Custom commands - are defined directly in PowerDesigner and can call executable programs or VB scripts
(see Adding Commands to the Tools Menu [page 360]).
● Menu and method extensions – are specified in a DBMS or language definition or extension file and define
commands for a specific target or model type (see Menus (Profile) [page 97]).
● ActiveX Add-Ins – are written in languages such as VB, C#, C++ or any language supporting COM, and permit
more complex interactions with PowerDesigner, such as enabling and disabling menu items based on object
selection, and interaction with the windows display environment (see Creating an ActiveX Add-in [page 356]).
● XML Add-Ins – define multiple commands to call executable programs or VB scripts. Commands linked to the
same applications (for example, ASE, IQ etc.) should be gathered into the same XML file (see Creating an XML
File Add-in [page 357]).
You can create your own menu items in the PowerDesigner Tools menu to access PowerDesigner objects using
your own scripts or executable programs. You can define up to 256 commands in the Customize Commands
dialog, and control the contexts (model, diagram, and target type) in which they appear.
Procedure
1. Select Tools Execute Commands Customize Commands and click the Add a row tool.
2. Enter the following properties:
Property Description
Name Specifies the name of the command that will appear in the menu. Names must be
unique and can contain a pick letter (&Generate Java will appear as Generate Java)
Submenu Specifies a submenu in which to place the command. You can enter your own or
select one of:
Context Specifies when the command is available. By default the command is available at
all times (*/*/*). Click the ellipsis button to restrict the display of the command to
a specific:
Command Line Specifies the path to the executable or script file to run. Click the ellipsis button to
navigate to a file. If your file is a VBScript, you can review or edit the script by click
ing the Edit With tool in the toolbar.
Comment Specifies text that is displayed in the status bar when you select the command.
[S]how in Menu Specifies that the command should be displayed. Deselect this field to hide the
command while retaining its definition.
Accelerator Key Associates one of ten reserved keyboard shortcuts Ctrl-Shift-0 to Ctrl-Shift-9 with
the command.
Note
Customized Commands are saved by default in the Registry at HKEY_CURRENT_USER\Software\Sybase
\PowerDesigner v\PlugInCommands\submenu and are available only to the user defining them. To
make them available to all users, create an entry at the same location under HKEY_LOCAL_MACHINE.
[Hide:][Key:accelerator:][Script:]commandline[ |comment]
If you want to insert a pipe within a command, you must escape it with a second pipe.
You can review the public metamodel in PowerDesigner by opening <install dir>\Examples
\[Link], and find exhaustive documentation of all the metamodel objects, collections, and methods
available via scripting, by selecting Help Metamodel Objects Help (see Using the Metamodel Objects Help
File [page 367]).
This OOM and help file help you understand the structure of your models, especially when working with:
● Generation Template Language (GTL) templates (see Customizing Generation with GTL [page 271]).
● VB scripts (see Scripting PowerDesigner [page 330]).
● PowerDesigner XML model files (see PowerDesigner Model File Format [page 369]).
Each of these top-level packages contains the follow kinds of sub-objects, organized by diagram or, in the case of
PdCommon, by sub-packages:
● Features - All the features implemented by classes in the model. For example, Report (available in all models)
belongs to PdCommon, and AbstractDataType belongs to PdPDM.
● Objects - Design objects in the model
● Symbols - Graphical representation of design objects
Each metaclass has a name, contains zero or more attributes and assumes zero or more roles in associations with
other classes, which allow you to identify collections. The PowerDesigner public metamodel uses standard UML
concepts:
● Public Names - Each object in the metamodel has a name and a code corresponding to the public name of the
object, which is the unique identifier of the object in a model library or package. Public names are referenced
in PowerDesigner XML model files and when using GTL and scripting. The public name often matches the
object's name in the PowerDesigner interface, but where the two diverge, the public name must be used in
scripts and GTL templates.
● Classes - are used to represent metadata in the following ways:
○ Abstract classes - are used only to share attributes and behaviors, and are not visible in the
PowerDesigner interface.
○ Instantiable/Concrete classes - correspond to objects displayed in the interface. They have their own
attributes and behaviors in addition to those they inherit from abstract classes through generalization
links. For example, NamedObject is an abstract class, which contains standard attributes like Name,
Code, Comment, Annotation, and Description, which are inherited by most PowerDesigner design
objects.
● Class attributes - are object properties. Classes linked to other classes with generalization links usually
contain derived attributes that are calculated from the attributes or collections of the parent class. Neither
When associations have two roles, only the collection with the navigable role will be saved in the XML file. In
the case, only the AttachedRules collection is saved.
● Compositions – express an association where the children live and die with the parent and, when the parent is
copied, the child is also copied. For example, Table has a composition association with the Column class:
● Generalizations - show the inheritance links existing between a more general, usually abstract, class and a
more specific, usually instantiable, class. The more specific class inherits from the attributes of the more
generic class, these attributes are called derived attributes. For example, Class inherits from Classifier
Each diagram shows classes the connections between metaclasses via associations and generalizations. Classes
in green are defined in the current diagram, while classes in purple are present only to provide context. To
investigate a purple class, right-click it and select Related Diagrams <diagram> to open the diagram where
it is defined.
In the following example, BusinessRule is being defined, while NamedObject and BaseModel are present only
to show inheritance and composition links:
● General - provides the public name in the Name and Code fields, a Comment providing a brief description of
the class, and shows whether it is Abstract.
Note
Objects, such as RepositoryGroup that do not support scripting bear the <<notScriptable>>
stereotype.
● Attributes - lists the properties defined directly on the class, but not those that it inherits via any parent
classes.
● Associations - lists the migrated associations for the class, which represent collections. The Role B column
lists the collections for the class, while the Role A column lists the collections in which the class figures.
● Operations - lists the methods available for scripting.
● Dependencies - contains the following sub-tabs (among others):
○ Associations
○ Generalizations - lists the generalization links where the current class is the child and inherits attributes
from a parent class.
○ Specializations - lists the generalization links where the current class is the parent and its children inherit
attributes from it.
○ Shortcuts - lists the shortcuts created for the current object.
● Notes - may include further information on the Description or Annotation sub-tabs.
PowerDesigner provides documentation of the metamodel available from Help Metamodel Objects Help .
The file can be opened from the Edit/Run Script dialog (see Running Scripts in PowerDesigner [page 331]) or from
a metaclass in a resource file (see Metaclasses (Profile) [page 39]) by clicking the Find in MetaModel Help button
or pressing Ctrl+F1. It can also be opened from any object property sheet by pressing Ctrl+F1 or clicking the
Property Sheet Menu button and selecting Find in MetaModel Help.
Appendix Includes an expandable hierarchy showing all the metaclasses in the PowerDesigner
metamodel, a VBScript code sample, and a list of the class ID constants used to
identify objects in certain contexts (see Accessing and Modifying Objects and Proper
ties (Scripting) [page 340]).
Each metaclass shows the hierarchy of ancestors from which it is descended and inherits. After a brief description
and symbol, it then lists:
● Specific Members - a table which lists the properties, collections, and methods defined directly on this
metaclass
● Full definition - which lists, in separate tables, the properties, collections, and methods inherited from each of
its ancestors. For example, the Table metaclass (located at Libraries\PdPDM\Table) inherits members
from:
○ [Link]
○ [Link]
○ [Link]
○ [Link]
○ [Link]
○ [Link]
○ [Link]
Caution
You can modify an XML model file using a text or XML editor, but you should take care, as even a minor syntax
error may render the file unusable. If you create an object in an XML file by copy and paste, make sure that you
remove the duplicated OID. PowerDesigner will automatically assign an OID to the new object when next you
open the model.
● <o:<object>> - A PowerDesigner model object. The first time the object is mentioned in a collection,
PowerDesigner assigns it an id using the <o:<object> Id="<XYZ>"> syntax (where <XYZ> is a unique
identifier automatically assigned to an object when it is found for the first time) or references it with the
<o:object Ref="<XYZ>"/> syntax. Object definition is only used in composition collections, where the
parent object owns the children in the association.
● <c:<collection>> - A collection of objects linked to another object. You can use the PowerDesigner
metamodel to visualize the collections of an object. For example <c:Children>.
● <a:<attribute>> - An object is made up of a number of attributes each of which you can modify
independently. For example <a:ObjectID>.
PowerDesigner XML model files have an <o:model> element at their root, which contains collections defined in
the PowerDesigner metamodel. The model object and all the other object elements that it contains define their
You can search for an object in the metamodel using its object name in the XML file in order to better understand
its definition. Once you have found an object in the metamodel you can read the following information:
● Each PowerDesigner object can have several collections corresponding to other objects to interact with, these
collections are represented by the associations existing between objects. The roles of the associations
(aggregations and compositions included) correspond to the collections of an object. For example, each
PowerDesigner model contains a collection of domains called Domains.
Usually associations have only one role, the role is displayed at the opposite of the class for which it
represents a collection. However, the metamodel also contains associations with two roles, in such case, both
collections cannot be saved in the XML file. You can identify the collection that will be saved from the
association property sheet: the role where the Navigable check box is selected is saved in the file.
In the following example, association has two roles which means Classifier has a collection Actors, and Actor2
has a collection ImplementationClasses:
If you display the association property sheet, you can see that the Navigable check box is selected for role
ImplementationClass, which means that only collection ImplementationClass will be saved in file.
The first object to appear is the root of the model <o:RootObject Id="01">. RootObject is a model container that is
defined by default whenever you create and save a model. RootObject contains a collection called Children that is
made up of models.
In our example, Children contains only one model object that is defined as follows:
<o:Model Id="o2">
<a:ObjectID>3CEC45F3-A77D-11D5-BB88-0008C7EA916D</a:ObjectID>
<a:Name>ObjectOrientedModel_1</a:Name>
<a:Code>OBJECTORIENTEDMODEL_1</a:Code>
<a:CreationDate>1000309357</a:CreationDate>
<a:Creator>arthur</a:Creator>
<a:ModificationDate>1000312265</a:ModificationDate>
<a:Modifier>arthur</a:Modifier>
<a:ModelOptionsText>
[ModelOptions]
...
Below the definition of the model object, you can see the series of ModelOptions attributes. Note that
ModelOptions is not restricted to the options defined in the Model Options dialog box of a model, it gathers all
properties saved in a model such as intermodel generation options.
After ModelOptions, you can identify collection <c:ObjectLanguage>. This is the object language linked to the
model. The second collection of the model is <c:ClassDiagrams>. This is the collection of diagrams linked to the
model, in our example, there is only one diagram defined in the following paragraph:
<o:ClassDiagram Id="o4">
<a:ObjectID>3CEC45F6-A77D-11D5-BB88-0008C7EA916D</a:ObjectID>
<a:Name>ClassDiagram_1</a:Name>
<a:Code>CLASSDIAGRAM_1</a:Code>
<a:CreationDate>1000309357</a:CreationDate>
<a:Creator>arthur</a:Creator>
<a:ModificationDate>1000312265</a:ModificationDate>
<a:Modifier>arthur</a:Modifier>
<a:DisplayPreferences>
...
Like for model options, ClassDiagram definition is followed by a series of display preference attributes.
Within the ClassDiagram collection, a new collection called <c:Symbols> is found. This collection gathers all the
symbols in the model diagram. The first object to be defined in collection Symbols is AssociationSymbol:
<o:AssociationSymbol Id="o5">
<a:CenterTextOffset>(1, 1)</a:CenterTextOffset>
<a:SourceTextOffset>(-1615, 244)</a:SourceTextOffset>
<a:DestinationTextOffset>(974, -2)</a:DestinationTextOffset>
<a:Rect>((-6637,-4350), (7988,1950))</a:Rect>
<a:ListOfPoints>((-6637,1950),(7988,-4350))</a:ListOfPoints>
<a:ArrowStyle>8</a:ArrowStyle>
<a:ShadowColor>13158600</a:ShadowColor>
<a:FontList>DISPNAME 0 Arial,8,N
<c:SourceSymbol>
<o:ClassSymbol Ref="o6"/>
</c:SourceSymbol>
<c:DestinationSymbol>
<o:ClassSymbol Ref="o7"/>
</c:DestinationSymbol>
The association symbols collection is followed by the<c:Symbols> collection. This collection contains the
definition of both class symbols.
<o:ClassSymbol Id="o6">
<a:CreationDate>1012204025</a:CreationDate>
<a:ModificationDate>1012204025</a:ModificationDate>
<a:Rect>((-18621,6601), (-11229,12675))</a:Rect>
<a:FillColor>16777215</a:FillColor>
<a:ShadowColor>12632256</a:ShadowColor>
<a:FontList>ClassStereotype 0 Arial,8,N
Collection <c:Classes> follows collection <c:Symbols>. In this collection, both classes are defined with their
collections of attributes.
<o:Class Id="o10">
<a:ObjectID>10929C96-8204-4CEE-911#-E6F7190D823C</a:ObjectID>
<a:Name>Order</a:Name>
<a:Code>Order</a:Code>
<a:CreationDate>1012204026</a:CreationDate>
<a:Creator>arthur</a:Creator>
<a:ModificationDate>1012204064</a:ModificationDate>
<a:Modifier>arthur</a:Modifier>
<c:Attributes>
<o:Attribute Id="o14">
Attribute is a terminal object: there is not further ramification required to define this object.
Each collection belonging to an analyzed object is expanded, and analyzed and the same occurs for collections
within collections.
Once all objects and collections are browsed, the following markups appear:
</o:RootObject>
</Model>
Coding Samples
Any software coding and/or code lines / strings ("Code") included in this documentation are only examples and are not intended to be used in a productive system
environment. The Code is only intended to better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and
completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, unless damages were caused by SAP
intentionally or by SAP's gross negligence.
Accessibility
The information contained in the SAP documentation represents SAP's current view of accessibility criteria as of the date of publication; it is in no way intended to be a
binding guideline on how to ensure accessibility of software products. SAP in particular disclaims any liability in relation to this document. This disclaimer, however, does
not apply in cases of wilful misconduct or gross negligence of SAP. Furthermore, this document does not result in any direct or indirect contractual obligations of SAP.
Gender-Neutral Language
As far as possible, SAP documentation is gender neutral. Depending on the context, the reader is addressed directly with "you", or a gender-neutral noun (such as "sales
person" or "working days") is used. If when referring to members of both sexes, however, the third-person singular cannot be avoided or a gender-neutral noun does not
exist, SAP reserves the right to use the masculine form of the noun and pronoun. This is to ensure that the documentation remains comprehensible.
Internet Hyperlinks
The SAP documentation may contain hyperlinks to the Internet. These hyperlinks are intended to serve as a hint about where to find related information. SAP does not
warrant the availability and correctness of this related information or the ability of this information to serve a particular purpose. SAP shall not be liable for any damages
caused by the use of related information unless damages have been caused by SAP's gross negligence or willful misconduct. All links are categorized for transparency
(see: [Link]