Book a Demo

Author Topic: Merge elements  (Read 7038 times)

ocroquette

  • EA User
  • **
  • Posts: 93
  • Karma: +0/-0
    • View Profile
Merge elements
« on: July 12, 2007, 10:48:03 pm »
Hi!

Let's say I have a class A and a class B, and I use both on several diagrams. I want to merge them, ie. that they become one single class having the role of both classes.

Is there any simple way to do that?
Same question for merging elements of different types, for example an actor and a component.

I think I could handle this by working directly in the database, but I would be happy if there was another (easier) solution.

thomaskilian

  • Guest
Re: Merge elements
« Reply #1 on: July 13, 2007, 01:18:15 am »
Not simple, but feasible. I do it the following way.
- open a scratch diagram and move both classes on it
- insert related elements from the "obsolete" class
- move the relations with shift-click
- ALT-G to the obsolete class and move its contents in the browser to the combined one
- CTRL-C the combined from the diagram
- CTRL-U with the obsolete selected
- Now go to the diagrams where it is used; delete it (DEL) and CTRL-V the combined; arrange diagram
- repeat until the obsolete is only in the temp diagram
- move the obsolete to trash (or CTRL-del if necessary).

There's probably no shorter way (except writing an add-in to do the above; but the layout might be tricky).

ocroquette

  • EA User
  • **
  • Posts: 93
  • Karma: +0/-0
    • View Profile
Re: Merge elements
« Reply #2 on: July 18, 2007, 03:46:46 am »
Quote
- Now go to the diagrams where it is used; delete it (DEL) and CTRL-V the combined; arrange diagram


Thanks for the reply.

The problem is at this point. If I do it this way on a sequence diagram, it means a lot of work, since at the time I delete the old class, all the messages will get lost too...

thomaskilian

  • Guest
Re: Merge elements
« Reply #3 on: July 18, 2007, 04:10:30 am »
I haven't tried this for sequence diagrams. So what if you first CTRL-V, re-arrange and then delete the old element?

ocroquette

  • EA User
  • **
  • Posts: 93
  • Karma: +0/-0
    • View Profile
Re: Merge elements
« Reply #4 on: July 18, 2007, 05:00:33 am »
Quote
I haven't tried this for sequence diagrams. So what if you first CTRL-V, re-arrange and then delete the old element?


Try it: for realistic sequence messages, it's a lot of boring work to "re-arrange"...

OK, it seems EA can not merge elements, that will be another feature request.

Dave_Bullet

  • EA User
  • **
  • Posts: 295
  • Karma: +0/-0
    • View Profile
Re: Merge elements
« Reply #5 on: July 23, 2007, 05:20:16 pm »
The best way to do bulk changes I've found is at the database level.

I've often thought about writing / compiling an add-on for "bulk" operations.  Of course it would require exclusive use of the database (ie. no active users) to be reliable.

Look at using UPDATE statements on the t_diagram, t_diagramlink and t_diagramobjects tables.  I think sequence diagrams (like all diagram types) are held in here.

You want to switch / replace Class A object_id for class B object_id (or other way round).

You'll also need to UPDATE t_connector - which is what Thomas proposed to move associations from one object to another - but does it in one operation at the database level.

Next time - make a re-usable stored procedure for the above process and you can invoke via an EA add-in you could write.

Cheers,
David.
« Last Edit: July 23, 2007, 05:20:42 pm by Dave_Bullet »
"I know I'm close to a good design, but it's like the balloon animals, squeeze in one spot and the problem moves down the line"

thomaskilian

  • Guest
Re: Merge elements
« Reply #6 on: July 23, 2007, 08:39:18 pm »
Just an additional hint: try this in your sandbox first! If you clobber your model with a nice SQL you'd also be happy about a backup.

I once went the add-in way and I have a nice tool chest. This is more reliable but it's a harder way to get there compared to the SQL approach.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Merge elements
« Reply #7 on: July 23, 2007, 11:42:43 pm »
Quote
Look at using UPDATE statements on the t_diagram, t_diagramlink and t_diagramobjects tables.  I think sequence diagrams (like all diagram types) are held in here.
Be warned me hearties...  Arrh... There be dragons...  Avast! In the ole' days  Sequence diagrams were unique (like the interface).  

Definitely make backups and do a lot of testing to make sure the sequence diagrams are still valid afterwards.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

brannstrom

  • EA User
  • **
  • Posts: 35
  • Karma: +0/-0
    • View Profile
Re: Merge elements
« Reply #8 on: March 11, 2008, 09:25:06 pm »
I am trying to write a plugin that can merge elements, but there is a lot of values to merge. I am using the built in plugin function when it can be used. But there is a lot of values and relations that must be accessed with sql.

The more I work with it the more I am beginning to think its not such a good idea to do. I am just finding more and more values and relationships to move.

Has anyone written a plugin that can merge elements without losing any values or relationships?