Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Synchronize to EObjects completely
Synchronize to EObjects completely [message #427436] Wed, 18 February 2009 00:42 Go to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
Hello.

Is there a way to synchronize two EObjects of the same type completely
by some kind of helper function, or do I have to do it manually?
So that one contains all data and children of the other one.
(I am not speaking of deep copying the object as both already exist.)

Kai
Re: Synchronize to EObjects completely [message #427439 is a reply to message #427436] Wed, 18 February 2009 06:20 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Kai,

If I understand correctly you want to have EObjects that are each
_contained_ by two other parent objects?
This is generally not possible at all, since containment is at least
internally always a bidirectional reference.
An EObject can always have at most one parent at a time.
I'd say you either have to work with deep copies or drop the containment
property of your references...

Cheers
/Eike

----
http://thegordian.blogspot.com



Kai Schlamp schrieb:
> Hello.
>
> Is there a way to synchronize two EObjects of the same type completely
> by some kind of helper function, or do I have to do it manually?
> So that one contains all data and children of the other one.
> (I am not speaking of deep copying the object as both already exist.)
>
> Kai


Re: Synchronize to EObjects completely [message #427452 is a reply to message #427439] Wed, 18 February 2009 12:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Guys,

Comments below.

Eike Stepper wrote:
> Kai,
>
> If I understand correctly you want to have EObjects that are each
> _contained_ by two other parent objects?
> This is generally not possible at all, since containment is at least
> internally always a bidirectional reference.
Yes, that doesn't make sense
> An EObject can always have at most one parent at a time.
> I'd say you either have to work with deep copies or drop the
> containment property of your references...
But I think he's saying he effectively already has a deep copy and is
trying to make them equal...
>
> Cheers
> /Eike
>
> ----
> http://thegordian.blogspot.com
>
>
>
> Kai Schlamp schrieb:
>> Hello.
>>
>> Is there a way to synchronize two EObjects of the same type
>> completely by some kind of helper function, or do I have to do it
>> manually?
The compare framework (and EMFT component) will let you structurally
compare two instance and describe the difference. One could use that to
transform on instance to be structurally equal to another. I think
Cedric is working on a "patch" mechanism for doing that...
>> So that one contains all data and children of the other one.
>> (I am not speaking of deep copying the object as both already exist.)
>>
>> Kai


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Synchronize to EObjects completely [message #427463 is a reply to message #427452] Wed, 18 February 2009 13:58 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
Comments below.

> But I think he's saying he effectively already has a deep copy and is
> trying to make them equal...

Yes, thats right. I already have a deep copy A' of object A.
Then I manipulate A' by changing some attributes, adding/deleting some
children. Now I want those modifications to be synchronized back to A by
for example adding a copy of an added child of A' to A.

> The compare framework (and EMFT component) will let you structurally
> compare two instance and describe the difference. One could use that to
> transform on instance to be structurally equal to another. I think
> Cedric is working on a "patch" mechanism for doing that...

I will look into that ... thanks.

Kai
Re: Synchronize to EObjects completely [message #427464 is a reply to message #427463] Wed, 18 February 2009 14:11 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020702050107090205000702
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi Kai,

We are in the process of integrating a contribution for this "EPatch"
mechanism. See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=262928
if you want an early try to the contribution :). As for when this will
be available : it will depend on the CQ (
https://dev.eclipse.org/ipzilla/show_bug.cgi?id=3063 ) and how fast
after this has been approved we can integrate this to the current code.

Laurent Goubet
Obeo

Kai Schlamp a
Re: Synchronize to EObjects completely [message #427477 is a reply to message #427463] Wed, 18 February 2009 21:38 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Hi Kai,

you could implement the synchronization using an
org.eclipse.emf.common.notify.Adapter, which listens on changes of A'
and updates A accordingly.
Use an EContentAdapter if you want to synchronize whole trees that way.

Sven


Kai Schlamp schrieb:
> Comments below.
>
>> But I think he's saying he effectively already has a deep copy and is
>> trying to make them equal...
>
> Yes, thats right. I already have a deep copy A' of object A.
> Then I manipulate A' by changing some attributes, adding/deleting some
> children. Now I want those modifications to be synchronized back to A by
> for example adding a copy of an added child of A' to A.
>
>> The compare framework (and EMFT component) will let you structurally
>> compare two instance and describe the difference. One could use that
>> to transform on instance to be structurally equal to another. I think
>> Cedric is working on a "patch" mechanism for doing that...
>
> I will look into that ... thanks.
>
> Kai
Re: Synchronize to EObjects completely [message #427480 is a reply to message #427477] Wed, 18 February 2009 23:20 Go to previous messageGo to next message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
Comments below.

Sven Efftinge schrieb:
> Hi Kai,
>
> you could implement the synchronization using an
> org.eclipse.emf.common.notify.Adapter, which listens on changes of A'
> and updates A accordingly.
> Use an EContentAdapter if you want to synchronize whole trees that way.

Thanks for your suggestion Sven. But I was just looking for a small and
straight forward solution. I want to work on A' and finally do a
synchronization at the end of all work back to A.
I just synchronized now everything manually. Using listeners and so on
would be overkill in my case. I was just looking for a one or two liner
with the help of some utility class.

Kai
Re: Synchronize to EObjects completely [message #427481 is a reply to message #427464] Wed, 18 February 2009 23:23 Go to previous message
Kai Schlamp is currently offline Kai SchlampFriend
Messages: 344
Registered: July 2009
Senior Member
Thanks for the help. I just implemented a manual sync now, but will take
a look into your code. A nice one or two liner would be a much nicer
solution then my manual synchronization.

Kai

laurent Goubet schrieb:
> Hi Kai,
>
> We are in the process of integrating a contribution for this "EPatch"
> mechanism. See bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=262928
> if you want an early try to the contribution :). As for when this will
> be available : it will depend on the CQ (
> https://dev.eclipse.org/ipzilla/show_bug.cgi?id=3063 ) and how fast
> after this has been approved we can integrate this to the current code.
>
> Laurent Goubet
> Obeo
>
> Kai Schlamp a écrit :
>> Comments below.
>>
>>> But I think he's saying he effectively already has a deep copy and is
>>> trying to make them equal...
>>
>> Yes, thats right. I already have a deep copy A' of object A.
>> Then I manipulate A' by changing some attributes, adding/deleting some
>> children. Now I want those modifications to be synchronized back to A
>> by for example adding a copy of an added child of A' to A.
>>
>>> The compare framework (and EMFT component) will let you structurally
>>> compare two instance and describe the difference. One could use that
>>> to transform on instance to be structurally equal to another. I
>>> think Cedric is working on a "patch" mechanism for doing that...
>>
>> I will look into that ... thanks.
>>
>> Kai
>
Previous Topic:[Teneo] Auto adding an annotation for every column and table
Next Topic:[CDO] Table naming strategy for DerbyStore
Goto Forum:
  


Current Time: Wed Apr 24 20:22:16 GMT 2024

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

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

Back to the top