|Re: Aggregation of Strings of different Objects [message #1413117 is a reply to message #1413098]
||Wed, 27 August 2014 21:09
| Zoltan Ujhelyi
Registered: July 2015
you are right, what you are looking for is not really possible in the graph pattern formalism of EMF-IncQuery. The results of a pattern (that is represented as a set) cannot be ordered directly (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=398768 for some related ideas); however, nothing stops you from loading the results programatically, then ordering the results using a Java comparator (or if you are using Java 8, Xtend or Guava, you can also use similar sort functions to the Epsilon code).
Concatenating string values from model attributes is possible with the eval constraint (https://wiki.eclipse.org/EMFIncQuery/UserDocumentation/QueryLanguage#Advanced_Pattern_Constraints), where you can use Java-like expressions to do the concatenation. However, you cannot combine the results of multiple matches, as that would greatly extend the capabilities of our language.
However, for such tasks as your I would suggest a combined Java/IncQuery approach. Define queries that are used to collect the model elements required for the aggregation, but do not manage the aggregation itself. Then do the aggregation using the results of these elementary patterns in Java code. The result could be similar to the Epsilon code shown above; the imperative code (that is most of the code above) should be written in Java, while the corresponding model element tuples can be assembled using EMF-IncQuery patterns.
I hope, the idea is clear enough. If not, feel free to ask for clarification.
Powered by FUDForum
. Page generated in 0.02489 seconds