Jump to: navigation, search

Difference between revisions of "AMW/Model Handler"

< AMW
Line 8: Line 8:
  
 
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.
  
 
==Model Handler methods==
 
==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.
  
===Creating an ATL launch configuration===
+
===Weaving models===
  
[[Image:sample_model_handler.png|center]]
+
====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.: [http://dev.eclipse.org/viewcvs/indextech.cgi/org.eclipse.gmt/AMW/org.eclipse.weaver/src/org/eclipse/weaver/providers/XMIIdentifierAdapter.java?view=markup XMIIdentifierAdapter], [http://dev.eclipse.org/viewcvs/indextech.cgi/org.eclipse.gmt/AMW/org.eclipse.weaver/src/org/eclipse/weaver/providers/GenericIdentifierAdapter.java?revision=1.2&view=markup 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
 +
        )
 +
  }
 +
 +
 +
==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.
 +
 +
[[Image:sample_model_handler.png|center]]
  
 
==Download and install==
 
==Download and install==
  
 +
The Amw Model Handler plug-in ('''org.eclipse.gmt.weaver.amw4atl''') is available for download in the [http://dev.eclipse.org/viewcvs/indextech.cgi/org.eclipse.gmt/AMW/ AMW CVS].
 +
 +
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.
  
  

Revision as of 08:43, 9 February 2007

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


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.

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.