Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] Loading each object in multiple resources
[Teneo] Loading each object in multiple resources [message #799208] Wed, 15 February 2012 16:04 Go to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
Hi,

We're trying to show a list of persons which input is set as an observablelist. Therefore we have a person EMF Resource which holds all persons. When a person is doubleclicked we want to make a separate resource for this person, so when this resource is saved, only one person is saved.

Is there a way to do this or is this the wrong approach?

[Updated on: Tue, 21 February 2012 10:54]

Report message to a moderator

Re: Loading each object in multiple resources [message #799224 is a reply to message #799208] Wed, 15 February 2012 16:16 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Ricky,

Comments below.

On 15/02/2012 5:04 PM, Ricky de Klerck wrote:
> Hi,
>
> We're trying to show a list of persons which input is set as an
> observablelist. Therefore we have a person EMF Resource which holds
> all persons. When a person is doubleclicked we want to make a separate
> resource for this person, so when this resource is saved, only one
> person is saved.
Is it intended they be removed from "all persons" resource.
>
> Is there a way to do this or is this the wrong approach?
What you describe is similar to the "ControlAction" which can be used to
move an object in a proxy resolving containment reference (a containment
reference that's allowed to cross resource boundaries) to its own resource.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Loading each object in multiple resources [message #799711 is a reply to message #799224] Thu, 16 February 2012 08:07 Go to previous messageGo to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
Thanks for your answer. Do you have an example on how to use this controlaction?
Re: Loading each object in multiple resources [message #799718 is a reply to message #799711] Thu, 16 February 2012 08:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Ricky,

You can see this in any model that has resolving containment proxies.
You need to set "Containment Proxies" to true in the GenModel for that
to be supported. An example you can try is in an Ecore model, an EClass
has "Control..." item on the context menu for invoking this action.


On 16/02/2012 9:07 AM, Ricky de Klerck wrote:
> Thanks for your answer. Do you have an example on how to use this
> controlaction?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Loading each object in multiple resources [message #799736 is a reply to message #799718] Thu, 16 February 2012 08:53 Go to previous messageGo to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
I see, that is exactly what i'm looking for.. but how should invoke it in my situation. My selection contains an EObject and I want to control this object.

My object is controllable because this: editingDomain.isControllable(object); returns true. But how can I gain control? Do I have to specify a new URI and load a new resource?

[Updated on: Thu, 16 February 2012 09:11]

Report message to a moderator

Re: Loading each object in multiple resources [message #799757 is a reply to message #799736] Thu, 16 February 2012 09:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Ricky,

What you described sounded a little different though. You had objects
that are directly contained in a resource and an object cannot be
contained by two resources at once. If you created an object that via
proxy resolving containment held all the Person instances, and set your
GenModel Containment Proxies to true, then it will "just work" in your
generated editor without you writing any code.


On 16/02/2012 9:53 AM, Ricky de Klerck wrote:
> I see, that is exactly what i'm looking for.. but how should invoke it
> in my situation. My selection contains an EObject and I want to
> control this object. I'm trying to do something like this:
>
>
> controlAction = new ControlAction(editingDomain);
> controlAction.updateSelection(new StructuredSelection(mObject));
>
>
> Is this the right approach?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Loading each object in multiple resources [message #799765 is a reply to message #799757] Thu, 16 February 2012 09:34 Go to previous messageGo to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
Ok, this is my model:

Container
- 0..* persons : Person
Person
- id
- name

My initial resource is loaded by 'hibernate://?sessionController=SC&query1=FROM Container'. My tableviewer with all persons is filled with this input: 'new EditingDomainEObjectObservableList(getEditingDomain(), INITIAL_RESOURCE, ModelPackage.Literals.CONTAINER__PERSONS);'.

When double clicking on a person, a new view is opened. When saving this person the resource of this EObject is still 'hibernate://?sessionController=SC&query1=FROM Container', so everything in this resource is saved.. I've set containment proxies to true, but it doesn't help. I really appreciate your help and I hope I can figure this out, cause it's really important.
Re: Loading each object in multiple resources [message #799774 is a reply to message #799765] Thu, 16 February 2012 09:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Ricky,

Comments below.

On 16/02/2012 10:34 AM, Ricky de Klerck wrote:
> Ok, this is my model:
>
> Container
> - 0..* persons : Person
> Person
> - id
> - name
>
> My initial resource is loaded by
> 'hibernate://?sessionController=SC&query1=FROM Container'. My
> tableviewer with all persons is filled with this input: 'new
> EditingDomainEObjectObservableList(getEditingDomain(),
> INITIAL_RESOURCE, ModelPackage.Literals.CONTAINER__PERSONS);'.
So you're using data binding, not the generated editor.
>
> When double clicking on a person, a new view is opened.
That's something you programmed yourself...
> When saving this person the resource of this EObject is still
> 'hibernate://?sessionController=SC&query1=FROM Container', so
> everything in this resource is saved.. I've set containment proxies to
> true, but it doesn't help. I really appreciate your help and I hope I
> can figure this out, cause it's really important.
So your question may be more of what about what does Teneo support?

The best I can suggest is you generate the standard editor and look at
how it behaves. If you've set Containment Proxies to true in your
GenModel and generate the standard editor, the context menu for Person
will have a Control... item on it. You can then use the debugger to see
how ControlAction supports that and from there figure out how you can do
something similar in your hand-written application. I don't know that
Teneo does or doesn't support cross document containment...


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Loading each object in multiple resources [message #799809 is a reply to message #799774] Thu, 16 February 2012 10:48 Go to previous messageGo to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
I'm not sure if it should work with Teneo. I now have two resources:

- uri='hibernate://?sessionController=SC&query1=FROM Container'
- uri='hibernate://?sessionController=SC&query1=FROM Person WHERE id = 2'

When saving the second one, everything in the first one is also saved. This should be the right approach though in my opinion.

[Updated on: Thu, 16 February 2012 10:48]

Report message to a moderator

Re: Loading each object in multiple resources [message #799821 is a reply to message #799809] Thu, 16 February 2012 10:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Ricky,

Comments below.

On 16/02/2012 11:48 AM, Ricky de Klerck wrote:
> I'm not sure if it should work with Teneo.
Me neither. You are using Teneo though?
> I now have two resources:
>
> - uri='hibernate://?sessionController=SC&query1=FROM Container'
> mailto:org.eclipse.emf.teneo.hibernate.resource.HibernateResource@4de3e1b8
> - uri='hibernate://?sessionController=SC&query1=FROM Person WHERE id = 2'
>
> When saving the second one, everything in the first one is also saved.
Are you calling Resource.save on just one resource?
> This should be the right approach though in my opinion.
I think so, but I really know little about Hibernate or Teneo, so if
your questions are specifically about that, best you use [Teneo] in the
title so Martin will notice your question. I believe he's traveling
today, so maybe not as quick to answer as usual.


Ed Merks
Professional Support: https://www.macromodeling.com/
[Teneo] Re: Loading each object in multiple resources [message #799827 is a reply to message #799821] Thu, 16 February 2012 11:07 Go to previous messageGo to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
I just call EOBJECT.eResource.save()..

[Updated on: Tue, 21 February 2012 10:55]

Report message to a moderator

Re: [Teneo] Re: Loading each object in multiple resources [message #803440 is a reply to message #799827] Tue, 21 February 2012 10:55 Go to previous messageGo to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
Changed title with prefix '[Teneo]'
Re: [Teneo] Re: Loading each object in multiple resources [message #803700 is a reply to message #803440] Tue, 21 February 2012 17:17 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Now I noticed :-), checking your last question. Hibernate will cascade the save action to other resources as well, there
is nothing to do about it. Hibernate needs to save also the references (often, if they have changed or are new) and
these references can be in objects in other resources.

To get back to your original question about opening a new view with a person.Normally only the changed objects are saved
to the database, don't you see this?

gr. Martin

On 02/21/2012 11:55 AM, Ricky de Klerck wrote:
> Changed title with prefix '[Teneo]'


--

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] Re: Loading each object in multiple resources [message #805030 is a reply to message #803700] Thu, 23 February 2012 09:07 Go to previous messageGo to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
True, only changed objects are saved.. but since we make use of databinding, changes are directly put into the object. When doing a save on one object, every changed object in that resource is saved.

I understand about the cascade, but shouldn't every person have a it's own resource? We now have one resource containing all persons, but shouldn't it be one container resource containing a bunch of person resources? Each person having it's own resource? I'm just guessing here..
Re: [Teneo] Re: Loading each object in multiple resources [message #805092 is a reply to message #805030] Thu, 23 February 2012 10:19 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
We are not useing Resources at all in our Teneo and Databinding driven
RCP-Application.

We simply load objects through the hibernate-session (every View has its
own session) provided by teneo and later on call persist on it.

It's a long overdue bloh post from me to explain our Application Design
because we solved many many typical problems people have with using
Teneo in RCP applications.

Tom

Am 23.02.12 10:08, schrieb Ricky de Klerck:
> True, only changed objects are saved.. but since we make use of
> databinding, changes are directly put into the object. When doing a save
> on one object, every changed object in that resource is saved.
>
> I understand about the cascade, but shouldn't every person have a it's
> own resource? We now have one resource containing all persons, but
> shouldn't it be one container resource containing a bunch of person
> resources? Each person having it's own resource? I'm just guessing here..
Re: [Teneo] Re: Loading each object in multiple resources [message #805148 is a reply to message #805092] Thu, 23 February 2012 11:45 Go to previous messageGo to next message
Ricky de Klerck is currently offline Ricky de KlerckFriend
Messages: 295
Registered: January 2011
Senior Member
I would certainly be very interested in such a blog post. We're struggling with our application design for a while now..
Re: [Teneo] Re: Loading each object in multiple resources [message #805162 is a reply to message #805030] Thu, 23 February 2012 12:13 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
I have limited experience with rcp (I work mostly in web app environments), but I would say that you want to put
everything what needs to be saved together in one resource.

gr. Martin

On 02/23/2012 10:08 AM, Ricky de Klerck wrote:
> True, only changed objects are saved.. but since we make use of databinding, changes are directly put into the object.
> When doing a save on one object, every changed object in that resource is saved.
>
> I understand about the cascade, but shouldn't every person have a it's own resource? We now have one resource containing
> all persons, but shouldn't it be one container resource containing a bunch of person resources? Each person having it's
> own resource? I'm just guessing here..


--

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] Re: Loading each object in multiple resources [message #805232 is a reply to message #805162] Thu, 23 February 2012 14:25 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Oeps missed the reply from Tom, in general I don't like the resource concept that much for data-driven applications. I
like it much better to work directly with the hibernate session and do queries. Hopefully Tom will publish a blog post
soon...

gr. Martin

On 02/23/2012 01:13 PM, Martin Taal wrote:
> I have limited experience with rcp (I work mostly in web app environments), but I would say that you want to put
> everything what needs to be saved together in one resource.
>
> gr. Martin
>
> On 02/23/2012 10:08 AM, Ricky de Klerck wrote:
>> True, only changed objects are saved.. but since we make use of databinding, changes are directly put into the object.
>> When doing a save on one object, every changed object in that resource is saved.
>>
>> I understand about the cascade, but shouldn't every person have a it's own resource? We now have one resource containing
>> all persons, but shouldn't it be one container resource containing a bunch of person resources? Each person having it's
>> own resource? I'm just guessing here..
>
>


--

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
Previous Topic:[DataBinding]How to bind multi-level lists together
Next Topic:[CDO] Find All EClassifiers in CDOResource
Goto Forum:
  


Current Time: Fri Apr 19 14:36:10 GMT 2024

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

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

Back to the top