How to 'force' loading of uml resource with incorrect reference [message #1824486] |
Thu, 16 April 2020 06:29  |
Eclipse User |
|
|
|
Hi
I've an uml resource which contains some errors. When loading the resource programmatically, the resource loading process is stopped because of the error, for example:
Caused by: org.eclipse.emf.ecore.xmi.UnresolvedReferenceException: Unresolved reference 'EAID_29EABB12_178A_4d3d_ADF5_6DDF1E5F3684'.
Even I could resolve these error at the source, I'm wondering if there is a loading option to ignore these error and continue resource loading. I'm asking that, because it looks possible as I'm able to load the resource in the Eclipse View 'UML Model Editor'.
Thank you,
stay healthy.
|
|
|
Re: How to 'force' loading of uml resource with incorrect reference [message #1824487 is a reply to message #1824486] |
Thu, 16 April 2020 07:06   |
Eclipse User |
|
|
|
You'll see the following "pattern" in generated editors: public void createModel()
{
URI resourceURI = EditUIUtil.getURI(getEditorInput(), editingDomain.getResourceSet().getURIConverter());
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);
} In other words, while the getResource(..., true) might well throw an exception, the resource itself is created in the resource set and it is loaded as much as is possible. Note also that all issues with loading are recorded in resource.getErrors() and resource.getWarnings().
|
|
|
|
Powered by
FUDForum. Page generated in 0.03856 seconds