Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Adam on April 04, 2007, 06:16:44 pm

Title: Show/copy relationships
Post by: Adam on April 04, 2007, 06:16:44 pm
Is there any way to show or copy relationships specified between elements to element instances.

For example, I've got Components or Classes with relationships like dependencies or associations, I have some objects or instances of components on a diagram and I'd like to show the same relationships between them as specified on the actual components.

Is it possible?
Title: Re: Show/copy relationships
Post by: Jan ´Bary´ Glas on April 04, 2007, 10:36:47 pm
Hi Adam,

the links are run-time instances of associations. "An association specifies a semantic relationship that can occur between typed instances." (UML Superstructure Specification 2.1.1 chapter 7.3.3)
That mean you cannot show them until you define them (until you explicitly say, that such a link on your diagram has a sense). You cannot copy them; it is a different level (abstraction/instance). You want to instantiate them.

And as a conclusion: I don't know how to achieve it. Anyone else does?
Title: Re: Show/copy relationships
Post by: «Midnight» on April 05, 2007, 01:37:30 am
I thought there was an option somewhere to make a copy of a set of elements including the relationships between them.

EDIT: Here it is. The deep copy will create new instances of the elements, as well as new connectors between them. Both the elements and the connectors can then evolve independently.

EDIT: The EA help file (build 805) refers to the other (i.e. not "deep") copy option as "shenable" rather than "shallow" as is shown on the dialog. I've reported the flaw.
Title: Re: Show/copy relationships
Post by: KjellElster on April 13, 2007, 01:58:35 am
I don't think this is what Adam is after.

My guess he's looking for a way to instanciate an association. Like you instanciate an object from a class.

As Jan Glas says, there seems to be no way of doing that with EA. From the interface I have drawn the conclusion that instanciating an object from a class also was impossible and someone made that possible through special case operation. E.g. why can't change the class of an object? Not even from <null> to SomeClass?

I have further more not found a way to show values for attribute(-instances) for the objects.

These problems makes it hard to make "story boards" with EA.
Title: Re: Show/copy relationships
Post by: KjellElster on April 13, 2007, 01:58:52 am
I don't think this is what Adam is after.

My guess he's looking for a way to instanciate an association. Like you instanciate an object from a class.

As Jan Glas says, there seems to be no way of doing that with EA. From the interface I have drawn the conclusion that instanciating an object from a class also was impossible and someone made that possible through special case operation. E.g. why can't change the class of an object? Not even from <null> to SomeClass?

I have further more not found a way to show values for attribute(-instances) for the objects.

These problems makes it hard to make "story boards" with EA.
Title: Re: Show/copy relationships
Post by: KjellElster on April 13, 2007, 02:02:49 am
I don't think this is what Adam is after.

My guess he's looking for a way to instantiate an association. Like you instantiate an object from a class.

As Jan Glas says, there seems to be no way of doing that with EA. From the user interface I have drawn the conclusion that instantiating an object from a class also was impossible and someone made that possible through special case operation. E.g. why can't change the class of an object? Not even from <null> to SomeClass?
The EA's meta model seems not to support this easily.

I have further more not found a way to show values for attribute(-instances) for the objects.

These problems makes it hard to make "story boards" with EA.
Title: Re: Show/copy relationships
Post by: KjellElster on April 13, 2007, 04:35:33 am
I don't think this is what Adam is after.

My guess he's looking for a way to instantiate an association. Like you instantiate an object from a class.

As Jan Glas says, there seems to be no way of doing that with EA. From the user interface I have drawn the conclusion that instantiating an object from a class also was impossible and someone made that possible through special case operation. E.g. why can't change the class of an object? Not even from <null> to SomeClass?
The EA's meta model seems not to support this easily.

I have further more not found a way to show values for attribute(-instances) for the objects.

These problems makes it hard to make "story boards" with EA.
Title: Re: Show/copy relationships
Post by: thomaskilian on April 17, 2007, 03:28:23 am
Maybe you can explain why you want the relations to be copied. As the objects are instanciated, they already inherit the relations from the underlying classes. So what would be the point in copying them?

KjellElster: You can remove your duplicate posts by using the Remove button
Title: Re: Show/copy relationships
Post by: JohnWSaundersIII on April 18, 2007, 08:56:55 am
Quote
As the objects are instanciated, they already inherit the relations from the underlying classes. So what would be the point in copying them?


I just created an object diagram. I dragged into it class ClassA that has an association to ClassB, which I also dragged into the diagram. I chose the "instance" option in the dialog that comes up when you drop.

Although the two classes are joined by an association, the two objects are not joined by a link. I even tried Insert Related Elements on both objects, and there was no effect.

Is this the behavior you would expect? I would have expected links to be created for all such objects, or at least to be easily creatable.

John

P.S. The duplicate posts by the other poster may have been caused by the server error I just saw in posting this. I tried again, and found I had two copies of the post. I was told to inform [email protected].
Title: Re: Show/copy relationships
Post by: «Midnight» on April 18, 2007, 02:06:22 pm
John,

