Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Fix broken references due XMI deserialisation
Fix broken references due XMI deserialisation [message #429263] Wed, 15 April 2009 21:43 Go to next message
Süleyman Vurucu is currently offline Süleyman VurucuFriend
Messages: 34
Registered: July 2009
Member
Hi together,

I have a serialized xmi file by EMF. I know that XMI is a
serialisation and the logic must be consistent with the serialized xmi File.

So far so good. Now my issue.

I delete a metaclass from my metamodel and generate the modelcode again.
So it's normal that I get FeatureNodeFoundExcaption if I try to load
the "old" XMI file.

Is that possible to load the xmi file yet, by setting a loadoption
so that the borken objects can be skiped?

With Regards, Süleyman
Re: Fix broken references due XMI deserialisation [message #429264 is a reply to message #429263] Wed, 15 April 2009 23:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030402050508010908030902
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Süleyman,

Did you try this option yet?

/**
* This options allows you to record unknown features during
deserialization/loading.
* The default is <code>Boolean.FALSE</code> unless set to
<code>Boolean.TRUE</code> explicitly.
* The unknown features and their values can be accessed via
getEObjectToExtensionMap().
* @see #getEObjectToExtensionMap()
*/
String OPTION_RECORD_UNKNOWN_FEATURE = "RECORD_UNKNOWN_FEATURE";


Süleyman Vurucu wrote:
> Hi together,
>
> I have a serialized xmi file by EMF. I know that XMI is a
> serialisation and the logic must be consistent with the serialized xmi File.
>
> So far so good. Now my issue.
>
> I delete a metaclass from my metamodel and generate the modelcode again.
> So it's normal that I get FeatureNodeFoundExcaption if I try to load
> the "old" XMI file.
>
> Is that possible to load the xmi file yet, by setting a loadoption
> so that the borken objects can be skiped?
>
> With Regards, Süleyman
>

--------------030402050508010908030902
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">
Süleyman,<br>
<br>
Did you try this option yet?<small><br>
</small>
<blockquote><small>  /**</small><br>
<small>   * This options allows you to record unknown features during
deserialization/loading.</small><br>
<small>   * The default is &lt;code&gt;Boolean.FALSE&lt;/code&gt;
unless set to &lt;code&gt;Boolean.TRUE&lt;/code&gt; explicitly. </small><br>
<small>   * The unknown features and their values can be accessed via
getEObjectToExtensionMap().</small><br>
<small>   * @see #getEObjectToExtensionMap()  </small><br>
<small>   */</small><br>
<small>  String OPTION_RECORD_UNKNOWN_FEATURE =
"RECORD_UNKNOWN_FEATURE";</small><br>
</blockquote>
<br>
Süleyman Vurucu wrote:
<blockquote cite="mid:gs5kd6$nhq$1@build.eclipse.org" type="cite">
<pre wrap="">Hi together,

I have a serialized xmi file by EMF. I know that XMI is a
serialisation and the logic must be consistent with the serialized xmi File.

So far so good. Now my issue.

I delete a metaclass from my metamodel and generate the modelcode again.
So it's normal that I get FeatureNodeFoundExcaption if I try to load
the "old" XMI file.

Is that possible to load the xmi file yet, by setting a loadoption
so that the borken objects can be skiped?

With Regards, Süleyman
</pre>
</blockquote>
</body>
</html>

--------------030402050508010908030902--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Fix broken references due XMI deserialisation [message #429272 is a reply to message #429264] Thu, 16 April 2009 11:46 Go to previous message
Süleyman Vurucu is currently offline Süleyman VurucuFriend
Messages: 34
Registered: July 2009
Member
Hi Ed,

thanks a lot for fast reply. I found this option by following the thrown
exceptions.But I didn't find out how to I set this option, last evening.
So I set the option before I register my metamodel and voila
EMF skip the broken links and load the valid part of my datamodell.

My working Code:
public void load(String path) {
if (path != null && !path.equals("")) {
try {
File file = new File(path);
FileInputStream fin = new FileInputStream(file);
ResourceSet resourceSet = new ResourceSetImpl();

//Skip broken references and not existing classes
loadOptions = resourceSet.getLoadOptions();
loadOptions.
put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE,Boolean.TRUE);

EMOFResourceFactoryImpl loadFactory =
new EMOFResourceFactoryImpl();
resourceSet.getResourceFactoryRegistry()
.getExtensionToFactoryMap().put(
Resource.Factory.Registry.DEFAULT_EXTENSION,
new XMIResourceFactoryImpl());

resourceSet.getPackageRegistry().put(LogicPackage.eNS_URI, LogicPackage.eINSTANCE);

URI fileURI = URI.createFileURI(path);

Resource resource = resourceSet.getResource(fileURI,true);

resource.load(loadOptions);
this.sys =(Sys)resource.getContents().get(0);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}


Am Wed, 15 Apr 2009 19:07:34 -0400 schrieb Ed Merks:

> Süleyman,
>
> Did you try this option yet?
>
> /**
> * This options allows you to record unknown features during
> deserialization/loading.
> * The default is <code>Boolean.FALSE</code> unless set to
> <code>Boolean.TRUE</code> explicitly.
> * The unknown features and their values can be accessed via
> getEObjectToExtensionMap().
> * @see #getEObjectToExtensionMap()
> */
> String OPTION_RECORD_UNKNOWN_FEATURE = "RECORD_UNKNOWN_FEATURE";
>
>
> Süleyman Vurucu wrote:
>> Hi together,
>>
>> I have a serialized xmi file by EMF. I know that XMI is a serialisation
>> and the logic must be consistent with the serialized xmi File.
>>
>> So far so good. Now my issue.
>>
>> I delete a metaclass from my metamodel and generate the modelcode
>> again. So it's normal that I get FeatureNodeFoundExcaption if I try to
>> load the "old" XMI file.
>>
>> Is that possible to load the xmi file yet, by setting a loadoption so
>> that the borken objects can be skiped?
>>
>> With Regards, Süleyman
>>
> <!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"> Süleyman,<br>
> <br>
> Did you try this option yet?<small><br> </small>
> <blockquote><small>  /**</small><br>
> <small>   * This options allows you to record unknown features during
> deserialization/loading.</small><br>
> <small>   * The default is &lt;code&gt;Boolean.FALSE&lt;/code&gt;
> unless set to &lt;code&gt;Boolean.TRUE&lt;/code&gt; explicitly.
> </small><br>
> <small>   * The unknown features and their values can be accessed via
> getEObjectToExtensionMap().</small><br>
> <small>   * @see #getEObjectToExtensionMap()  </small><br> <small>  
> */</small><br>
> <small>  String OPTION_RECORD_UNKNOWN_FEATURE =
> "RECORD_UNKNOWN_FEATURE";</small><br> </blockquote>
> <br>
> Süleyman Vurucu wrote:
> <blockquote cite="mid:gs5kd6$nhq$1@build.eclipse.org" type="cite">
> <pre wrap="">Hi together,
>
> I have a serialized xmi file by EMF. I know that XMI is a serialisation
> and the logic must be consistent with the serialized xmi File.
>
> So far so good. Now my issue.
>
> I delete a metaclass from my metamodel and generate the modelcode again.
> So it's normal that I get FeatureNodeFoundExcaption if I try to load the
> "old" XMI file.
>
> Is that possible to load the xmi file yet, by setting a loadoption so
> that the borken objects can be skiped?
>
> With Regards, Süleyman
> </pre>
> </blockquote>
> </body>
> </html>
Previous Topic:Create instance from string
Next Topic:Lazy loading resources with dynamic content using proxies
Goto Forum:
  


Current Time: Fri Apr 19 21:34:12 GMT 2024

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

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

Back to the top