Volker Eckardt's picture

Hello Aris Community,

today I like to share with you two simple examples how to implement extended semantic checks. The requirement is the following:

  • Semantic check for a "function attribute to be equal or greater than 5"
  • Semantic check for a "function attribute to follow a certain format, here CCC-NN-NN".

To implement such checks you need to work with JavaScript. This guide helps you to understand and implement your own validations.

Let's start!

1. We need to define our two custom rule types.

2. Right click on Administration > Evaluation > Semantic checks > Rule Types, and follow the wizard steps.

3. Enter the name and the context. In this case we will perform the checks on model level of type BPMN.

4. Accept the default output formats.

5. Now define the two rules itself. Notice that you have only to define a name here.

6. And this is the second rule definition:

7. Now we have the rules defined. Let's now check what code we already got. Switch over to the Script section and naviagte again to the just defined Rule. You will see two function fragments, we need now to define the check itself.

8. First we should define some globals, the language is important. The ruleTypeId is the Id you can get from the properties itself.

9. For the first function we will add some code, it mainly loops through the given model and through the objects in it (here functions only). The constant AT_BPMN_START_QUANT is the attribute you are going to check.

10. The validation is right here, I like to react in case the number is lower than 5 or not maintained. The additional code lines take care about the error reporting.

11.  Some more lines to provide a nice layout, and fill the statistic, if requested.

12. The code for the second check looks quite similar, whereas the semantic check itself and the error message are different. The attribute to check here is determined by the constant AT_ID.

13. The code closes with some helper functions for the sematic check printout.

13b. For sure we are maintaining the text elements in the string table (in German and English):

 

14. Now, as the checks itself are ready, we need to call them. I am using my own Custom Semantic Check profile for easier testing. You may also attach these new checks to other, already existing profiles.

15. Such a profile you can again define by using a wizard.

16. And in the second step you link the checks into it.

Now, let's test the two new check!

17. Right click on the model > semantic check. Choose your own profile, in my case it is the "Custom  Semantic Check".

18. Choose the output options. To get also the inline warnings and tool tip, check everything.

 

19. That's our result

 

20. And the inline warnings and tool tips are looking like this.

 

You can download the whole code from the links below:

I hope this example helps you to understand the strength of symantic checks in Aris!

Best Regards

Volker

Tags: script