Option Explicit
Private Sub Print_TriggerTypes(VOB As CCVOB)
' Get the trigger types collection from the VOB
Dim TriggerTypes As CCTriggerTypes
Set TriggerTypes = VOB.TriggerTypes
Dim str As String
str = "Found " & TriggerTypes.Count & " trigger type(s)" & vbCrLf
' Iterate the collection, gathering info about each trigger type
Dim TriggerType As CCTriggerType
For Each TriggerType In TriggerTypes
str = str & "Name: " & TriggerType & " Type: "
' Get the kind of trigger
Select Case TriggerType.KindOfTrigger
Case ccKind_Type
str = str & "Type"
Case ccKind_Element
str = str & "Element"
Case ccKind_AllElement
str = str & "All Element"
Case Else
str = str & "Unknown"
End Select
' Get the trigger type's owner and group
str = str & vbCrLf & vbTab & "Owner: " & TriggerType.Owner & _
", Group: " & TriggerType.Group & vbCrLf
' Get the firing conditions
str = str & vbTab & "Firing On: "
Select Case TriggerType.Firing
Case ccFiring_PreOp
str = str & "Pre-operation(s)"
Case ccFiring_PostOp
str = str & "Post-operation(s)"
Case Else
str = str & "'Bad Value'"
End Select
str = str & vbCrLf
' Get the actions array
Dim Num as Long
Num = TriggerType.NumberOfActions
If Num = 0 Then
str = str & vbTab & "No actions"
Else
Dim Actions As Variant
Dim vtype As Variant
Actions = TriggerType.ActionsArray
str = str & vbTab & "Actions array: "
For I = 0 to Num - 1
If I <> 0 Then str = str & ", "
Select Case Actions(I, 0)
Case ccAction_Exec
str = str & "Exec '" & Actions(I, 1) & "'"
Case ccAction_ExecUnix
str = str & "ExecUNIX '" & Actions(i, 1) & "'"
Case ccAction_ExecWin
str = str & "ExecWin '" & Actions(i, 1) & "'"
Case ccAction_Mklabel
Set vtype = Actions(I, 1)
str = str & "Mklabel-" & vtype
Case ccAction_Mkattr
Set vtype = Actions(I, 1)
str = str & "Mkattr-" & vtype & "=" & Actions(I, 2)
Case ccAction_MkhlinkTo
Set vtype = Actions(I, 1)
str = str & "Mkhlink-" & vtype & ",to=" & Actions(I, 2)
Case ccAction_MkhlinkFrom
Set vtype = Actions(I, 1)
str = str & "Mkhlink-" & vtype & ",from=" & Actions(I, 2)
Case Else
str = str & "'Unknown Action'"
End Select
Next
str = str & vbCrLf
End If
' If you wanted to, you could also gather for display the
' operation kinds, inclusions (for type triggers), restrictions
' (for element triggers) and exempt users list.
Next
' Display the result
MsgBox str
End Sub
' Connect to the top-level ClearCase object
Dim CC As New ClearCase.Application
' Create a trigger type builder
Dim VOB As CCVOB
Set VOB = CC.VOB("\caroltest")
Dim Builder As CCTriggerTypeBuilder
Set Builder = VOB.CreateTriggerTypeBuilder
' Set up the trigger type parameters
Builder.DebugPrinting = True
Builder.Name = "TempTriggerType"
Builder.KindOfTrigger = ccKind_Type
Builder.Firing = ccFiring_PreOp
Builder.FireOn ccOp_unlock
Builder.FireOn ccOp_rntype
Builder.IncludeOn VOB.BranchType("main")
Builder.IncludeOn ccAll_HyperlinkTypes
Builder.AddExecAction "%SystemRoot%\system32\echo.exe hello"
Builder.DebugPrinting = False
' Create the trigger type from the Builder
Dim TriggerType As CCTriggerType
Set TriggerType = Builder.Create _
("Test creating trigger type from CAL example")
' Print information about all trigger types
Print_TriggerTypes VOB
' Remove the type
TriggerType.RemoveType
' Print the information again
Print_TriggerTypes VOB