Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » resource resolve() issues
resource resolve() issues [message #407714] Mon, 12 March 2007 15:01 Go to next message
Eclipse User
Originally posted by: pkelly03.gmail.com

Hi,

I have a model that looks like the following :

<mrd:RepositoryModel xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<classification xsi:type="mrd:RepositoryModelClassification"/>
<solution xsi:type="mrd:RepositoryModelContents">
<artifact xsi:type="mdp:_Artifact" >
<artifact name="IFW System of Record Model">
<reference><element href="design/XX.ldm#_5w9gHczQEduQo_D6tiKB0g"/>
</artifact>
</artifact>


The problem is when I load the resource in my ResourceSet it goes and
loads the <reference> element (design/XX.ldm) and opens it in the editor
window. I don't want this happening, its can be very time consuming
depending on the number of artifacts and clutters up the editor area.

What I want is to return the resource from the resource set without
loading all the hrefs.

I tried setting the loadOnDemand to false - but it just returns a null
for the resource (fair enough). I then tried getting the contents from
an IFile and loading the resource that way (using the
OPTION_DEFER_IDREF_RESOLUTION load option).

file = ResourcesPlugin.getWorkspace().getRoot().getFile(new
Path(platformResourcePath.toString()));
InputStream is = file.getContents();

options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION,Boolea n.TRUE);
resource.load(is, options);

This worked fine - but when I add it to the resourceset,

RepositoryPlugin.INSTANCE.getEditingDomain().getResourceSet( ).getResources().add(resource);

it repeats the exercise of resolving all hrefs listed and opening each
one in the editor window.

I wondering is there a way to turn off the resolve of all hrefs on a
resource load?

I seen the following in XMLHelper.setResource that might turn it off
depending on the URI type.

deresolve = resourceURI != null && !resourceURI.isRelative() &&
resourceURI.isHierarchical();

Any help much appreciated,

Cheers,

