Hmm, a bit sloppy of the author not to update his documentation.
Here's an example of a real word resolve function
This is from a validator rule that says all classes in the same package should have the same color on a diagram.
The addin basically calls the function resolve() with the guid of wathever element, attribute, operation, connector,... is being checked.
The rest is like regular scripting, but without the EA quirks. Only the Repository object is present. No Session.
function resolve (itemGuid)
resolve = false 'initial value
dim sqlData
sqlGetData = "select do.Diagram_ID from t_diagramobjects do where do.Instance_ID = " & itemGuid
dim diagram
set diagram = getDiagramFromQuery(sqlGetData)
'get element
sqlGetData = "select do.Object_ID from t_diagramobjects do where do.Instance_ID = " & itemGuid
dim elements
set elements = Repository.GetElementSet(sqlGetData,2)
dim element
set element = elements(0)
'get diagramObject
dim diagramObject as EA.DiagramObject
for each diagramObject in diagram.DiagramObjects
if diagramObject.ElementID = element.ElementID then
'reset background color
diagramObject.BackgroundColor = -1
diagramObject.Update
'return success
resolve = true
exit for
end if
next
end function
function getDiagramFromQuery(sqlGetData)
dim xmlResult
xmlResult = Repository.SQLQuery(sqlGetData)
dim diagramIDs
diagramIDs = convertQueryResultToArray(xmlResult)
dim diagramID
dim diagram
set diagram = nothing
for each diagramID in diagramIDs
if diagramID > 0 then
set diagram = Repository.GetDiagramByID(diagramID)
exit for
end if
next
'return
set getDiagramFromQuery = diagram
end function
'converts the query results from Repository.SQLQuery from xml format to a two dimensional array of strings
Public Function convertQueryResultToArray(xmlQueryResult)
Dim arrayCreated
Dim i
i = 0
Dim j
j = 0
Dim result()
Dim xDoc
Set xDoc = CreateObject( "MSXML2.DOMDocument" )
'load the resultset in the xml document
If xDoc.LoadXML(xmlQueryResult) Then
'select the rows
Dim rowList
Set rowList = xDoc.SelectNodes("//Row")
Dim rowNode
Dim fieldNode
arrayCreated = False
'loop rows and find fields
For Each rowNode In rowList
j = 0
If (rowNode.HasChildNodes) Then
'redim array (only once)
If Not arrayCreated Then
ReDim result(rowList.Length, rowNode.ChildNodes.Length)
arrayCreated = True
End If
For Each fieldNode In rowNode.ChildNodes
'write f
result(i, j) = fieldNode.Text
j = j + 1
Next
End If
i = i + 1
Next
end if
convertQueryResultToArray = result
End Function
Geert