Jump to: navigation, search

Snippet: Work with Model Artifacts

Revision as of 22:33, 17 February 2008 by Erdillon.cisco.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

< To: Tigerstripe_APIs

This snippet illustrates how to work with model artifacts.


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
// 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() {
      public boolean canExecute() {
        return true;
      public void execute() {
      public void redo() {

Note that as this command is executed and commits, the POJO is renamed accordingly.


Note: the Old API is soon going to be deprecated