Paul
Re: resource resolve() issues [message #407720 is a reply to message #407714] Mon, 12 March 2007 15:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26048
Registered: July 2009
Senior Member
Paul,

Comments below.


Paul Kelly wrote:
> Hi,
>
> I have a model that looks like the following :
>
> <mrd:RepositoryModel xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
> <classification xsi:type="mrd:RepositoryModelClassification"/>
> <solution xsi:type="mrd:RepositoryModelContents">
> <artifact xsi:type="mdp:_Artifact" >
> <artifact name="IFW System of Record Model">
> <reference><element
> href="design/XX.ldm#_5w9gHczQEduQo_D6tiKB0g"/>
> </artifact>
> </artifact>
>
>
> The problem is when I load the resource in my ResourceSet it goes and
> loads the <reference> element (design/XX.ldm) and opens it in the
> editor window. I don't want this happening, its can be very time
> consuming depending on the number of artifacts and clutters up the
> editor area.
>
> What I want is to return the resource from the resource set without
> loading all the hrefs.
That's want happens when you load, but once you start accessing the
data, it needs to resolve the proxies to do that. You can call
eGet(feature, false) or for multi-valued features cast to InternalEList
and call basicGet.
>
> I tried setting the loadOnDemand to false - but it just returns a null
> for the resource (fair enough). I then tried getting the contents from
> an IFile and loading the resource that way (using the
> OPTION_DEFER_IDREF_RESOLUTION load option).
>
> file = ResourcesPlugin.getWorkspace().getRoot().getFile(new
> Path(platformResourcePath.toString()));
> InputStream is = file.getContents();
>
> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION,Boolea n.TRUE);
> resource.load(is, options);
This just affects how IDREFS are resolved and you are dealing with cross
document references.
>
> This worked fine - but when I add it to the resourceset,
>
> RepositoryPlugin.INSTANCE.getEditingDomain().getResourceSet( ).getResources().add(resource);
>
>
> it repeats the exercise of resolving all hrefs listed and opening each
> one in the editor window.
Proxies should not be resolved just because you've added the object to
the resource set. (But there may well be adapters do this under the
covers, like the ECrossReferenceAdapter; but it can be specialized not
to do that by overriding resolve() to return false.)
>
> I wondering is there a way to turn off the resolve of all hrefs on a
> resource load?
It should not happen purely because of a load. It only happens as a
result of looking at the data.
>
> I seen the following in XMLHelper.setResource that might turn it off
> depending on the URI type.
>
> deresolve = resourceURI != null && !resourceURI.isRelative() &&
> resourceURI.isHierarchical();
This has to do with resolving or deresolving URIs to make them absolute
or relative and is not directly related to proxy resolution.
>
> Any help much appreciated,
>
> Cheers,
>
> Paul
Re: resource resolve() issues [message #407721 is a reply to message #407720] Mon, 12 March 2007 15:36 Go to previous messageGo to next message
Eclipse User
Originally posted by: pkelly03.gmail.com

Thanks for the update Ed,

I see the ResourceSet does have a CrossReferenceAdapter attached to it and it is set to true like you say.
Any idea how to detach the current crossReferenceAdapter and add a new one with resolve set to false?

Sorry to be a nuisance.

Cheers,

Paul



Ed Merks wrote:
> Paul,
>
> Comments below.
>
>
> Paul Kelly wrote:
>> Hi,
>>
>> I have a model that looks like the following :
>>
>> <mrd:RepositoryModel xmi:version="2.0"
>> xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
>> <classification xsi:type="mrd:RepositoryModelClassification"/>
>> <solution xsi:type="mrd:RepositoryModelContents">
>> <artifact xsi:type="mdp:_Artifact" >
>> <artifact name="IFW System of Record Model">
>> <reference><element
>> href="design/XX.ldm#_5w9gHczQEduQo_D6tiKB0g"/>
>> </artifact>
>> </artifact>
>>
>>
>> The problem is when I load the resource in my ResourceSet it goes and
>> loads the <reference> element (design/XX.ldm) and opens it in the
>> editor window. I don't want this happening, its can be very time
>> consuming depending on the number of artifacts and clutters up the
>> editor area.
>>
>> What I want is to return the resource from the resource set without
>> loading all the hrefs.
> That's want happens when you load, but once you start accessing the
> data, it needs to resolve the proxies to do that. You can call
> eGet(feature, false) or for multi-valued features cast to InternalEList
> and call basicGet.
>>
>> I tried setting the loadOnDemand to false - but it just returns a null
>> for the resource (fair enough). I then tried getting the contents from
>> an IFile and loading the resource that way (using the
>> OPTION_DEFER_IDREF_RESOLUTION load option).
>>
>> file = ResourcesPlugin.getWorkspace().getRoot().getFile(new
>> Path(platformResourcePath.toString()));
>> InputStream is = file.getContents();
>>
>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION,Boolea n.TRUE);
>> resource.load(is, options);
> This just affects how IDREFS are resolved and you are dealing with cross
> document references.
>>
>> This worked fine - but when I add it to the resourceset,
>>
>> RepositoryPlugin.INSTANCE.getEditingDomain().getResourceSet( ).getResources().add(resource);
>>
>>
>> it repeats the exercise of resolving all hrefs listed and opening each
>> one in the editor window.
> Proxies should not be resolved just because you've added the object to
> the resource set. (But there may well be adapters do this under the
> covers, like the ECrossReferenceAdapter; but it can be specialized not
> to do that by overriding resolve() to return false.)
>>
>> I wondering is there a way to turn off the resolve of all hrefs on a
>> resource load?
> It should not happen purely because of a load. It only happens as a
> result of looking at the data.
>>
>> I seen the following in XMLHelper.setResource that might turn it off
>> depending on the URI type.
>>
>> deresolve = resourceURI != null && !resourceURI.isRelative() &&
>> resourceURI.isHierarchical();
> This has to do with resolving or deresolving URIs to make them absolute
> or relative and is not directly related to proxy resolution.
>>
>> Any help much appreciated,
>>
>> Cheers,
>>
>> Paul
Re: resource resolve() issues [message #407722 is a reply to message #407721] Mon, 12 March 2007 16:58 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26048
Registered: July 2009
Senior Member
Paul,

Probably you should figure out where this is created and see how to
specialize that code to create your own derived version. I.e., set a
breakpoint in the constructor and see when it is invoked.


Paul Kelly wrote:
> Thanks for the update Ed,
>
> I see the ResourceSet does have a CrossReferenceAdapter attached to it
> and it is set to true like you say.
> Any idea how to detach the current crossReferenceAdapter and add a new
> one with resolve set to false?
>
> Sorry to be a nuisance.
>
> Cheers,
>
> Paul
>
>
>
> Ed Merks wrote:
>> Paul,
>>
>> Comments below.
>>
>>
>> Paul Kelly wrote:
>>> Hi,
>>>
>>> I have a model that looks like the following :
>>>
>>> <mrd:RepositoryModel xmi:version="2.0"
>>> xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
>>> <classification xsi:type="mrd:RepositoryModelClassification"/>
>>> <solution xsi:type="mrd:RepositoryModelContents">
>>> <artifact xsi:type="mdp:_Artifact" >
>>> <artifact name="IFW System of Record Model">
>>> <reference><element
>>> href="design/XX.ldm#_5w9gHczQEduQo_D6tiKB0g"/>
>>> </artifact>
>>> </artifact>
>>>
>>>
>>> The problem is when I load the resource in my ResourceSet it goes
>>> and loads the <reference> element (design/XX.ldm) and opens it in
>>> the editor window. I don't want this happening, its can be very time
>>> consuming depending on the number of artifacts and clutters up the
>>> editor area.
>>>
>>> What I want is to return the resource from the resource set without
>>> loading all the hrefs.
>> That's want happens when you load, but once you start accessing the
>> data, it needs to resolve the proxies to do that. You can call
>> eGet(feature, false) or for multi-valued features cast to
>> InternalEList and call basicGet.
>>>
>>> I tried setting the loadOnDemand to false - but it just returns a
>>> null for the resource (fair enough). I then tried getting the
>>> contents from an IFile and loading the resource that way (using the
>>> OPTION_DEFER_IDREF_RESOLUTION load option).
>>>
>>> file = ResourcesPlugin.getWorkspace().getRoot().getFile(new
>>> Path(platformResourcePath.toString()));
>>> InputStream is = file.getContents();
>>>
>>> options.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION,Boolea n.TRUE);
>>> resource.load(is, options);
>> This just affects how IDREFS are resolved and you are dealing with
>> cross document references.
>>>
>>> This worked fine - but when I add it to the resourceset,
>>>
>>> RepositoryPlugin.INSTANCE.getEditingDomain().getResourceSet( ).getResources().add(resource);
>>>
>>>
>>> it repeats the exercise of resolving all hrefs listed and opening
>>> each one in the editor window.
>> Proxies should not be resolved just because you've added the object
>> to the resource set. (But there may well be adapters do this under
>> the covers, like the ECrossReferenceAdapter; but it can be
>> specialized not to do that by overriding resolve() to return false.)
>>>
>>> I wondering is there a way to turn off the resolve of all hrefs on a
>>> resource load?
>> It should not happen purely because of a load. It only happens as a
>> result of looking at the data.
>>>
>>> I seen the following in XMLHelper.setResource that might turn it off
>>> depending on the URI type.
>>>
>>> deresolve = resourceURI != null && !resourceURI.isRelative() &&
>>> resourceURI.isHierarchical();
>> This has to do with resolving or deresolving URIs to make them
>> absolute or relative and is not directly related to proxy resolution.
>>>
>>> Any help much appreciated,
>>>
>>> Cheers,
>>>
>>> Paul
Previous Topic:Custom EMF serialization
Next Topic:Re: Cerating EMap in EMF
Goto Forum:
  


Current Time: Wed Sep 17 21:43:53 GMT 2014

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

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