Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Snippet: Work with Model Artifacts
Contents
< To: Tigerstripe_APIs
This snippet illustrates how to work with model artifacts.
EMF-Based API
Note: the EMF-Based API is still under construction and is not fully implemented
// Start by getting the Model Manager of the project ITigerstripeModelProject project = ... IModelManager mMgr = project.getModelManager(); // // For now the default repository is hardcoded to be a PojoModelRepository, // This should be configurable in the future. IModelRepository repo = mMgr.getDefaultRepository(); // // Use the EMF-generated factory to create a new artifact IManagedEntityArtifact nMea = MetamodelFactory.eINSTANCE.createIManagedEntityArtifact(); // Name & Package are required before a Repository can store an Artifact nMea.setName("Mea"); nMea.setPackage("com.mycompany.testNO"); // The pojo is created in a transaction repo.store(nMea, true); // // To change an attribute on the Mea once it belongs to a repository, // A transaction is needed: final IManagedEntityArtifact fMea = nMea; TransactionalEditingDomain editingDomain = repo.getEditingDomain(); // editingDomain.getCommandStack().execute(new AbstractCommand() { @Override public boolean canExecute() { return true; } @Override public void execute() { fMea.setName("newName"); fMea.setAbstract(true); fMea.setPackage("com.moo"); } @Override public void redo() { } });
Note that as this command is executed and commits, the POJO is renamed accordingly.
Old API
Note: the Old API is soon going to be deprecated