Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Ignacio G. T. 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.
-
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
-
Try this as SQL-Search:
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
-
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?
-
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
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
-
Yep, that did the trick
This now works on .eap files as well.
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
-
Sorry, Geert, but I get exactly the same error. Something else must be happening.
-
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...
-
Are you sure it's a transition?
Otherwise remove the part
c.Connector_Type = 'StateFlow'
and and try again
Geert
-
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) :-?
-
Shouldn't states be embedded inside a state machine node (and the corresponding diagram also)??
Best regards,
Günther
-
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...
-
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:
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
-
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:
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