Creating an AIM
This section shows example code to create an AIM.
'////////////////////////////////////////////////////////////////////////////////
'
' Meta_CreateModel
'
' Adds the definition of a model with the name 'modelName' to the
' repository. The owner and group names for the model are 'ownerName' and
' 'groupName', respectively.
'
'/////////////////////////////////////////////////////////////////////////////////
Public Sub Meta_CreateModel(modelName As String, _
groupName As String, _
ownerName As String, _
ErrorOK As Boolean)
Dim item As ListItem
Dim modelID, classID, relID As Long
Dim model As New MetaModelInfo
Dim keyList As New MetaInfoKeyList
Repository.BeginTransaction
model.name = modelName
model.Description = modelName & " Description"
model.ApplicationGroup = groupName
model.Owner = ownerName
model.Permission = 777
model.Create
model.Read 1
If modelName = CANNED_MODEL_NAME Then
ScriptingModelID = model.ObjectID
End If
' define ScriptingClass1 and its associated properties
Dim class As New MetaClassInfo
class.name = CANNED_CLASS_NAME1
class.Description = "Scripting Class Description"
model.AddClass class
ScriptingClass1 = class.ObjectID
Dim prop As New MetaPropertyInfo
prop.name = STRING_PROPERTY_NAME
prop.Identifier = 1
prop.Description = "Scripting Property Description"
prop.VARIANT_Type = vtString
prop.SQL_Type = sqlVarChar
prop.Length = 1024
class.AddProperty prop
Set prop = Nothing
Dim propInt As New MetaPropertyInfo
propInt.name = INTEGER_PROPERTY_NAME
propInt.Identifier = 2
propInt.Description = "Scripting Property Description"
propInt.VARIANT_Type = vtLong
propInt.SQL_Type = sqlInteger
propInt.Length = 1024
class.AddProperty propInt
Set propInt = Nothing
Dim relation As New MetaRelationshipInfo
relation.name = CANNED_CLASS1_CLASS2_RELATION
relation.Description = "Class0 contains Class1 relationship"
relation.OriginClassID = class.ObjectID
relation.DestinationClassID = Class1.ObjectID
model.AddRelationship relation
RelID_Class0Class1 = relation.ObjectID
RelGUID_Class0Class1 = relation.ObjectGUID
Repository.CommitTransaction
Exit Sub
End Sub