|
Re: Finding all elements of an association in a subtree [message #1007993 is a reply to message #1007892] |
Fri, 08 February 2013 14:52 |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi,
currently there is no operator for traversing the containment hierarchy generically, however, you could use some helper patterns to get what you want. I suggest something as follows:
/*
* Subcategory relation
*/
pattern subCategory(c : Category, s : Category) {
Category.children(c, s);
}
/*
* List of all categories contained in the selected Category 'c'. The result also includes 'c'.
pattern allSubCategories(c : Category, s : Category) {
c == s;
} or {
//This is required as find subCategory+ does no return direct relations; and there is no find subCategory* support in the language
find subCategory(c, s);
} or {
find subCategory+(c, s);
}
@DerivedFeature
pattern allNotes(c: Category, n: Note) {
find allSubCategories(c, s);
Category.notes(s, n);
}
If you would have multiple paths to check in the containment hierarchy, your helper patterns should look for those cases as well.
I hope, this is helps.
Cheers,
Zoltán
|
|
|
Re: Finding all elements of an association in a subtree [message #1008042 is a reply to message #1007993] |
Fri, 08 February 2013 15:53 |
Remy Honig Messages: 4 Registered: March 2012 |
Junior Member |
|
|
Hi Zoltán,
I also found an old github ticket (github.com/ujhelyiz/EMF-IncQuery/issues/350) of your project which I found helpful as well.
My patterns now look like this as you suggested, but I did not add ...or {find subCategories(This, Child);}... and still I get the result I was expecting. Not sure why that is.
private pattern subCategories(This: Category, Child: Category) {
Category.children(This, Child);
}
private pattern thisAndSubCategories(This: Category, Child: Category) {
find subCategories+(This, Child);
} or {
This == Child;
}
@DerivedFeature
pattern allNotes(This: Category, Notes: Note) {
find thisAndSubCategories(This, Child);
Category.notes(Child, Notes);
}
Thank your for your help, I greatly appreciate it.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03945 seconds