Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Detecting unresolvable Resources
Detecting unresolvable Resources [message #423239] Thu, 25 September 2008 11:42 Go to next message
Eclipse UserFriend
Originally posted by: andreas-scharf.gmx.de

Hi,

In my model I have two objects A and B, where A is referencing (not
containing!) B's. The A's and B's are serialized into different files.

In my GEF based editor I can open and edit A's and B's. Now I'm fighting
a bit with this scenario: Let's say the user created A.xmi and B.xmi. in
A.xmi he referenced B.xmi. Then (maybe outside my editor or even outside
the workbench of my rcp) he deletes B.xmi.

What's the best way to detect the unresolvable B instance in A.xmi
during loading A.xmi into my GEF based editor? Something like
allResolvable(eObject) would be great which returns something like a
status which objects cannot be resolved (since their underlying file
doesn't exist anymore). Then I could clean A.xmi to no longer reference
the missing B and display a message to the user.

Any hints a greatly appreciated.

Cheers,
Andreas
Re: Detecting unresolvable Resources [message #423240 is a reply to message #423239] Thu, 25 September 2008 11:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30806
Registered: July 2009
Senior Member
Andreas,

Comments below.


Andreas Scharf wrote:
> Hi,
>
> In my model I have two objects A and B, where A is referencing (not
> containing!) B's. The A's and B's are serialized into different files.
>
> In my GEF based editor I can open and edit A's and B's. Now I'm
> fighting a bit with this scenario: Let's say the user created A.xmi
> and B.xmi. in A.xmi he referenced B.xmi. Then (maybe outside my editor
> or even outside the workbench of my rcp) he deletes B.xmi.
>
> What's the best way to detect the unresolvable B instance in A.xmi
> during loading A.xmi into my GEF based editor? Something like
> allResolvable(eObject) would be great which returns something like a
> status which objects cannot be resolved (since their underlying file
> doesn't exist anymore). Then I could clean A.xmi to no longer
> reference the missing B and display a message to the user.
EcoreUtil.UnresolvedProxyCrossReferencer is useful for that.
>
> Any hints a greatly appreciated.
>
> Cheers,
> Andreas
Re: Detecting unresolvable Resources [message #423242 is a reply to message #423240] Thu, 25 September 2008 12:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: andreas-scharf.gmx.de

Ed,

that's exactly what I was looking for. Many thanks for the fast reply.

Andreas

Ed Merks schrieb:
> Andreas,
>
> Comments below.
>
>
> Andreas Scharf wrote:
>> Hi,
>>
>> In my model I have two objects A and B, where A is referencing (not
>> containing!) B's. The A's and B's are serialized into different files.
>>
>> In my GEF based editor I can open and edit A's and B's. Now I'm
>> fighting a bit with this scenario: Let's say the user created A.xmi
>> and B.xmi. in A.xmi he referenced B.xmi. Then (maybe outside my editor
>> or even outside the workbench of my rcp) he deletes B.xmi.
>>
>> What's the best way to detect the unresolvable B instance in A.xmi
>> during loading A.xmi into my GEF based editor? Something like
>> allResolvable(eObject) would be great which returns something like a
>> status which objects cannot be resolved (since their underlying file
>> doesn't exist anymore). Then I could clean A.xmi to no longer
>> reference the missing B and display a message to the user.
> EcoreUtil.UnresolvedProxyCrossReferencer is useful for that.
>>
>> Any hints a greatly appreciated.
>>
>> Cheers,
>> Andreas
Re: Detecting unresolvable Resources [message #423265 is a reply to message #423242] Thu, 25 September 2008 15:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: andreas-scharf.gmx.de

Ed,

I've got another question: Currently I'm trying to keep the resourceset
of my TransactionalEditingDomain as clean as possible. Due to the check
of the EcoreUtil.UnresolvedProxyCrossReferencer, the unresolvable
resourcres are now contained in the resourceset. Is there any option to
tell the CrossReferencer (or something else) to remove the unresolvable
resources from the resourceset? Or do I have to do that manually after
the call EcoreUtil.UnresolvedProxyCrossReferencer.find(r)? I would
remove all resources from the resourceset which contain errors. Is that
safe?

Thanks,
Andreas

Andreas Scharf schrieb:
> Ed,
>
> that's exactly what I was looking for. Many thanks for the fast reply.
>
> Andreas
>
> Ed Merks schrieb:
>> Andreas,
>>
>> Comments below.
>>
>>
>> Andreas Scharf wrote:
>>> Hi,
>>>
>>> In my model I have two objects A and B, where A is referencing (not
>>> containing!) B's. The A's and B's are serialized into different files.
>>>
>>> In my GEF based editor I can open and edit A's and B's. Now I'm
>>> fighting a bit with this scenario: Let's say the user created A.xmi
>>> and B.xmi. in A.xmi he referenced B.xmi. Then (maybe outside my
>>> editor or even outside the workbench of my rcp) he deletes B.xmi.
>>>
>>> What's the best way to detect the unresolvable B instance in A.xmi
>>> during loading A.xmi into my GEF based editor? Something like
>>> allResolvable(eObject) would be great which returns something like a
>>> status which objects cannot be resolved (since their underlying file
>>> doesn't exist anymore). Then I could clean A.xmi to no longer
>>> reference the missing B and display a message to the user.
>> EcoreUtil.UnresolvedProxyCrossReferencer is useful for that.
>>>
>>> Any hints a greatly appreciated.
>>>
>>> Cheers,
>>> Andreas
Re: Detecting unresolvable Resources [message #423266 is a reply to message #423265] Thu, 25 September 2008 15:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Andreas,

I think that should be safe: check for resources that are !isLoaded and
that have errors, and just remove them. For good measure, cleare their
eAdapters() lists, too.

As you're in a transactional context, you should do that in a
runExclusive() to ensure that somebody doesn't concurrently attempt any
proxy resolutions on the same unresolved proxies.

HTH,

Christian


Andreas Scharf wrote:
> Ed,
>
> I've got another question: Currently I'm trying to keep the resourceset
> of my TransactionalEditingDomain as clean as possible. Due to the check
> of the EcoreUtil.UnresolvedProxyCrossReferencer, the unresolvable
> resourcres are now contained in the resourceset. Is there any option to
> tell the CrossReferencer (or something else) to remove the unresolvable
> resources from the resourceset? Or do I have to do that manually after
> the call EcoreUtil.UnresolvedProxyCrossReferencer.find(r)? I would
> remove all resources from the resourceset which contain errors. Is that
> safe?
>
> Thanks,
> Andreas
>
> Andreas Scharf schrieb:
>> Ed,
>>
>> that's exactly what I was looking for. Many thanks for the fast reply.
>>
>> Andreas
>>
>> Ed Merks schrieb:
>>> Andreas,
>>>
>>> Comments below.
>>>
>>>
>>> Andreas Scharf wrote:
>>>> Hi,
>>>>
>>>> In my model I have two objects A and B, where A is referencing (not
>>>> containing!) B's. The A's and B's are serialized into different files.
>>>>
>>>> In my GEF based editor I can open and edit A's and B's. Now I'm
>>>> fighting a bit with this scenario: Let's say the user created A.xmi
>>>> and B.xmi. in A.xmi he referenced B.xmi. Then (maybe outside my
>>>> editor or even outside the workbench of my rcp) he deletes B.xmi.
>>>>
>>>> What's the best way to detect the unresolvable B instance in A.xmi
>>>> during loading A.xmi into my GEF based editor? Something like
>>>> allResolvable(eObject) would be great which returns something like a
>>>> status which objects cannot be resolved (since their underlying file
>>>> doesn't exist anymore). Then I could clean A.xmi to no longer
>>>> reference the missing B and display a message to the user.
>>> EcoreUtil.UnresolvedProxyCrossReferencer is useful for that.
>>>>
>>>> Any hints a greatly appreciated.
>>>>
>>>> Cheers,
>>>> Andreas
Re: Detecting unresolvable Resources [message #423268 is a reply to message #423265] Thu, 25 September 2008 16:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30806
Registered: July 2009
Senior Member
Andreas,

Comments below.

Andreas Scharf wrote:
> Ed,
>
> I've got another question: Currently I'm trying to keep the
> resourceset of my TransactionalEditingDomain as clean as possible. Due
> to the check of the EcoreUtil.UnresolvedProxyCrossReferencer, the
> unresolvable resourcres are now contained in the resourceset. Is there
> any option to tell the CrossReferencer (or something else) to remove
> the unresolvable resources from the resourceset? Or do I have to do
> that manually after the call
> EcoreUtil.UnresolvedProxyCrossReferencer.find(r)? I would remove all
> resources from the resourceset which contain errors. Is that safe?
Each time you access the proxy via the instance model, the framework
will try to resolve it and hence will demand load a resource for it
again. When you're cleaning up the proxies you can cast each one to
InternalEObject to call eProxyURI. If the resource referenced by that
proxy URI is empty (and the Resource.getErrors() isn't empty) you could
remove it from the resource set as part of the cleanup phase.
>
> Thanks,
> Andreas
>
> Andreas Scharf schrieb:
>> Ed,
>>
>> that's exactly what I was looking for. Many thanks for the fast reply.
>>
>> Andreas
>>
>> Ed Merks schrieb:
>>> Andreas,
>>>
>>> Comments below.
>>>
>>>
>>> Andreas Scharf wrote:
>>>> Hi,
>>>>
>>>> In my model I have two objects A and B, where A is referencing (not
>>>> containing!) B's. The A's and B's are serialized into different files.
>>>>
>>>> In my GEF based editor I can open and edit A's and B's. Now I'm
>>>> fighting a bit with this scenario: Let's say the user created A.xmi
>>>> and B.xmi. in A.xmi he referenced B.xmi. Then (maybe outside my
>>>> editor or even outside the workbench of my rcp) he deletes B.xmi.
>>>>
>>>> What's the best way to detect the unresolvable B instance in A.xmi
>>>> during loading A.xmi into my GEF based editor? Something like
>>>> allResolvable(eObject) would be great which returns something like
>>>> a status which objects cannot be resolved (since their underlying
>>>> file doesn't exist anymore). Then I could clean A.xmi to no longer
>>>> reference the missing B and display a message to the user.
>>> EcoreUtil.UnresolvedProxyCrossReferencer is useful for that.
>>>>
>>>> Any hints a greatly appreciated.
>>>>
>>>> Cheers,
>>>> Andreas
Re: Detecting unresolvable Resources [message #423285 is a reply to message #423268] Fri, 26 September 2008 10:10 Go to previous message
Eclipse UserFriend
Originally posted by: andreas-scharf.gmx.de

Christan and Ed,

thanks for the hints. I'll try that out.

Andreas

Ed Merks schrieb:
> Andreas,
>
> Comments below.
>
> Andreas Scharf wrote:
>> Ed,
>>
>> I've got another question: Currently I'm trying to keep the
>> resourceset of my TransactionalEditingDomain as clean as possible. Due
>> to the check of the EcoreUtil.UnresolvedProxyCrossReferencer, the
>> unresolvable resourcres are now contained in the resourceset. Is there
>> any option to tell the CrossReferencer (or something else) to remove
>> the unresolvable resources from the resourceset? Or do I have to do
>> that manually after the call
>> EcoreUtil.UnresolvedProxyCrossReferencer.find(r)? I would remove all
>> resources from the resourceset which contain errors. Is that safe?
> Each time you access the proxy via the instance model, the framework
> will try to resolve it and hence will demand load a resource for it
> again. When you're cleaning up the proxies you can cast each one to
> InternalEObject to call eProxyURI. If the resource referenced by that
> proxy URI is empty (and the Resource.getErrors() isn't empty) you could
> remove it from the resource set as part of the cleanup phase.
>>
>> Thanks,
>> Andreas
>>
>> Andreas Scharf schrieb:
>>> Ed,
>>>
>>> that's exactly what I was looking for. Many thanks for the fast reply.
>>>
>>> Andreas
>>>
>>> Ed Merks schrieb:
>>>> Andreas,
>>>>
>>>> Comments below.
>>>>
>>>>
>>>> Andreas Scharf wrote:
>>>>> Hi,
>>>>>
>>>>> In my model I have two objects A and B, where A is referencing (not
>>>>> containing!) B's. The A's and B's are serialized into different files.
>>>>>
>>>>> In my GEF based editor I can open and edit A's and B's. Now I'm
>>>>> fighting a bit with this scenario: Let's say the user created A.xmi
>>>>> and B.xmi. in A.xmi he referenced B.xmi. Then (maybe outside my
>>>>> editor or even outside the workbench of my rcp) he deletes B.xmi.
>>>>>
>>>>> What's the best way to detect the unresolvable B instance in A.xmi
>>>>> during loading A.xmi into my GEF based editor? Something like
>>>>> allResolvable(eObject) would be great which returns something like
>>>>> a status which objects cannot be resolved (since their underlying
>>>>> file doesn't exist anymore). Then I could clean A.xmi to no longer
>>>>> reference the missing B and display a message to the user.
>>>> EcoreUtil.UnresolvedProxyCrossReferencer is useful for that.
>>>>>
>>>>> Any hints a greatly appreciated.
>>>>>
>>>>> Cheers,
>>>>> Andreas
Previous Topic:limit number (other than 1) of children in an EReference
Next Topic:[Teneo] 2 Configuration Questions
Goto Forum:
  


Current Time: Mon Jan 20 17:06:32 GMT 2020

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

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

Back to the top