Blog

Display used links for given metaclass

Display used links for given metaclass

MEGA has an excellent feature for controlling the behaviour of certain functionalities as export, protection of objects etc. The feature is called perimeters. A perimeter is actually used to determine the scope of these functionalities. Using perimeters is not a difficult thing to do and we will cover this in one of the next topics. However it’s difficult from time to time to have a clear view on all the links (metaAssociationEnds) used in the repository.

In order to have a view on this,  I created a script to help me out when I setup perimeters. The script will list out all the used MetaAssociations (concrete and abstract) for a given metaclass. In order to run the script, fill in a metaclass name for strMetaClass and paste the script in the script editor in MEGA.

 
strMetaClass = "<METACLASS NAME>"
strSQL = "Select MetaAssociationEnd where [MetaOppositeClass] = '" & strMetaClass & "'"
oRoot = megaDb()
set colLinks = oRoot.GetSelection(strSQL)
for each oLinks in colLinks
set colObjects = oRoot.GetSelection("Select [" & strMetaclass & "] where [" & oLinks.GetProp("Short Name") & "]")
if colObjects.Count > 0 then
print "there are " & colObjects.Count & " " & strMetaClass & " with the link " & oLinks.GetProp("Short Name")
end if
next
'need to run next section for the abstract metaAssociations
strSQL = "Select MetaAssociationEnd where [MetaOppositeClass].[SubMetaClass] = '" & strMetaClass & "'"
set colLinks = oRoot.GetSelection(strSQL)
for each oLinks in colLinks
set colObjects = oRoot.GetSelection("Select [" & strMetaclass & "] where [" & oLinks.GetProp("Short Name") & "]")
if colObjects.Count > 0 then
print "there are " & colObjects.Count & " " & strMetaClass & " with the link " & oLinks.GetProp("Short Name")
end if
next

Leave a Reply