« Back to AAU Project

Restrict number of contained elements in Group

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
I would like to restrict a specific class that acts as a container to a certain number of instances contained (for example only  5 instances). Is this possible in ADOxx.
Attachment

Attachments: img.png (6.6k)

RE: Restrict number of contained elements in Group
community class cardinality documentation
Answer
6/26/17 11:33 AM as a reply to Anonymous.
Hi,

yes, ADOxx allows you to define such restrictions using Class Cardinalities that can be defined for each class using the "Class cardinality" attribute.

Background: Container/Aggregation Classes
For container elements this is also possible, as any class derived from __D_aggregation__ has an in an invisible relation class associated and is created between the container (=Group) and any instance of class put inside. This relation is called "Is inside" and you can also use a) queries to find the relation as there is not visualization (e.g. AQL Statement:  
1({"INSTANCE_NAME":"Group"}<-"Is inside") OR ({"INSTANCE_NAME":"Group"}->"Is inside"))
or
move the group with all contained elements by holding down the SHIFT key when selecting the group and moving it) THis helps you to check whether the relation is available.

Class Cardinalities
To restrict the maximum number of conainted objects, you have to define a cardinality rule like below:
1RELATION "Is inside"
2max-incoming:5
3max-outgoing:5

This rule needs to be defined in the container class, class attribute "Class cardinalities". An example using the BPMN library from here is shown in the screenshot attached (Restricting the containment to 5 elements for a Group instance).
Further details on the syntax of the class cardinalities are available here: https://www.adoxx.org/live/class-cardinalities and also in the FAQ section in multiple threads.

Cardinalities Check Trigger
The trigger for a rule check can be configured. By default it is manual, meaning the modeller needs to a) have a model open and b) clicks on "Model" -> "Check cardinalities" (see screenshot attached). In case you want to trigger it during the modelling, you can update this as a configuration the in the library attribute "Default configuration" of the dynamic library in chapter "Modelling".

1CHECK_CARDINALITIES before-save: boolVal after-modeling-action: boolVal
where boolVal is 0 or 1. An example configuration for an "before-save" check is shown in the attached screenshot.
The effect is that each modelling step and/or when a model is saved the check is run.
Attachment

Attachment

Attachment

Attachments: Failed Check.png (28.1k), Trigger_Automatic.png (16.6k), Trigger_Manual.png (51.9k)