Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF-IncQuery » Unique names of derived features?
Unique names of derived features? [message #1250477] Wed, 19 February 2014 09:30 Go to next message
Emre T is currently offline Emre TFriend
Messages: 119
Registered: April 2013
Senior Member
Hello,

do the names of the derived features in a model have to be unique, so that they can be declared as well behaving derived feature queries? Because I believe that this is not possible to declare a pattern with the same name twice, but also the pattern names have to be the same as the name of the derived feature they are querying or they have the "feature" parameter in QueryBasedFeature annotation to reference the derived feature.

Is there a workaround for this? Since the model I am building has lots of specific model elements, which might have the same kind of derived reference. And giving all of them different names would be cumbersome.

Thanks!

Emre
Re: Unique names of derived features? [message #1250493 is a reply to message #1250477] Wed, 19 February 2014 09:46 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 246
Registered: July 2009
Senior Member
Hi,

for the exact same reason you mentioned, it is possible to add parameters to the @QueryBasedFeature annotation, selecting the feature, source and target values, instead of relying on the convention of the pattern name and parameter settings.

You are most likely interested in the feature, source and target parameters.

Cheers,
Zoltán
Re: Unique names of derived features? [message #1250538 is a reply to message #1250493] Wed, 19 February 2014 10:31 Go to previous messageGo to next message
Emre T is currently offline Emre TFriend
Messages: 119
Registered: April 2013
Senior Member
Ok, I thought so. An example for the usage of the annotation parameters would be like this then:

Lets say we have two model elements "A" and "B", which have a derived reference with the same name "derivedReference" and the same type (e.g. "Class" element from model being referenced). When I define the two patterns for these two derived references, I could do it as the following.

@QueryBasedFeature (feature = "derivedReference", source = "A", target = "Class")
pattern firstDerivedReference (This: A, Target: Class) { ... }


@QueryBasedFeature (feature = "derivedReference", source = "B", target = "Class")
pattern secondDerivedReference (This: B, Target: Class) { ... }


Would it be the right usage? Could EMF IncQuery then differentiate between the two derived references and generate the notifiers accordingly?

Best regards,
Emre

[Updated on: Wed, 19 February 2014 10:31]

Report message to a moderator

Re: Unique names of derived features? [message #1250539 is a reply to message #1250538] Wed, 19 February 2014 10:32 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 246
Registered: July 2009
Senior Member
Hi,

as far as I understand it, yes. If not, please report it back as a bug. Smile

Zoltán
Re: Unique names of derived features? [message #1250544 is a reply to message #1250538] Wed, 19 February 2014 10:37 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 116
Registered: July 2009
Senior Member
Just a quick response, the example you wrote is not exactly correct.

The 'source' and 'target' parameters refer to _parameters_, not EClasses. So in your case, use:

@QueryBasedFeature (feature = "derivedReference", source = This, target = Target)
pattern firstDerivedReference (This: A, Target: Class) { ... }


@QueryBasedFeature (feature = "derivedReference", source = This, target = Target)
pattern secondDerivedReference (This: B, Target: Class) { ... }


As written in the wiki, you don't have to declare 'source' and 'target' if only two parameters are used in the query and the first is the source and the second is the target.

Edit: I corrected the example to make sure the information is correct for future readers.

[Updated on: Mon, 24 February 2014 00:46]

Report message to a moderator

Re: Unique names of derived features? [message #1250551 is a reply to message #1250544] Wed, 19 February 2014 10:47 Go to previous messageGo to next message
Emre T is currently offline Emre TFriend
Messages: 119
Registered: April 2013
Senior Member
Ok, but will IncQuery still be able to differentiate which pattern corresponds to which derived feature from the query pattern parameters, so the generation of the getters/notifiers happen accordingly?

Emre
Re: Unique names of derived features? [message #1250557 is a reply to message #1250551] Wed, 19 February 2014 10:54 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 246
Registered: July 2009
Senior Member
Hi,

as I said it before, it should be working this way. If you try it out and does not work, please report back that as a bug.

Cheers,
Zoltán
Re: Unique names of derived features? [message #1250573 is a reply to message #1250557] Wed, 19 February 2014 11:15 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 116
Registered: July 2009
Senior Member
Yes, the differentiation happens because in one case, the type of 'This' is 'A', while in the other case, it's 'B'. The generation should happen correctly.
Re: Unique names of derived features? [message #1251805 is a reply to message #1250573] Thu, 20 February 2014 16:14 Go to previous messageGo to next message
Emre T is currently offline Emre TFriend
Messages: 119
Registered: April 2013
Senior Member
Hello, as far as I can see, they are functioning correctly. Thanks again!
Re: Unique names of derived features? [message #1254940 is a reply to message #1251805] Mon, 24 February 2014 00:36 Go to previous messageGo to next message
Emre T is currently offline Emre TFriend
Messages: 119
Registered: April 2013
Senior Member
Hello again,

I needed to use the parameters again, and I am getting the following error: Invalid parameter type String. Expected Variable

I use them, like you have corrected:
@QueryBasedFeature (feature = "ref", source = "This", target = "Target")
pattern refQuery(This: A, Middle: B, Target: C) = { ... }


The source is the derived feature is A, the target is B, but I have to make a definitive stop at the Middle B, to be able traverse the model.

What might be the reason?

Thanks!

EDIT: Ok, it's solved, clearly, I should have been more careful to the error. After removing quotes, it was gone.

[Updated on: Mon, 24 February 2014 00:44]

Report message to a moderator

Re: Unique names of derived features? [message #1254947 is a reply to message #1254940] Mon, 24 February 2014 00:47 Go to previous message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 116
Registered: July 2009
Senior Member
Yes, I incorrectly added the quotes when replying. Great to hear you got it working, I edited my reply for future reference.
Previous Topic:Queries for derived features with constrains
Next Topic:Variable has a type which has multiple definitions
Goto Forum:
  


Current Time: Tue May 05 12:26:44 GMT 2015

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

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