Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Loading a resource with invalid non contained reference
Loading a resource with invalid non contained reference [message #659136] Fri, 11 March 2011 08:54 Go to next message
Phil M. Fischer is currently offline Phil M. FischerFriend
Messages: 60
Registered: November 2010
Location: Germany
Member
Hi All,

I am facing the trouble that i have to read data for an EMF Model through a resource. The actual Problem is, that this data is likely to contain uncontained references having invalid IDs. So they are referencing items that don't exist in the data and or in the model anymore. Reading this data i am getting an exception which is fine. But i would like to ignore this since i don't have to rely on this uncontained reference. Does anyone know how to diable this?

Cheers

Phil
Re: Loading a resource with invalid non contained reference [message #659213 is a reply to message #659136] Fri, 11 March 2011 14:58 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26281
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060809000507050007000701
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Phil,

The editor loads a resource like this:

Exception exception = null;
Resource resource = null;
try
{
// Load the resource through the editing domain.
//
resource =
editingDomain.getResourceSet().getResource(resourceURI, true);
}
catch (Exception e)
{
exception = e;
resource =
editingDomain.getResourceSet().getResource(resourceURI, false);
}

That ensures that even if the loading itself throws an exception, it
still grabs hold of the resource that was doing the loading and is thus
able to show the partial contents that did successfully load.


Phil M. Fischer wrote:
> Hi All,
>
> I am facing the trouble that i have to read data for an EMF Model
> through a resource. The actual Problem is, that this data is likely to
> contain uncontained references having invalid IDs. So they are
> referencing items that don't exist in the data and or in the model
> anymore. Reading this data i am getting an exception which is fine.
> But i would like to ignore this since i don't have to rely on this
> uncontained reference. Does anyone know how to diable this?
>
> Cheers
>
> Phil

--------------060809000507050007000701
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">
Phil,<br>
<br>
The editor loads a resource like this:<br>
<blockquote><small>    Exception exception = null;</small><br>
<small>    Resource resource = null;</small><br>
<small>    try</small><br>
<small>    {</small><br>
<small>      // Load the resource through the editing domain.</small><br>
<small>      //</small><br>
<small>      resource =
editingDomain.getResourceSet().getResource(resourceURI, true);</small><br>
<small>    }</small><br>
<small>    catch (Exception e)</small><br>
<small>    {</small><br>
<small>      exception = e;</small><br>
<small>      resource =
editingDomain.getResourceSet().getResource(resourceURI, false);</small><br>
<small>    }</small><br>
</blockquote>
That ensures that even if the loading itself throws an exception, it
still grabs hold of the resource that was doing the loading and is thus
able to show the partial contents that did successfully load.<br>
<br>
<br>
Phil M. Fischer wrote:
<blockquote cite="mid:ilcnjs$lss$1@news.eclipse.org" type="cite">Hi
All,
<br>
<br>
I am facing the trouble that i have to read data for an EMF Model
through a resource. The actual Problem is, that this data is likely to
contain uncontained references having invalid IDs. So they are
referencing items that don't exist in the data and or  in the model
anymore. Reading this data i am getting an exception which is fine. But
i would like to ignore this since i don't have to rely on this
uncontained reference. Does anyone know how to diable this?
<br>
<br>
Cheers
<br>
<br>
Phil
<br>
</blockquote>
</body>
</html>

--------------060809000507050007000701--
Previous Topic:Remove Title from generated EMF editor
Next Topic:[Ecore] deep copying properties of Ecore elements without subcontents
Goto Forum:
  


Current Time: Thu Dec 18 21:13:38 GMT 2014

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

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