Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EMF-IncQuery » Distinct Query
Distinct Query [message #1243743] Tue, 11 February 2014 06:33 Go to next message
Christian Mohr is currently offline Christian Mohr
Messages: 14
Registered: June 2012
Junior Member
Hi again,

i'am thinking about a way to create a distinct pattern result, but i can't come up with a solution.

Example:
Lets say there are multiple Students (your school example + students with fore- and surname) with the same surname. Now i want to get all distinct surnames. (duplicate surnames shouldn't match).

Is there a way with incquery or is it impossible at the moment?

Thanks for any advice/help.

Greets Christian
Re: Distinct Query [message #1243746 is a reply to message #1243743] Tue, 11 February 2014 06:39 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel Hegedus
Messages: 62
Registered: July 2009
Member
Did you try the "getAllValuesOfX" methods? (see https://wiki.eclipse.org/EMFIncQuery/UserDocumentation/API#Matcher)
Re: Distinct Query [message #1243757 is a reply to message #1243746] Tue, 11 February 2014 06:53 Go to previous message
Gabor Bergmann is currently offline Gabor Bergmann
Messages: 12
Registered: July 2009
Junior Member
Also, if you need to use the set of all distinct surnames in the definition of another pattern, you can capture it as a pattern as well:
pattern surname(name) = {
 Person.surname(_somePerson, name);
}

Since match results always have SET semantics in the mathematical sense (i.e. matches do not have multiplicities, each combination of pattern parameters is either in the query results exactly once or it doesn't match at all), here every string that is a surname of a Person in the model will appear exactly once in the match set of the pattern.

Note that the above pattern is different from the following one:
pattern surname(person, name) = { // notice the additional parameter
 Person.surname(person, name);
}

In the second example the same name will appear multiple times in the query results, if there are multiple Persons with the same surname.
Previous Topic:IncQuery support for XText 2.5
Next Topic:setSelectionToViewer NoSuchMethod exception
Goto Forum:
  


Current Time: Sat Apr 19 00:44:00 EDT 2014

Powered by FUDForum. Page generated in 0.01454 seconds