Jump to: navigation, search

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

(Registering artifacts)
Line 12: Line 12:
 
   
 
   
 
  using {
 
  using {
  ecore : !MetaMetamodel = OclUndefined
+
ecore : !MetaMetamodel = OclUndefined
  familiesMetamodel : !Metamodel = OclUndefined
+
familiesMetamodel : !Metamodel = OclUndefined
  personsMetamodel : !Metamodel = OclUndefined
+
personsMetamodel : !Metamodel = OclUndefined
  }  
+
  }
 +
 
  do{
 
  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
+
'''''-- Creates the Ecore metametamodel element in the megamodel'''''
  '''  thisModule.register(
+
  '''  '''thisModule.'''register('''
      thisModule.metametamodel(
+
    thisModule.metametamodel(
          thisModule.identifier('identifier', 'http://www.eclipse.org/emf/2002/Ecore', 'GlobalModelManagement::URI')
+
          thisModule.identifier('identifier', 'http://www.eclipse.org/emf/2002/Ecore', 'GlobalModelManagement::URI')
          ,thisModule.locator('locator', 'http://www.eclipse.org/emf/2002/Ecore',  
+
        ,thisModule.locator('locator', 'http://www.eclipse.org/emf/2002/Ecore',  
                                        'GlobalModelManagement::EPackagesRegistryLocator')
+
                                        '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'''
+
ecore <- !Model.allInstances()->any(m | m.identifier.value = 'http://www.eclipse.org/emf/2002/Ecore');
  thisModule.register(
+
 
    thisModule.metamodel(
+
'''''-- Creates the Families metamodel element in the megamodel'''''
      thisModule.identifier('identifier', '/Families2Persons/Persons.ecore', 'GlobalModelManagement::URI'),
+
thisModule.'''register'''(
      thisModule.locator('locator', '/Families2Persons/Persons.ecore', 'GlobalModelManagement::EFSLocator'),
+
  thisModule.metamodel(
      ecore
+
    thisModule.identifier('identifier', '/Families2Persons/Families.ecore', 'GlobalModelManagement::URI'),
    )   
+
    thisModule.locator('locator', '/Families2Persons/Families.ecore', 'GlobalModelManagement::EFSLocator'),
  );
+
    ecore
 
+
  )   
  familiesMetamodel <- !Model.allInstances()->any(m | m.identifier.value = '/Families2Persons/Families.ecore');
+
);
   
+
  '''-- Registers the Families metamodel in the EMF package register'''
+
  familiesMetamodel.registerInEMFpkgReg();  
+
 
   
 
   
  '''-- Creates the Families model element in the megamodel'''
+
'''''-- Creates the Persons metamodel element in the megamodel'''''
  thisModule.register(
+
thisModule.'''register'''(
    thisModule.terminalmodel(
+
  thisModule.metamodel(
      thisModule.identifier('identifier', '/Families2Persons/sample-Families.xmi', 'GlobalModelManagement::URI'),
+
    thisModule.identifier('identifier', '/Families2Persons/Persons.ecore', 'GlobalModelManagement::URI'),
      thisModule.locator('locator', '/Families2Persons/sample-Families.xmi', 'GlobalModelManagement::EFSLocator'),
+
    thisModule.locator('locator', '/Families2Persons/Persons.ecore', 'GlobalModelManagement::EFSLocator'),
      familiesMetamodel
+
    ecore
    )
+
  )
  );  
+
);
 
   
 
   
  personsMetamodel <- !Model.allInstances()->any(m | m.identifier.value = '/Families2Persons/Persons.ecore');
+
familiesMetamodel <- !Model.allInstances()->any(m | m.identifier.value = '/Families2Persons/Families.ecore');
   
+
 
  '''-- Registers the Persons metamodel in the EMF package register'''
+
'''''-- Registers the Families metamodel in the EMF package register'''''
  personsMetamodel.registerInEMFpkgReg();
+
familiesMetamodel.'''registerInEMFpkgReg'''();
 
+
  '''-- Creates the Families model element in the megamodel'''
+
'''''-- Creates the Families model element in the megamodel'''''
  thisModule.register(
+
thisModule.'''register'''(
    thisModule.terminalmodel(
+
  thisModule.terminalmodel(
      thisModule.identifier('identifier', '/Families2Persons/sample-Persons.xmi', 'GlobalModelManagement::URI'),
+
    thisModule.identifier('identifier', '/Families2Persons/sample-Families.xmi', 'GlobalModelManagement::URI'),
      thisModule.locator('locator', '/Families2Persons/sample-Persons.xmi', 'GlobalModelManagement::EFSLocator'),
+
    thisModule.locator('locator', '/Families2Persons/sample-Families.xmi', 'GlobalModelManagement::EFSLocator'),
      personsMetamodel
+
    familiesMetamodel
    )
+
  )
  );
+
);
 
+
  '''-- Registers the Families2Person.atl transformations in the megamodel'''
+
personsMetamodel <- !Model.allInstances()->any(m | m.identifier.value = '/Families2Persons/Persons.ecore');
  thisModule.register(
+
 
    thisModule.atlModule(
+
'''''-- Registers the Persons metamodel in the EMF package register'''''
      thisModule.identifier('identifier', '/Families2Persons/Families2Persons.atl', 'GlobalModelManagement::URI'),
+
personsMetamodel.'''registerInEMFpkgReg'''();
      thisModule.locator('locator', '/Families2Persons/Families2Persons.atl', 'GlobalModelManagement::EFSLocator')
+
    )
+
'''''-- Creates the Families model element in the megamodel'''''
  );
+
thisModule.'''register'''(
 +
  thisModule.terminalmodel(
 +
    thisModule.identifier('identifier', '/Families2Persons/sample-Persons.xmi', 'GlobalModelManagement::URI'),
 +
    thisModule.locator('locator', '/Families2Persons/sample-Persons.xmi', 'GlobalModelManagement::EFSLocator'),
 +
    personsMetamodel
 +
  )
 +
);
 +
 +
'''''-- Registers the Families2Person.atl transformations in the megamodel'''''
 +
thisModule.'''register'''(
 +
  thisModule.atlModule(
 +
    thisModule.identifier('identifier', '/Families2Persons/Families2Persons.atl', 'GlobalModelManagement::URI'),
 +
    thisModule.locator('locator', '/Families2Persons/Families2Persons.atl', 'GlobalModelManagement::EFSLocator')
 +
  )
 +
);
 
  }
 
  }

