Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Re: [Teneo] Problem using ChangeRecorder with EObject(s) loaded with HB resource
Re: [Teneo] Problem using ChangeRecorder with EObject(s) loaded with HB resource [message #422273] Thu, 28 August 2008 10:11 Go to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Mdu,
I tested this and with me it works fine. I used the following code (which is the same as yours):
URI uri1 = URI.createURI("hibernate://?dsname=Library&query1=FROM Course");
Resource res1 = new ResourceSetImpl().createResource(uri1);
try {
res1.load(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}

eobject = res1.getContents().get(0);
ChangeRecorder cr = new ChangeRecorder(res1);
eobject.eSet(courseName, "English 1");
System.out.println(eobject);
System.out.println(eobject.eGet(courseName));

ChangeDescription changeDescription = cr.endRecording();

EMap<EObject, EList<FeatureChange>> objectChanges = changeDescription.getObjectChanges();
System.out.println("change size: " + objectChanges.size());

And the output is this:
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@12dd538 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@15f1f9c (name: Course) (instanceClassName: null) (abstract:
false, interface: false))
English 1
change size: 1

which seemed fine.

btw, support for Teneo is given on the EMF newsgroup (which I cc-ed).

gr. Martin

Mdu wrote:
> All,
> I would like to use ChangeRecorder to capture changes made on HB
> resource eobjects. I'm able to record changes when an EObject is newly
> created but not when it is loaded from HB resource.
> Please take a look at attached example.
>
> P.S.: Martin, Ed, thanks for all your help and patience.
>
> Rgs,
> -Mdu


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Problem using ChangeRecorder with EObject(s) loaded with HB resource [message #422276 is a reply to message #422273] Thu, 28 August 2008 07:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mduduzi.keswa.isizwe.com

Martin, Thanks,
I originally thought the problem was with Teneo - but it is more
basic than that and thus my post in the .emft newsgroup 'How to retrieve
newValue for FeatureChange...'; and yes I was able to reproduce the same
results with code similar to yours.
As I understand it, ChangeDescription (somewhere) will contain
oldValue and newValue of courseName. I could then get oldValue by
calling FeatureChange.getValue() - but I couldn't access the newValue
within the FeatureChange.
Is it because my understanding of
ChangeRecorder/ChangeDescription/Featurechange is incorrect on what gets
recorded?
What is ListChange supposed to store within FeatureChange. Is it only
when attribute being changed is a reference?


Regards,
-Mdu


Martin Taal wrote:
> Hi Mdu,
> I tested this and with me it works fine. I used the following code
> (which is the same as yours):
> URI uri1 =
> URI.createURI("hibernate://?dsname=Library&query1=FROM Course");
> Resource res1 = new ResourceSetImpl().createResource(uri1);
> try {
> res1.load(Collections.EMPTY_MAP);
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> eobject = res1.getContents().get(0);
> ChangeRecorder cr = new ChangeRecorder(res1);
> eobject.eSet(courseName, "English 1");
> System.out.println(eobject);
> System.out.println(eobject.eGet(courseName));
>
> ChangeDescription changeDescription = cr.endRecording();
>
> EMap<EObject, EList<FeatureChange>> objectChanges =
> changeDescription.getObjectChanges();
> System.out.println("change size: " + objectChanges.size());
>
> And the output is this:
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@12dd538 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@15f1f9c (name: Course)
> (instanceClassName: null) (abstract: false, interface: false))
> English 1
> change size: 1
>
> which seemed fine.
>
> btw, support for Teneo is given on the EMF newsgroup (which I cc-ed).
>
> gr. Martin
>
> Mdu wrote:
>> All,
>> I would like to use ChangeRecorder to capture changes made on HB
>> resource eobjects. I'm able to record changes when an EObject is newly
>> created but not when it is loaded from HB resource.
>> Please take a look at attached example.
>>
>> P.S.: Martin, Ed, thanks for all your help and patience.
>>
>> Rgs,
>> -Mdu
>
>
Re: [Teneo] Problem using ChangeRecorder with EObject(s) loaded with HB resource [message #422284 is a reply to message #422276] Thu, 28 August 2008 13:06 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Mdu,

As it turns out, I think its an assumption you're making about the
nature of the change description. You're assuming it's a description of
how to get to the original state to the final state when in fact it's a
description from how to get to the current state to some other state.
Hence in this scenario, it's a reverse delta. The reason for this
design (often people ask, why did you do it like this?) is because the
change description is a model instance you can save. Hence when it
saves references to the objects that have changed, it needs to serialize
those based on the actual current state of those objects. Consider for
example if something was added to the tree via containment. The
reference needs to be to the new object containing within the resource.
If you did applyAndReverse, you'd see that result would be that the
object that was added is now contained by the ChangeDescription itself
and instead of a REMOVE the change has become an ADD...


Mdu wrote:
> Martin, Thanks,
> I originally thought the problem was with Teneo - but it is more
> basic than that and thus my post in the .emft newsgroup 'How to
> retrieve newValue for FeatureChange...'; and yes I was able to
> reproduce the same results with code similar to yours.
> As I understand it, ChangeDescription (somewhere) will contain
> oldValue and newValue of courseName. I could then get oldValue by
> calling FeatureChange.getValue() - but I couldn't access the newValue
> within the FeatureChange.
> Is it because my understanding of
> ChangeRecorder/ChangeDescription/Featurechange is incorrect on what
> gets recorded?
> What is ListChange supposed to store within FeatureChange. Is it only
> when attribute being changed is a reference?
>
>
> Regards,
> -Mdu
>
>
> Martin Taal wrote:
>> Hi Mdu,
>> I tested this and with me it works fine. I used the following code
>> (which is the same as yours):
>> URI uri1 =
>> URI.createURI("hibernate://?dsname=Library&query1=FROM Course");
>> Resource res1 = new ResourceSetImpl().createResource(uri1);
>> try {
>> res1.load(Collections.EMPTY_MAP);
>> } catch (IOException e) {
>> e.printStackTrace();
>> }
>>
>> eobject = res1.getContents().get(0);
>> ChangeRecorder cr = new ChangeRecorder(res1);
>> eobject.eSet(courseName, "English 1");
>> System.out.println(eobject);
>> System.out.println(eobject.eGet(courseName));
>>
>> ChangeDescription changeDescription = cr.endRecording();
>>
>> EMap<EObject, EList<FeatureChange>> objectChanges =
>> changeDescription.getObjectChanges();
>> System.out.println("change size: " + objectChanges.size());
>>
>> And the output is this:
>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@12dd538 (eClass:
>> org.eclipse.emf.ecore.impl.EClassImpl@15f1f9c (name: Course)
>> (instanceClassName: null) (abstract: false, interface: false))
>> English 1
>> change size: 1
>>
>> which seemed fine.
>>
>> btw, support for Teneo is given on the EMF newsgroup (which I cc-ed).
>>
>> gr. Martin
>>
>> Mdu wrote:
>>> All,
>>> I would like to use ChangeRecorder to capture changes made on HB
>>> resource eobjects. I'm able to record changes when an EObject is
>>> newly created but not when it is loaded from HB resource.
>>> Please take a look at attached example.
>>>
>>> P.S.: Martin, Ed, thanks for all your help and patience.
>>>
>>> Rgs,
>>> -Mdu
>>
>>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:How to retrieve newValue for FeatureChange when using ChangeRecorder
Next Topic:Eclipse (Graphical) Modeling Framework Training
Goto Forum:
  


Current Time: Thu Apr 25 18:09:29 GMT 2024

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

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

Back to the top