Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » EMF-IncQuery » Find the feature of changed elements(Find the feature of changed elements)
Find the feature of changed elements [message #1703378] Fri, 31 July 2015 08:12 Go to next message
Van Cam PHAM is currently offline Van Cam PHAMFriend
Messages: 13
Registered: July 2015
Junior Member
Hi,
I'm working with Incquery and I have a question that if I have a value that is contained by a container. How can I find the feature of the container corresponding to the value. For example, I have a feature value (an operation or attribute), I want to to find the feature ownedOperation or onwedAttribute, respectively. I can get it programmatically by get all feature values and check if ithey contain the given value.

Thanks,
Re: Find the feature of changed elements [message #1703384 is a reply to message #1703378] Fri, 31 July 2015 08:37 Go to previous messageGo to next message
Gabor Bergmann is currently offline Gabor BergmannFriend
Messages: 28
Registered: July 2009
Junior Member
Hi Van Cam,

I think you might find that EObject#eContainer(), combined with EObject#eContainingFeature() or EObject#eContainmentFeature(), will do what you want for EObject values.

And if you want to find which EObject has a given value in which of their attributes, I recommend using NavigationHelper in the EMF-IncQuery Base API, specifically NavigationHelper#findByAttributeValue(Object).

Cheers,
Gábor
Re: Find the feature of changed elements [message #1703385 is a reply to message #1703378] Fri, 31 July 2015 08:48 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 343
Registered: July 2015
Senior Member
Hi,

for index performance reasons, IncQuery current does not support referencing the containment hierarchy directly, however, if you know which features to check, there is a workaround for that: you can have a pattern that provides the union of all features. For example, see the following helper pattern:

pattern container(EObject container, EObject object) {
  Class.ownedOperation(container, object);
} or {
  StructuredClassifier.ownedAttributes(container, object);
} or {
  //You have to have a body for all interesting containment references
 ...
}

If you have this pattern, and bind the second parameter to the value you have, the matcher will bind the first parameter to the container. This is equivalent of getting all feature values and checking whether they are contained.

I hope, this idea helps. If not, feel free to ask for clarification.

Cheers,
Zoltán
Re: Find the feature of changed elements [message #1703386 is a reply to message #1703384] Fri, 31 July 2015 08:48 Go to previous messageGo to next message
Van Cam PHAM is currently offline Van Cam PHAMFriend
Messages: 13
Registered: July 2015
Junior Member
Hi Gabor,

It's exactly what I'm looking for. I will check it.

Thanks
Re: Find the feature of changed elements [message #1703387 is a reply to message #1703385] Fri, 31 July 2015 08:52 Go to previous messageGo to next message
Van Cam PHAM is currently offline Van Cam PHAMFriend
Messages: 13
Registered: July 2015
Junior Member
Zoltan Ujhelyi wrote on Fri, 31 July 2015 08:48
Hi,

for index performance reasons, IncQuery current does not support referencing the containment hierarchy directly, however, if you know which features to check, there is a workaround for that: you can have a pattern that provides the union of all features. For example, see the following helper pattern:

pattern container(EObject container, EObject object) {
  Class.ownedOperation(container, object);
} or {
  StructuredClassifier.ownedAttributes(container, object);
} or {
  //You have to have a body for all interesting containment references
 ...
}



Hi Zoltan,

Yes I'm using this kind of query and transitive closure to find the containment hierarchy and it works. But I'm looking for if I can get the feature of the container corresponding to the given value
Re: Find the feature of changed elements [message #1703388 is a reply to message #1703384] Fri, 31 July 2015 08:58 Go to previous messageGo to next message
Van Cam PHAM is currently offline Van Cam PHAMFriend
Messages: 13
Registered: July 2015
Junior Member
Gabor Bergmann wrote on Fri, 31 July 2015 08:37
Hi Van Cam,

I think you might find that EObject#eContainer(), combined with EObject#eContainingFeature() or EObject#eContainmentFeature(), will do what you want for EObject values.


Hi Gabor, I've tried this but it does not work. Did you try it or do you have any example?
Re: Find the feature of changed elements [message #1703393 is a reply to message #1703388] Fri, 31 July 2015 09:19 Go to previous message
Gabor Bergmann is currently offline Gabor BergmannFriend
Messages: 28
Registered: July 2009
Junior Member
Van Cam PHAM wrote on Fri, 31 July 2015 10:58

Hi Gabor, I've tried this but it does not work.


Does not work how?
Did you read the Javadoc?

Anyway, I think you should ask about your difficulties with these methods at the EMF forum instead, since the EMF Java API does not have anything to do with IncQuery.

[Updated on: Fri, 31 July 2015 09:19]

Report message to a moderator

Previous Topic:Using Incquery as EVM for notifying UML papyrus changes
Next Topic:no packages to be imported in query definition wizard?
Goto Forum:
  


Current Time: Tue Nov 20 14:00:45 GMT 2018

Powered by FUDForum. Page generated in 0.02888 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top