Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » create an instance of association in EMF
create an instance of association in EMF [message #428853] Tue, 31 March 2009 20:08 Go to next message
wws_ques wws_ques is currently offline wws_ques wws_quesFriend
Messages: 64
Registered: July 2009
Member
I noticed that in EMF you can only create an instance of Class that has an
composition to another class, such as the Library Example in the EMF
Validation Tutorial. For example considering the CD:
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.validation.doc/tutorials/validationTutorial.html
I cannot create an instance of Person and Lendable in the 2nd running
Eclipse. In other words, If I removed replace all compositions with
association, I cannot create an instance of all classes except for
Library? So, I must have composition in a class diagram. Thanks.
Wuwei
Re: create an instance of association in EMF [message #428857 is a reply to message #428853] Wed, 01 April 2009 00:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Wuwei,

Comments below

Wuwei wrote:
> I noticed that in EMF you can only create an instance of Class that
> has an composition to another class, such as the Library Example in
> the EMF Validation Tutorial.
By default, the GenFeature properites to support child creation are only
enabled for containment references
> For example considering the CD:
> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.validation.doc/tutorials/validationTutorial.html
>
> I cannot create an instance of Person and Lendable in the 2nd running
> Eclipse.
Yes, that's how the GenModel is configured for that exam;ple.
> In other words, If I removed replace all compositions with
> association, I cannot create an instance of all classes except for
> Library?
By default, yes.
> So, I must have composition in a class diagram. Thanks.
If you enable child creation for non-containment references, you'll need
to specialize the generated item providers so that the child you create
for a non-containment reference is somehow contained by something,
otherwise it will be a dangling reference that can't be serialized.
> Wuwei
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: create an instance of association in EMF [message #428859 is a reply to message #428857] Wed, 01 April 2009 02:13 Go to previous messageGo to next message
wws_ques wws_ques is currently offline wws_ques wws_quesFriend
Messages: 64
Registered: July 2009
Member
Ed,
Thanks for your reply.

>> I noticed that in EMF you can only create an instance of Class that
>> has an composition to another class, such as the Library Example in
>> the EMF Validation Tutorial.
> By default, the GenFeature properites to support child creation are only
> enabled for containment references

And when I add sibling, I still cannot create an instance of a class
which is not contained by another class. In reality, there exist many CDs
where a class is not contained in another class. Like class Student goes
to Class University. In that case, after generating all, I cannot validate
any object diagram which is an instance of the above simiple class
diagram? Is there anyway I can verify the association btw classes Student
and University? Thanks.
Wuwei
>> For example considering the CD:
>>
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.validation.doc/tutorials/validationTutorial.html
>>
>> I cannot create an instance of Person and Lendable in the 2nd running
>> Eclipse.
> Yes, that's how the GenModel is configured for that exam;ple.
>> In other words, If I removed replace all compositions with
>> association, I cannot create an instance of all classes except for
>> Library?
> By default, yes.
>> So, I must have composition in a class diagram. Thanks.
> If you enable child creation for non-containment references, you'll need
> to specialize the generated item providers so that the child you create
> for a non-containment reference is somehow contained by something,
> otherwise it will be a dangling reference that can't be serialized.
>> Wuwei
>>
Re: create an instance of association in EMF [message #428870 is a reply to message #428859] Wed, 01 April 2009 11:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Wuwei,

Comments below.

Wuwei wrote:
> Ed,
> Thanks for your reply.
>
>>> I noticed that in EMF you can only create an instance of Class that
>>> has an composition to another class, such as the Library Example in
>>> the EMF Validation Tutorial.
>> By default, the GenFeature properites to support child creation are
>> only enabled for containment references
>
> And when I add sibling, I still cannot create an instance of a
> class which is not contained by another class.
Sibling creation is just the same as child creation except that you've
specified a particular location at which to insert the new child.
> In reality, there exist many CDs where a class is not contained in
> another class.
I can imagine.
> Like class Student goes to Class University.
I suppose, though that seems like a bad example to me. The university
tends to have a file that contains all the student records.
> In that case, after generating all, I cannot validate any object
> diagram which is an instance of the above simiple class diagram?
Sure, you just have to create lots of resources..
> Is there anyway I can verify the association btw classes Student and
> University? Thanks.
Create a resource with a student, then one for the university, and then
use Load Resource... to load the student resource into the university
resource's editor. At that point you'll be able to use the properties
view to add the student to the universities student reference..
> Wuwei
>>> For example considering the CD:
> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.validation.doc/tutorials/validationTutorial.html
>
>>>
>>> I cannot create an instance of Person and Lendable in the 2nd
>>> running Eclipse.
>> Yes, that's how the GenModel is configured for that exam;ple.
>>> In other words, If I removed replace all compositions with
>>> association, I cannot create an instance of all classes except for
>>> Library?
>> By default, yes.
>>> So, I must have composition in a class diagram. Thanks.
>> If you enable child creation for non-containment references, you'll
>> need to specialize the generated item providers so that the child you
>> create for a non-containment reference is somehow contained by
>> something, otherwise it will be a dangling reference that can't be
>> serialized.
>>> Wuwei
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: create an instance of association in EMF [message #428891 is a reply to message #428870] Wed, 01 April 2009 13:41 Go to previous messageGo to next message
wws_ques wws_ques is currently offline wws_ques wws_quesFriend
Messages: 64
Registered: July 2009
Member
Ed,
Thanks for your reply.

>> Like class Student goes to Class University.
> I suppose, though that seems like a bad example to me. The university
> tends to have a file that contains all the student records.

I think what you said here containment is composition in UML, ,right?
Then, in reality, Class Student should not be contained by Class
University bc when an instance of University does not exist, an instance
of Student still exists and can go to another instance of University.
Otherwise, onbody would like to go to a Unviersity -:). Here, I can
understand the composition between University and StudentRecord.

>> In that case, after generating all, I cannot validate any object
>> diagram which is an instance of the above simiple class diagram?
> Sure, you just have to create lots of resources..
>> Is there anyway I can verify the association btw classes Student and
>> University? Thanks.
> Create a resource with a student, then one for the university, and then
> use Load Resource... to load the student resource into the university
> resource's editor. At that point you'll be able to use the properties
> view to add the student to the universities student reference..

How can I create a resource for Student and University and then load a
Resource... Thanks.
Wuwei
Re: create an instance of association in EMF [message #428894 is a reply to message #428891] Wed, 01 April 2009 13:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Wuwei,

Wuwei wrote:
> Ed,
> Thanks for your reply.
>
>>> Like class Student goes to Class University.
>> I suppose, though that seems like a bad example to me. The
>> university tends to have a file that contains all the student records.
>
> I think what you said here containment is composition in UML,
> ,right? Then, in reality, Class Student should not be contained by
> Class University bc when an instance of University does not exist, an
> instance of Student still exists and can go to another instance of
> University.
But if a student isn't in any university are they actually a student?
Of course a student can simply exist in their own resource without
being contained, so that's not actually a problem.
> Otherwise, onbody would like to go to a Unviersity -:). Here, I can
> understand the composition between University and StudentRecord.
>
>>> In that case, after generating all, I cannot validate any object
>>> diagram which is an instance of the above simiple class diagram?
>> Sure, you just have to create lots of resources..
>>> Is there anyway I can verify the association btw classes Student and
>>> University? Thanks.
>> Create a resource with a student, then one for the university, and
>> then use Load Resource... to load the student resource into the
>> university resource's editor. At that point you'll be able to use
>> the properties view to add the student to the universities student
>> reference..
>
> How can I create a resource for Student and University and then load
> a Resource... Thanks.
The wizard lets you create a resource with any object from your model
and the context menu has the Load Resource... item.
> Wuwei
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: create an instance of association in EMF [message #428900 is a reply to message #428894] Wed, 01 April 2009 14:38 Go to previous messageGo to next message
wws_ques wws_ques is currently offline wws_ques wws_quesFriend
Messages: 64
Registered: July 2009
Member
Ed,

Sorry, I dont get the wizard to create a Resource? Can you tell me
what I should do so that in the EMF Validation Framework Examples I can
create an instance of Lendable? Should I add a new container class that
contains Lendable?In that case, the new model is a different one from the
one shown in the example Thanks.
Wuwei


Wuwei

>> How can I create a resource for Student and University and then load
>> a Resource... Thanks.
> The wizard lets you create a resource with any object from your model
> and the context menu has the Load Resource... item.
>> Wuwei
>>
Re: create an instance of association in EMF [message #428903 is a reply to message #428900] Wed, 01 April 2009 15:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Wuwei,

Comments below.

Wuwei wrote:
> Ed,
>
> Sorry, I dont get the wizard to create a Resource?
I assume you've followed one of the basic introductory tutorials which
shows you how to generate a fully functional editor and of course in
order to open an editor, you need to create a resource with an initial
object. You've not done that?
> Can you tell me what I should do so that in the EMF Validation
> Framework Examples I can create an instance of Lendable? Should I add
> a new container class that contains Lendable?In that case, the new
> model is a different one from the one shown in the example Thanks.
I'm not familiar with the details of every example from every
component. I imagine like every other model, there is a wizard to
create a new instance of the model.
> Wuwei
>
>
> Wuwei
>
>>> How can I create a resource for Student and University and then
>>> load a Resource... Thanks.
>> The wizard lets you create a resource with any object from your model
>> and the context menu has the Load Resource... item.
>>> Wuwei
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: create an instance of association in EMF [message #428916 is a reply to message #428903] Wed, 01 April 2009 19:04 Go to previous messageGo to next message
wws_ques wws_ques is currently offline wws_ques wws_quesFriend
Messages: 64
Registered: July 2009
Member
Ed,
Thank you very much. Now, I understand what you mean about resource. I
have another question. How can I update a generated EMF model after I
adding some new interfaces to src. I used Annotated Java to generate an
EMF model. Thanks.
Wuwei
Re: create an instance of association in EMF [message #428917 is a reply to message #428916] Wed, 01 April 2009 19:16 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Wuwei,

Sure you can use "Reload..." from the context menu for the *.genmodel
file, or when you have it open in the editor, from the Generator menubar
item. Then you regenerate to produce the rest.


Wuwei wrote:
> Ed,
> Thank you very much. Now, I understand what you mean about resource.
> I have another question. How can I update a generated EMF model after
> I adding some new interfaces to src. I used Annotated Java to generate
> an EMF model. Thanks.
> Wuwei
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:serialized EObjects with xmi
Next Topic:Copy paste
Goto Forum:
  


Current Time: Sat Apr 20 01:21:12 GMT 2024

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

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

Back to the top