How to create weaving metamodel extensions?

The AMW prototype is developed based on the core weaving metamodel. The weaving metamodel extensions that are used by the prototype must extend this core, or extend other weaving extensions.

We illustrate the development of metamodel extensions using the simplest extension provided by the weaver, supporting generic link management.

The following classes of the core metamodel can be extended: WModel, WModelRef, WElementRef, WLink, WLinkEnd, WElementRef.

WModel

The WModel extensions are the root element of a weaving model. The references leftModel and rightModel refer to the woven models. They must subset the wovenModel reference from the core weaving metamodel.

The subsets annotation means that these references are derived from the wovenModel reference. The AMW prototype uses this annotation to load the woven models correctly.

If a weaving metamodel has more than one extension of WModel, the second page of the AMW wizard proposes to choose one root element.

class Model extends WModel {

    -- @subsets wovenModel
    reference leftModel container : WModelRef;
    
    -- @subsets wovenModel
    reference rightModel container : WModelRef;
}

Obs.: The annotations must be defined after a blank line. This is due to some limitations on the parser.

WModelRef

The WModelRef extensions are used to identify the woven models. A different extension to WModel must be created for every different identification mechanism that we want to support. For instance, the ModelRef class is used to identify model elements through XPointers, and ModelRefXMI uses XMI IDs.

When creating a weaving model using the AMW wizard, the user selects the WModelRefs he wants to create in the third page of the AMW wizard. This page is also used to set up the ref attribute. This attribute stores the URI of the woven models.

The -- @welementRefType ElementRef annotation indicates the type of WElementRef that is created in the ownedElementRef reference.

-- @welementRefType ElementRef
class ModelRef extends WModelRef {
}

-- @welementRefType ElementRefXMI
class ModelRefXMI extends WModelRef {
}	

Obs.: This elements are not explicitly shown in the AMW prototype. They are automatically created after the wizard is executed.

WElementRef

The WElementRef extensions are the elements that point to the elements of the woven models (woven elements). The weaving model has one WElementRef for every woven element.

The ID of the woven element is stored in the ref attribute. The format of the ID depends on the type of the containing WModelRef. The exact type of the WModelRef is specified in the wmodelRefType annotation. This annotation is necessary because a WElementRef element may be referenced by different WModelRefs.

-- @wmodelRefType ModelRef
class ElementRef extends WElementRef {
}	

-- @wmodelRefType ModelRef
class ElementRefXMI extends WElementRef{
}

Obs.: This elements are not explicitly shown in the AMW prototype. They are automatically created when creating different WLinkEnd elements.

WLink

The extensions of WLink elements are of major importance in a weaving model. This is because these elements define the domain specific linking semantics. Usually, all new extensions of the weaving core have a different extension of WLink.

The Link below defines basic link management. It is used to link a left and a right elements. The WLink extensions may have references that subsets the end reference, e.g., the left and right references below. These references specify which kind of elements are linked, and their cardinality. A WLink can also have child links through the child reference.

There are many different kinds of links that can be defined, for instance Equality, Equivalence, Annotation, Merge, etc.

class Link extends WLink {
 
   -- @subsets end
   reference left container : WLinkEnd oppositeOf link;

   -- @subsets end
   reference right container : WLinkEnd oppositeOf link;
}

WLinkEnd

The WLinkEnd elements specify the end points of a WLink. In other words, it indicates the type of elements that are linked. The reference element refers to the WElementRef elements, which contain the identifiers of the woven elements. The WElementRef are not referenced directly by WLinks because it is possible to refer the same woven model element by different link endpoints. For example, one model element may be linked by more than one WLink.

class LinkEnd extends WLinkEnd {
}