Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Save EList
Save EList [message #424852] Fri, 07 November 2008 02:13 Go to next message
Oelerink is currently offline OelerinkFriend
Messages: 129
Registered: July 2009
Senior Member
Hello,

i have an Object with two multi-valued attributes. One of these
attributes is editable over a gmf editor. the other attribute is
effected programmatically. When i save the object, there is only the
first attribute saved. The second is not in the xmi representation. Why
is that?

Thanks for your help
Jörg Oelerink
Re: Save EList [message #424859 is a reply to message #424852] Fri, 07 November 2008 10:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Jörg,

Maybe it's marked with EStructuralFeature.transient being true? Of
maybe EObject.eIsSet(<feature>) returns false indicating the value is
not or or isn't different from the default.


Jörg wrote:
> Hello,
>
> i have an Object with two multi-valued attributes. One of these
> attributes is editable over a gmf editor. the other attribute is
> effected programmatically. When i save the object, there is only the
> first attribute saved. The second is not in the xmi representation.
> Why is that?
>
> Thanks for your help
> Jörg Oelerink


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Save EList [message #424897 is a reply to message #424859] Mon, 10 November 2008 10:43 Go to previous messageGo to next message
Oelerink is currently offline OelerinkFriend
Messages: 129
Registered: July 2009
Senior Member
Hello,

thanks a lot,but it depends on the containment feature. I add every
single element on this way:
resource.getContents().add((EObject) entry.getValue());

is there a better way, so i can have containments, which are saved in
the xmi representation?

Greetings

Ed Merks schrieb:
> Jörg,
>
> Maybe it's marked with EStructuralFeature.transient being true? Of
> maybe EObject.eIsSet(<feature>) returns false indicating the value is
> not or or isn't different from the default.
>
>
> Jörg wrote:
>> Hello,
>>
>> i have an Object with two multi-valued attributes. One of these
>> attributes is editable over a gmf editor. the other attribute is
>> effected programmatically. When i save the object, there is only the
>> first attribute saved. The second is not in the xmi representation.
>> Why is that?
>>
>> Thanks for your help
>> Jörg Oelerink
Re: Save EList [message #424899 is a reply to message #424897] Mon, 10 November 2008 11:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Jörg,

I see. Only an XMIResourceImpl will save multiple root objects, because
it serializes a "fake" XMI root elememt. An XMLResourceImpl will only
save a single root object, so you'd need to define a class whose
instances can hold multiple objects and use one of those as the root.


Jörg wrote:
> Hello,
>
> thanks a lot,but it depends on the containment feature. I add every
> single element on this way:
> resource.getContents().add((EObject) entry.getValue());
>
> is there a better way, so i can have containments, which are saved in
> the xmi representation?
>
> Greetings
>
> Ed Merks schrieb:
>> Jörg,
>>
>> Maybe it's marked with EStructuralFeature.transient being true? Of
>> maybe EObject.eIsSet(<feature>) returns false indicating the value is
>> not or or isn't different from the default.
>>
>>
>> Jörg wrote:
>>> Hello,
>>>
>>> i have an Object with two multi-valued attributes. One of these
>>> attributes is editable over a gmf editor. the other attribute is
>>> effected programmatically. When i save the object, there is only the
>>> first attribute saved. The second is not in the xmi representation.
>>> Why is that?
>>>
>>> Thanks for your help
>>> Jörg Oelerink


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Save EList [message #424936 is a reply to message #424899] Tue, 11 November 2008 09:36 Go to previous messageGo to next message
Oelerink is currently offline OelerinkFriend
Messages: 129
Registered: July 2009
Senior Member
Hello,

hmm multiple roots would be okay, i need the correct childrentree. but
in the xml representation he has now one root with no childs. The
rootelement has children in a contained elist. How can i get them into
the resource. the add method ignores now the none root elements.
Thanks

Jörg

Ed Merks schrieb:
> Jörg,
>
> I see. Only an XMIResourceImpl will save multiple root objects, because
> it serializes a "fake" XMI root elememt. An XMLResourceImpl will only
> save a single root object, so you'd need to define a class whose
> instances can hold multiple objects and use one of those as the root.
>
>
> Jörg wrote:
>> Hello,
>>
>> thanks a lot,but it depends on the containment feature. I add every
>> single element on this way:
>> resource.getContents().add((EObject) entry.getValue());
>>
>> is there a better way, so i can have containments, which are saved in
>> the xmi representation?
>>
>> Greetings
>>
>> Ed Merks schrieb:
>>> Jörg,
>>>
>>> Maybe it's marked with EStructuralFeature.transient being true? Of
>>> maybe EObject.eIsSet(<feature>) returns false indicating the value is
>>> not or or isn't different from the default.
>>>
>>>
>>> Jörg wrote:
>>>> Hello,
>>>>
>>>> i have an Object with two multi-valued attributes. One of these
>>>> attributes is editable over a gmf editor. the other attribute is
>>>> effected programmatically. When i save the object, there is only the
>>>> first attribute saved. The second is not in the xmi representation.
>>>> Why is that?
>>>>
>>>> Thanks for your help
>>>> Jörg Oelerink
Re: Save EList [message #424938 is a reply to message #424936] Tue, 11 November 2008 11:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Jörg,

Keep in mind that generally adding a child to the contents of a resource
will remove it from the parent. So perhaps you need to be more careful
that if eContainer() != null and if eResource() != null that you don't
try to add that object to the root of a resource because it's already
indirectly contained by a resource.


Jörg wrote:
> Hello,
>
> hmm multiple roots would be okay, i need the correct childrentree. but
> in the xml representation he has now one root with no childs. The
> rootelement has children in a contained elist. How can i get them into
> the resource. the add method ignores now the none root elements.
> Thanks
>
> Jörg
>
> Ed Merks schrieb:
>> Jörg,
>>
>> I see. Only an XMIResourceImpl will save multiple root objects,
>> because it serializes a "fake" XMI root elememt. An XMLResourceImpl
>> will only save a single root object, so you'd need to define a class
>> whose instances can hold multiple objects and use one of those as the
>> root.
>>
>>
>> Jörg wrote:
>>> Hello,
>>>
>>> thanks a lot,but it depends on the containment feature. I add every
>>> single element on this way:
>>> resource.getContents().add((EObject) entry.getValue());
>>>
>>> is there a better way, so i can have containments, which are saved
>>> in the xmi representation?
>>>
>>> Greetings
>>>
>>> Ed Merks schrieb:
>>>> Jörg,
>>>>
>>>> Maybe it's marked with EStructuralFeature.transient being true? Of
>>>> maybe EObject.eIsSet(<feature>) returns false indicating the value
>>>> is not or or isn't different from the default.
>>>>
>>>>
>>>> Jörg wrote:
>>>>> Hello,
>>>>>
>>>>> i have an Object with two multi-valued attributes. One of these
>>>>> attributes is editable over a gmf editor. the other attribute is
>>>>> effected programmatically. When i save the object, there is only
>>>>> the first attribute saved. The second is not in the xmi
>>>>> representation. Why is that?
>>>>>
>>>>> Thanks for your help
>>>>> Jörg Oelerink


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Save EList [message #424951 is a reply to message #424938] Tue, 11 November 2008 15:22 Go to previous message
Oelerink is currently offline OelerinkFriend
Messages: 129
Registered: July 2009
Senior Member
Thanks a lot. Now i got it.

Ed Merks schrieb:
> Jörg,
>
> Keep in mind that generally adding a child to the contents of a resource
> will remove it from the parent. So perhaps you need to be more careful
> that if eContainer() != null and if eResource() != null that you don't
> try to add that object to the root of a resource because it's already
> indirectly contained by a resource.
>
>
> Jörg wrote:
>> Hello,
>>
>> hmm multiple roots would be okay, i need the correct childrentree. but
>> in the xml representation he has now one root with no childs. The
>> rootelement has children in a contained elist. How can i get them into
>> the resource. the add method ignores now the none root elements.
>> Thanks
>>
>> Jörg
>>
>> Ed Merks schrieb:
>>> Jörg,
>>>
>>> I see. Only an XMIResourceImpl will save multiple root objects,
>>> because it serializes a "fake" XMI root elememt. An XMLResourceImpl
>>> will only save a single root object, so you'd need to define a class
>>> whose instances can hold multiple objects and use one of those as the
>>> root.
>>>
>>>
>>> Jörg wrote:
>>>> Hello,
>>>>
>>>> thanks a lot,but it depends on the containment feature. I add every
>>>> single element on this way:
>>>> resource.getContents().add((EObject) entry.getValue());
>>>>
>>>> is there a better way, so i can have containments, which are saved
>>>> in the xmi representation?
>>>>
>>>> Greetings
>>>>
>>>> Ed Merks schrieb:
>>>>> Jörg,
>>>>>
>>>>> Maybe it's marked with EStructuralFeature.transient being true? Of
>>>>> maybe EObject.eIsSet(<feature>) returns false indicating the value
>>>>> is not or or isn't different from the default.
>>>>>
>>>>>
>>>>> Jörg wrote:
>>>>>> Hello,
>>>>>>
>>>>>> i have an Object with two multi-valued attributes. One of these
>>>>>> attributes is editable over a gmf editor. the other attribute is
>>>>>> effected programmatically. When i save the object, there is only
>>>>>> the first attribute saved. The second is not in the xmi
>>>>>> representation. Why is that?
>>>>>>
>>>>>> Thanks for your help
>>>>>> Jörg Oelerink
Previous Topic:Where can I get TreeNodeItemProvider or MappingItemProvider examples?
Next Topic:[EMF] Problems registering package namespaces.
Goto Forum:
  


Current Time: Tue Apr 23 14:18:16 GMT 2024

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

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

Back to the top