I have created a stereotype for an operation called 'AtomicAction' within a profile (which has been imported as an MDG technology) which contains a TaggedValue called 'List of UDETs' which contains a list of elements of another defined stereotype, 'UDET', that I had created.
When I create a new method with the 'AtomicAction' stereotype via the EA GUI, all the TaggedValues are automatically added into operation. For the 'List of UDETs' TaggedValue I can browse and multi-select a set of UDET stereotyped elements.
But if I can't find a similar way to do this via the automation API. Firstly I create the method as follows:
op = nc.Methods.AddNew(aa1.Key(), "AA-Response")
currentMethods.Add(aa1.Key(), op)
op.Stereotype = "AtomicAction"
op.Update()
The TaggedValues are not automatically added into the method. I can add them via code, but they do not automatically appear as they do through the GUI. Is there a way to do that via the API?
Secondly, how do I add a list of elements into a Tagged Value via the automation API. It looked like it was just holding a comma delimited list of GUIDs within the TaggedValue.value so I constructed a string with the list of GUIDs as follows:
If udetGuids.Count > 0 Then
Dim stringOfGuids As String = ""
For Each guid As String In udetGuids
stringOfGuids += guid + ","
Next
' remove last comma
stringOfGuids = stringOfGuids.Substring(0, stringOfGuids.Length - 1)
Dim mt As MethodTag
Try
mt = op.TaggedValues.GetByName("List of UDETs")
Catch ex As Exception
mt = op.TaggedValues.AddNew("List of UDETs", "TaggedValue")
End Try
If mt Is Nothing Then
mt = op.TaggedValues.AddNew("List of UDETs", "TaggedValue")
End If
If stringOfGuids.Length <= 255 Then
mt.Value = stringOfGuids
Else
mt.Value = "<memo>"
mt.Notes = stringOfGuids
End If
mt.Update()
op.TaggedValues.Refresh()
End If
The value looks identical to the ones constructed via the GUI, but it doesn't then allow me to browse for the elements from the TaggedValue within the GUI - it is just text in the TaggedValue value field. I assume I have to somehow set the TaggedValue to be of a type list of 'UDETs' in the code.
Is there any simple solutions to these problems?
Thanks,
njf