Skip to main content
Jump to: navigation, search

MoScript/Use Cases/Megamodel Population Part 2

< MoScript
Revision as of 07:48, 26 December 2011 by (Talk | contribs) (Registering artifacts)

Megamodel Population Part 2

Continuing with the use case Megamodel Population Part 1, this use cases shows how to programmatically populate the megamodel with models, metamodels and transformations. For this purpose we are going to populate it with the content of an ATL project that can be found in the ATL Transformations Zoo

Environment Preparation
  • Download the Families to Persons source code from here
  • Unzip the project and import it into eclipse copying the files into the workspace
Registering artifacts

The first thing we have to do is to declare the variables we are going to use along the rest of the code. We declare variables for holding the the ecore metametamodel, and the metamodels of the Families2PersonExample.

program megamodelPopulation 

using { 
  ecore : !MetaMetamodel = OclUndefined
  familiesMetamodel : !Metamodel = OclUndefined
  personsMetamodel : !Metamodel = OclUndefined

After declaring variables we proceed to register the Ecore metametamodel in the megamodel to be able to register metamodels that conform to it.


           thisModule.identifier('identifier', '', 'GlobalModelManagement::URI')
          ,thisModule.locator('locator', '', 

Next, we query the megamodel to find the just registered metametamodel and assign it to the ecore variable

  ecore <- !Model.allInstances()->any(m | m.identifier.value = '');

Next we register the Families.ecore and Persons.ecore metamodels in the megamodel. Note that the third parameter of the metamodel operation is the ecore variable, which corresponds to the Ecore metametamodel.

      thisModule.identifier('identifier', '/Families2Persons/Families.ecore', 'GlobalModelManagement::URI'),
      thisModule.locator('locator', '/Families2Persons/Families.ecore', 'GlobalModelManagement::EFSLocator'),

      thisModule.identifier('identifier', '/Families2Persons/Persons.ecore', 'GlobalModelManagement::URI'),
      thisModule.locator('locator', '/Families2Persons/Persons.ecore', 'GlobalModelManagement::EFSLocator'),

Back to the top