re-nest

Started by margolyesh, August 09, 2024, 02:34:28 AM

Previous topic - Next topic

margolyesh

Hi, Phil!

There are 2 elements on a view without nest.
// Add some ArchiMate elements to the Model
var app = model.createElement("application-component", "App");
var api = model.createElement("application-interface", "API");

// Add an ArchiMate relationship to the Model
var relationship = model.createRelationship("composition-relationship", "", app, api);

// Add an ArchiMate view to the default "Views" folder
var archimateView = model.createArchimateView("View 1");

// Add some objects to the ArchiMate view containing the elements (-1 = default width and height)
var object1 = archimateView.add(app, 10, 10, 200, 150, false);
var object2 = archimateView.add(api, 500, 300, -1, -1, false);

// Add a visual connection containing the relationship
var connection = archimateView.add(relationship, object1, object2);

Then I want to make them nested, and have the model be valid. Is this possible? It doesn't work for me.
For some reasons I don't want to do it this way:
// Add some ArchiMate elements to the Model
var app = model.createElement("application-component", "App");
var api = model.createElement("application-interface", "API");

// Add an ArchiMate relationship to the Model
var relationship = model.createRelationship("composition-relationship", "", app, api);

// Add an ArchiMate view to the default "Views" folder
var archimateView = model.createArchimateView("View 1");

// Add some objects to the ArchiMate view containing the elements (-1 = default width and height)
var object1 = archimateView.add(app, 10, 10, 200, 150, false);
var object2 = archimateView.add(api, 30, 30, -1, -1, true);

// Add a visual connection containing the relationship
var connection = archimateView.add(relationship, object1, object2);


Phil Beauvoir

At the moment, jArchi doesn't support moving a visual object from one parent to another (see here). An alternative approach when creating visual objects is to add the new object to a parent object instead of to the view with the nesting option:

var object1 = archimateView.add(app, 10, 10, 200, 150);
var object2 = object1.add(api, 45, 45, -1, -1);
var connection = archimateView.add(relationship, object1, object2);
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

margolyesh

Got it. Is there any possibility to put connection on view if one object is nested and the other is not? With jArchi, of course.