Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Generated Model Code- ******.impl get, set properties (Set propery code for multiple upper bound references doesn't exist )
Generated Model Code- ******.impl get, set properties [message #1488141] Wed, 26 November 2014 10:45 Go to next message
Basheer Jasser is currently offline Basheer JasserFriend
Messages: 23
Registered: September 2014
Location: University Putra Malaysia...
Junior Member
Hi,

I was exploring the get, set properties for the generated model code for a specific meta-model I'm working on.

I observed that the E-reference with 0-1 upper boundary has set, get properties, but the E-references with 0-* upper boundary (multiple) has only get property while there isn't set property. I need to access this set property to get a some intended behavior.

is there any idea about how these multiple E-references list values being set ?

Thank you in advance
Basheer
Re: Generated Model Code- ******.impl get, set properties [message #1488221 is a reply to message #1488141] Wed, 26 November 2014 12:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30133
Registered: July 2009
Senior Member
Basheer,

Comments below.

On 26/11/2014 11:45 AM, Basheer Jasser wrote:
> Hi,
> I was exploring the get, set properties for the generated model code
> for a specific meta-model I'm working on.
> I observed that the E-reference with 0-1 upper boundary has set, get
> properties, but the E-references with 0-* upper boundary (multiple)
> has only get property while there isn't set property. I need to
> access this set property to get a some intended behavior.
There isn't one and one isn't needed.
>
> is there any idea about how these multiple E-references list values
> being set ?
They're not set. The list that's returned is the state of the model and
you can modify it directly using the List/EList APIs. You might use a
utility like org.eclipse.emf.common.util.ECollections.setEList(EList<T>,
List<? extends T>), but unless the list isn't currently empty,
List.addAll is just as good.
> Thank you in advance Basheer
Re: Generated Model Code- ******.impl get, set properties [message #1488302 is a reply to message #1488221] Wed, 26 November 2014 13:43 Go to previous messageGo to next message
Basheer Jasser is currently offline Basheer JasserFriend
Messages: 23
Registered: September 2014
Location: University Putra Malaysia...
Junior Member
Thanks Ed for your reply. it helped me to start with something for my aim. now Actually I'm having some other issue: using the generated model code for multiple variable or references, there exists the method "public void eSet(int featureID, Object newValue) {}" and it is used to set the list as you mentioned (list.addAll).

I'm having EClass IncludedMachine which is referencing itself by shares EReference which has multiple values (means that every included machine may share with more than one). For example I may have three instances im1, im2 and im3 of IncludedMachine E-class

Setting this property of one included machine im1 to the value im2 is done only in one side of im1 , and I want to happen in the other side im2 to save user time of process repetition. I'm trying to do that using eSet(int featureID, Object newValue) method which is generated in the model code IncludedMachineimpl.java but I'm not really sure how to do that ?

I tried doing that similarly for single valued self E-reference, and the behavior was unexpected and the debugger was unable to run perfectly. Any idea of what to do to set the E-reference in the opposite side im2 instance while setting the E-reference for this im1 instance ??
Re: Generated Model Code- ******.impl get, set properties [message #1488357 is a reply to message #1488302] Wed, 26 November 2014 14:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30133
Registered: July 2009
Senior Member
Basheer,

Comments below.

On 26/11/2014 2:43 PM, Basheer Jasser wrote:
> Thanks Ed for your reply. it helped me to start with something for my
> aim. now Actually I'm having some other issue: using the generated
> model code for multiple variable or references, there exists the
> method "public void eSet(int featureID, Object newValue) {}" and it
> is used to set the list as you mentioned (list.addAll).
Yes, it does a clear and an addAll.
> I'm having EClass IncludedMachine which is referencing itself by
> shares EReference which has multiple values (means that every included
> machine may share with more than one). For example I may have three
> instances im1, im2 and im3 of IncludedMachine E-class
> Setting this property of one included machine im1 to the value im2 is
> done only in one side of im1 , and I want to happen in the other side
> im2 to save user time of process repetition. I'm trying to do that
> using eSet(int featureID, Object newValue) method which is generated
> in the model code IncludedMachineimpl.java but I'm not really sure how
> to do that ?
It sounds like you want a bidirectional reference.
> I tried doing that similarly for single valued self E-reference, and
> the behavior was unexpected and the debugger was unable to run perfectly.
What behavior? What does that have to do with running the debugger?
> Any idea of what to do to set the E-reference in the opposite side im2
> instance while setting the E-reference for this im1 instance ??
It sounds like you want something like two EReferences, i.e.,
Machine.includes and Machine.includers both can be multi-valued of type
Machine and they can be each other's eOpposites. Then if you have two
instance m1 and m2 and do m1.getIncludes().add(m2) you'll find
afterwards m2.getIcluders().contains(m1) is true.
Re: Generated Model Code- ******.impl get, set properties [message #1488961 is a reply to message #1488357] Thu, 27 November 2014 02:24 Go to previous messageGo to next message
Basheer Jasser is currently offline Basheer JasserFriend
Messages: 23
Registered: September 2014
Location: University Putra Malaysia...
Junior Member
Yes Actually I need bidirectional E-References, but the issue is not about including machine m1 and included one m2. it about two machine which share some property and they are exactly equal in roles, there is no difference between m1 and m2 and they both should have the same role for each other (which is shares property).

the issue is that I observed before, while exploring previous topics,that bidirectional E-References are not allowed in the E-core model (E-Opposite property). So I'm trying to handle this using java model code for both single values and multiple values E-references.

Re: Generated Model Code- ******.impl get, set properties [message #1489197 is a reply to message #1488961] Thu, 27 November 2014 07:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30133
Registered: July 2009
Senior Member
Basheer,

Comments below.

On 27/11/2014 3:24 AM, Basheer Jasser wrote:
> Yes Actually I need bidirectional E-References, but the issue is not
> about including machine m1 and included one m2. it about two machine
> which share some property
And what's a property?
> and they are exactly equal in roles,
What are roles? What do equal roles mean?
> there is no difference between m1 and m2 and they both should have the
> same role for each other (which is shares property).
It sounds like you're suggesting it's similar to previous posts of the
idea, Person.friends, where presumably friendship is mutual. This can't
be directly modeled with Ecore (nor EMOF nor UML) because bidirectional
references must be a pair of references (or with UML, and association
must have two different ends). You get into the odd situation of things
like can a Person be their own friend; in the bidirectional hand shaking
this would require special handling.
>
> the issue is that I observed before, while exploring previous
> topics,that bidirectional E-References are not allowed in the E-core
> model (E-Opposite property).
The eOpposite must be a different reference, yes.
> So I'm trying to handle this using java model code for both single
> values and multiple values E-references.
You'd need a special list implementation. It's hard to imagine the
single valued case being useful for anything in the real world. And
even in general, there always seems to be some directionality involved,
i.e., Person.friends doesn't deal with the fact that while I might
consider someone my friend, they might not consider me their friend.
Re: Generated Model Code- ******.impl get, set properties [message #1489429 is a reply to message #1489197] Thu, 27 November 2014 11:01 Go to previous messageGo to next message
Basheer Jasser is currently offline Basheer JasserFriend
Messages: 23
Registered: September 2014
Location: University Putra Malaysia...
Junior Member
Ed,

Actually from my understanding of E-core models, E-class is meant to represent an abstract concept which may be instantiated during run-time. So for example when we are talking about Machine E-class, it could be instantiated into M1 and M2 which it is represented same E-class during E-core modeling. So it's not that I'm giving a relationship for the machine with itself rather than providing an option for Machine E-class instances to have this shares relationship among them. This is how I actually get the idea and tried to implement it.
Re: Generated Model Code- ******.impl get, set properties [message #1489523 is a reply to message #1489429] Thu, 27 November 2014 12:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30133
Registered: July 2009
Senior Member
Basheer,

Comments below.

On 27/11/2014 12:01 PM, Basheer Jasser wrote:
> Ed,
> Actually from my understanding of E-core models, E-class is meant to
> represent an abstract concept which may be instantiated during run-time.
Yes.
> So for example when we are talking about Machine E-class, it could be
> instantiated into M1 and M2 which it is represented same E-class
> during E-core modeling.
Yes.
> So it's not that I'm giving a relationship for the machine with itself
> rather
Given this shares relation is on Machine there would not nothing
preventing a machine from sharing itself, whatever that means.
> than providing an option for Machine E-class instances to have this
> shares relationship among them.
Yes, so a machine instance has the option to share itself.
> This is how I actually get the idea and tried to implement it.
So there are no more questions...
Re: Generated Model Code- ******.impl get, set properties [message #1489538 is a reply to message #1489523] Thu, 27 November 2014 13:02 Go to previous messageGo to next message
Basheer Jasser is currently offline Basheer JasserFriend
Messages: 23
Registered: September 2014
Location: University Putra Malaysia...
Junior Member
Ed, Thanks a lot for your replies.

in the E-core model Machine E-class is sharing itself. During the run time I have M1 and M2 as instances of Machine E-class. When setting (M1.shares = M2) then (M2.shares=null). What I want is when setting shares property for M1 (M1.shares=M2), M2 shares property is also set to M1 automatically (M2.shares=M1). Because the relationship between M1 and M2 is reflexive. For the time being, I should set the shares property for both M1 and M2 using two processes while I'm trying to save it in one process to make more usable and applicable. I'm trying to do it using jave model code eSet (){} method (multiple values) setShares(){} (single value). Any advice in this context ???



Re: Generated Model Code- ******.impl get, set properties [message #1489602 is a reply to message #1489538] Thu, 27 November 2014 14:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30133
Registered: July 2009
Senior Member
Basheer,

Comments below.

On 27/11/2014 2:02 PM, Basheer Jasser wrote:
> Ed, Thanks a lot for your replies.
>
> in the E-core model Machine E-class is sharing itself. During the run
> time I have M1 and M2 as instances of Machine E-class. When setting
> (M1.shares = M2) then (M2.shares=null).
Are these like toy examples? I've already explained that an EReference
can't be its own opposite. Sorry about that, but it's the way it is.
> What I want is when setting shares property for M1 (M1.shares=M2), M2
> shares property is also set to M1 automatically (M2.shares=M1).
Like a bidirectional reference but I've explained that just doesn't work.
> Because the relationship between M1 and M2 is reflexive.
Yes, presumably like friendship.
> For the time being, I should set the shares property for both M1 and
> M2 using two processes while I'm trying to save it in one process to
> make more usable and applicable.
I have to wonder what it's used for and what it's applicable too.
> I'm trying to do it using jave model code eSet (){} method (multiple
> values) setShares(){} (single value). Any advice in this context ???
Don't try. Implementing directional references is extremely
complicated and you won't get it right, ever. And even if you did get
it right, the framework won't expect the behavior you've implemented, so
and command framework won't work, notifications will be confusing to the
adapter/listeners, you'll have a hard time deserializing the results,
copying the objects, and so on. It's a rat hole that you ought to avoid.


>
>
>
Re: Generated Model Code- ******.impl get, set properties [message #1490266 is a reply to message #1489602] Fri, 28 November 2014 03:02 Go to previous messageGo to next message
Basheer Jasser is currently offline Basheer JasserFriend
Messages: 23
Registered: September 2014
Location: University Putra Malaysia...
Junior Member
Ed., below are my comments

> in the E-core model Machine E-class is sharing itself. During the run
> time I have M1 and M2 as instances of Machine E-class. When setting
> (M1.shares = M2) then (M2.shares=null).
Are these like toy examples? I've already explained that an EReference
can't be its own opposite. Sorry about that, but it's the way it is.

* Actually these are part of research project UML-B and Event-B in which EMF is used for UML-B meta-model.

> What I want is when setting shares property for M1 (M1.shares=M2), M2
> shares property is also set to M1 automatically (M2.shares=M1).
Like a bidirectional reference but I've explained that just doesn't work.

* In this project I really need the situation to be like that M1 is sharing a property with M2 and same applies to M2.

> Because the relationship between M1 and M2 is reflexive.
Yes, presumably like friendship.

* relationship between M1 and M2 is reflexive and it should be like that for my theoretical aim.

> For the time being, I should set the shares property for both M1 and
> M2 using two processes while I'm trying to save it in one process to
> make more usable and applicable.
I have to wonder what it's used for and what it's applicable too.

* if I only allow M1 to share with M2, it means that only M1 has access to M2 attributes and events which is not the intended case. That's why I need also to make M2 shares its attributes and events with M1. May be this way is E-reference is not the best way to do it, but theoretically this is how want it to be for my aim.

> I'm trying to do it using jave model code eSet (){} method (multiple
> values) setShares(){} (single value). Any advice in this context ???
Don't try. Implementing directional references is extremely
complicated and you won't get it right, ever. And even if you did get
it right, the framework won't expect the behavior you've implemented, so
and command framework won't work, notifications will be confusing to the
adapter/listeners, you'll have a hard time deserializing the results,
copying the objects, and so on. It's a rat hole that you ought to avoid.

* maybe I should change the recent meta-model trying to achieve my theoretical aim, or I just stick with adding both shares properties through two steps for both M1 and M2. And really thank you for alerting me trying this way so that I save my time and don't try something unavailable to be implemented.
Re: Generated Model Code- ******.impl get, set properties [message #1490478 is a reply to message #1490266] Fri, 28 November 2014 07:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30133
Registered: July 2009
Senior Member
Basheer,

Notice that EReference.eOpposite itself is of this nature and there too
it cannot be made its own opposite and so both sides must be set
explicitly and there is a constraint define that checks that the
r.getEOpposite() == null || r.getEOpposite().getEOpposite() == r. In
this case the generated item provider is modified so that the user in
the editor does not need to set both sides

On 28/11/2014 4:02 AM, Basheer Jasser wrote:
> Ed., below are my comments
>
>> in the E-core model Machine E-class is sharing itself. During the run
>> time I have M1 and M2 as instances of Machine E-class. When setting
>> (M1.shares = M2) then (M2.shares=null).
> Are these like toy examples? I've already explained that an EReference
> can't be its own opposite. Sorry about that, but it's the way it is.
>
> * Actually these are part of research project UML-B and Event-B in
> which EMF is used for UML-B meta-model.
>> What I want is when setting shares property for M1 (M1.shares=M2), M2
>> shares property is also set to M1 automatically (M2.shares=M1).
> Like a bidirectional reference but I've explained that just doesn't work.
>
> * In this project I really need the situation to be like that M1 is
> sharing a property with M2 and same applies to M2.
>> Because the relationship between M1 and M2 is reflexive.
> Yes, presumably like friendship.
>
> * relationship between M1 and M2 is reflexive and it should be like
> that for my theoretical aim.
>> For the time being, I should set the shares property for both M1 and
>> M2 using two processes while I'm trying to save it in one process to
>> make more usable and applicable.
> I have to wonder what it's used for and what it's applicable too.
>
> * if I only allow M1 to share with M2, it means that only M1 has
> access to M2 attributes and events which is not the intended case.
> That's why I need also to make M2 shares its attributes and events
> with M1. May be this way is E-reference is not the best way to do it,
> but theoretically this is how want it to be for my aim.
>> I'm trying to do it using jave model code eSet (){} method (multiple
>> values) setShares(){} (single value). Any advice in this context ???
> Don't try. Implementing directional references is extremely
> complicated and you won't get it right, ever. And even if you did get
> it right, the framework won't expect the behavior you've implemented, so
> and command framework won't work, notifications will be confusing to the
> adapter/listeners, you'll have a hard time deserializing the results,
> copying the objects, and so on. It's a rat hole that you ought to avoid.
>
> * maybe I should change the recent meta-model trying to achieve my
> theoretical aim, or I just stick with adding both shares properties
> through two steps for both M1 and M2. And really thank you for
> alerting me trying this way so that I save my time and don't try
> something unavailable to be implemented.
Re: Generated Model Code- ******.impl get, set properties [message #1493885 is a reply to message #1490478] Mon, 01 December 2014 03:00 Go to previous messageGo to next message
Basheer Jasser is currently offline Basheer JasserFriend
Messages: 23
Registered: September 2014
Location: University Putra Malaysia...
Junior Member
Ed,

are you suggesting adding OCL constraint in order to fulfill the requirement of automatically adding the E-Opposite without the user intervention ?

if so., I started doing that with opening Ecore model using OCLineEcore Editor, and adding the necessary operation and invariant. This eventually must be reflected in the generated java item provider. Am I on the right way of doing it ??

Re: Generated Model Code- ******.impl get, set properties [message #1494186 is a reply to message #1493885] Mon, 01 December 2014 08:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30133
Registered: July 2009
Senior Member
Basheer,

No, that's not what I'm suggesting. I'm suggesting you do something
like what's done in
org.eclipse.emf.ecore.provider.EReferenceItemProvider.addEOppositePropertyDescriptor(Object).
I.e., ensure that in the editor you get this automatic behavior to make
life easier for the user, but just live with the behavior in the
programmatic API itself.


On 01/12/2014 4:00 AM, Basheer Jasser wrote:
> Ed,
> are you suggesting adding OCL constraint in order to fulfill the
> requirement of automatically adding the E-Opposite without the user
> intervention ?
> if so., I started doing that with opening Ecore model using
> OCLineEcore Editor, and adding the necessary operation and invariant.
> This eventually must be reflected in the generated java item provider.
> Am I on the right way of doing it ??
>
>
Re: Generated Model Code- ******.impl get, set properties [message #1494423 is a reply to message #1494186] Mon, 01 December 2014 13:09 Go to previous messageGo to next message
Basheer Jasser is currently offline Basheer JasserFriend
Messages: 23
Registered: September 2014
Location: University Putra Malaysia...
Junior Member
Ed,

I searched for org.eclipse.emf.ecore.provider.EReferenceItemProvider java class. I was able to find it in the javadoc EMF documentation "http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/". I tried also to get the source code from EMF repository (here are the links "http://git.eclipse.org/c/emf/org.eclipse.emf.git/snapshot/R2_10_1.zip" and "http://www.eclipse.org/modeling/download.php?file=/modeling/emf/emf/downloads/drops/2.10.1/R201409011055/emf-xsd-Update-2.10.1.zip" emf sdk repository). I'm not able to find EReferenceItemProvider.java class in this repository. The class which I found and may help my aim is EReferenceImpl which includes "getEOpposite(), basicGetEOpposite(), setEOpposite(EReference newEOpposite), and other methods".

where can I find EReferenceItemProvider class and its method addEOppositePropertyDescriptor(Object) ?

Many thanks in advance
Re: Generated Model Code- ******.impl get, set properties [message #1494524 is a reply to message #1494423] Mon, 01 December 2014 14:46 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30133
Registered: July 2009
Senior Member
http://git.eclipse.org/c/emf/org.eclipse.emf.git/tree/plugins/org.eclipse.emf.ecore.edit/src/org/eclipse/emf/ecore/provider/EReferenceItemProvider.java

On 01/12/2014 2:09 PM, Basheer Jasser wrote:
> Ed,
> I searched for org.eclipse.emf.ecore.provider.EReferenceItemProvider
> java class. I was able to find it in the javadoc EMF documentation
> "http://download.eclipse.org/modeling/emf/emf/javadoc/2.10.0/". I
> tried also to get the source code from EMF repository (here are the
> links
> "http://git.eclipse.org/c/emf/org.eclipse.emf.git/snapshot/R2_10_1.zip" and
> "http://www.eclipse.org/modeling/download.php?file=/modeling/emf/emf/downloads/drops/2.10.1/R201409011055/emf-xsd-Update-2.10.1.zip"
> emf sdk repository). I'm not able to find EReferenceItemProvider.java
> class in this repository. The class which I found and may help my aim
> is EReferenceImpl which includes "getEOpposite(), basicGetEOpposite(),
> setEOpposite(EReference newEOpposite), and other methods".
>
> where can I find EReferenceItemProvider class and its method
> addEOppositePropertyDescriptor(Object) ?
> Many thanks in advance
Previous Topic:Custom EMF-based TreeViewer for E4
Next Topic:[CDO] interface CDOStaleObject not visible from class loader for legacy model
Goto Forum:
  


Current Time: Thu May 23 18:44:44 GMT 2019

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

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

Back to the top