Jump to: navigation, search

Difference between revisions of "AMW/Model Handler"

< AMW
Line 5: Line 5:
 
[[Image:AmwLogo.png|right]]
 
[[Image:AmwLogo.png|right]]
  
The AMW Model Handler enables a better integration of ATL transformations and weaving models. It provides a set of primitives constantly needed when developing transformations that have weaving models as input or output.
+
The [[AMW]] Model Handler enables a better integration of [[ATL]] transformations and weaving models. It provides a set of primitives constantly needed when developing transformations that have weaving models as input or output.
  
In the [[ATL]] terminology, a model handler is a library providing primitives for handling models, such creating new models, or adding and deleting elements. See the [[ATL Model Handlers]] page to know the base model handlers provided by the ATL plug-ins.
+
In the [[ATL]] terminology, a model handler is a library providing primitives for handling models, such creating new models, or adding and deleting elements. See the [[ATL/Model Handlers]] page to know the base model handlers provided by the ATL plug-ins.
  
This model handler inherits from the ATL EMF ModelHandler, thus it supports all the base EMF primitives. It can be used for weaving models and for woven models as well. The model handler is being improved with new primitives, according to new user requirements. It will be separated in two different model handlers (one for the woven and one for the weaving models) in future versions.
+
This model handler inherits from the ATL [[EMF]] ModelHandler, thus it supports all the base EMF primitives. It can be used for weaving models and for woven models as well. The model handler is being improved with new primitives, according to new user requirements. It will be separated in two different model handlers (one for the woven and one for the weaving models) in future versions.
  
 
==Model Handler methods==
 
==Model Handler methods==
Line 128: Line 128:
 
[[Category:GMT]]
 
[[Category:GMT]]
 
[[Category:AMMA]]
 
[[Category:AMMA]]
 +
[[Category:AMW]]

Revision as of 04:26, 13 December 2010

< To: AMMA
< To: GMT
< To: AMW

AmwLogo.png

The AMW Model Handler enables a better integration of ATL transformations and weaving models. It provides a set of primitives constantly needed when developing transformations that have weaving models as input or output.

In the ATL terminology, a model handler is a library providing primitives for handling models, such creating new models, or adding and deleting elements. See the ATL/Model Handlers page to know the base model handlers provided by the ATL plug-ins.

This model handler inherits from the ATL EMF ModelHandler, thus it supports all the base EMF primitives. It can be used for weaving models and for woven models as well. The model handler is being improved with new primitives, according to new user requirements. It will be separated in two different model handlers (one for the woven and one for the weaving models) in future versions.

Model Handler methods

The AMW model handler provides methods that can be called on elements of a weaving model or on the elements of the woven models. They are explained below.

Weaving models

getReferredElement

This method takes as input a WLinkEnd of a weaving model and it returns the referred element of a woven model (e.g., a MOF!EClassifier).

Example:

  rule Example {
     from
         mmw : AMW!ElementEqual ( not mmw.left.getReferredElement().oclIsUndefined() )
     to
  ...

Woven models

generateModelRef

This methods generates the value of the "ref" attribute for a woven model. In other words, it generates an identifier for woven models. The current implementation returns the models' URI.

Example:

  create OUT : AMW from left : MOF, right : MOF;	
  ...
  rule Example {	
    from 
      ...
    to
       lefta : AMW!ModelRefXMI (
            name <- 'leftModel',
            ref <- MOF!EPackage.generateModelRef('left')
       )
   }		

getElementID

This method returns the identifier (ID) of a woven element. It is necessary to pass as parameter the related weaving model. In that way it is possible to find which WElementRef is used, and which adapter class is called. The adapter class is the implementation of the identification mechanisms. Ex.: XMIIdentifierAdapter, GenericIdentifierAdapter.

Example:

  create OUT : AMW from IN : AMW, left : MOF, right : MOF;
  ...
  rule example {
     from
        element : MOF!EClass 
     to
        out : AMW!ElementRef (
            name <- element.name,
            ref <- element.getElementID('IN')
        )
  }  

getElementIDbyRefType

This method returns the identifier (ID) of a woven element. In this method it is necessary to pass the type of element ref (that inherits from WElementRef) as parameter. The type of WElementRef specifies which identification mechanism is used. The WElementRefs are associated with adapters of identification mechanisms (see below). For instance, the ElementRefXMI is associated with the XMIIdentifierAdapter class. It returns the XMI ID.

This method is used when the user wants to create a new weaving model and he does not have yet the information concerning its identification mechanism.

  rule NewElementRef {
     from
        element : MOF!EClassifier 		
     to
        out : AMW!ElementRefXMI (
           name <- element.name,
           ref <- element.getElementIDbyRefType('ElementRefXMI'),
           modelRef <- element.setModelRef			
        )
  }

setElementIDbyRefType

This method sets up the identifier (ID) of a model element. In this method it is necessary to pass the type of element ref (that inherits from WElementRef) as parameter. The type of WElementRef specifies which identification mechanism is used. The WElementRefs are associated with adapters of identification mechanisms (see below). For instance, the ElementRefXMI is associated with the XMIIdentifierAdapter class. It sets up the XMI ID.

The value of the new ID is passed as second parameter. It must be a string object, because it is the same value that should be saved in the ref attribute of the WElementRefs. If the second parameters is null (OclIsUndefined), the ID will be set up based on the value of the object.

This method is used when the user wants to set up the ID of an element and he does not have yet the information concerning its identification mechanism.

  rule NewElement {
     from
        element : MOF!EClassifier 		
     to
        out : MOF!EClassifier (
        )
     do
       {
        out.setElementIDbyRefType('ElementRefXMI', 'newIDValue'),
     }
  }

Creating an ATL launch configuration

The screenshot below shows how to set up an ATL launch configuration with the AMW model handler. The AMW handler will be available in the list of model handlers .

First the user sets up the input and output models . Then the user must select the weaving metamodel (e.g., mmw_weaving.core) or the woven metamodels (e.g., MOF), or both as shown below. Then select 'AMW', and click on the Select Model Handler button. AMW is shown in the third column of the Path Editor.

The transformation is ready to run.

Sample model handler.png


Download and install

The Amw Model Handler plug-in (org.eclipse.gmt.weaver.amw4atl) is available for download in the AMW CVS, and in the development build of AMW (binary version).

The plug-in must be checked out in the Eclipse workspace and a new Runtime Workspace must be launched. Then, the model handler is ready to use.

A binary release will be available in the next complete release of the AMW plug-ins.