Page tree
Skip to end of metadata
Go to start of metadata

Note that when running AIP Console in CAST Imaging mode (i.e. using the dedicated AIP Core for CAST Imaging) the Quality Rule Models tab is not available.

Introduction

This page explains the creation of a hypothetical Quality Rule model to check for a specific situation. This example will produce a Quality Rule model that tests whether any Java Constructors in your Application directly access Tables in your database. This example assumes that a front end Java application and a back end database have already been analyzed. This is simply an example to show how Quality Rule models function.

Step 1 - Create the empty model

Switch to the Architecture Studio:

You can access the Architecture Studio using the following URL: http://<server>:8081/ui/index.html#/ac-studio

Now switch to the Quality Rule model interface and click Create:

A dialog box will then be displayed enabling you to define a name for the new model, click OK to proceed:

The name of model also determines the name of the corresponding .castrule file that stores the definition of the model. You can change the name at a later time if necessary, but the file name cannot be changed.

The new model will be generated and the model editor will be displayed:

When a Quality Rule Model is created, two default Sets called Scope and Violations are automatically initialized:

Scope

The default Scope set defines the "scope" of objects that will be tested by this Quality Rule Model.

For example you may want to test some aspect of the Java Constructors in your Application: then you should use this set to define these objects, either directly, or through another Set. You can then define additional blocks to create "conditions" - i.e. all Java Constructors, except those which are named in a specific way.

You are free to configure this set exactly as you want.

Violations

The default Violations set defines the the objects that will appear as Violations. By default, the objects defined by the default Scope set will always be included, however, you can then define additional "blocks" to create "conditions.

For example, you may want to test whether the Java Constructors in your Application directly access objects in a database, such as a Table. In this case, the Java Constructors are already included (via the Scope set), so you will need to define an additional "block" which creates an AND condition, i.e. all Java Constructors which ALSO access Tables directly.

  • This set can only have one selection criterion, it is not possible to add another selection criterion, however, it is possible to have many conditions (blocks) in the same selection criterion.
  • The member-of Scope block can not be removed / edited / replaced.
  • If there is no other sets configured, it is not possible to add another member-of block to this section as the only set is already used (the default Scope set).


  • These two Sets cannot be removed or renamed
  • Quality Rule Models support only the creation of additional Sets of objects (the creation of custom Layers and Dependencies between items is not supported).

Step 2 - Define Java set and content

We want to test whether the Java Constructors access Tables, therefore we first need to define the Scope set: this set will contain the Java Constructors. To achieve this, we will add an additional set (called Java Constructors) and then define a "block" in the Java Constructors set that matches all Java Constructors. Finally, we need to ensure that the Scope set re-uses the Java Constructor set.

 Click here to expand...

Create a new set called Java Methods:

Display the new set in the editor:

Click the new set to select it:

Define the content for the Java Constructors set: in this example we will re-use the Java Constructors set in the default Scope set, therefore we need to define a block that matches all Java Constructors. In the right hand panel (ensure the Java Constructors set is selected), click the + button in the All Objects Matching block and choose Property - Identification to be able to define the Java Constructors we want to "capture":

Define the properties to match Java Constructor objects and click the tick icon to save the block:

Now check that the block captures the objects you require: first change the context to the application you are creating the model for (if you have not already run an analysis for the application it is not possible to check the objects are correctly matched):

A check mark will now appear in the right hand panel, click this to view a list of objects captured by the block:

Click to enlarge

 

Finally, we need to ensure that the Scope set re-uses the Java Constructor set. Select the Scope set and click the Add button highlighted below in the right hand panel to add a new block:

In the new block, click the Add button and choose Member of:

In the drop down list, choose the Java Constructors set you created previously and save the block:

The editor will update to show that the Scope set re-uses the configuration defined in the Java Methods set:

Step 3 - Define the Tables Set

We want to test whether the Java Constructors access Tables, therefore we now need to define the Violations set: this set will contain the criteria that define the objects that will be returned as violations. To achieve this, we will add an additional set (called Tables) and then define an additional "block" in the Tables set that matches all Tables. Finally, we need to ensure that the Violations set defines the Tables set via a caller-of block. This is a similar process to the creation of the Java Constructors set:

 Click here to expand...

Create a new set called Tables, display the new set in the editor and select it:

Define the content for the Tables set: in this example we will re-use the Tables set in the default Violations set, therefore we need to define a block that matches all Tables. In the right hand panel (ensure the Tables set is selected), click the + button in the All Objects Matching block and choose Property - Identification to be able to define the Tables we want to "capture". Again, click the check icon to ensure that you are capturing the objects you require:

Finally, we need to ensure that the Violations set re-uses the Tables set through a "caller-of" block:

Choose the type of caller you require - in this example we are choosing all link types between Java Constructors and Tables. We have left the Depth Level at the default value "1" (directly called objects). Click the tick to save the configuration:

Now click the Add button in the new Caller Of block to add in the Tables set, via a Member of configuration:

The editor will update to show that the Violations set re-uses the configuration defined in the Tables set:

Step 4 - Check content and view results

Now that the model is complete, first save it:

Finally, click the check icon on the toolbar to view the results against the required Application

AIP Console will now retrieve the required data. Results are displayed with a numerical indication in the title bar of your sets. This number refers to the number of objects that exactly match the selection criteria defined for your set. In addition, any violations of the model will be listed:

In this example we have the following details:

  • The two custom sets match the following number of objects:
    • Java Constructors = 4
    • Tables = 15
  • The two default sets match the following number of objects:
    • Scope = 4 (same as the Java Constructors custom set)
    • Violations = 1

Therefore in this model we have 1 object that is violating the model: a Java Constructor that directly accesses a database Table.

If you want to publish this model and systematically include it in every new analysis/snapshot, see the instructions in AIP Console - Architecture Studio - Quality Rule models - publish the model.

  • No labels