Author Topic: Find transitions by name  (Read 15406 times)

Ignacio G. T.

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Find transitions by name
« on: November 21, 2012, 03:19:22 am »
Transitions seem not to be first-order citizens in EA. I cannot find transitions by name with a model search. Yes, I can search triggers by name, but this is not the same.

This is my use case: I have plenty of state diagrams, inherited from an ancient tool, that gave each transition a name (such as TMAS2S32). The trigger, guards and effect of each transition was given in text form with tables.

The name gives us a unique identifier for each transition, which has two benefits: it is easily searched, and can be used for tracing purposes (in documentation, code, etc.).

But I have just found that search by name, apparently, does not work for transitions. Is this true? Is there a workaround?

Thanks.

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Find transitions by name
« Reply #1 on: November 21, 2012, 04:02:24 am »
Transitions appear in the t_connector table and you might develop special SQL search statements to search for them according the criteria you need.

Just an idea, I don't know if this is really feasible for your needs.

HTH
Günther


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13287
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Find transitions by name
« Reply #2 on: November 22, 2012, 01:06:08 am »
Try this as SQL-Search:

Code: [Select]
select statemachine.ea_guid as CLASSGUID, statemachine.Object_Type as CLASSTYPE,
c.name as transition,o_from.Name as FromObject, o_to.Name as ToObject
from t_connector c
inner join t_object o_from on c.Start_Object_ID= o_from.Object_ID
inner join t_object o_to on c.End_Object_ID = o_to.Object_ID
inner join t_object statemachine on o_from.ParentID = statemachine.Object_ID
where c.Connector_Type = 'StateFlow'
and c.Name like '#WC#<Search Term>#WC#'

Geert

Ignacio G. T.

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Find transitions by name
« Reply #3 on: November 27, 2012, 07:30:05 pm »
Hi, Geert, thanks.

Running the search gives me the following error:

DAO.QueryDef [3075]
Syntax error (missing operator) in query expression 'c.Start_Object_ID =
o_from.Object_ID
inner join t_object o_to on c.End_Object_ID = o_to.Object_ID
inner join t_object statemachine on o_from.ParentID = statemachine.Object_ID'

I'm not an expert in SQL  :(

Can you see where is the error?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13287
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Find transitions by name
« Reply #4 on: November 27, 2012, 07:50:47 pm »
Hmm, yes, that's because I wrote the query on an SQL Server repository, and you are probably on a .eap (MS Access) repository.

It has probably has to do with some brackets that are missing according to MS Acces's twisted SQL syntax.

you have to to something like
Code: [Select]
from ((table1
inner join table2 on x=y)
inner join table3 on k=i)

I'll try to make an MS-Access save version later today.

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13287
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Find transitions by name
« Reply #5 on: November 27, 2012, 08:25:11 pm »
Yep, that did the trick
This now works on .eap files as well.
Code: [Select]
select statemachine.ea_guid as CLASSGUID, statemachine.Object_Type as CLASSTYPE,
c.name as transition,o_from.Name as FromObject, o_to.Name as ToObject
from (((t_connector c
inner join t_object o_from on c.Start_Object_ID= o_from.Object_ID)
inner join t_object o_to on c.End_Object_ID = o_to.Object_ID)
inner join t_object statemachine on o_from.ParentID = statemachine.Object_ID)
where c.Connector_Type = 'StateFlow'
and c.Name like '#WC#<Search Term>#WC#'

Geert

Ignacio G. T.

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Find transitions by name
« Reply #6 on: November 29, 2012, 01:05:24 am »
Sorry, Geert, but I get exactly the same error. Something else must be happening.

Ignacio G. T.

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Find transitions by name
« Reply #7 on: November 29, 2012, 01:17:28 am »
Forget it: I was copying the modified query in the wrong window  :-[

Now, the query does not result in any errors, but it is not finding the transition I'm looking for. I'll investigate a little more...

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13287
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Find transitions by name
« Reply #8 on: November 29, 2012, 01:26:31 am »
Are you sure it's a transition?
Otherwise remove the part
Code: [Select]
c.Connector_Type = 'StateFlow'
and
and try again

Geert
« Last Edit: November 29, 2012, 01:26:55 am by Geert.Bellekens »

Ignacio G. T.

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Find transitions by name
« Reply #9 on: November 29, 2012, 02:28:23 am »
Yes, I'm sure it's a transition.

I think I see where the problem is. This is the relevant part of table t_connector:

Connector_ID  Name Start_Object_ID
191           TECI    226

Table t_object:

Object_ID Object_Type Parent_ID
226       State       0

As you can see, the states have no parents (!) In the browser you can see the states at the same level as the diagrams that use them. There must be other way to locate the diagram knowing the state. Or perhaps you can only locate the package that contains the state (and, therefore, the diagram)  :-?

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: Find transitions by name
« Reply #10 on: November 29, 2012, 03:05:47 am »
Shouldn't states be embedded inside a state machine node (and the corresponding diagram also)??

Best regards,
Günther

Ignacio G. T.

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
Re: Find transitions by name
« Reply #11 on: November 29, 2012, 03:31:36 am »
Well, not necessarily. When I'm modelling at a high level (a system, a communication protocol, etc.) there are still no classes or elements to which a state machine could be attached. So, I draw a state machine directly under some package, and only create state machine nodes if I want to have sub-state machines.

And yes, if I create a state machine node on purpose and move my diagram and states below it, or add a state machine to an existing element (like a class) and draw my machine there, the query does work.  :)

But still, I cannot use the query in my old state machines that do not belong to a state machine node...

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13287
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Find transitions by name
« Reply #12 on: November 29, 2012, 04:13:09 am »
Oh, in that case you can make an outer join to the statemachine.

I'm not sure of the exact syntax, but I think this should be it:

Code: [Select]
select statemachine.ea_guid as CLASSGUID, statemachine.Object_Type as CLASSTYPE,
c.name as transition,o_from.Name as FromObject, o_to.Name as ToObject
from (((t_connector c
inner join t_object o_from on c.Start_Object_ID= o_from.Object_ID)
inner join t_object o_to on c.End_Object_ID = o_to.Object_ID)
left outer join t_object statemachine on o_from.ParentID = statemachine.Object_ID)
where c.Connector_Type = 'StateFlow'
and c.Name like '#WC#<Search Term>#WC#'

Geert

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: Find transitions by name
« Reply #13 on: November 29, 2012, 05:21:00 am »
Quote
Well, not necessarily. When I'm modelling at a high level (a system, a communication protocol, etc.) there are still no classes or elements to which a state machine could be attached.

Well, I don't think it's necessary to embed a state machine in a class to describe high level behavior of the system. The UML 2.3 Spec says:
Quote
15.3.12 StateMachine (from BehaviorStateMachines)

State machines can be used to express the behavior of part of a system. Behavior is modeled as a traversal of a graph of state nodes interconnected by one or more joined transition arcs that are triggered by the dispatching of series of (event) occurrences. During this traversal, the state machine executes a series of activities associated with various elements of the state machine.

That doesn't say that a state machine needs to be part of a class. event triggers or actions executed on transitions need to stem from classifiers though. But a classifier can be anything, even high level system elements.

You can do this in EA simply by adding an element of type 'StateMachine' directly using the 'Add->Add Element...' menu command from the packages context menu in the project browser.

IMHO this is fully UML compliant and should remedy your problems (may be in an easier and finally more consitent way as Geert's recent proposal).

Best regards,
Günther
« Last Edit: November 29, 2012, 05:36:12 am by g.makulik »
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/