Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "MoScript/Use Cases/Megamodel Population Part 2"

(Megamodel Population Part 2)
(Registering artifacts)
Line 14: Line 14:
 
   
 
   
 
  using {  
 
  using {  
ecore : !MetaMetamodel = OclUndefined
+
  ecore : !MetaMetamodel = OclUndefined
familiesMetamodel : !Metamodel = OclUndefined
+
  familiesMetamodel : !Metamodel = OclUndefined
personsMetamodel : !Metamodel = OclUndefined
+
  personsMetamodel : !Metamodel = OclUndefined
 
  }
 
  }
  
 
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.  
 
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.  
  
do{  
+
do{  
  
 
   -- Removes all the identified elements form the megamodel
 
   -- Removes all the identified elements form the megamodel

Revision as of 07:38, 26 December 2011

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 following is the code of the megamodel population

program megamodelPopulation 

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

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.

do{ 
 -- Removes all the identified elements form the megamodel
for(identifiedElement in !IdentifiedElement.allInstances()->select(ie | not (ie.identifier = OclUndefined) )) {
  identifiedElement.remove();
}

 -- Creates the Ecore metametamodel element in the megamodel
  thisModule.register(
      thisModule.metametamodel(
           thisModule.identifier('identifier', 'http://www.eclipse.org/emf/2002/Ecore', 'GlobalModelManagement::URI')
          ,thisModule.locator('locator', 'http://www.eclipse.org/emf/2002/Ecore', 
                                         'GlobalModelManagement::EPackagesRegistryLocator')
      )
  );
  
  ecore <- !Model.allInstances()->any(m | m.identifier.value = 'http://www.eclipse.org/emf/2002/Ecore');
  
  -- Creates the Families metamodel element in the megamodel
thisModule.register(
  thisModule.metamodel(
    thisModule.identifier('identifier', '/Families2Persons/Families.ecore', 'GlobalModelManagement::URI'),
    thisModule.locator('locator', '/Families2Persons/Families.ecore', 'GlobalModelManagement::EFSLocator'),
    ecore
  )  
);

-- Creates the Persons metamodel element in the megamodel
thisModule.register(
  thisModule.metamodel(
    thisModule.identifier('identifier', '/Families2Persons/Persons.ecore', 'GlobalModelManagement::URI'),
    thisModule.locator('locator', '/Families2Persons/Persons.ecore', 'GlobalModelManagement::EFSLocator'),
    ecore
  )  
);

Back to the top