Home » Modeling » EMF » create an instance of association in EMF
|
Re: create an instance of association in EMF [message #428857 is a reply to message #428853] |
Wed, 01 April 2009 00:21 |
Ed Merks 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 |
wws_ques wws_ques 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 |
Ed Merks 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 |
wws_ques wws_ques 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 |
Ed Merks 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 #428917 is a reply to message #428916] |
Wed, 01 April 2009 19:16 |
Ed Merks 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/
|
|
|
Goto Forum:
Current Time: Sat Apr 20 01:21:12 GMT 2024
Powered by FUDForum. Page generated in 0.03607 seconds
|