Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Loading a GMF diagram resource from Hibernate
Loading a GMF diagram resource from Hibernate [message #114032] Fri, 07 March 2008 10:41 Go to next message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi,

I have a problem loading a GMF diagram I saved in a Hibernate database.

In the editor and in the property view the diagram is shown, but when I
try to change a property,say, a name of an object, the name in the diagram
and in the property view is NOT changed. In the property view, after
leaving the input cell, the old value of the property is shown.
But the value I changed has been written into the model object! So the
notification to the model object did happen, but not the notification back
to the diagram editor.

In debug I see that all my own model objects do not have the
TransactionChangeRecorder listening to them. Since this is the main
difference to the objects I add to a newly created diagram or to the GMF
diagram objects in the loaded resource I believe this to be cause of the
behaviour.

I load the diagram with an URI containing a query that ensures I am
loading only one diagram out of the database. Since my root model object
is contained in the root diagram object as EObject element, my model
objects should be loaded with the diagram objects - and they are. But only
the diagram objects
got the Transaction Change Recorder listener.

I made some experiments with loadStrategy=StoreResource.ADD_TO_CONTENTS
and I loaded my model objects explicitly before the load of the diagram,
but nothing did help.

(This has nothing to do with the readOnly problem of the hibernate
resource. I have overwritten the DiagramEditingDomain(Factory) to ensure
that all hibernate resources are read-write.)


I would be glad if someone can help me.

With regards

Manfred Hahn
Re: Loading a GMF diagram resource from Hibernate [message #114044 is a reply to message #114032] Fri, 07 March 2008 11:36 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
I don't have a solution right away.
The TransactionChangeRecorder has a setTarget method which sets the changerecorder in the content of
the resource. However when I look at this method it only adds itself to the root of the resource. So
not to the children. So this seems fine and inline with what you see. For the rest I know nothing
about how the views are update on the basis of model changes. Maybe Ed can say something about this.

btw, fyi I am also looking at the gmf teneo integration (see the my posts of today on the emf
newsgroup).

gr. Martin

Manfred Hahn wrote:
> Hi,
>
> I have a problem loading a GMF diagram I saved in a Hibernate database.
> In the editor and in the property view the diagram is shown, but when I
> try to change a property,say, a name of an object, the name in the
> diagram and in the property view is NOT changed. In the property view,
> after leaving the input cell, the old value of the property is shown.
> But the value I changed has been written into the model object! So the
> notification to the model object did happen, but not the notification
> back to the diagram editor.
>
> In debug I see that all my own model objects do not have the
> TransactionChangeRecorder listening to them. Since this is the main
> difference to the objects I add to a newly created diagram or to the GMF
> diagram objects in the loaded resource I believe this to be cause of the
> behaviour.
>
> I load the diagram with an URI containing a query that ensures I am
> loading only one diagram out of the database. Since my root model object
> is contained in the root diagram object as EObject element, my model
> objects should be loaded with the diagram objects - and they are. But
> only the diagram objects got the Transaction Change Recorder listener.
>
> I made some experiments with loadStrategy=StoreResource.ADD_TO_CONTENTS
> and I loaded my model objects explicitly before the load of the diagram,
> but nothing did help.
>
> (This has nothing to do with the readOnly problem of the hibernate
> resource. I have overwritten the DiagramEditingDomain(Factory) to ensure
> that all hibernate resources are read-write.)
>
>
> I would be glad if someone can help me.
>
> With regards
>
> Manfred Hahn
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #114101 is a reply to message #114044] Fri, 07 March 2008 20:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Martin,

When the adapter is added to an eAdaters list, it will cause setTarget
to be called (just like bidirectional handshaking), so the way it's
written, adding the adapter to a resource set, resource, or object
should recursively cause the adapters to be added to the entire
containment tree starting from that point. So the fact that adapters
are missing from some portion of the tree is definitely a sign that
something isn't quite right in the expected behavior of the model.


Martin Taal wrote:
> Hi Manfred,
> I don't have a solution right away.
> The TransactionChangeRecorder has a setTarget method which sets the
> changerecorder in the content of the resource. However when I look at
> this method it only adds itself to the root of the resource. So not to
> the children. So this seems fine and inline with what you see. For the
> rest I know nothing about how the views are update on the basis of
> model changes. Maybe Ed can say something about this.
>
> btw, fyi I am also looking at the gmf teneo integration (see the my
> posts of today on the emf newsgroup).
>
> gr. Martin
>
> Manfred Hahn wrote:
>> Hi,
>>
>> I have a problem loading a GMF diagram I saved in a Hibernate database.
>> In the editor and in the property view the diagram is shown, but when
>> I try to change a property,say, a name of an object, the name in the
>> diagram and in the property view is NOT changed. In the property
>> view, after leaving the input cell, the old value of the property is
>> shown. But the value I changed has been written into the model
>> object! So the notification to the model object did happen, but not
>> the notification back to the diagram editor.
>>
>> In debug I see that all my own model objects do not have the
>> TransactionChangeRecorder listening to them. Since this is the main
>> difference to the objects I add to a newly created diagram or to the
>> GMF diagram objects in the loaded resource I believe this to be cause
>> of the behaviour.
>>
>> I load the diagram with an URI containing a query that ensures I am
>> loading only one diagram out of the database. Since my root model
>> object is contained in the root diagram object as EObject element, my
>> model objects should be loaded with the diagram objects - and they
>> are. But only the diagram objects got the Transaction Change Recorder
>> listener.
>>
>> I made some experiments with
>> loadStrategy=StoreResource.ADD_TO_CONTENTS and I loaded my model
>> objects explicitly before the load of the diagram, but nothing did help.
>>
>> (This has nothing to do with the readOnly problem of the hibernate
>> resource. I have overwritten the DiagramEditingDomain(Factory) to
>> ensure that all hibernate resources are read-write.)
>>
>>
>> I would be glad if someone can help me.
>>
>> With regards
>>
>> Manfred Hahn
>>
>>
>
>
Re: Loading a GMF diagram resource from Hibernate [message #114107 is a reply to message #114101] Fri, 07 March 2008 21:08 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ed, okay clear, Manfred is this something that you can debug to see what goes wrong (with me it
works fine afaics). From there we can try to find a solution.

gr. Martin

Ed Merks wrote:
> Martin,
>
> When the adapter is added to an eAdaters list, it will cause setTarget
> to be called (just like bidirectional handshaking), so the way it's
> written, adding the adapter to a resource set, resource, or object
> should recursively cause the adapters to be added to the entire
> containment tree starting from that point. So the fact that adapters
> are missing from some portion of the tree is definitely a sign that
> something isn't quite right in the expected behavior of the model.
>
>
> Martin Taal wrote:
>> Hi Manfred,
>> I don't have a solution right away.
>> The TransactionChangeRecorder has a setTarget method which sets the
>> changerecorder in the content of the resource. However when I look at
>> this method it only adds itself to the root of the resource. So not to
>> the children. So this seems fine and inline with what you see. For the
>> rest I know nothing about how the views are update on the basis of
>> model changes. Maybe Ed can say something about this.
>>
>> btw, fyi I am also looking at the gmf teneo integration (see the my
>> posts of today on the emf newsgroup).
>>
>> gr. Martin
>>
>> Manfred Hahn wrote:
>>> Hi,
>>>
>>> I have a problem loading a GMF diagram I saved in a Hibernate database.
>>> In the editor and in the property view the diagram is shown, but when
>>> I try to change a property,say, a name of an object, the name in the
>>> diagram and in the property view is NOT changed. In the property
>>> view, after leaving the input cell, the old value of the property is
>>> shown. But the value I changed has been written into the model
>>> object! So the notification to the model object did happen, but not
>>> the notification back to the diagram editor.
>>>
>>> In debug I see that all my own model objects do not have the
>>> TransactionChangeRecorder listening to them. Since this is the main
>>> difference to the objects I add to a newly created diagram or to the
>>> GMF diagram objects in the loaded resource I believe this to be cause
>>> of the behaviour.
>>>
>>> I load the diagram with an URI containing a query that ensures I am
>>> loading only one diagram out of the database. Since my root model
>>> object is contained in the root diagram object as EObject element, my
>>> model objects should be loaded with the diagram objects - and they
>>> are. But only the diagram objects got the Transaction Change Recorder
>>> listener.
>>>
>>> I made some experiments with
>>> loadStrategy=StoreResource.ADD_TO_CONTENTS and I loaded my model
>>> objects explicitly before the load of the diagram, but nothing did help.
>>>
>>> (This has nothing to do with the readOnly problem of the hibernate
>>> resource. I have overwritten the DiagramEditingDomain(Factory) to
>>> ensure that all hibernate resources are read-write.)
>>>
>>>
>>> I would be glad if someone can help me.
>>>
>>> With regards
>>>
>>> Manfred Hahn
>>>
>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #114113 is a reply to message #114101] Fri, 07 March 2008 21:16 Go to previous messageGo to next message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Ed,

I understand that recursive behaviour. The
TransactionChangeRecorder.setTarget() method does this thing. But it only
adds itself to the
((EObject) target).eContents()) elements
and in my debug sessions I have seen only the one-to-many-Features of the
Diagram called. The thing boils down to the question, why the
ViewImpl.element feature is not in the contents list. Is this a problem of
the one-to-one relation? Do I (or the GMF team) have to modify the
ViewImpl?
But some more questions arise, look at my parallel question to Martin. I
still hope I made a complete silly - and easy to correct - mistake
somewhere.

Thanks for your help

Manfred
Re: Loading a GMF diagram resource from Hibernate [message #114118 is a reply to message #114044] Fri, 07 March 2008 21:20 Go to previous messageGo to next message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Martin,

I detected some strange behavior:

In order to force the TransactionChangeRecorder listening on my model
object I loaded them before the diagram load with the
loadStrategy=StoreResource.ADD_TO_CONTENTS. As expected every object got
the TransactionChangeRecorder as listener. (Look at Ed's comment)

Then I loaded the diagram resource in the same session, but with another
query. But this load created new model objects (in the debugger they have
new IDs, but they were loaded from the same database row) and of course
they had no TransactionChangeRecorder listening. They run into the
instanceNotYetLoaded method of the loader class. I expected every object
to be loaded only one time!

So I looked again at the Hibernate EMF Resource documentation - the fat
printet hint. In my case I have an object A1 (my model root) as root
object of one resource loaded by a query. I have another object A0 (the
diagram) as a root object in in another resource loaded by another query.
A0 contains A1. I do not understand the resolving=true/false hint
(annotation, property?? Where do I set it?), but looking at the
ViewImpl.getElement() method it looks like a simple one way reference that
has been modified. Anyway the two resources reside in the same ResourceSet
and share the same session. Can you explain why there is that double load?

Manfred
Re: Loading a GMF diagram resource from Hibernate [message #114122 is a reply to message #114118] Fri, 07 March 2008 22:48 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
See my comments inline.

gr. Martin

Manfred Hahn wrote:
> Hi Martin,
>
> I detected some strange behavior:
>
> In order to force the TransactionChangeRecorder listening on my model
> object I loaded them before the diagram load with the
> loadStrategy=StoreResource.ADD_TO_CONTENTS. As expected every object got
> the TransactionChangeRecorder as listener. (Look at Ed's comment)
>
> Then I loaded the diagram resource in the same session, but with another
> query. But this load created new model objects (in the debugger they
> have new IDs, but they were loaded from the same database row) and of
> course they had no TransactionChangeRecorder listening. They run into
> the instanceNotYetLoaded method of the loader class. I expected every
> object to be loaded only one time!
MT>> Yes I would also expect this also. Are sure that the extra objects are not present in the db?
So that the model objects are persisted twice during save? Otherwise I can only explain this if the
two resources have been loaded using different sessions.

> So I looked again at the Hibernate EMF Resource documentation - the fat
> printet hint. In my case I have an object A1 (my model root) as root
> object of one resource loaded by a query. I have another object A0 (the
> diagram) as a root object in in another resource loaded by another
> query. A0 contains A1. I do not understand the resolving=true/false hint
> (annotation, property?? Where do I set it?),
MT>> It is the resolved proxies property of the ereference. If the generated code supports
containment proxies then an object can be in a different resource than its parent.

but looking at the
> ViewImpl.getElement() method it looks like a simple one way reference
> that has been modified. Anyway the two resources reside in the same
> ResourceSet and share the same session. Can you explain why there is
> that double load?
>
> Manfred
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #114124 is a reply to message #114113] Fri, 07 March 2008 22:54 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
You mean that the ViewImpl.element association is not traversed when setting the adapter
(changerecorder)? As far as I can see the ViewImpl.element is not a containment relation. So this
explains why it is not considered in the all contents list. If you mean this.
When using the load strategy addtocontents (=the default) the refered-to objects should be added to
the resource in the top of the resource or the container of the object should be present there.

gr. Martin

Manfred Hahn wrote:
> Hi Ed,
>
> I understand that recursive behaviour. The
> TransactionChangeRecorder.setTarget() method does this thing. But it
> only adds itself to the ((EObject) target).eContents()) elements
> and in my debug sessions I have seen only the one-to-many-Features of
> the Diagram called. The thing boils down to the question, why the
> ViewImpl.element feature is not in the contents list. Is this a problem
> of the one-to-one relation? Do I (or the GMF team) have to modify the
> ViewImpl?
> But some more questions arise, look at my parallel question to Martin. I
> still hope I made a complete silly - and easy to correct - mistake
> somewhere.
>
> Thanks for your help
>
> Manfred
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #114127 is a reply to message #114122] Sat, 08 March 2008 09:16 Go to previous messageGo to next message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Martin,

my usage of the sessionController parameter in the URI was wrong: I simply
added the parameter to the URI string and did not delete the dsname
parameter, so the sessionController was not activated.

And: with this one Session my Problem was solved!!! (Hurray)

So this is the workaround for loading diagrams in a way that they are
editable:
- load the model objects before loading the diagram objects with the
loadStrategy=StoreResource.ADD_TO_CONTENTS (the latter is indispensable)
- load the diagram objects in the same session as the model objects

Though I'm very happy that this works it is not the way it should be:
loading only the diagram objects without extra activities should do a
correct load and initialization with the correct listeners. Since
everything in the ViewImpl seems to be correct this is a question of the
loading strategie!?!

Thanks and best regards from

Manfred
Re: Loading a GMF diagram resource from Hibernate [message #114128 is a reply to message #114127] Sat, 08 March 2008 12:58 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
Good to hear that this issue is not a problem after all.

Regarding the adapters. Would it be possible for you to debug why just loading the diagram does not
work? Why are the adapters not added to the children (the model objects)? With me it works fine
otherwise I would test it out.

Btw, I changed the resource implementation which should solve three things:
- loading a resource can now be done without the disable_notify parameter
- saving a resource does not need to be done a emft transaction anymore (the notifications are
disabled during save)
- removed objects were still validated, so a resource with a removed object which was invalid does
not save (because of validation errors). This is solved.

If you are interested the builds with these solutions can be downloaded here:
http://emft.eclipse.org/modeling/emft/downloads/?project=ten eo&sortBy=date&hlbuild=0#latest

The latest S build is for eclipse 3.4, the latest I build is for eclipse 3.3.

Today I will solve another issue, nl. that when doing save - undo - save in the diagram results in a
hibernate error.

gr. Martin

Manfred Hahn wrote:
> Hi Martin,
>
> my usage of the sessionController parameter in the URI was wrong: I
> simply added the parameter to the URI string and did not delete the
> dsname parameter, so the sessionController was not activated.
>
> And: with this one Session my Problem was solved!!! (Hurray)
>
> So this is the workaround for loading diagrams in a way that they are
> editable:
> - load the model objects before loading the diagram objects with the
> loadStrategy=StoreResource.ADD_TO_CONTENTS (the latter is indispensable)
> - load the diagram objects in the same session as the model objects
>
> Though I'm very happy that this works it is not the way it should be:
> loading only the diagram objects without extra activities should do a
> correct load and initialization with the correct listeners. Since
> everything in the ViewImpl seems to be correct this is a question of the
> loading strategie!?!
>
> Thanks and best regards from
>
> Manfred
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #114235 is a reply to message #114128] Sun, 09 March 2008 11:26 Go to previous messageGo to next message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Martin,

I've debugged everything to the ground in the last days, so I can not tell
you any more than I told in the pevious entries:

The first (root) object that is loaded is the diagram object. While
loading (in StoreResource.addToContent()) the TransactionChangeRecorder
gets a notification and adds itself as listener to the diagram object.
This in turn calls the TransactionChangeRecorder.setTarget() method.

This method goes through the eContents-List of the target (the diagram
object) and adds itself (the TransactionChangeRecorder) to every feature
in the list. Since my model root object located in the diagram field
"element" is not in the list, the TransactionChangeRecorder is never added
to that object. The eContents list only has the sublists of diagram
(eAnnotation,children,styles,transientChildren,edges and transientEdges).
So every subobject in this lists got the TransactionChangeRecorder as
listener, but none of my model elements.

I think the reason is that from the diagram point of view all model
objects are not referenced as containment relationship but only as
assotiation. Perhaps this explains the need for the previous load of my
business object model.

Since I have made myself an explanation for the behaviour that sounds
logical I am astonished that things work in another way in your
environment.

Thanks for the hint to the new build. I will try the S version, since I
didn't switch to eclipse 3.4 until now.

Best regards

Manfred
Re: Loading a GMF diagram resource from Hibernate [message #114297 is a reply to message #114235] Sun, 09 March 2008 18:51 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Ed (or someone else who knows GMF-EMF), as far as I can see the description of Manfred sounds
logical (as the element efeature is not a containment relation the adapter is not added to the model
objects). I will debug it myself but if someone knows the answer why it works that would be great
ofcourse.

Manfred, I will debug to find out why it works in my environment. Btw, the s build is for 3.4 and
the i build for 3.3. I don't think it makes a big difference because both are built from the same
source tree.

gr. Martin

Manfred Hahn wrote:
> Hi Martin,
>
> I've debugged everything to the ground in the last days, so I can not
> tell you any more than I told in the pevious entries:
>
> The first (root) object that is loaded is the diagram object. While
> loading (in StoreResource.addToContent()) the TransactionChangeRecorder
> gets a notification and adds itself as listener to the diagram object.
> This in turn calls the TransactionChangeRecorder.setTarget() method.
> This method goes through the eContents-List of the target (the diagram
> object) and adds itself (the TransactionChangeRecorder) to every feature
> in the list. Since my model root object located in the diagram field
> "element" is not in the list, the TransactionChangeRecorder is never
> added to that object. The eContents list only has the sublists of
> diagram (eAnnotation,children,styles,transientChildren,edges and
> transientEdges). So every subobject in this lists got the
> TransactionChangeRecorder as listener, but none of my model elements.
>
> I think the reason is that from the diagram point of view all model
> objects are not referenced as containment relationship but only as
> assotiation. Perhaps this explains the need for the previous load of my
> business object model.
>
> Since I have made myself an explanation for the behaviour that sounds
> logical I am astonished that things work in another way in your
> environment.
> Thanks for the hint to the new build. I will try the S version, since I
> didn't switch to eclipse 3.4 until now.
>
> Best regards
>
> Manfred
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #114323 is a reply to message #114297] Sun, 09 March 2008 21:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Martin,

From what I understand of this GMF scenario, the change recorder is
added to the resource set so when the proxy from the diagram to the root
object of the model is resolved, the model's resource should be loaded
and the end result of all that processing should be that the change
recorder ends up being attached to all the objects in the model
resource. So perhaps there is some issue with the notifications that
result during demand loading that lead to this misbehavior...


Martin Taal wrote:
> Ed (or someone else who knows GMF-EMF), as far as I can see the
> description of Manfred sounds logical (as the element efeature is not
> a containment relation the adapter is not added to the model objects).
> I will debug it myself but if someone knows the answer why it works
> that would be great ofcourse.
>
> Manfred, I will debug to find out why it works in my environment. Btw,
> the s build is for 3.4 and the i build for 3.3. I don't think it makes
> a big difference because both are built from the same source tree.
>
> gr. Martin
>
> Manfred Hahn wrote:
>> Hi Martin,
>>
>> I've debugged everything to the ground in the last days, so I can not
>> tell you any more than I told in the pevious entries:
>>
>> The first (root) object that is loaded is the diagram object. While
>> loading (in StoreResource.addToContent()) the
>> TransactionChangeRecorder gets a notification and adds itself as
>> listener to the diagram object. This in turn calls the
>> TransactionChangeRecorder.setTarget() method.
>> This method goes through the eContents-List of the target (the
>> diagram object) and adds itself (the TransactionChangeRecorder) to
>> every feature in the list. Since my model root object located in the
>> diagram field "element" is not in the list, the
>> TransactionChangeRecorder is never added to that object. The
>> eContents list only has the sublists of diagram
>> (eAnnotation,children,styles,transientChildren,edges and
>> transientEdges). So every subobject in this lists got the
>> TransactionChangeRecorder as listener, but none of my model elements.
>>
>> I think the reason is that from the diagram point of view all model
>> objects are not referenced as containment relationship but only as
>> assotiation. Perhaps this explains the need for the previous load of
>> my business object model.
>>
>> Since I have made myself an explanation for the behaviour that sounds
>> logical I am astonished that things work in another way in your
>> environment.
>> Thanks for the hint to the new build. I will try the S version, since
>> I didn't switch to eclipse 3.4 until now.
>>
>> Best regards
>>
>> Manfred
>>
>>
>
>
Re: Loading a GMF diagram resource from Hibernate [message #114347 is a reply to message #114323] Mon, 10 March 2008 07:48 Go to previous messageGo to next message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Martin, Ed,

I don't know enough about proxy resolution. My model root object was
instantiated directly after the instantiation of the diagram object. So I
thought this is the 'real' object and not the proxy. Model objects that
exists deeper in the model tree came to life later on, after every object
of the gmf diagram had been instantiated and filled with the
TransactionChangeRecorder listener.

Perhaps your or Ed can tell me a source code point for setting my
breakpoint to verify the situation when proxy resolution takes place. I
think this had to be the second point where the seeding of the
TransactionChangeRecorder should take place, but in my environment it
doesn't.

Regards, Manfred
Re: Loading a GMF diagram resource from Hibernate [message #114375 is a reply to message #114347] Mon, 10 March 2008 08:25 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
Proxy resolving ends up in the EcoreUtil class and then this method:
public static EObject resolve(EObject proxy, ResourceSet resourceSet)

From there it goes to the ResourceSet.getEObject method which opens a resource.

Btw, when I look at my example there are many more element references to model objects, so not only
to the rootobject, for example my diagram.xmi:
<children xmi:type="notation:Node" xmi:id="_V1wv0OvwEdyFq5MoP8jkCw" type="1002">
<children xmi:type="notation:Node" xmi:id="_V1zzIOvwEdyFq5MoP8jkCw" type="4002">
<layoutConstraint xmi:type="notation:Location" xmi:id="_V10aMOvwEdyFq5MoP8jkCw" y="5"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_V1wv0evwEdyFq5MoP8jkCw" fontName="Bitstream
Vera Sans"/>
<element xmi:type="statem:StartState" href="teneo.statem?DISABLE_NOTIFY=true#StartState|id=16"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_V1wv0uvwEdyFq5MoP8jkCw" x="432" y="32"/>
</children>

My feel is that it is somehow related to non-loaded lazy loading lists... You can try to set a
breakpoint in the method StoreResource.getNonResolvingAllContents method. This method will not load
lazy loaded lists while maybe EMF expects a full iterator over all model objects.

gr. Martin

Manfred Hahn wrote:
> Hi Martin, Ed,
>
> I don't know enough about proxy resolution. My model root object was
> instantiated directly after the instantiation of the diagram object. So
> I thought this is the 'real' object and not the proxy. Model objects
> that exists deeper in the model tree came to life later on, after every
> object of the gmf diagram had been instantiated and filled with the
> TransactionChangeRecorder listener.
> Perhaps your or Ed can tell me a source code point for setting my
> breakpoint to verify the situation when proxy resolution takes place. I
> think this had to be the second point where the seeding of the
> TransactionChangeRecorder should take place, but in my environment it
> doesn't.
>
> Regards, Manfred
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #114405 is a reply to message #114375] Mon, 10 March 2008 15:01 Go to previous messageGo to next message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Martin,

hmm, my environment seems to be completely different, I don't have any
xmi file especially not for the diagram resource (my own model is
designed with rose as shown in the emf tutorials). The diagram resource
structure is directly taken from the EcorePackage.eINSTANCE and
NotationPackage.eINSTANCE which I gave to the HbDataStore.setEPackages().

Looking at your extract of the diagram.xmi I see that the element feature
has a direct connection to your model (I think the statem:StartState is
one element of your model?!). This direct connection is NOT present in my
environment! Since I took the NotationPackage as it is, the element
feature (derived from View) has an EObject type.

Where does your xmi file come from? How can I generate that specialized
diagram resource?

The eEObject.resolve() method is never called (!?)

The StoreResource.getNonResolvingAllContents() is called every time I load
a resource in the context of setTrackingModification(true). There the
modificationTrackingAdapter is set to the Objects. This is done after the
TransactionChangeRecorder has been tagged to the objects. My model object
is not in the list that getNonResolvingAllContents() gives back for the
DiagramImp object. Dont't know if this helps you.
Re: Loading a GMF diagram resource from Hibernate [message #114452 is a reply to message #114405] Mon, 10 March 2008 16:28 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
I don't store the diagram in the database (although I might try your approach today), the model data
is stored in the database. So the diagram data (were the icons are placed in the graphical view) are
defined in a xmi file while the data is defined in the database. The teneo.statem resource (you can
see in xmi) is a HibernateResource which uses a DataStore with the name statem.

The latest s build also solves the issue I had with the create - save - delete - save - undo delete
- save scenario.

I can also try to save the diagram in the db. I have sent an email to the gmf developers if this
persistedChildren issue can not be solved (there is a ptach for it available). I am a bit reluctant
to implement a specific EListPropertyHandler just for this. But maybe I will try. I will do a demo
on eclipsecon on monday with a gmf teneo integration so therefore I am interested to make this nicer.

gr. Martin

Manfred Hahn wrote:
> Hi Martin,
>
> hmm, my environment seems to be completely different, I don't have any
> xmi file especially not for the diagram resource (my own model is
> designed with rose as shown in the emf tutorials). The diagram resource
> structure is directly taken from the EcorePackage.eINSTANCE and
> NotationPackage.eINSTANCE which I gave to the HbDataStore.setEPackages().
>
> Looking at your extract of the diagram.xmi I see that the element
> feature has a direct connection to your model (I think the
> statem:StartState is one element of your model?!). This direct
> connection is NOT present in my environment! Since I took the
> NotationPackage as it is, the element feature (derived from View) has an
> EObject type.
> Where does your xmi file come from? How can I generate that specialized
> diagram resource?
>
> The eEObject.resolve() method is never called (!?)
>
> The StoreResource.getNonResolvingAllContents() is called every time I
> load a resource in the context of setTrackingModification(true). There
> the modificationTrackingAdapter is set to the Objects. This is done
> after the TransactionChangeRecorder has been tagged to the objects. My
> model object is not in the list that getNonResolvingAllContents() gives
> back for the DiagramImp object. Dont't know if this helps you.
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #615621 is a reply to message #114032] Fri, 07 March 2008 11:36 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
I don't have a solution right away.
The TransactionChangeRecorder has a setTarget method which sets the changerecorder in the content of
the resource. However when I look at this method it only adds itself to the root of the resource. So
not to the children. So this seems fine and inline with what you see. For the rest I know nothing
about how the views are update on the basis of model changes. Maybe Ed can say something about this.

btw, fyi I am also looking at the gmf teneo integration (see the my posts of today on the emf
newsgroup).

gr. Martin

Manfred Hahn wrote:
> Hi,
>
> I have a problem loading a GMF diagram I saved in a Hibernate database.
> In the editor and in the property view the diagram is shown, but when I
> try to change a property,say, a name of an object, the name in the
> diagram and in the property view is NOT changed. In the property view,
> after leaving the input cell, the old value of the property is shown.
> But the value I changed has been written into the model object! So the
> notification to the model object did happen, but not the notification
> back to the diagram editor.
>
> In debug I see that all my own model objects do not have the
> TransactionChangeRecorder listening to them. Since this is the main
> difference to the objects I add to a newly created diagram or to the GMF
> diagram objects in the loaded resource I believe this to be cause of the
> behaviour.
>
> I load the diagram with an URI containing a query that ensures I am
> loading only one diagram out of the database. Since my root model object
> is contained in the root diagram object as EObject element, my model
> objects should be loaded with the diagram objects - and they are. But
> only the diagram objects got the Transaction Change Recorder listener.
>
> I made some experiments with loadStrategy=StoreResource.ADD_TO_CONTENTS
> and I loaded my model objects explicitly before the load of the diagram,
> but nothing did help.
>
> (This has nothing to do with the readOnly problem of the hibernate
> resource. I have overwritten the DiagramEditingDomain(Factory) to ensure
> that all hibernate resources are read-write.)
>
>
> I would be glad if someone can help me.
>
> With regards
>
> Manfred Hahn
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #615628 is a reply to message #114044] Fri, 07 March 2008 20:24 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Martin,

When the adapter is added to an eAdaters list, it will cause setTarget
to be called (just like bidirectional handshaking), so the way it's
written, adding the adapter to a resource set, resource, or object
should recursively cause the adapters to be added to the entire
containment tree starting from that point. So the fact that adapters
are missing from some portion of the tree is definitely a sign that
something isn't quite right in the expected behavior of the model.


Martin Taal wrote:
> Hi Manfred,
> I don't have a solution right away.
> The TransactionChangeRecorder has a setTarget method which sets the
> changerecorder in the content of the resource. However when I look at
> this method it only adds itself to the root of the resource. So not to
> the children. So this seems fine and inline with what you see. For the
> rest I know nothing about how the views are update on the basis of
> model changes. Maybe Ed can say something about this.
>
> btw, fyi I am also looking at the gmf teneo integration (see the my
> posts of today on the emf newsgroup).
>
> gr. Martin
>
> Manfred Hahn wrote:
>> Hi,
>>
>> I have a problem loading a GMF diagram I saved in a Hibernate database.
>> In the editor and in the property view the diagram is shown, but when
>> I try to change a property,say, a name of an object, the name in the
>> diagram and in the property view is NOT changed. In the property
>> view, after leaving the input cell, the old value of the property is
>> shown. But the value I changed has been written into the model
>> object! So the notification to the model object did happen, but not
>> the notification back to the diagram editor.
>>
>> In debug I see that all my own model objects do not have the
>> TransactionChangeRecorder listening to them. Since this is the main
>> difference to the objects I add to a newly created diagram or to the
>> GMF diagram objects in the loaded resource I believe this to be cause
>> of the behaviour.
>>
>> I load the diagram with an URI containing a query that ensures I am
>> loading only one diagram out of the database. Since my root model
>> object is contained in the root diagram object as EObject element, my
>> model objects should be loaded with the diagram objects - and they
>> are. But only the diagram objects got the Transaction Change Recorder
>> listener.
>>
>> I made some experiments with
>> loadStrategy=StoreResource.ADD_TO_CONTENTS and I loaded my model
>> objects explicitly before the load of the diagram, but nothing did help.
>>
>> (This has nothing to do with the readOnly problem of the hibernate
>> resource. I have overwritten the DiagramEditingDomain(Factory) to
>> ensure that all hibernate resources are read-write.)
>>
>>
>> I would be glad if someone can help me.
>>
>> With regards
>>
>> Manfred Hahn
>>
>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Loading a GMF diagram resource from Hibernate [message #615629 is a reply to message #114101] Fri, 07 March 2008 21:08 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Ed, okay clear, Manfred is this something that you can debug to see what goes wrong (with me it
works fine afaics). From there we can try to find a solution.

gr. Martin

Ed Merks wrote:
> Martin,
>
> When the adapter is added to an eAdaters list, it will cause setTarget
> to be called (just like bidirectional handshaking), so the way it's
> written, adding the adapter to a resource set, resource, or object
> should recursively cause the adapters to be added to the entire
> containment tree starting from that point. So the fact that adapters
> are missing from some portion of the tree is definitely a sign that
> something isn't quite right in the expected behavior of the model.
>
>
> Martin Taal wrote:
>> Hi Manfred,
>> I don't have a solution right away.
>> The TransactionChangeRecorder has a setTarget method which sets the
>> changerecorder in the content of the resource. However when I look at
>> this method it only adds itself to the root of the resource. So not to
>> the children. So this seems fine and inline with what you see. For the
>> rest I know nothing about how the views are update on the basis of
>> model changes. Maybe Ed can say something about this.
>>
>> btw, fyi I am also looking at the gmf teneo integration (see the my
>> posts of today on the emf newsgroup).
>>
>> gr. Martin
>>
>> Manfred Hahn wrote:
>>> Hi,
>>>
>>> I have a problem loading a GMF diagram I saved in a Hibernate database.
>>> In the editor and in the property view the diagram is shown, but when
>>> I try to change a property,say, a name of an object, the name in the
>>> diagram and in the property view is NOT changed. In the property
>>> view, after leaving the input cell, the old value of the property is
>>> shown. But the value I changed has been written into the model
>>> object! So the notification to the model object did happen, but not
>>> the notification back to the diagram editor.
>>>
>>> In debug I see that all my own model objects do not have the
>>> TransactionChangeRecorder listening to them. Since this is the main
>>> difference to the objects I add to a newly created diagram or to the
>>> GMF diagram objects in the loaded resource I believe this to be cause
>>> of the behaviour.
>>>
>>> I load the diagram with an URI containing a query that ensures I am
>>> loading only one diagram out of the database. Since my root model
>>> object is contained in the root diagram object as EObject element, my
>>> model objects should be loaded with the diagram objects - and they
>>> are. But only the diagram objects got the Transaction Change Recorder
>>> listener.
>>>
>>> I made some experiments with
>>> loadStrategy=StoreResource.ADD_TO_CONTENTS and I loaded my model
>>> objects explicitly before the load of the diagram, but nothing did help.
>>>
>>> (This has nothing to do with the readOnly problem of the hibernate
>>> resource. I have overwritten the DiagramEditingDomain(Factory) to
>>> ensure that all hibernate resources are read-write.)
>>>
>>>
>>> I would be glad if someone can help me.
>>>
>>> With regards
>>>
>>> Manfred Hahn
>>>
>>>
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #615630 is a reply to message #114101] Fri, 07 March 2008 21:16 Go to previous message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Ed,

I understand that recursive behaviour. The
TransactionChangeRecorder.setTarget() method does this thing. But it only
adds itself to the
((EObject) target).eContents()) elements
and in my debug sessions I have seen only the one-to-many-Features of the
Diagram called. The thing boils down to the question, why the
ViewImpl.element feature is not in the contents list. Is this a problem of
the one-to-one relation? Do I (or the GMF team) have to modify the
ViewImpl?
But some more questions arise, look at my parallel question to Martin. I
still hope I made a complete silly - and easy to correct - mistake
somewhere.

Thanks for your help

Manfred
Re: Loading a GMF diagram resource from Hibernate [message #615631 is a reply to message #114044] Fri, 07 March 2008 21:20 Go to previous message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Martin,

I detected some strange behavior:

In order to force the TransactionChangeRecorder listening on my model
object I loaded them before the diagram load with the
loadStrategy=StoreResource.ADD_TO_CONTENTS. As expected every object got
the TransactionChangeRecorder as listener. (Look at Ed's comment)

Then I loaded the diagram resource in the same session, but with another
query. But this load created new model objects (in the debugger they have
new IDs, but they were loaded from the same database row) and of course
they had no TransactionChangeRecorder listening. They run into the
instanceNotYetLoaded method of the loader class. I expected every object
to be loaded only one time!

So I looked again at the Hibernate EMF Resource documentation - the fat
printet hint. In my case I have an object A1 (my model root) as root
object of one resource loaded by a query. I have another object A0 (the
diagram) as a root object in in another resource loaded by another query.
A0 contains A1. I do not understand the resolving=true/false hint
(annotation, property?? Where do I set it?), but looking at the
ViewImpl.getElement() method it looks like a simple one way reference that
has been modified. Anyway the two resources reside in the same ResourceSet
and share the same session. Can you explain why there is that double load?

Manfred
Re: Loading a GMF diagram resource from Hibernate [message #615632 is a reply to message #114118] Fri, 07 March 2008 22:48 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
See my comments inline.

gr. Martin

Manfred Hahn wrote:
> Hi Martin,
>
> I detected some strange behavior:
>
> In order to force the TransactionChangeRecorder listening on my model
> object I loaded them before the diagram load with the
> loadStrategy=StoreResource.ADD_TO_CONTENTS. As expected every object got
> the TransactionChangeRecorder as listener. (Look at Ed's comment)
>
> Then I loaded the diagram resource in the same session, but with another
> query. But this load created new model objects (in the debugger they
> have new IDs, but they were loaded from the same database row) and of
> course they had no TransactionChangeRecorder listening. They run into
> the instanceNotYetLoaded method of the loader class. I expected every
> object to be loaded only one time!
MT>> Yes I would also expect this also. Are sure that the extra objects are not present in the db?
So that the model objects are persisted twice during save? Otherwise I can only explain this if the
two resources have been loaded using different sessions.

> So I looked again at the Hibernate EMF Resource documentation - the fat
> printet hint. In my case I have an object A1 (my model root) as root
> object of one resource loaded by a query. I have another object A0 (the
> diagram) as a root object in in another resource loaded by another
> query. A0 contains A1. I do not understand the resolving=true/false hint
> (annotation, property?? Where do I set it?),
MT>> It is the resolved proxies property of the ereference. If the generated code supports
containment proxies then an object can be in a different resource than its parent.

but looking at the
> ViewImpl.getElement() method it looks like a simple one way reference
> that has been modified. Anyway the two resources reside in the same
> ResourceSet and share the same session. Can you explain why there is
> that double load?
>
> Manfred
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #615634 is a reply to message #114113] Fri, 07 March 2008 22:54 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
You mean that the ViewImpl.element association is not traversed when setting the adapter
(changerecorder)? As far as I can see the ViewImpl.element is not a containment relation. So this
explains why it is not considered in the all contents list. If you mean this.
When using the load strategy addtocontents (=the default) the refered-to objects should be added to
the resource in the top of the resource or the container of the object should be present there.

gr. Martin

Manfred Hahn wrote:
> Hi Ed,
>
> I understand that recursive behaviour. The
> TransactionChangeRecorder.setTarget() method does this thing. But it
> only adds itself to the ((EObject) target).eContents()) elements
> and in my debug sessions I have seen only the one-to-many-Features of
> the Diagram called. The thing boils down to the question, why the
> ViewImpl.element feature is not in the contents list. Is this a problem
> of the one-to-one relation? Do I (or the GMF team) have to modify the
> ViewImpl?
> But some more questions arise, look at my parallel question to Martin. I
> still hope I made a complete silly - and easy to correct - mistake
> somewhere.
>
> Thanks for your help
>
> Manfred
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #615637 is a reply to message #114122] Sat, 08 March 2008 09:16 Go to previous message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Martin,

my usage of the sessionController parameter in the URI was wrong: I simply
added the parameter to the URI string and did not delete the dsname
parameter, so the sessionController was not activated.

And: with this one Session my Problem was solved!!! (Hurray)

So this is the workaround for loading diagrams in a way that they are
editable:
- load the model objects before loading the diagram objects with the
loadStrategy=StoreResource.ADD_TO_CONTENTS (the latter is indispensable)
- load the diagram objects in the same session as the model objects

Though I'm very happy that this works it is not the way it should be:
loading only the diagram objects without extra activities should do a
correct load and initialization with the correct listeners. Since
everything in the ViewImpl seems to be correct this is a question of the
loading strategie!?!

Thanks and best regards from

Manfred
Re: Loading a GMF diagram resource from Hibernate [message #615638 is a reply to message #114127] Sat, 08 March 2008 12:58 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
Good to hear that this issue is not a problem after all.

Regarding the adapters. Would it be possible for you to debug why just loading the diagram does not
work? Why are the adapters not added to the children (the model objects)? With me it works fine
otherwise I would test it out.

Btw, I changed the resource implementation which should solve three things:
- loading a resource can now be done without the disable_notify parameter
- saving a resource does not need to be done a emft transaction anymore (the notifications are
disabled during save)
- removed objects were still validated, so a resource with a removed object which was invalid does
not save (because of validation errors). This is solved.

If you are interested the builds with these solutions can be downloaded here:
http://emft.eclipse.org/modeling/emft/downloads/?project=ten eo&sortBy=date&hlbuild=0#latest

The latest S build is for eclipse 3.4, the latest I build is for eclipse 3.3.

Today I will solve another issue, nl. that when doing save - undo - save in the diagram results in a
hibernate error.

gr. Martin

Manfred Hahn wrote:
> Hi Martin,
>
> my usage of the sessionController parameter in the URI was wrong: I
> simply added the parameter to the URI string and did not delete the
> dsname parameter, so the sessionController was not activated.
>
> And: with this one Session my Problem was solved!!! (Hurray)
>
> So this is the workaround for loading diagrams in a way that they are
> editable:
> - load the model objects before loading the diagram objects with the
> loadStrategy=StoreResource.ADD_TO_CONTENTS (the latter is indispensable)
> - load the diagram objects in the same session as the model objects
>
> Though I'm very happy that this works it is not the way it should be:
> loading only the diagram objects without extra activities should do a
> correct load and initialization with the correct listeners. Since
> everything in the ViewImpl seems to be correct this is a question of the
> loading strategie!?!
>
> Thanks and best regards from
>
> Manfred
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #615643 is a reply to message #114128] Sun, 09 March 2008 11:26 Go to previous message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Martin,

I've debugged everything to the ground in the last days, so I can not tell
you any more than I told in the pevious entries:

The first (root) object that is loaded is the diagram object. While
loading (in StoreResource.addToContent()) the TransactionChangeRecorder
gets a notification and adds itself as listener to the diagram object.
This in turn calls the TransactionChangeRecorder.setTarget() method.

This method goes through the eContents-List of the target (the diagram
object) and adds itself (the TransactionChangeRecorder) to every feature
in the list. Since my model root object located in the diagram field
"element" is not in the list, the TransactionChangeRecorder is never added
to that object. The eContents list only has the sublists of diagram
(eAnnotation,children,styles,transientChildren,edges and transientEdges).
So every subobject in this lists got the TransactionChangeRecorder as
listener, but none of my model elements.

I think the reason is that from the diagram point of view all model
objects are not referenced as containment relationship but only as
assotiation. Perhaps this explains the need for the previous load of my
business object model.

Since I have made myself an explanation for the behaviour that sounds
logical I am astonished that things work in another way in your
environment.

Thanks for the hint to the new build. I will try the S version, since I
didn't switch to eclipse 3.4 until now.

Best regards

Manfred
Re: Loading a GMF diagram resource from Hibernate [message #615648 is a reply to message #114235] Sun, 09 March 2008 18:51 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Ed (or someone else who knows GMF-EMF), as far as I can see the description of Manfred sounds
logical (as the element efeature is not a containment relation the adapter is not added to the model
objects). I will debug it myself but if someone knows the answer why it works that would be great
ofcourse.

Manfred, I will debug to find out why it works in my environment. Btw, the s build is for 3.4 and
the i build for 3.3. I don't think it makes a big difference because both are built from the same
source tree.

gr. Martin

Manfred Hahn wrote:
> Hi Martin,
>
> I've debugged everything to the ground in the last days, so I can not
> tell you any more than I told in the pevious entries:
>
> The first (root) object that is loaded is the diagram object. While
> loading (in StoreResource.addToContent()) the TransactionChangeRecorder
> gets a notification and adds itself as listener to the diagram object.
> This in turn calls the TransactionChangeRecorder.setTarget() method.
> This method goes through the eContents-List of the target (the diagram
> object) and adds itself (the TransactionChangeRecorder) to every feature
> in the list. Since my model root object located in the diagram field
> "element" is not in the list, the TransactionChangeRecorder is never
> added to that object. The eContents list only has the sublists of
> diagram (eAnnotation,children,styles,transientChildren,edges and
> transientEdges). So every subobject in this lists got the
> TransactionChangeRecorder as listener, but none of my model elements.
>
> I think the reason is that from the diagram point of view all model
> objects are not referenced as containment relationship but only as
> assotiation. Perhaps this explains the need for the previous load of my
> business object model.
>
> Since I have made myself an explanation for the behaviour that sounds
> logical I am astonished that things work in another way in your
> environment.
> Thanks for the hint to the new build. I will try the S version, since I
> didn't switch to eclipse 3.4 until now.
>
> Best regards
>
> Manfred
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #615651 is a reply to message #114297] Sun, 09 March 2008 21:50 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Martin,

From what I understand of this GMF scenario, the change recorder is
added to the resource set so when the proxy from the diagram to the root
object of the model is resolved, the model's resource should be loaded
and the end result of all that processing should be that the change
recorder ends up being attached to all the objects in the model
resource. So perhaps there is some issue with the notifications that
result during demand loading that lead to this misbehavior...


Martin Taal wrote:
> Ed (or someone else who knows GMF-EMF), as far as I can see the
> description of Manfred sounds logical (as the element efeature is not
> a containment relation the adapter is not added to the model objects).
> I will debug it myself but if someone knows the answer why it works
> that would be great ofcourse.
>
> Manfred, I will debug to find out why it works in my environment. Btw,
> the s build is for 3.4 and the i build for 3.3. I don't think it makes
> a big difference because both are built from the same source tree.
>
> gr. Martin
>
> Manfred Hahn wrote:
>> Hi Martin,
>>
>> I've debugged everything to the ground in the last days, so I can not
>> tell you any more than I told in the pevious entries:
>>
>> The first (root) object that is loaded is the diagram object. While
>> loading (in StoreResource.addToContent()) the
>> TransactionChangeRecorder gets a notification and adds itself as
>> listener to the diagram object. This in turn calls the
>> TransactionChangeRecorder.setTarget() method.
>> This method goes through the eContents-List of the target (the
>> diagram object) and adds itself (the TransactionChangeRecorder) to
>> every feature in the list. Since my model root object located in the
>> diagram field "element" is not in the list, the
>> TransactionChangeRecorder is never added to that object. The
>> eContents list only has the sublists of diagram
>> (eAnnotation,children,styles,transientChildren,edges and
>> transientEdges). So every subobject in this lists got the
>> TransactionChangeRecorder as listener, but none of my model elements.
>>
>> I think the reason is that from the diagram point of view all model
>> objects are not referenced as containment relationship but only as
>> assotiation. Perhaps this explains the need for the previous load of
>> my business object model.
>>
>> Since I have made myself an explanation for the behaviour that sounds
>> logical I am astonished that things work in another way in your
>> environment.
>> Thanks for the hint to the new build. I will try the S version, since
>> I didn't switch to eclipse 3.4 until now.
>>
>> Best regards
>>
>> Manfred
>>
>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Loading a GMF diagram resource from Hibernate [message #615657 is a reply to message #114323] Mon, 10 March 2008 07:48 Go to previous message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Martin, Ed,

I don't know enough about proxy resolution. My model root object was
instantiated directly after the instantiation of the diagram object. So I
thought this is the 'real' object and not the proxy. Model objects that
exists deeper in the model tree came to life later on, after every object
of the gmf diagram had been instantiated and filled with the
TransactionChangeRecorder listener.

Perhaps your or Ed can tell me a source code point for setting my
breakpoint to verify the situation when proxy resolution takes place. I
think this had to be the second point where the seeding of the
TransactionChangeRecorder should take place, but in my environment it
doesn't.

Regards, Manfred
Re: Loading a GMF diagram resource from Hibernate [message #615662 is a reply to message #114347] Mon, 10 March 2008 08:25 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
Proxy resolving ends up in the EcoreUtil class and then this method:
public static EObject resolve(EObject proxy, ResourceSet resourceSet)

From there it goes to the ResourceSet.getEObject method which opens a resource.

Btw, when I look at my example there are many more element references to model objects, so not only
to the rootobject, for example my diagram.xmi:
<children xmi:type="notation:Node" xmi:id="_V1wv0OvwEdyFq5MoP8jkCw" type="1002">
<children xmi:type="notation:Node" xmi:id="_V1zzIOvwEdyFq5MoP8jkCw" type="4002">
<layoutConstraint xmi:type="notation:Location" xmi:id="_V10aMOvwEdyFq5MoP8jkCw" y="5"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_V1wv0evwEdyFq5MoP8jkCw" fontName="Bitstream
Vera Sans"/>
<element xmi:type="statem:StartState" href="teneo.statem?DISABLE_NOTIFY=true#StartState|id=16"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_V1wv0uvwEdyFq5MoP8jkCw" x="432" y="32"/>
</children>

My feel is that it is somehow related to non-loaded lazy loading lists... You can try to set a
breakpoint in the method StoreResource.getNonResolvingAllContents method. This method will not load
lazy loaded lists while maybe EMF expects a full iterator over all model objects.

gr. Martin

Manfred Hahn wrote:
> Hi Martin, Ed,
>
> I don't know enough about proxy resolution. My model root object was
> instantiated directly after the instantiation of the diagram object. So
> I thought this is the 'real' object and not the proxy. Model objects
> that exists deeper in the model tree came to life later on, after every
> object of the gmf diagram had been instantiated and filled with the
> TransactionChangeRecorder listener.
> Perhaps your or Ed can tell me a source code point for setting my
> breakpoint to verify the situation when proxy resolution takes place. I
> think this had to be the second point where the seeding of the
> TransactionChangeRecorder should take place, but in my environment it
> doesn't.
>
> Regards, Manfred
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: Loading a GMF diagram resource from Hibernate [message #615666 is a reply to message #114375] Mon, 10 March 2008 15:01 Go to previous message
Manfred Hahn is currently offline Manfred HahnFriend
Messages: 64
Registered: July 2009
Member
Hi Martin,

hmm, my environment seems to be completely different, I don't have any
xmi file especially not for the diagram resource (my own model is
designed with rose as shown in the emf tutorials). The diagram resource
structure is directly taken from the EcorePackage.eINSTANCE and
NotationPackage.eINSTANCE which I gave to the HbDataStore.setEPackages().

Looking at your extract of the diagram.xmi I see that the element feature
has a direct connection to your model (I think the statem:StartState is
one element of your model?!). This direct connection is NOT present in my
environment! Since I took the NotationPackage as it is, the element
feature (derived from View) has an EObject type.

Where does your xmi file come from? How can I generate that specialized
diagram resource?

The eEObject.resolve() method is never called (!?)

The StoreResource.getNonResolvingAllContents() is called every time I load
a resource in the context of setTrackingModification(true). There the
modificationTrackingAdapter is set to the Objects. This is done after the
TransactionChangeRecorder has been tagged to the objects. My model object
is not in the list that getNonResolvingAllContents() gives back for the
DiagramImp object. Dont't know if this helps you.
Re: Loading a GMF diagram resource from Hibernate [message #615673 is a reply to message #114405] Mon, 10 March 2008 16:28 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Manfred,
I don't store the diagram in the database (although I might try your approach today), the model data
is stored in the database. So the diagram data (were the icons are placed in the graphical view) are
defined in a xmi file while the data is defined in the database. The teneo.statem resource (you can
see in xmi) is a HibernateResource which uses a DataStore with the name statem.

The latest s build also solves the issue I had with the create - save - delete - save - undo delete
- save scenario.

I can also try to save the diagram in the db. I have sent an email to the gmf developers if this
persistedChildren issue can not be solved (there is a ptach for it available). I am a bit reluctant
to implement a specific EListPropertyHandler just for this. But maybe I will try. I will do a demo
on eclipsecon on monday with a gmf teneo integration so therefore I am interested to make this nicer.

gr. Martin

Manfred Hahn wrote:
> Hi Martin,
>
> hmm, my environment seems to be completely different, I don't have any
> xmi file especially not for the diagram resource (my own model is
> designed with rose as shown in the emf tutorials). The diagram resource
> structure is directly taken from the EcorePackage.eINSTANCE and
> NotationPackage.eINSTANCE which I gave to the HbDataStore.setEPackages().
>
> Looking at your extract of the diagram.xmi I see that the element
> feature has a direct connection to your model (I think the
> statem:StartState is one element of your model?!). This direct
> connection is NOT present in my environment! Since I took the
> NotationPackage as it is, the element feature (derived from View) has an
> EObject type.
> Where does your xmi file come from? How can I generate that specialized
> diagram resource?
>
> The eEObject.resolve() method is never called (!?)
>
> The StoreResource.getNonResolvingAllContents() is called every time I
> load a resource in the context of setTrackingModification(true). There
> the modificationTrackingAdapter is set to the Objects. This is done
> after the TransactionChangeRecorder has been tagged to the objects. My
> model object is not in the list that getNonResolvingAllContents() gives
> back for the DiagramImp object. Dont't know if this helps you.
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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
Previous Topic:[Teneo] many to many relations with java-annotations
Next Topic:[Teneo/EMF] Question
Goto Forum:
  


Current Time: Thu Mar 28 23:22:44 GMT 2024

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

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

Back to the top