Is it possible that ECoreUtil.Copy() changes an EObject? [message #423992] |
Mon, 13 October 2008 16:32 |
Eclipse User |
|
|
|
Originally posted by: zhodaie.gmail.com
Hi all,
I encountered a problem using ECoreUtil.Copy() method. Here are the
steps I did:
1. create objA (it contains a hierarchy of containments and EObjects
referencing each other)
2. copy to create objB (objB = (cast)ECoreUtil.Copy(objA))
3. serialize both objects to separate files
Now i expect that the two files have exactly identical contents. But
they differ in just one line, in which two references of an ordered
containment are output vice versa.
I am sure that no problem occurs during serialization as i checked the
serialization routine with the same object (i.e. serialize(objA, objA))
and both files were identical. That is, EcoreUtil.Copy() changes
contents of objA as its being copied to objB.
Can someone please explain what is the possible problem?
Thanks in advance,
Zardosht
|
|
|
|
Re: Is it possible that ECoreUtil.Copy() changes an EObject? [message #424010 is a reply to message #423993] |
Tue, 14 October 2008 10:04 |
Eclipse User |
|
|
|
Originally posted by: zhodaie.gmail.com
thank you Ed for your fast reply. The problem was in model. An Attribute
of one of containments had its derived value set to true. I don't how
it fixed the problem, but it was the cause.
Ed Merks schrieb:
> Zardosht,
>
> This should not be possible. You could add an adapter to listen for
> any changes. E.g., you might use an EContentAdapter on the original
> object to monitor any notifications that changes would produce...
>
>
>
> Zardosht Hodaie wrote:
>> Hi all,
>>
>> I encountered a problem using ECoreUtil.Copy() method. Here are the
>> steps I did:
>>
>> 1. create objA (it contains a hierarchy of containments and EObjects
>> referencing each other)
>> 2. copy to create objB (objB = (cast)ECoreUtil.Copy(objA))
>> 3. serialize both objects to separate files
>>
>> Now i expect that the two files have exactly identical contents. But
>> they differ in just one line, in which two references of an ordered
>> containment are output vice versa.
>> I am sure that no problem occurs during serialization as i checked the
>> serialization routine with the same object (i.e. serialize(objA,
>> objA)) and both files were identical. That is, EcoreUtil.Copy()
>> changes contents of objA as its being copied to objB.
>>
>> Can someone please explain what is the possible problem?
>>
>> Thanks in advance,
>> Zardosht
|
|
|
Re: Is it possible that ECoreUtil.Copy() changes an EObject? [message #424013 is a reply to message #424010] |
Tue, 14 October 2008 10:18 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Zardosht,
Yes, derived features aren't copied. The assumption is that they are
derived/computed from the values of other non-derived features.
Zardosht Hodaie wrote:
> thank you Ed for your fast reply. The problem was in model. An
> Attribute of one of containments had its derived value set to true. I
> don't how it fixed the problem, but it was the cause.
>
>
> Ed Merks schrieb:
>> Zardosht,
>>
>> This should not be possible. You could add an adapter to listen
>> for any changes. E.g., you might use an EContentAdapter on the
>> original object to monitor any notifications that changes would
>> produce...
>>
>>
>>
>> Zardosht Hodaie wrote:
>>> Hi all,
>>>
>>> I encountered a problem using ECoreUtil.Copy() method. Here are the
>>> steps I did:
>>>
>>> 1. create objA (it contains a hierarchy of containments and EObjects
>>> referencing each other)
>>> 2. copy to create objB (objB = (cast)ECoreUtil.Copy(objA))
>>> 3. serialize both objects to separate files
>>>
>>> Now i expect that the two files have exactly identical contents. But
>>> they differ in just one line, in which two references of an ordered
>>> containment are output vice versa.
>>> I am sure that no problem occurs during serialization as i checked
>>> the serialization routine with the same object (i.e. serialize(objA,
>>> objA)) and both files were identical. That is, EcoreUtil.Copy()
>>> changes contents of objA as its being copied to objB.
>>>
>>> Can someone please explain what is the possible problem?
>>>
>>> Thanks in advance,
>>> Zardosht
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03354 seconds