Element substitution for another element in the model

Started by Manj75, January 26, 2024, 17:34:39 PM

Previous topic - Next topic

Manj75

Is there any easy way to replace an element in a view with another existing element in the model moving all relationships from the old element to the new element?

If any has come across this and written a jArchi script that can be shared that would be great.

I want to substitute an element with another retaining all relationships and positioning on the view diagram.

e.g.

Chrome Browser <Application Component> ---association---> Web Browsing <Capability>

Substitute with existing Edge Browser <Application Component> and all relationships that Chrome Browser had are moved over in the view to now show:

Edge Browser <Application Component> ---association---> Web Browsing <Capability>

Any suggestions/advice is greatly appreciated if I need to write my own script.


Phil Beauvoir

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Manj75

Wow - that is a one line of code that is powerful and on paper is what I need.

However, thinking about my use case I will have an issue (I've not tested it yet)...

Use Case
  • I have created a Hub and Spoke view diagram positioned as a template view
  • The Hub is the <Application Component> and the Spoke Node elements display the property values of the target element which is the Hub, using the Label feature.
  • I want a jArchi script that will generate an actual view diagram of the template by duplicating it and replacing it with a selected <Application Component> when run
  • This duplicated view name will be renamed and all the Spoke Node elements will display updated values of the new Hub <Application Component

The issue will be that using the element.merge() will change the template view with the new <Application Component> too.

Ideally, it needs to make a copy of the Hub in the duplicated view - the only way I can think of doing this is to include the duplication process in the script to make a copy