Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: TheBlueSki on February 15, 2024, 09:18:17 pm
-
My level of SQL experience is not great (better on the managing database cluster end), but I'm a quick learner and have a lot of experience with pretty much everything else. Enterprise Architect is new to me, but I'm trying to help some people out with it and improve the information they can pull out of it. I have an SQL query which does produce some of the results I need, however I wish to also pull out in columns some of the tag information.
What I have so far is this – (which also deals with the fact we have a duplicate model, so I don’t want to pull double the results).
SQL Example –
Select t_object.Name as Name,
MIN(t_object.Object_ID) as Object_ID,
t_object.Note as Description,
t_object.Phase as Phase from t_object
inner join t_objectproperties on t_object.Object_ID = t_objectproperties.Object_ID
where t_object.Object_Type = ‘Requirement’
and t_object.Sterotype = ‘Supporter’
and t_object.Status = ‘Approved’
and t_object.Phase = ‘1’
group by t_object.Name
order by t_object.Name, MIN(t_object.Object_ID)
(With this query I get the columns I need, Name, Object_ID, Description and Phase). What I would also like is to pull some of the tag information out under heading which is seen below. But I’m unsure how to do this. It’s in there somewhere t_objectproperties.Value.
“Tag Names” “Values”
Compliance extra detail <memo>
Compliance statement text
Compliance target Compliant
Design Response text
Hardware Requirements No
MVP No
RMT No
Specialist Testing No
Verification Method Inspection
Any ideas or suggestions please? Many thanks.
-
One option I use very often in these cases is the Excel Import/Export tool of Geert Bellekens (see https://bellekens.com/ea-excel-import-export/ (https://bellekens.com/ea-excel-import-export/)).
It also contains a configuration sheet with SQL you can change yourself which could be used as an example to create the specific export you need.
I, for instance, altered it to only export information on certain stereotypes.
-
Thank you I will give that a try.
-
This is a script which can be used in VBA in Excel. Just select the elements you want in the project browser and run the script:
'Lists the Taggedvalues and their values for the selected elements in the Project Browser
Sub taggedvaluelist()
Dim repository As EA.repository
Set eaapp = GetObject(, "EA.App")
Set repository = eaapp.repository
Dim selectedElements As EA.Collection
Set selectedElements = repository.GetTreeSelectedElements()
Dim p As Integer, j As Integer
Dim selectedElementCount, i
selectedElementCount = selectedElements.Count
p = 2
Set outputws = Worksheets("TaggedValuesList")
outputws.Rows("2:" & Rows.Count).ClearContents
If selectedElementCount > 0 Then
For i = 0 To selectedElementCount - 1
Dim theelement As EA.element
Set theelement = selectedElements.GetAt(i)
Dim tags As EA.Collection
Set tags = theelement.taggedvalues
If tags.Count = 0 Then
outputws.Cells(p, 1) = theelement.Name
outputws.Cells(p, 2) = theelement.StereotypeEx
outputws.Cells(p, 5) = theelement.ElementID
p = p + 1
End If
For j = 0 To tags.Count - 1
Dim currentTag As EA.taggedvalue
Set currentTag = tags.GetAt(j)
outputws.Cells(p, 1) = theelement.Name
outputws.Cells(p, 2) = theelement.StereotypeEx
outputws.Cells(p, 3) = currentTag.Name
outputws.Cells(p, 4) = currentTag.Value
outputws.Cells(p, 5) = currentTag.ElementID
outputws.Cells(p, 6) = currentTag.PropertyID
p = p + 1
Debug.Print theelement.Name & ":" & currentTag.Name & ":" & currentTag.Value
Next
Next
End If
End Sub
-
You simply have to join t_objectproperties multiple times to get the tagged values
Something like this
select o.Name, tv1.Value as DesignResponse, tv2.Value as Compliance
from t_object o
left join t_objectproperties tv1 on tv1.Object_ID = o.Object_ID
and tv1.Property = 'Design Response'
left join t_objectproperties tv2 on tv2.Object_ID = o.Object_ID
and tv2.Property = 'Compliance'
Geert
-
That worked very well. Do you think there is away to get a count out of the number of rows returned. That I can set as a variable and atatched to a report or EA template?
-
Putting a COUNT(*) as COUNT from(
<<<The SQL query>>>
) mytable
Did the trick, but probably not the best way.