Filters

 

Why use filters?

Filters can be used in code, diagram and documentation templates to specify that only elements which fulfill certain criteria will be taken into account by the template in question. Filters are defined on navigation nodes.

 

For example, a user can specify that only classes annotated with the {analysis} tagged value are to be taken into account by the template being developed.

 

In this way, the use of filters in templates allows users to include only information which is relevant to a given context in the code, diagram or documentation produced by the template in question.

 

Opening the “Filter definition” window

To select an existing filter or define a new filter, the “Filter definition” window is used. This window is opened by double-clicking on the  button when the “Filter” property field is selected for a navigation node.

 

Selecting an existing filter

Objecteering MDA Modeler provides the following filters for use in code, diagram and documentation templates:

·         Is stereotyped”: For a given navigation node, the user can indicate that only elements with the specified stereotype are to be taken into account.

·         Has a tagged value”: For a given navigation node, the user can indicate that only elements with the specified tagged value are to be taken into account.

·         Has a note”: For a given navigation node, the user can indicate that only elements with the specified note are to be taken into account.

·         “Properties”: For a given navigation node, the user can indicate that only elements with the specified property are to be taken into account.

 

Figure 112 illustrates how to select an existing filter.

 

Figure 112. Selecting an existing filter

 

Steps:

1.      Select a navigation node.

2.      Click in the “Value” field associated with the “Filter” property. The icon then appears. Click on this icon to open the “Filter definition” window.

3.      In the “Filter definition” window, expand the “Has a note” filter. We are now going to indicate that we only want elements with a specific note type to be taken into account by the template.

4.      Double-click on the “description” note, to indicate that only elements with a description-type note are to be taken into account by the template.

5.      When you double-click on a note type (as described in step 4), the associated J code for the filter automatically appears in the right-hand zone.

6.      Click on “OK” to confirm.

 

The result of this operation is shown in Figure 113 below.

 

Figure 113. The filter selected for the “Classes” navigation node

 

Defining new filters

To define a new filter which will be used on elements retrieved by the selected navigation node scan method, a filter expression must be entered:

·         either in the value field of the “Filter” property for a selected navigation node (as shown in Figure 114 below)

·         or in the right-hand zone of the “Filter definition” window

 

Let's imagine we wish to define a filter, which will indicate that all public operations without the {nocode} tagged value will be taken into account by the template being developed. To do this, carry out the steps shown in Figure 114 below.

     

Figure 114. Defining a new filter

 

Steps:

1.      Select the “Operations” navigation node.

2.      Select the “Filter” property.

3.      In the “Value” field, enter the following: IsPublic && !isTaggedValue ("nocode"). Please note that the name of the tagged value must be surrounded by inverted commas.

4.      Click on “OK” to confirm.

 

For more information on entering J code, please see “Inserting J code”.

 

Alternative to the filters

To filter the elements retrieved by the scan method, it is possible to insert the filter directly into the scan method, with a J code more complex.

 

Figure 115. Insert the filter in the scan method

 

Steps:

1.      Select the “Operations” navigation node.

2.      Select the “Scan method” property.

3.      In the “Value” field, enter the following: PartOperation.<select (IsPublic && !isTaggedValue ("nocode")). Remove the content of the “Filter” property. This solution is the same as the figure 114.

 

For more information on entering J code, please see “Inserting J code”.