СУБД Oracle / Литература / PowerDesigner 9 / GeneralFeatures
.pdf&KDSWHU 0DQDJLQJ 2EMHFWV
Set C = RepositoryConnection
C.Open "MyRepDef"
’ Retrieve the deepest folder under the connection Dim D, P
set P = Nothing
for each D in C.ChildObjects
if D.IsKindOf (cls_RepositoryFolder) then D.DeleteEmptyFolder
c.refresh end if
next
0DQLSXODWLQJ UHSRUWV
Example
Example
Example
General Features Guide
You can generate HTML and RTF reports using VBScript, but you cannot create reports.
The main actions you can perform for model reports and multi-model reports are the following:
♦%URZVH D UHSRUW IRU D PRGHO
You can browse a report for a model using the following collection on BaseModelReport: Reports As ObjectCol.
set m = ActiveModel
For each Report in m.Reports
Output Report.name
♦5HWULHYH D PXOWLPRGHO UHSRUW
You can retrieve a multimodel report using the following function:
OpenModel( filename As String, flags As Long =omf_Default) As Object
OpenModel ("c:\temp\mmr1.mmr")
♦*HQHUDWH DQ +70/ UHSRUW
You can generate a model report or a multimodel report as HTML using the following method on BaseModelReport: GenerateHTML(ByVal FileName As String) As Boolean.
set m = ActiveModel
For each Report in m.Reports
$FFHVVLQJ REMHFWV XVLQJ 9%6FULSW
Filename = Report.name & ".htm"
Report.GenerateHTML (filename)
next
♦*HQHUDWH D 57) UHSRUW
You can generate a model report or a multimodel report as RTF using the following method on BaseModelReport: GenerateRTF(ByVal FileName As String) As Boolean
Example set m = ActiveModel
For each Report in m.Reports
Filename = Report.name & ".rtf"
Report.GenerateRTF (filename)
next
9%6FULSW XVHV LQ 3RZHU'HVLJQHU
VBScript has various others uses in PowerDesigner.
It is used to:
♦Create templates or commands in the GTL
♦Create custom checks
♦Create customized commands
♦Manipulate PowerDesigner objects from other applications via OLE Automation
For more information on the use of VBScript in the GTL, see section Using Macros in chapter Generation Reference Guide in the $GYDQFHG 8VHU 'RFXPHQWDWLRQ.
For more information on the use of VBScript to create custom checks,
see section Defining a custom check in a profile in chapter Managing Profiles in the $GYDQFHG 8VHU 'RFXPHQWDWLRQ.
For more information on the use of VBScript to create customized commands, see section Defining a customized command.
For more information on the use of VBScript in OLE Automation, see section OLE Automation.
|
PowerDesigner |
&KDSWHU 0DQDJLQJ 2EMHFWV
2/( $XWRPDWLRQ
OLE Automation is a way to communicate with PowerDesigner from another application using VBScripting. OLE automation can also be called Visual Basic for Application.
Word and Excel macros, VB, or even PowerBuilder are examples of applications that can be used to communicate with PowerDesigner.
OLE automation lets other applications communicate with PowerDesigner using the COM architecture in the same application or in other applications. Communication with PowerDesigner can also be done through other different languages.
With a VBA program, the main difference resides in the fact that you must declare a PowerDesigner application object in the other application then instanciate it before you can manipulate PowerDesigner objects.
When you want to access Powerdesigner objects from an external application, the following occurs depending on PowerDesigner status:
3RZHU'HVLJQHU DSSOLFDWLRQ |
:LQGRZV EHKDYLRXU |
|
Closed |
Starts the application |
|
Opened |
Uses the same application session |
|
|
|
Shortcuts
Example
General Features Guide
If the model contains shortcuts, we recommend to use Dim obj (without type), otherwise the program will try to return the target object and the IsShortcut function will be disabled.
If the target model is closed, you will get a runtime error.
’*******************************************************
’* File: List Tables.vb
’* Purpose: This VB program shows how to display properties of the first 5 tables
’* |
defined in the current active PDM using |
message box. |
|
’* Title: |
Display tables properties in message box |
’*******************************************************
Option Explicit
’-------------------------------------------------------
’ Show properties of tables
$FFHVVLQJ REMHFWV XVLQJ 9%6FULSW
’-------------------------------------------------------
Sub ListTables()
’ PowerDesigner server connection
’ (it must not be reset until client is over) Dim PD As PdCommon.Application
’ Get Application object
Set PD = CreateObject("PowerDesigner.Application")
’ Get the current active model Dim model As PdCommon.BaseModel Set model = PD.ActiveModel
If (model Is Nothing) Or (Not model.IsKindOf(PdPDM.cls_Model)) Then
MsgBox "The current model is not a PDM model."
Else
ShowProperties PD, model
End If
’ Clean Up
Set PD = Nothing
End Sub
’-------------------------------------------------------
’ Show properties of tables defined in a package ’-------------------------------------------------------
Sub ShowProperties(PD, package)
|
’ Get the Tables collection |
|
Dim ModelTables |
|
Set ModelTables = package.Tables |
|
MsgBox "The model or package ’" + package.Name + "’ |
|
contains " + CStr(ModelTables.Count) + " tables." |
|
’ For each table |
|
PowerDesigner |
&KDSWHU 0DQDJLQJ 2EMHFWV
Dim tbl
Dim noTable
Dim bShortcutClosed
Dim Desc
noTable = 1
For Each tbl In ModelTables
If IsObject(tbl) Then
bShortcutClosed = False If tbl.IsShortcut Then
If tbl.Status = "Opened" Then
Set tbl = tbl.TargetObject
Else
bShortcutClosed = True
End If
End If
Desc = "Table " + CStr(noTable) + ":"
If Not bShortcutClosed Then
Desc = Desc + vbCrLf + "ObjectID: " + tbl.ObjectID
Desc = Desc + vbCrLf + "Name: " + tbl.Name
Desc = Desc + " " + "Code: " + tbl.Code
If IsObject(tbl.Parent) Then
Desc = Desc + vbCrLf + "Parent: " + tbl.Parent.Name
Else
Desc = Desc + vbCrLf + "Parent: " +
"<None>"
End If
Desc = Desc + vbCrLf + "DisplayName: " + tbl.DisplayName
Desc = Desc + vbCrLf + "ObjectType: " + tbl.ObjectType
Desc = Desc + vbCrLf + "CreationDate: " +
CStr(tbl.CreationDate)
Desc = Desc + vbCrLf + "Creator: " +
|
tbl.Creator |
General Features Guide |
|
$FFHVVLQJ REMHFWV XVLQJ 9%6FULSW
Desc = Desc + vbCrLf + "ModificationDate: " + CStr(tbl.ModificationDate)
Desc = Desc + vbCrLf + "Modifier: " + tbl.Modifier
Desc = Desc + vbCrLf + "Comment: " +
tbl.Comment
Desc = Desc + vbCrLf + "Description: " +
PD.Rtf2Ascii(tbl.Description)
Else
Desc = Desc + vbCrLf + "The target object of the table shortcut " + tbl.Code + " is not accessible."
End If
MsgBox Desc
Else
MsgBox "Not an object!"
End If
noTable = noTable + 1
If noTable > 5 Then
Exit For
End If
Next
’ Display tables defined in subpackages
Dim subpackage
For Each subpackage In package.Packages
ShowProperties PD, subpackage
Next
End Sub
8VLQJ FXVWRPL]HG FRPPDQGV
You can access PowerDesigner objects using your own scripts.
|
PowerDesigner |
&KDSWHU 0DQDJLQJ 2EMHFWV
From the Tools application menu, you can add your own submenu entries that will allow you to execute the following commands:
♦Executable programs
♦VB scripts
You can also gather commands into submenus, modify existing commands, and apply to them accelerator keys.
'HILQLQJ D FXVWRPL]HG FRPPDQG
You can define commands in the Customize Commands dialog box. The number of commands you can define is limited to 256.
When you define a command, the name you typed for the command appears as a submenu entry of the Execute Commands menu item. Command names appear alphabetically sorted.
You can define a context for that command, so it becomes diagram dependent and displays as a submenu only when it is relevant.
The following picture illustrates the result of commands definition performed in the Customize Commands dialog box.
To define a command, you have to specify the following in the Customize commands dialog box:
|
&RPPDQG GHILQLWLRQ |
|
'HVFULSWLRQ |
|
|
Name |
|
Name of the command that appears as a submenu in |
|
|
|
|
the Execute Commands menu item. Names are unique |
|
|
|
|
and can contain a pick letter (&Generate Java will |
|
|
|
|
appear as *enerate Java) |
|
General Features Guide |
|
|
||
|
$FFHVVLQJ REMHFWV XVLQJ 9%6FULSW
|
&RPPDQG GHILQLWLRQ |
'HVFULSWLRQ |
|
Submenu |
Name of the submenu that groups commands. It |
|
|
appears in the Execute Commands menu item. You |
|
|
can select a default submenu from the dropdown |
|
|
listbox (<None>, Check Model, Export, Generation, |
|
|
Import, Reverse) or create your own submenu that |
|
|
will be added to the listbox. If you select <None> or |
|
|
leave the box empty, the command you defined will |
|
|
be directly added in the submenu of the Execute |
|
|
Commands menu item |
|
Context |
Optional information that allows the display of the |
|
||
|
|
command according to the opened diagram. If you do |
|
|
not define a context for the command, it will appear |
|
|
in the Execute Commands menu item whatever the |
|
|
opened diagram, and even when no diagram is active |
|
Type |
Type of the command that you select from the |
|
||
|
|
dropdown listbox. It can be an executable or a VB |
|
|
script |
|
Command Line |
Path of the command file. The Ellipsis button allows |
|
||
|
|
you to browse for a file or any argument. If the |
|
|
command file is a VB script, you can click the button |
|
|
in the toolbar to directly open the VBScript editor and |
|
|
preview or edit the script |
|
Comment |
Descriptive label for the command. It appears in the |
|
||
|
|
status bar when you select a command name in the |
|
|
Exexcute Commands menu item |
|
Show in Menu |
Indicates whether the command name should be |
|
||
|
|
displayed in the Execute Commands menu item or |
|
|
not. It allows you to disable a command in the menu |
|
|
without deleting the command definition |
|
Accelerator Key |
Allows you to apply an accelerator key to the |
|
||
|
|
command. You can select one from the dropdown |
|
|
listbox. The use of an accelerator must be unique |
Context option |
|
|
The Context option allows you to define a diagram dependent command that |
||
|
will appear only when the parameters you declared in its definition matches |
|
|
the current diagram. |
|
When no matches are found, the command is unavailable.
|
PowerDesigner |
|
|
|
|
&KDSWHU 0DQDJLQJ 2EMHFWV |
|
|
|
|
|
|
|
|
When you click the Ellipsis button in the Context column of the Customize |
||||
|
Commands dialog box, you open the Context Definition dialog box in which |
||||
|
you are asked to select the following optional parameters: |
||||
|
|
|
|
|
|
|
3DUDPHWHU |
|
'HVFULSWLRQ |
||
|
|
|
|
|
|
|
Model |
|
Allows you to select a model type from the Model |
||
|
|
|
dropdown listbox |
||
|
|
|
|
|
|
|
Diagram |
|
Allows you to select a diagram type for the selected model |
||
|
|
|
from the Diagram dropdown listbox |
||
|
|
|
|
|
|
|
Target resource |
|
Allows you to select or type a XEM file from the Target |
||
|
|
|
Resource dropdown listbox, which contains all the XEM |
||
|
|
|
files defined for the selected model type. The path button |
||
|
|
|
allows you to browse for another particular target resource |
||
|
|
|
(XOL or XDB) in another folder |
||
|
|
|
|
||
|
Here are some examples of context definitions as they display in the Context |
||||
|
column of the Customize Commands dialog box: |
||||
|
&RQWH[W GHILQLWLRQ |
|
'HVFULSWLRQ |
|
|
|
|
||||
|
*/*/* |
|
|
Default value. The command is displayed in the |
|
|
|
|
|
Execute Commands menu item whatever the |
|
|
|
|
|
opened diagram, and even when no diagram is |
|
|
|
|
|
active |
|
|
OOM/*/* |
|
The command is displayed in the Execute |
||
|
|
||||
|
|
|
|
Commands menu item whenever an OOM is |
|
|
|
|
|
opened, whatever the opened diagram and the |
|
|
|
|
|
selected target resource |
|
|
OOM/Class diagram/* |
|
The command is displayed in the Execute |
||
|
|
||||
|
|
|
|
Commands menu item whenever an OOM is |
|
|
|
|
|
opened with a class diagram, whatever the selected |
|
|
|
|
|
target resource |
|
|
OOM/Class diagram/Java |
The command is displayed in the Execute |
|||
|
|||||
|
|
|
|
Commands menu item whenever an OOM is |
|
|
|
|
|
opened with a class diagram which target resource |
|
|
|
|
|
is Java |
|
Import/Export |
|
|
|||
When you select Import or Export in the submenu dropdown listbox of the |
|||||
submenus |
Customize Commands dialog box, the command you defined appears not |
||||
|
only as a submenu entry of the Execute Commands menu item of the Tools |
||||
|
menu but also as a submenu entry of the Import or Export menu items of the |
||||
|
File menu. |
|
|
|
|
General Features Guide |
|
|
|
|
$FFHVVLQJ REMHFWV XVLQJ 9%6FULSW
For example you defined the following command in the Customize
Commands dialog box:
The command appears as follows in the Tools menu:
|
PowerDesigner |