Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Renaming GMF Resource Files
Renaming GMF Resource Files [message #839146] Sun, 08 April 2012 07:07 Go to next message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
Hello,

i got a problem with some GMF Resource Files.
What i want to implement are some Rename/Move/Delete Actions on these Files.
Now the problem :

These files use bidirectional cross-references.
This means they load external resources and set external references.

What i tried to do is (for renaming):

-load all resources in a single resourceSet.
-edit the uri by calling setUri(newpathuri) on the element that should be changed.
-save the whole resourceSet.

But this only creates me a new file, this might be ok, because i can simply delete the old one, BUT :

The relation is not updated. What i expect is 2 new files with a correct references between them ...

What im doing wrong ?
Do i really have to update all the references by myself ?
Is there a trick to do that ?
Re: Renaming GMF Resource Files [message #839155 is a reply to message #839146] Sun, 08 April 2012 07:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
It's important to ensure that all the proxies are resolved before
changing the resource URIs because proxies contain the original URI.
EcoreUtil.resolveAll on the resource set will help with that. Note also
that there's support for Resource.delete, though it sounds like you're
just renaming your resource so you can use
resourceSet.getURIConverter().delete to delete the underlying contents
at the old URI.


On 08/04/2012 9:07 AM, Snakebyte Mising name wrote:
> Hello,
>
> i got a problem with some GMF Resource Files.
> What i want to implement are some Rename/Move/Delete Actions on these
> Files.
> Now the problem :
>
> These files use bidirectional cross-references.
> This means they load external resources and set external references.
>
> What i tried to do is (for renaming):
>
> -load all resources in a single resourceSet.
> -edit the uri by calling setUri(newpathuri) on the element that should
> be changed.
> -save the whole resourceSet.
>
> But this only creates me a new file, this might be ok, because i can
> simply delete the old one, BUT :
>
> The relation is not updated. What i expect is 2 new files with a
> correct references between them ...
>
> What im doing wrong ?
> Do i really have to update all the references by myself ?
> Is there a trick to do that ?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Renaming GMF Resource Files [message #839213 is a reply to message #839155] Sun, 08 April 2012 09:30 Go to previous messageGo to next message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
What you say is right.

But doing this still result in the same issue.

The bidirectional cross referencere are not clearly maintained. They are not changed in referencing files.

Lets assume i have two files :

File A and
File B

A und B have a bidirectional reference between them.

Now i do what you and I explained :

-load single ResourceSet
-resolveAll - now calling setUri(newUri) - and afterwards calling ResourseSet.getUriConverter.delete(FileA,Collections.EMPTY_MAP)
-afterwards save all


The reference from file B still not points correctly then. When i look in the files it seems like that one XMI-File uses a complete uri starting with :

file:/

and the other starting with

platform:/resource

if i change this manually in the xmi files the references are maintained correctly.
What i have to do, to achieve this correctly when renaming ? (when saving resources..to always use file or platform formatted URIs)

Greetings



[Updated on: Sun, 08 April 2012 09:33]

Report message to a moderator

Re: Renaming GMF Resource Files [message #839247 is a reply to message #839213] Sun, 08 April 2012 10:49 Go to previous messageGo to next message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
Ah by the way :

Is there any way to automatically delete all bidirectional defined references between files which cannot be resolved in the resource set or have no opponent relation ?

Like creating a whole resourceSet and iterate ?

Anyone could give me some code hints or suggestions on how to do that ?


[Updated on: Sun, 08 April 2012 17:38]

Report message to a moderator

Re: Renaming GMF Resource Files [message #839695 is a reply to message #839247] Mon, 09 April 2012 04:14 Go to previous messageGo to next message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
ok i maked it so far.
but i still need to find bad references.
is it in any way possible to get the opposite reference if you got one side ?
Re: Renaming GMF Resource Files [message #839732 is a reply to message #839213] Mon, 09 April 2012 05:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Comments below.

On 08/04/2012 11:30 AM, Snakebyte Mising name wrote:
> What you say is right.
>
> But doing this still result in the same issue.
Then you've likely not described well exactly what you're doing.
>
> The bidirectional cross referencere are not clearly maintained. They
> are not changed in referencing files.
Then you must be saving unresolved proxies are saving before you've
renamed the resource containing the proxy.
>
> Lets assume i have two files :
>
> File A and
> File B
>
> A und B have a bidirectional reference between them.
>
> Now i do what you and I explained :
>
> -load single ResourceSet
> -resolveAll - now calling setUri(newUri) -
On which resource? How many resources in the resource set? Does
EcoreUtil.UnresolvedProxyCrossReferencer find unresolved proxies?
> and afterwards calling
> ResourseSet.getUriConverter.delete(FileA,Collections.EMPTY_MAP)
> -afterwards save all
So you're saving B and it ends up referring to the old URI for FileA?
Either you must have an unresolveable proxy the refers to FileA (use the
cross referencer to find it), or you've not renamed the resource
containing the FileA's contents.
>
>
> The reference from file B still not points correctly then. When i look
> in the files it seems like that one XMI-File uses a complete uri
> starting with :
>
> file:/
The URIs will be of course based on what you've loaded and what's in the
resources you've loaded.
> and the other starting with
> platform:/resource
So it's likely you're loading resources with URIs that don't allow cross
document references to be properly resolved. You've said nothing about
the URIs you've been using so I can only guess.
>
> if i change this manually in the xmi files the references are
> maintained correctly.
> What i have to do, to achieve this correctly when renaming ?
Explain what URIs you've used to load the resource.
>
> Greetings
> S
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Renaming GMF Resource Files [message #839736 is a reply to message #839695] Mon, 09 April 2012 05:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
It sounds like you're chasing symptoms now (fixing proxies) rather than
addressing the underlying issue, i.e., the proxies should resolve
properly in the first place.

Of course if you have some object x with a directional reference r to
some other object y then you'll know the opposite of r, i.e., ro =
r.getEOpposite(), and you'll know that y has a directional reference ro
to x.


On 09/04/2012 6:14 AM, Snakebyte Mising name wrote:
> ok i maked it so far.
> but i still need to find bad references.
> is it in any way possible to get the opposite reference if you got one
> side ?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Renaming GMF Resource Files [message #840155 is a reply to message #839736] Mon, 09 April 2012 18:38 Go to previous message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
ok your suggestions helped. Thank you.
Previous Topic:Copy-paste betwen diagrams
Next Topic:Read an unsaved value
Goto Forum:
  


Current Time: Thu Apr 25 20:49:16 GMT 2024

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

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

Back to the top