Can Be Child - Constraint: Child of each Concept only once

I want to create some kind of optional attributes:

My parent-concept has 0..n children of type Attributes.
Attributes has several sub-concepts.
Now I want to create a constraint so that each sub-concept is only allowed once.
textbox {
length 15
height 10
color blue

The problem:
When i create a constraint "can be child"
and test if the parent concept has already one child of that concept, then it would work as expected.
BUT: The constraint is also called to check the model and then it's not ok, cause now the parent has a one concept and that doesnt fullfill the constraint.

What I would need to do is to know if can be child is called to get the suggestions or if it is called to check the model.

Any ideas on that?

A solution would be if I could access the child's instance when it is available (on the check of the model). Otherwise it could be null.
Comment actions Permalink
You are right - it's not possible to access "this" reference neither from "canBeChild" nor from "canBeParent/Ancestor" constraints now.. Can you please file s feature request for it?
Comment actions Permalink
issue: MPS-12628

Do you have any idea on a work-around?
Comment actions Permalink
Only making single concept Attribute and distinguish between attribute types by some property...
Comment actions Permalink
Sorry Alex, but i don't understand your answer. Could you explain it? Rephrase it?

IMHO this feature is really necessary!
There are many use-cases where you want to do this.
e.g. in the editor (see screenshot)
Comment actions Permalink
You are right. We have to fix this issue.

And as I already said, i do not see any workarounds for now..

Please sign in to leave a comment.