Rational Rose Generate Data Model Report

Well I was looking in my mail box to cleanup my old mails and suddenly found this old script that I wrote a decade back.

To give a brief background on this. Rose Data Modeler features allow the database designer and the software developer to communicate requirements using the same tool. As a database designer or developer, you can use Rose Data Modeler to model and design databases, and to integrate your application and database.You can model and design a database using an object model transformed to a data model or by reverse engineering an existing database schema or DDL script to create a data model.

By default in those days, when the Word Application was being upgraded to lates versions, all the required tools were not being upgraded, and due to the incompatibility issues with Office XP and Office 2000, Rational Rose Modeler used to fail when I tried to generate the Data Model Report.

So I came up with my own script to generate the Data Model Report in Rational Rose Script.

The below script when used inside the Rose Modeler Tool , can generate  and Write Data Model Dictionary into word document’ in hierarchical order with their names.

  • Write Data Model Dictionary into word document


' Write Data Model Dictionary into word document
' in hierarchical order with their names.
' You'll probably need to
' change the template and output filenames.
' Author Shreedhara C.A.

Const vbCr$ = Chr$(13)
Const vbLf$ = Chr$(10)
Const vbCrLf$ = vbCr$ + vbLf$
Const vbTab$ = Chr$(9)
Const vbNL$ = Chr$(11)
const PublicAccess$ = "PublicAccess"
const ProtectedAccess$ = "ProtectedAccess"
const PrivateAccess$ = "PrivateAccess"

Const none$ = ""

const cg$ = "cg"
const Datascope$ = "Datascope"

const inLabel$ = "In"
const outLabel$ = "Out"
const inOutLabel$ = "InOut"

const returnValuesLabel$ = "ReturnValues"

Const namePrefix = "Design View::"
Const toolName = "DictateDataModel"
Const TemplateFileName ="normal.dot"
'Const SaveFileName ="D:\RoseDocs\DataModelDict.doc"

Sub CopyDiagram(wordApp As Object, diagram As Diagram)

Dim theClassDiagram As ClassDiagram
Dim theSeqDiagram As ScenarioDiagram
Dim theClasses As ClassCollection
Dim theColumns As ClassCollection

Dim theClass As Class
Dim theSubClass As Class
Dim AllScenarioDiagrams As ScenarioDiagramCollection
Dim AllObjectInstances As ObjectInstanceCollection
Dim AllClassDiagrams As ClassDiagramCollection
Dim theObjectInstance As ObjectInstance
Dim theAttributes As New AttributeCollection
Dim theAttribute As Attribute
Dim theParameters As ParameterCollection
Dim theParameter1 As Parameter
Dim op As Operation
Dim i As Integer, j As Integer
Dim str As String

WordApp.FormatStyle "Heading 3"
wordApp.Insert diagram.Name

If diagram.CanTypeCast(theClassDiagram) Then
Set theClassDiagram = diagram.TypeCast (theClassDiagram)
Set theClasses = theClassDiagram.GetClasses ()

If(theClassDiagram.IsDataModelingDiagram) Then

WordApp.FormatStyle "Heading 3"
wordApp.Insert "TABLES INVLOVED"

For j=1 To theClasses.Count

Set theClass = theClasses.GetAt(j)

For lineSeperator=1 To 80
WordApp.Insert "-"
Next lineSeperator

WordApp.FormatStyle "Heading 3"

wordApp.Insert theClass.Name
WordApp.FormatStyle "Body Text"
wordApp.Insert theClass.Documentation

WordApp.FormatStyle "Heading 5"

wordApp.Insert "Attributes"

For lineSeperator=1 To 80
WordApp.Insert "-"
Next lineSeperator

For k=1 To theClass.Attributes.count

Set theAttribute = theClass.Attributes.getAt(k)

WordApp.FormatStyle "Body Text"
WordApp.Insert theAttribute.Name +" : "+theAttribute.Type+":"+theAttribute.Documentation

Next k

WordApp.FormatStyle "Heading 5"

wordApp.Insert "Operations"

For lineSeperator=1 To 80
WordApp.Insert "-"
Next lineSeperator

For k=1 To theClass.Operations.count

Set op = theClass.Operations.getAt(k)

WordApp.FormatStyle "Body Text"
WordApp.Insert op.Name +" : "+op.Documentation

Next k

Next j

exit sub

End If
'Cycle through all the classes in a Class diagram

End If

End Sub

Sub Main
Dim wordApp As Object
Dim colDiagrams As DiagramCollection
Dim theModel As Model
Set wordApp = CreateObject ("Word.Basic")
Set theModel = RoseApp.CurrentModel
Set colDiagrams = theModel.GetSelectedDiagrams ()
Dim filename As String
Dim theExtensions As String

theExtensions = "*.doc:*.doc"

If( colDiagrams.Count =0) Then

msgbox "Please Select a Diagram before running the Script" ,0,toolName

filename = SaveFileName$("Save the rose Diagram File", theExtensions)
If filename = "" Then
Exit Sub
End If

wordApp.FileNew TemplateFileName

For i=1 To colDiagrams.Count
Set theDiagram = colDiagrams.GetAt (i)

CopyDiagram wordApp,colDiagrams.GetAt (i)
Next i


wordApp.FileSaveAs filename


End If

msgbox toolName +" -- V 1.0 Tool By Shreedhara C A",0,toolName ,TRUE,0


End Sub