When you generate your database script with domains that are not associated with any columns you will see some warnings.
So this script will output all Domains that do not have any columns linked to them.
'******************************************************************************
'* File: CDM_Find_Domain_With_No_Dependency.vbs
'* Purpose: Find Domains With No Dependency
'* Title:
'* Category: CDM
'* Version: 1.0
'* Company: Dev
'* Developer: Hussain Naji Al-Safafeer
'* Date: 2012-9-1
'******************************************************************************
Option Explicit
Dim mdl
Dim Fldr
Dim RQ
Dim isFound
Dim strLongReferenceNames
dim iCountChanged, iCountNotChanged, iCountEntities
dim iAllTables
dim iAllIndex
dim iCountFound
dim glob_IndexFound
dim glob_iIndex_Removed
' Get the current active model
Set mdl = ActiveModel
call mainProcedure
'-----------------------------------------------------------------------------
' Main function
'-----------------------------------------------------------------------------
sub mainProcedure()
If (mdl Is Nothing) Then
MsgBox "There is no Active Model"
exit sub
End If
If Not mdl.IsKindOf(PdCDM.cls_Model) Then
MsgBox "This is not CDM"
exit sub
end if
Set Fldr = ActiveDiagram.Parent
RQ = MsgBox ("Starting at Folder: " & Fldr.Name & " Is Run ?", vbYesNo + vbInformation,"Confirmation")
if RQ= VbNo then
exit sub
end if
'------------------------------------
iCountChanged = 0
iCountEntities = 0
iCountNotChanged = 0
iCountFound = 0
listDomainsWithNoDependency mdl
'showColumnsDomains mdl
'countEntities mdl
output "_____Domains With No Dependency Found = " & iCountFound & " in " & iCountEntities
End Sub
'-----------------------------------------------------------------------------
' Output the domains that do not have dependencies
'-----------------------------------------------------------------------------
Sub listDomainsWithNoDependency(package)
Dim dom
For Each dom In package.Domains
If IsObject(dom) Then
If dom.IsShortcut = false Then
iCountEntities = iCountEntities + 1
'output dom.dataitem.code
if isDomainHasItems(package, dom.code) then
' found dependency not wanted
else
iCountFound = iCountFound + 1
output dom.code
end if
End If
End If
Next
End Sub
'-----------------------------------------------------------------------------
' Return true if the domain is not linked to any column
'-----------------------------------------------------------------------------
function isDomainHasItems(parentPackage_, domainCode_)
Dim tbl
Dim col
Dim isFound
For Each tbl In parentPackage_.Entities
If IsObject(tbl) Then
If tbl.IsShortcut = false Then
'output domainCode_
For Each col In tbl.Attributes
If col.IsShortcut = false Then
if col.domain is nothing = false then
'output "the col dom=" & col.domain.Code
if col.domain.Code = domainCode_ then
isDomainHasItems = true
exit function
end if
end if
end if
Next
End If
End If
Next
Dim subpackage
For Each subpackage in parentPackage_.Packages
If Not subpackage.IsShortcut Then
isFound=isDomainHasItems (subpackage, domainCode_)
if isFound then
isDomainHasItems = true
exit function
end if
End If
Next
End function
'-----------------------------------------------------------------------------
' Count the number of enities
'-----------------------------------------------------------------------------
sub countEntities(package)
Dim tbl
Dim col
Dim isFound
For Each tbl In package.Entities
If IsObject(tbl) Then
If tbl.IsShortcut = false Then
iCountEntities = iCountEntities + 1
End If
End If
Next
Dim subpackage
For Each subpackage in package.Packages
If Not subpackage.IsShortcut Then
countEntities subpackage
End If
Next
End sub
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
6 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |