Defining UML extensions

 

Creating a new profile

The next step in this quick tour is to create the profile inside which your future generator will be created. For this, simply carry out the operations shown in Figure 6 below.

 

Figure 6. Creating a new profile

 

Steps:

1.      In the explorer, select the “Profiles” folder.

2.      Click on the  icon in the explorer palette.

3.      Name the profile “Java”.

4.      Confirm by clicking on the “OK” button.

 

The new profile is then automatically created and contains a link to the reference metamodel and to the “ObjecteeringTypes” types package.

 

For more information on creating profiles, please see “Creating profiles”.

 

Referencing a metaclass

Metaclass references are “proxy” metaclasses that refer to the metaclasses belonging to the reference metamodel. Extensions such as tagged values, notes, J attributes or J operations can be directly defined on metaclass references.

 

For the purposes of this quick tour project, we are going to create the “Operation” metaclass reference.

To reference a metaclass, carry out the steps shown in Figure 7.

 

Figure 7. Creating a reference

 

Steps:

1.      In the explorer, click on the “Java” profile.

2.      Click on the  icon in the explorer palette. The “Create a reference” window then appears.

3.      In this window, expand “Objecteering UML” and then “Metamodel”, and then click on the “Operation” metaclass.

4.      Click on “OK” to confirm. The new reference is then created and appears in the explorer.

 

Note:      You can either select a metaclass directly in the metamodel tree or simply type the name of the metaclass in the  field. If you choose to enter the metaclass name, you will see that even if you only enter the first few letters of the metaclass name, MDA Modeler will select the first available metaclass corresponding to this entry (for example, if you enter “pack”, the “Package” metaclass is automatically selected in the metamodel tree). The  field is not case sensitive.

 

After confirmation, the following elements are created:

·         a reference named “Operation” (this is a class stereotyped “reference”)

·         a static diagram named “Detailed view of Operation”, providing a detailed view of the “Operation” metaclass reference

 

At this stage, your model looks like the one shown in Figure 8.

 

Figure 8. The model you have built so far

 

For more information on referencing metaclasses, please see “Creating and managing references”.

 

 

Creating a note type

We are now going to define a note type, which will be used to enter Java code on J operations. This note type will only be accessible for the “Operation” metaclass, for which we have already created a metaclass reference.

 

To create the new note type, carry out the operations shown in Figure 9 below.

 

Figure 9. Creating the "JavaCode" note type

 

Steps:

1.      Select the “Operation” metaclass reference in the explorer.

2.      Click on the  icon in the explorer palette. The “Note type” dialog box then appears.

3.      In the “Note type” dialog box, enter “JavaCode” as the name of the new note type.

4.      Confirm creation of this new note type by clicking on “OK”.

 

For more information on creating notes, please see “Creating notes”.

 

 

Creating an attribute

The next step in our quick tour project is to define a new type of attribute, the “synchronized” attribute. This attribute will allow you to automatically generate the “synchronized” keyword, which will be the header of the operations that own it.

 

To create this new attribute, carry out the operations shown in Figure 10 below.

 

Figure 10. Creating the {synchronized} attribute

 

Steps:

1.      Select the “Operation” metaclass reference in the explorer.

2.      Click on the  icon in the explorer palette. The “Attribute” dialog box then appears.

3.      In the “Name” field of the “Attribute” dialog box, enter “synchronized”.

4.      In the “Type” field, select “boolean”.

5.      Confirm creation of this new attribute by clicking on “OK”.

 

The model you have built so far should look like the one shown in Figure 11 below.

 

Figure 11. The model you have built so far

 

For more information on creating attributes, please see “Creating attributes”.