If you have two instances, then this is not a case where you are joining two "classes" but one where you are joining two objects. So, the relationship should not be automatically propagated. EA has it correct.

I'm sorry, but I don't have the answer to the rest of your questions.

David
Title: Re: Show/copy relationships
Post by: KP on April 18, 2007, 02:20:07 pm
Quote
E.g. why can't change the class of an object? Not even from <null> to SomeClass?

Ctrl+L (Right-click > Advanced > Instance Classifier)

Quote
I have further more not found a way to show values for attribute(-instances) for the objects.

Ctrl+Shift+R (Right-click > Advanced > Set Run State)
Title: Re: Show/copy relationships
Post by: KP on April 18, 2007, 02:30:16 pm
Quote
I just created an object diagram. I dragged into it class ClassA that has an association to ClassB, which I also dragged into the diagram. I chose the "instance" option in the dialog that comes up when you drop.

Although the two classes are joined by an association, the two objects are not joined by a link. I even tried Insert Related Elements on both objects, and there was no effect.

Is this the behavior you would expect?

I'd say so. Consider a class diagram with an Address class and a Person class with a "livesAt" association between them. Ctrl+Drag one of each onto an object diagram, call them "KP:Person" and "BuckinghamPalace:Address". I wouldn't want EA to automatically create a "livesAt" association.


Quote
I would have expected links to be created for all such objects, or at least to be easily creatable.

I'd say they are easily creatable, using the toolbox or the quicklinker, the same as any other connector :)
Title: Re: Show/copy relationships
Post by: sl@sh on April 18, 2007, 10:26:13 pm
Quote
I'd say so. Consider a class diagram with an Address class and a Person class with a "livesAt" association between them. Ctrl+Drag one of each onto an object diagram, call them "KP:Person" and "BuckinghamPalace:Address". I wouldn't want EA to automatically create a "livesAt" association.

I agree with respect to creating instances on a diagram, but what is the Insert Related Elements function good for if not for putting associated objects onto the diagram and the accompanying relationships?

What you are saying, is that this function shouldn't do anything for instances. I beg to disagree.
Title: Re: Show/copy relationships
Post by: thomaskilian on April 18, 2007, 10:29:34 pm
The Insert Related Elements is meant to help you creating an overview for an element to see the element and all the related ones.
Title: Re: Show/copy relationships
Post by: sl@sh on April 18, 2007, 10:37:36 pm
Quote
The Insert Related Elements is meant to help you creating an overview for an element to see the element and all the related ones.

Well, if related elements only includes elements that you have personally and manually drawn the relationships for, what is the point? You already have them on the diagram...
Title: Re: Show/copy relationships
Post by: thomaskilian on April 18, 2007, 11:37:47 pm
Imagine you have a couple of diagrams with one element appearing in more than one of them. Now you may have relations used in diagram A but not in B. If you later want to explicitely show a diagram for this specific class you can create a new diagram and insert the element with all the relations it has. Does that make sense to you?
Title: Re: Show/copy relationships
Post by: sl@sh on April 19, 2007, 01:10:56 am
Yes it does - for a class. I thought we were discussing instances?

I did consider this, but for instances I really don't know why anyone would want to do this. For a class, yes that makes sense, and that's what I thought one of the applications of the function.

For an instance however - why would I want to design a diagram just for the purpose of showing a single instance's relations when I could just show the class' relations instead? Yes, this would possibly include some relations that certain instances would not make use of, but deleting connections (or hiding them, rather) - if you really don't want to model that particular relationship - can be done much faster than redrawing exactly the same associations over and over again.

Moreover, the need to recreate associations on instances is vastly error prone - you can easily choose the wrong type of association, give it a different name (so you don't any longer see the actual connection to the relations shown on the class diagram), or simply create associations that don't exist on the class (yet), meaning you don't get proper dependencies when generating the code.

The decoupling of class associations from instance associations is rather awkward, to say the least.
Title: Re: Show/copy relationships
Post by: thomaskilian on April 19, 2007, 03:41:04 am
Maybe it's because Insert Related Elements works for all elements - even those where it does not make much sense, like instances.
Title: Re: Show/copy relationships
Post by: JohnWSaundersIII on April 19, 2007, 06:39:24 am
At the very least, there should be a way to create links based on the associations, so I don't wind up creating the wrong kind. Perhaps a dialog showing me a list of associations from the classifier of the selected element, and allowing me to check whether to create links. It might also allow me to specify, for an association with a target multiplicity > 1, to create "n" objects and links to them.

Obviously, I haven't thought this through in detail. A moment's reflection suggests EA would want to do something about constraints, ordering, etc. But in the meantime, I'd at least have some correspondence between the links and associations.

And perhaps even a <<trace>> relationship from the association to the link(s)?

John
Title: Re: Show/copy relationships
Post by: Paolo F Cantoni on April 19, 2007, 12:25:57 pm
"...And a partridge in a pear tree" too, please  ;)

Paolo