Skip to content

How to configure the QR patterns catalogue

marcoriol edited this page Oct 28, 2019 · 1 revision

In order to implement your own QR patterns catalogue, you may start with the example provided at:

https://github.com/q-rapids/qrapids-qr_generation/blob/master/src/main/resources/QRcatalog.json

You may also export your current catalogue in PABRE and use it as the basis to modify the JSON file and import it again. In this case, you will see that the structure of the JSON file includes also a field "id" for each JSON element with an internal numeric identifier. This field is optional, you may include or not a numeric “id” on your new quality requirement pattern.

  • If you include the field “id” in the import, you will force PABRE to use that internal identifier.
  • If you do not include the field “id” in the import, PABRE will create a new internal identifier automatically.

Structure of the JSON file

The JSON file to import a catalogue includes the following mandatory elements:

{
    "metrics": […],
    "patterns": […],
    "schemas": […]
}

To extend the catalogue with a new QR pattern we need to:

  • add an additional entry in the list of patterns, in order to create a new QR pattern.
  • add an additional entry in the list of schemas, in order to map the new QR pattern with a Quality Alert.

Patterns

This JSON element contains the list of QR Patterns of the catalogue. In order to create a new QR pattern, we need to add an additional entry in such list.


"patterns":[
    ...
    // We need to add an additional QR pattern as follows:
    { 
        "name": "Name that identifies your QR pattern",
        "description": "A short description",
        "comments": "Some internal comments",
        "versions": [{ 
        //PABRE allows multiple versions of a QR Pattern but for Q-Rapids, only one version is needed.
            "versionDate": "DD-MM-YYYY hh:mm:ss",
            "author": "Author of this version of the QR pattern",
            "goal": " Goal of this version of the QR pattern (This goal is displayed in the Q-Rapids Dashboard) ",
            "numInstances": 0,
            "available": true,
            "statsNumInstances": 0,
            "statsNumAssociates": 0,
            "artifactsRelation": "",
            "keywords": [],
            "forms": [{
  	    //PABRE allows multiple forms for a QR Pattern version. But for Q-Rapids, only one form is needed.
                "name": "Name that identifies the QR pattern form",
                "description": "Description of the QR Pattern form (This is what will be displayed in Q-Rapids as Description of the QR pattern)",
                "comments": "Some internal comments",
                "author": "Author of the Requirement Pattern form",
                "modificationDate": "DD-MM-YYYY hh:mm:ss",
                "numInstances": 0,
                "statsNumInstances": 0,
                "statsNumAssociates": 0,
                "pos": 0,
                "available": true,
                "fixedPart": {
                    "patternText": "This is what will be displayed in Q-Rapids as ‘Requirement’ (e.g. Ratio of files without critical or blocker quality rule violations should be below %value%)",
                    "questionText": "",
                    "numInstances": 0,
                    "available": true,
                    "statsNumInstances": 0,
                    "artifactsRelation": "",
                    "parameters": [{
                        "name": "value",
                        "correctnessCondition": "Stay between 0 and 100",
                        "description": "",
                        "metricName": "Integer that represents a percentage"
                    }]
                }
            }]
        }],
        "editable": false
    }
]

Schemas

The schema is the element that structures the QR patterns inside internalClassifiers.

An internalClassifiers is an element that is used to map a Quality Alert to the list of Quality Requirements that resolve that alert. Hence, we need to add an additional entry in the list internalClassifiers. The internalClassifiers are organized as follows:

There is a rootClassifiers which includes internalClassifiers. In turn, internalClassifiers can have other internalClassifiers. The structure of the schema should follow the Quality Model defined. The root classifier should have internalClassifiers (e.g. for Quality factors), and those, in turn, can have internalClassifiers (e.g for Quality metrics). This allows that an alert on a Quality factor, can obtain the list of quality requirement patterns that are mapped on its quality metrics.


   "schemas": [
        {
        "name": "Schema Q-rapids",
        "description": "descripcion schema",
        "comments": "",
        "rootClassifiers": [{
            "name": "Root",
            "description": "",
            "comments": "",
            "sourcesByIdentifier": [],
            "type": 0,
            "npatterns": 0,
            "pos": 0,
            "requirementPatterns": [],
            "internalClassifiers": [
             ...
             //we need to add a new internalClassifier as follows:
             {
                "name": "The name that identifies the internalClassifier. It has to be equal to the category of the alert",
                "description": "A short description",
                "comments": "Some comments",
                "sourcesByIdentifier": [],
                "type": 1,
                "internalClassifiers": [
          	  (The list of internalClassifiers that belong to this 
 	    	  internalClassifier. If the InternalClassifier doesn’t 
 		  have other internalClassifiers, the list is empty. 
		  The structure of the internalClassifier is the same 
		  as the structure described in this section.) 
                ],
                "npatterns": 0 (if it is a classifier without direct quality requirements patterns (e.g. for quality factors) of 1 if it is a classifier with 1 quality requirement pattern (e.g. for quality metrics),
                "pos": (Number corresponding to the position of the internalClassifier in the list of internalClassifiers. The first internal classifier in the list has pos=0, the following one, pos=1, etc.)
                "requirementPatterns": [“The list of names that identifies the QR patterns (e.g. “My new QR Pattern 1”, “My new QR Pattern 2”)]
            }]
	}]
  }]      

Importing the catalogue:

To import the catalogue, follow the instructions described at:

https://github.com/q-rapids/qrapids-qr_generation/wiki/How-to-deploy-the-QR-patterns-catalogue-in-the-PABRE-WS-tool