Book a Demo

Author Topic: SQL Query/Search and template fragments  (Read 5045 times)

ali.king

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
SQL Query/Search and template fragments
« on: September 25, 2013, 10:26:28 pm »
I have a SQL query that provides me with the list of elements (from t_object) for a given diagram.

What I would like to do is create a template fragment that can use this query to then generate a report using the Element and Connector sections  as per normal RTF generation.

If I run the query for a given Diagram Name, it correctly provides me with the results I expect and from the Query output I can gen a report using a non-fragment template and all is as expected.

Is it possible to use this with model docs etc and or using the SQL query itself in a fragment?

What I was hoping was something like this:

Main Template contains:
Package>
Diagram>
Diagram.DiagramImg
<fragment>

where fragment would use the Diagram name/GUID to fetch list of Objects from t_object to populate the:
...
Element>
 Connector>
  Source>
  Target>

sections.

for info the query is:
------------------------------------------
select o.ea_guid as CLASSGUID, o.object_type as CLASSTYPE, o.name as Name, o.stereotype, o.object_type, p.name
from t_package p, t_object o
where p.package_id = o.package_id
and o.object_type = 'Component' and o.object_id in
(      select object_id
      from t_diagramobjects
      where diagram_id =
      (      select diagram_id
            from t_diagram
            where name= '<Search Term>'
      )
)
------------------------------------------

Dermot

  • EA Administrator
  • EA User
  • *****
  • Posts: 591
  • Karma: +7/-0
    • View Profile
Re: SQL Query/Search and template fragments
« Reply #1 on: September 30, 2013, 10:33:17 am »
The parameters that can used here are reference to PackageID and  ElmentID , but not the DiagramID - see:
http://www.sparxsystems.com/enterprise_architect_user_guide/10/reporting/custom_query_fragments.html
If there is only one diagram in the Package you could use the #PACKAGEID# as a reference to the diagram via t_Package.
« Last Edit: September 30, 2013, 10:34:02 am by Dermot »

ali.king

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: SQL Query/Search and template fragments
« Reply #2 on: September 30, 2013, 07:24:27 pm »
So, do you think what I want to do, is '... not do-able..' ?

ta

ali.king

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: SQL Query/Search and template fragments
« Reply #3 on: October 02, 2013, 12:16:06 am »
Sussed it!

Ok, so I have solved my initial problem, just followed these blinding obvious steps (in the usual Sparx EA twister-esque manner)

KEY stuff to achieve the package-agnostic element reporting:
Template:
Add both Diagram.Element
And
Package.Element
Sections to your template
***Leave the Diagram.Element section empty***
Put your good stuff in the Package.Element section

***THEN set this option in your Document Options dialog
'Include child elements even if the parent element is filtered out'
As I wasn't using filters - it never occurred to me that this 'filtered' was not related to 'Filters'
« Last Edit: October 02, 2013, 12:21:58 am by ali.king »