Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: cstokes on January 09, 2004, 02:12:43 pm
-
Hi,
I am trying to create a tool in VB that lists all Use Cases and the requirements they satisfy. I am generating a file that lists USE CASE => REQUIREMENT. Any tips on how I can use the Automation Interface to acheive this.
Chris Stokes
-
A relationship matrix inside EA won't do? You can export to a csv-file from there too.
But I guess it is not exactly the kind of list you are looking for, or you might want to automate it further.
Mikkel
-
We need to use the realization relationship between the various requirements, usecases and the classes for getting the Links. Is there any way we can automate this ? Alternately, can we do some tagging instead of the drag,drop approach suggested in the help ?
-
The downloadable VB example (which IMO may 'work' but is a can of worms to modify/extend) at least lets you learn how these things work. Also, look at the code samples in the help.
Assuming p is already set as an ea.package object in your model, in VB the code is pleasingly simple;
dim p as ea.package
dim el as ea.element
dim c as ea.connector
for each el in p.elements
if el.type = "UseCase" then
for each c in el.connectors
if c.type = "Realisation" then 'yes, that's realisation with an 's'
' get the element at the other end
if c.clientid = el.elementid then
otherel = getelementbyid(c.supplierid)
else
otherel = getelementbyid(c.clientid)
endif
if otherel.type = "Requirement" then
'... do something
print "Use Case " + el.name + " is realised by requirement " + otherel.name
endif
endif
next c
endif
next el
If you've used child diagrams/elements, you will need to add another loop 'for each subel in el.elements'
Above assumes you've got a recent EA which supports 'for each' iteration, see the automation help.
HTH
Ian