Revision as of 10:49, 23 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 fiels into the workspace
Registering artifacts
program megamodelPopulation

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

do{

-- 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
  )  
);

familiesMetamodel <- !Model.allInstances()->any(m | m.identifier.value = '/Families2Persons/Families.ecore');
  
-- Registers the Families metamodel in the EMF package register
familiesMetamodel.registerInEMFpkgReg(); 

-- Creates the Families model element in the megamodel
thisModule.register(
  thisModule.terminalmodel(
    thisModule.identifier('identifier', '/Families2Persons/sample-Families.xmi', 'GlobalModelManagement::URI'),
    thisModule.locator('locator', '/Families2Persons/sample-Families.xmi', 'GlobalModelManagement::EFSLocator'),
    familiesMetamodel
  )
); 

personsMetamodel <- !Model.allInstances()->any(m | m.identifier.value = '/Families2Persons/Persons.ecore');
  
-- Registers the Persons metamodel in the EMF package register
personsMetamodel.registerInEMFpkgReg();

-- Creates the Families model element in the megamodel
thisModule.register(
  thisModule.terminalmodel(
    thisModule.identifier('identifier', '/Families2Persons/sample-Persons.xmi', 'GlobalModelManagement::URI'),
    thisModule.locator('locator', '/Families2Persons/sample-Persons.xmi', 'GlobalModelManagement::EFSLocator'),
    personsMetamodel
  )
);

-- Registers the Families2Person.atl transformations in the megamodel
thisModule.register(
  thisModule.atlModule(
    thisModule.identifier('identifier', '/Families2Persons/Families2Persons.atl', 'GlobalModelManagement::URI'),
    thisModule.locator('locator', '/Families2Persons/Families2Persons.atl', 'GlobalModelManagement::EFSLocator')
  )
);
}