Adding Elements to a Model

How do I add ArchiMateApplicationComponents created programmatically using Open API to a Model.

// Create the Model
IModel eimApplicationCatalogueModel = IModelElementFactory.instance().createModel();
eimApplicationCatalogueModel.setName(“AppCatalogue”);

// Create Application Components
DiagramManager diagramManager = applicationManager.getDiagramManager();
IArchiMateApplicationComponent applicationComponent = IModelElementFactory.instance().createArchiMateApplicationComponent();
applicationComponent.setUserID(“123456”);
applicationComponent.setName(“Some Name”);
applicationComponent.setDescription(“Some Description”);

Query 1. How do I add that applicationComponent to the Model?

Query 2. How do I retrieve all existing components from a Model?

Query 3: I can see IModelElementFactory.instance().createModel() to create a Model, how do I get a list of all the existing Models?

		IModel lModel = ...;
		IArchiMateApplicationComponent lApplicationComponent = ...;
		IProject lProject = ApplicationManager.instance().getProjectManager().getProject();
		
		// Q1
		lModel.addChild(lApplicationComponent);

		// Q2		
		lModel.toChildArray();
		lModel.toChildArray(IModelElementFactory.MODEL_TYPE_ARCHI_MATE_APPLICATION_COMPONENT);
		
		// Q3
		lProject.toAllLevelModelElementArray(IModelElementFactory.MODEL_TYPE_MODEL);

For Query 1: I had tried the following

// Create the Model
IModel applicationCatalogueModel = IModelElementFactory.instance().createModel();
applicationCatalogueModel.setName(“Application Catalogue”);

// Create Application Components
DiagramManager diagramManager = applicationManager.getDiagramManager();
IArchiMateApplicationComponent applicationComponent = IModelElementFactory.instance().createArchiMateApplicationComponent();
applicationComponent.setUserID(“123456”);
applicationComponent.setName(“Some Name”);
applicationComponent.setDescription(“Some Description”);

// Add the child to the model
applicationCatalogueModel.addChild( applicationComponent );

and the behaviour I am getting is

image

I needed all the ApplicationComponents to be directly a part of the Application Catalogue and not create a model ( folders of ModelNNNN )of its own as in screenshot.

Needed this instead

image