Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Reference Updating
Reference Updating [message #474755] Wed, 01 August 2007 11:08 Go to next message
Andrew Carton is currently offline Andrew CartonFriend
Messages: 104
Registered: July 2009
Senior Member
Hi,

Imagine one has an UML Element 'A', and many unknown UML Elements that
reference this element. Given another uml element 'B' of the same type
as A, I'd like to force all the references that point to A to now point
to B. Also, B may contain its own references that I'd also like to keep
intact, so simply replacing the instance of the Ecore properties of
element B with those of A and re-adding a copy of A to the model will
not work.

Is there any generic easy way of doing this? Perhaps using the EMF
reflection maybe?

Cheers,
Andrew.
Re: Reference Updating [message #474864 is a reply to message #474755] Wed, 01 August 2007 19:50 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Andrew,

I think a question like this was asked before - did you search the newsgroup
history?

Code that does something similar to this already exists in UML2 - take a
look at
org.eclipse.uml2.uml.resource.UML22UMLResoureHandler#reincar nate(...). This
method a) creates a new instance of the same or similar type, b) sets the
identifier for the new instance to be the same as the original, c) copies
the values of all of the features on the original element to the new
element, and d) redirects all known references to the original element to
the new element...

Kenn

"Andrew Carton" <cartona@cs.tcd.ie> wrote in message
news:f8ppjv$jot$1@build.eclipse.org...
> Hi,
>
> Imagine one has an UML Element 'A', and many unknown UML Elements that
> reference this element. Given another uml element 'B' of the same type as
> A, I'd like to force all the references that point to A to now point to B.
> Also, B may contain its own references that I'd also like to keep intact,
> so simply replacing the instance of the Ecore properties of element B with
> those of A and re-adding a copy of A to the model will not work.
>
> Is there any generic easy way of doing this? Perhaps using the EMF
> reflection maybe?
>
> Cheers,
> Andrew.
Re: Reference Updating [message #474866 is a reply to message #474864] Thu, 02 August 2007 11:05 Go to previous message
Andrew Carton is currently offline Andrew CartonFriend
Messages: 104
Registered: July 2009
Senior Member
Thats great, thanks Kenn. Sorry I didn't realise someone posted this
before, I thought the problem was too specific.

Andrew.

Ar 01/08/2007 20:50, Scríobh Kenn Hussey:
> Andrew,
>
> I think a question like this was asked before - did you search the newsgroup
> history?
>
> Code that does something similar to this already exists in UML2 - take a
> look at
> org.eclipse.uml2.uml.resource.UML22UMLResoureHandler#reincar nate(...). This
> method a) creates a new instance of the same or similar type, b) sets the
> identifier for the new instance to be the same as the original, c) copies
> the values of all of the features on the original element to the new
> element, and d) redirects all known references to the original element to
> the new element...
>
> Kenn
>
> "Andrew Carton" <cartona@cs.tcd.ie> wrote in message
> news:f8ppjv$jot$1@build.eclipse.org...
>> Hi,
>>
>> Imagine one has an UML Element 'A', and many unknown UML Elements that
>> reference this element. Given another uml element 'B' of the same type as
>> A, I'd like to force all the references that point to A to now point to B.
>> Also, B may contain its own references that I'd also like to keep intact,
>> so simply replacing the instance of the Ecore properties of element B with
>> those of A and re-adding a copy of A to the model will not work.
>>
>> Is there any generic easy way of doing this? Perhaps using the EMF
>> reflection maybe?
>>
>> Cheers,
>> Andrew.
>
>
Re: Reference Updating [message #624159 is a reply to message #474755] Wed, 01 August 2007 19:50 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Andrew,

I think a question like this was asked before - did you search the newsgroup
history?

Code that does something similar to this already exists in UML2 - take a
look at
org.eclipse.uml2.uml.resource.UML22UMLResoureHandler#reincar nate(...). This
method a) creates a new instance of the same or similar type, b) sets the
identifier for the new instance to be the same as the original, c) copies
the values of all of the features on the original element to the new
element, and d) redirects all known references to the original element to
the new element...

Kenn

"Andrew Carton" <cartona@cs.tcd.ie> wrote in message
news:f8ppjv$jot$1@build.eclipse.org...
> Hi,
>
> Imagine one has an UML Element 'A', and many unknown UML Elements that
> reference this element. Given another uml element 'B' of the same type as
> A, I'd like to force all the references that point to A to now point to B.
> Also, B may contain its own references that I'd also like to keep intact,
> so simply replacing the instance of the Ecore properties of element B with
> those of A and re-adding a copy of A to the model will not work.
>
> Is there any generic easy way of doing this? Perhaps using the EMF
> reflection maybe?
>
> Cheers,
> Andrew.
Re: Reference Updating [message #624161 is a reply to message #474864] Thu, 02 August 2007 11:05 Go to previous message
Andrew Carton is currently offline Andrew CartonFriend
Messages: 104
Registered: July 2009
Senior Member
Thats great, thanks Kenn. Sorry I didn't realise someone posted this
before, I thought the problem was too specific.

Andrew.

Ar 01/08/2007 20:50, Scríobh Kenn Hussey:
> Andrew,
>
> I think a question like this was asked before - did you search the newsgroup
> history?
>
> Code that does something similar to this already exists in UML2 - take a
> look at
> org.eclipse.uml2.uml.resource.UML22UMLResoureHandler#reincar nate(...). This
> method a) creates a new instance of the same or similar type, b) sets the
> identifier for the new instance to be the same as the original, c) copies
> the values of all of the features on the original element to the new
> element, and d) redirects all known references to the original element to
> the new element...
>
> Kenn
>
> "Andrew Carton" <cartona@cs.tcd.ie> wrote in message
> news:f8ppjv$jot$1@build.eclipse.org...
>> Hi,
>>
>> Imagine one has an UML Element 'A', and many unknown UML Elements that
>> reference this element. Given another uml element 'B' of the same type as
>> A, I'd like to force all the references that point to A to now point to B.
>> Also, B may contain its own references that I'd also like to keep intact,
>> so simply replacing the instance of the Ecore properties of element B with
>> those of A and re-adding a copy of A to the model will not work.
>>
>> Is there any generic easy way of doing this? Perhaps using the EMF
>> reflection maybe?
>>
>> Cheers,
>> Andrew.
>
>
Previous Topic:Draw UML graphically
Next Topic:retrieving model info
Goto Forum:
  


Current Time: Fri Apr 26 04:51:12 GMT 2024

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

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

Back to the top