How to reuse States in Sparx EA - enterprise-architect

How would I go about re-using states in Sparx EA State Machine Diagrams?
For my application I have a defined list of States (StateA,StateB,StateC, etc) but different objects may transition between them in different manners,
i.e. ObjectA: StateA--(no guard)-->StateB--(input=0)-->StateC
ObjectB: StateA--(input=2)-->StateB--(no guard)-->StateC
If I create these states and put them in their own "package", and then create 2 state machine diagrams and copy these states into the diagrams, whenever I make changes to one diagram the other diagram gets (wrongly) updated.
Or am I thinking about this wrong, and essentially every State Machine Diagram needs to have either its own definition of states/transitions (optionally can reuse existing state machines, but I don't think that solves this problem)?

Looks like I figured it out. If you right click on the state machine diagram, click "Paste as New" and un-click "Include Connectors" it won't copy the connectors into the new diagram, and if you make a transition on these states the other states won't get their transitions modified.

Related

Using EA as a registry

Besides using EA for developing and maintaining various model definitions - is it possible to use it as a repository of instance data?
Let's say that I have defined an class, "Activity". Can I use EA as a repo for the instances of this class?
In my particular use case I'm trying to document various aspects of our helpdesk. In addition to documenting the components pertaining to our support process, I would also like to store the actual implementation information pertaining to these components.
An example:
In a sense, I would like to use EA as a central database of configuration data (the collection of defined activities) and at the same time be able to trace each configuration data item to the formal class definition. Having the possibility to trace these relationships would make it easy for us to know what defined activities nned to be updated if we change the class model, and vice versa.
How can I implement this in EA?
Does this make sense, or am I completely off when it comes to what EA can be used for?
Yes you could do that by creating instances of your classes and setting the run-state.
Create an instance by (Ctrl+) dragging your class onto a class diagram and choosing Instance(Object) for Drop As:
Then use the context menu option Features | Set Run State (Ctrl + Shift + R) to set the run states.
Whether or not this is a good idea I'll leave in the middle.

How do you stop Sparx Enterprise Architect adding relationships to all diagrams?

When I add a relationship between two elements in a diagram (in this case a communication diagram) in Sparx EA it adds it to every diagram that has those two elements. This means I have to go back and remove it from every other diagram that has those two elements, a task that gets harder the more diagrams you have.
Is there a way to stop this happening?
Not going to discuss the meaning of what you are trying but you can select the connector after creation and from the context menu use Visibility/Hide in other diagrams.
You can also write an add-in that can do that automatically for you. In that case you need to subscribe to EAOnPostNewConnector.

Is it possible to create “synonyms” of entities?

PowerAMC/PowerDesigner allows you to create "graphical synonyms" of underlying entities allowing you to place the same entity twice (or more) on a diagram. Each is an instance of the same entity. This is great to pretty-up diagrams when, somehow, an entity must be linked to two others that happen to be on opposite ends of the diagram.
Is there a way to do this in Visio 2010 when using the database modeling template?
There are two ways of doing this:
Open the Table and Views panel (Database tab, Model Preferences, first tab, "when deleting an object from the diagram" should be on "Ask the user")
Drag and drop the existing table from that panel onto the diagram
This creates a duplicate of the logical entity and recreates all links (relations) to it. Not immediately useful to clean up the diagram but if you delete the extraneous links and say "No" when it asks if it should also delete the logical elements, then the links disappear visually but the foreign keys remain.
Second method:
Copy a table from the diagram (CTRL+C)
In the Home tab, choose to Paste, Special Paste and keep what should be the default mode: Visio diagram data
A copy of the table will appear but it won't be automatically linked to anything visually.
From both points, the duplicates on the diagram are both logically the same entity. This means that if you modify one, the other is also modified. If you link one to something, the other one is also logically linked (foreign keys will be listed in both, though only one may have the visual link).
Note: I'm using the French version of Visio so exact labels mentioned may be different in English. I tried translating to the best of my ability.
If you press the control key then click and drag an entity it will create a synonym.
I have yet to figure out how to remove a specific synonym without deleting all replicas of it.

Associating class properties to table columns in Enterprise Architect

In a project I work on there is a C# library containing business objects which are related to the backing database tables/stored procedures.
We imported the code into EA model (where we already have database model) and now I'd like to show dependency between a class and a table (or stored procedure output).
Since these are loosely coupled (i.e. only a portion of properties are shared between them) I'd like to have a relation between a class A and table B and in the properties of this relation to have the mapping (A.a <-> B.a , ...).
Is this possible and how?
You can draw connectors between two elements and then link one or both ends to an element feature (an attribute or an operation). Draw the connector, then right-click near the end and select Link to Element Feature.
You can draw any number of connectors between two elements, and link any number of them to any features at either or both ends.
You should note that this is an EA feature which is not in the UML standard. As such, it is also a little trickier to automate (the feature link is not documented in the API), but I've done it before for a client so it can be done. However, from your question I assume it's the manual case you're interested in.

Enterprise Architect Reverse Engineering - Associations

I have imported Sources in the Enterprise Architect and want to draw both class and sequence diagrams.
Class diagram
The issue here is, if I pull a class from the project browser to the "drawing stage", the members of this class are displayed within the class. How can I get the associations instead of (or in addition to) the members? So if I have a class Builder with a member Room. I want to have both classes and a association between these two. Do I have to pull all the members manually on the "drawing stage" or is there some automatic processing?
Sequence diagram
Can I let the EA draw a sequence diagram for me with just a "starting method" as input?
Thanks
Class diagram
Yes, you can add associated classes. Drop the class onto the diagram, then right-click it and select Add - Related Elements. This causes EA to add to the diagram other elements which have a connector to or from the element you right-clicked.
In the dialog EA opens you can specify a single element type (class, component, etc) to be added and/or a single connector type ("link" in this dialog), eg association, to be followed. Leaving either blank will result in EA adding all element types and/or following all connectors.
You can also specify the connector direction (if for instance you want to add only those directed associations going from the first class, not the ones going to it), as well as the number of links to follow in a chain ("levels").
If you want to hide the members for a specific class, you can right-click the class and select Set Feature Visibility, which brings up a dialog where you can switch the various compartments on or off for that class.
If instead you want to change the presentation of all classes in the diagram you can double-click an empty area of the diagram (or right-click and select Properties), and set presentation of the various compartments in the Elements tab.