Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EReference on a default ID
EReference on a default ID [message #431116] Mon, 29 June 2009 16:26 Go to next message
Eclipse UserFriend
Originally posted by: guillaume.surrel.scalagent.com

Hi all,

I'm new to emf and I'm currently stuck on something.
Here is my problem :
I've made an EClass 'B' which has an EReference 'link' on an EClass 'A'.
'A' has an EAttribute 'id' with the ID attribute set to true.

The problem is that I have something like this in the resulting XML :
<A id="default">
<B link="//@A.0">
instead of
<A id="default">
<B link="default">
when the id on A is not set and has the default value. Everything is as
expected when I explicitly set the id value of class A using the
properties view.


Thank you.
Re: EReference on a default ID [message #431119 is a reply to message #431116] Mon, 29 June 2009 16:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30685
Registered: July 2009
Senior Member
Guillaume,

The ID must be set to used. Are you suggesting you made "default" the
default value for the id attribute? That's not a good idea, because if
there is more than one 'A' they will have the same ID value, which is
invalid, and so you'll still have to set it.


Guillaume Surrel wrote:
> Hi all,
>
> I'm new to emf and I'm currently stuck on something.
> Here is my problem :
> I've made an EClass 'B' which has an EReference 'link' on an EClass 'A'.
> 'A' has an EAttribute 'id' with the ID attribute set to true.
>
> The problem is that I have something like this in the resulting XML :
> <A id="default">
> <B link="//@A.0">
> instead of
> <A id="default">
> <B link="default">
> when the id on A is not set and has the default value. Everything is
> as expected when I explicitly set the id value of class A using the
> properties view.
>
>
> Thank you.
Re: EReference on a default ID [message #431144 is a reply to message #431119] Tue, 30 June 2009 09:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: guillaume.surrel.scalagent.com

Thanks Ed for the quick reply.

Ed Merks a écrit :
> Guillaume,
>
> The ID must be set to used.
I'm not sure what you mean by this. Is this about eIsSet method
returning true ? Because modifying the generated code to do it seems to
do exactly what I'm expecting.

> Are you suggesting you made "default" the
> default value for the id attribute?
Exactly.

> That's not a good idea, because if
> there is more than one 'A' they will have the same ID value, which is
> invalid, and so you'll still have to set it.
Of course, but the purpose is to save a little time when keeping default
id value.


>
> Guillaume Surrel wrote:
>> Hi all,
>>
>> I'm new to emf and I'm currently stuck on something.
>> Here is my problem :
>> I've made an EClass 'B' which has an EReference 'link' on an EClass 'A'.
>> 'A' has an EAttribute 'id' with the ID attribute set to true.
>>
>> The problem is that I have something like this in the resulting XML :
>> <A id="default">
>> <B link="//@A.0">
>> instead of
>> <A id="default">
>> <B link="default">
>> when the id on A is not set and has the default value. Everything is
>> as expected when I explicitly set the id value of class A using the
>> properties view.
>>
>>
>> Thank you.
Re: EReference on a default ID [message #431146 is a reply to message #431144] Tue, 30 June 2009 09:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30685
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040600060109050106010909
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Guillaume,

Comments below.

Guillaume Surrel wrote:
>
> Thanks Ed for the quick reply.
>
> Ed Merks a
Re: EReference on a default ID [message #431156 is a reply to message #431146] Tue, 30 June 2009 11:19 Go to previous message
Eclipse UserFriend
Originally posted by: guillaume.surrel.scalagent.com

Ed Merks a écrit :
> Yes because it's implemented like this in EcoreUtil
>
> public static String getID(EObject eObject)
> {
> EClass eClass = eObject.eClass();
> EAttribute eIDAttribute = eClass.getEIDAttribute();
> return eIDAttribute == null || !eObject.eIsSet(eIDAttribute) ?
> null : convertToString(
> eIDAttribute.getEAttributeType(),
> eObject.eGet(eIDAttribute));
> }

Ok, thanks for pointing this out.

>>> That's not a good idea, because if there is more than one 'A' they
>>> will have the same ID value, which is invalid, and so you'll still
>>> have to set it.
>> Of course, but the purpose is to save a little time when keeping
>> default id value.
> It's common for there to be only one A in the resource?

Yes, there will be more likely a very small number of A.
Previous Topic:Regarding XPand template file
Next Topic:Proper namespace generation in document root
Goto Forum:
  


Current Time: Sat Dec 07 14:51:33 GMT 2019

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

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

Back to the top