Book a Demo

Author Topic: SQL Query to get the backward Activation path of a sequence Diagram Lifeline  (Read 6720 times)

max

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
I am trying to get the entire backward path from an arbitrary lifeline to the starting lifeline in the sequence diagram.
As seen in the image, I want to get the path from the Element bc: Boom Controller to the Driver backward using the connectors: 1.0 readCard <-- 1.1 checkAccessRight <--1.4 openBoom() .



The following SQL query is the one I have written so far:

Code: [Select]
SELECT con.Start_Object_ID AS StartObject_ID, o.Name AS StartObj_Name, con.End_Object_ID AS EndObject_ID, ob.Name AS EndObj_Name, con.Name AS ConnectionName, con.PtStartX AS Pt_StartX, con.PtStartY AS Pt_StartY
FROM t_Object o, t_Object ob, t_connector con
WHERE con.Start_Object_ID = o.Object_ID
AND con.End_Object_ID = ob.Object_ID
AND con.End_Object_ID = 17430
AND con.Connector_Type = 'Sequence'
ORDER By con.PtStartX, con.PtStartY

With this query I can unfortunately not get the exact backward path, but only all connectors that lead to a certain element with the entered Object_ID.

Could someone please give me an idea how this can be solved with SQL?
Many thanks in advance for the suggestions.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
That is possible, but it won't be that easy.

You'll first have to determine which messages you want to determine how you algorithm should select the correct messages.
In your example you are skipping messages 1.2 and 1.3. Figure out why that is, and adjust your query accordingly.

Furthermore I think it would be useful to use different queries for each level, and stitch them together with unions.

So you can have a first query that returns the actual connector 1.4 openBoom(), a second query that returns 1.1CheckAccessRight(), and a third one that returns 1.0 readCard()

downside of this approach is that you have to work with a fixed set of levels. You'll need to determine the maximum number of levels you'll ever need and write that many queries.

Another approach would be to use recursive queries, but EA requires each query to start with SELECT. There have been a few tries with recursive queries, but I don't think anyone got it working, except if you add your own views to the database.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
I would just use somehing different to SQL which is called code ;-) (Not that SQL wouldn't be code too, but it's kinda limited)

q.

max

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Thank you very much for your quick answers and the suggestions, which I will try.