Introduction
This page explains the creation of a hypothetical Quality Rule model (see AIP Console - Architecture Studio for more information about the different models available) 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 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.
|
- 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.
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:
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
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 - Publishing models.