|
|
Re: Fix broken references due XMI deserialisation [message #429272 is a reply to message #429264] |
Thu, 16 April 2009 11:46 |
Süleyman Vurucu 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 <code>Boolean.FALSE</code>
> unless set to <code>Boolean.TRUE</code> 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>
|
|
|
Powered by
FUDForum. Page generated in 0.06561 seconds