Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Utility to obtain model root(How can I easily obtain the model root object from a resource?)
Utility to obtain model root [message #508624] Tue, 19 January 2010 16:27
Pierre Francis Roy is currently offline Pierre Francis RoyFriend
Messages: 12
Registered: July 2009
Junior Member
Hi,

My application have two models that are persisted using Teneo. Each model have its own root which are contained in a resourceSet loaded from my database.

Here's my model root aggregates (using containment).

Application
Workspaces
Services
Database
Products
Samples
Results
Analysis

I'm searching an effective way to get a reference to Application and Database object from the resource object instead of doing something like this:

Resource resource = editingDomain.getResourceSet().getResource(resourceURI, true);
Application app = (Application) resource.get(0);
Database data = (Database) resource.get(1);

And having to guess that Application will be at index 0 and Database at index 1 (or vice-versa). I saw an article where the examples was using a utility function to easily get the root object, but can't find it back. Can you please give me hints about this subject?

Pierre
Re: Utility to obtain model root [message #508632 is a reply to message #508624] Tue, 19 January 2010 11:44 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020105090708070809010301
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Pierre,

See EcoreUtil.getObjectByType*.*


Pierre Francis Roy wrote:
> Hi,
>
> My application have two models that are persisted using Teneo. Each
> model have its own root which are contained in a resourceSet loaded
> from my database.
>
> Here's my model root aggregates (using containment).
>
> Application
> Workspaces
> Services
> Database
> Products
> Samples
> Results
> Analysis
>
> I'm searching an effective way to get a reference to Application and
> Database object from the resource object instead of doing something
> like this:
>
> Resource resource =
> editingDomain.getResourceSet().getResource(resourceURI, true);
> Application app = (Application) resource.get(0);
> Database data = (Database) resource.get(1);
>
> And having to guess that Application will be at index 0 and Database
> at index 1 (or vice-versa). I saw an article where the examples was
> using a utility function to easily get the root object, but can't find
> it back. Can you please give me hints about this subject?
>
> Pierre

--------------020105090708070809010301
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Pierre,<br>
<br>
See EcoreUtil.getObjectByType<b>.</b><br>
<br>
<br>
Pierre Francis Roy wrote:
<blockquote cite="mid:hj4mh5$tc3$1@build.eclipse.org" type="cite">Hi,
<br>
<br>
My application have two models that are persisted using Teneo. Each
model have its own root which are contained in a resourceSet loaded
from my database.
<br>
<br>
Here's my model root aggregates (using containment).
<br>
<br>
Application
<br>
 Workspaces
<br>
 Services
<br>
Database
<br>
 Products
<br>
 Samples
<br>
 Results
<br>
 Analysis
<br>
<br>
I'm searching an effective way to get a reference to Application and
Database object from the resource object instead of doing something
like this:
<br>
<br>
Resource resource =
editingDomain.getResourceSet().getResource(resourceURI, true);
<br>
Application app = (Application) resource.get(0);
<br>
Database data = (Database) resource.get(1);
<br>
<br>
And having to guess that Application will be at index 0 and Database at
index 1 (or vice-versa). I saw an article where the examples was using
a utility function to easily get the root object, but can't find it
back. Can you please give me hints about this subject?
<br>
<br>
Pierre
<br>
</blockquote>
</body>
</html>

--------------020105090708070809010301--
Previous Topic:Problem in opening an editor in a multipage editor from a table
Next Topic:EditingDomain.getRoot(Object)
Goto Forum:
  


Current Time: Fri Nov 22 16:09:28 GMT 2019

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

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

Back to the top