Home » Modeling » UML2 » EcoreUtil.copy() and stereotypes
EcoreUtil.copy() and stereotypes [message #470936] |
Thu, 15 February 2007 11:03 |
Eclipse User |
|
|
|
Originally posted by: itai.segall.weizmann.ac.il
Hi,
I am trying to clone a UML2 model. As suggested in this newsgroup, I
used newModel = (Model)EcoreUtil.copy(oldModel).
Problem is stereotypes are not copied to the new model. The profiles
seem to be applied to the model, but the stereotypes are not applied to
the elements and their data is lost.
Is there a way to fix this problem? Any way to completely clone a model,
including its stereotypes?
Thanks,
Itai
|
|
|
Re: EcoreUtil.copy() and stereotypes [message #470944 is a reply to message #470936] |
Thu, 15 February 2007 14:42 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Itai,
Using the EcorUtil.copy(Collection) form of the copy API, you can copy your
model and all of its applied stereotypes. Doing the copy in a single
operation in this way ensures that the stereotype copies applied to the
copies of your model elements, not the originals.
It is particularly convenient if your model and its stereotype applications
are contained in a single resource. Just do
EcoreUtil.copy(resource.getContents()) in that case.
HTH,
Christian
Itai Segall wrote:
> Hi,
>
> I am trying to clone a UML2 model. As suggested in this newsgroup, I
> used newModel = (Model)EcoreUtil.copy(oldModel).
> Problem is stereotypes are not copied to the new model. The profiles
> seem to be applied to the model, but the stereotypes are not applied to
> the elements and their data is lost.
>
> Is there a way to fix this problem? Any way to completely clone a model,
> including its stereotypes?
>
> Thanks,
> Itai
|
|
|
Re: EcoreUtil.copy() and stereotypes [message #470952 is a reply to message #470944] |
Fri, 16 February 2007 15:47 |
Eclipse User |
|
|
|
Originally posted by: itai.segall.weizmann.ac.il
Thanks Christian,
But I still couldn't manage to correctly clone my model. I either get an
exception, or a model without sterotypes, or a new reference to the same
model. How can I get everything into a single resource? How do I create
a new resource from the Collection that EcoreUtil.copyAll(Collection)
returns?
If anyone could spare a few minutes, and help me write a method:
public static Model copyModel(Model origModel) {...},
I would really appreciate it.
Thanks,Itai
Christian W. Damus wrote:
> Hi, Itai,
>
> Using the EcorUtil.copy(Collection) form of the copy API, you can copy your
> model and all of its applied stereotypes. Doing the copy in a single
> operation in this way ensures that the stereotype copies applied to the
> copies of your model elements, not the originals.
>
> It is particularly convenient if your model and its stereotype applications
> are contained in a single resource. Just do
> EcoreUtil.copy(resource.getContents()) in that case.
>
> HTH,
>
> Christian
>
>
> Itai Segall wrote:
>
>> Hi,
>>
>> I am trying to clone a UML2 model. As suggested in this newsgroup, I
>> used newModel = (Model)EcoreUtil.copy(oldModel).
>> Problem is stereotypes are not copied to the new model. The profiles
>> seem to be applied to the model, but the stereotypes are not applied to
>> the elements and their data is lost.
>>
>> Is there a way to fix this problem? Any way to completely clone a model,
>> including its stereotypes?
>>
>> Thanks,
>> Itai
>
|
|
|
Re: EcoreUtil.copy() and stereotypes [message #470954 is a reply to message #470952] |
Sat, 17 February 2007 00:32 |
Kenn Hussey Messages: 1620 Registered: July 2009 |
Senior Member |
|
|
Itai,
What exception did you get? Are you sure you copied all of the contents of
the resource containing the model?
I would expect something like this to work:
Resource oldResource = model.eResource();
Resource newResource =
oldResource.getResourceSet().createResource(oldResource.getU RI().trimFileExtension().appendSegment( "copy").appendFileExtension("uml"));
newResource.getContents().addAll(EcoreUtil.copyAll(oldResour ce.getContents()));
newResource.save(null);
Kenn
"Itai Segall" <itai.segall@weizmann.ac.il> wrote in message
news:er4jlt$m60$1@utils.eclipse.org...
> Thanks Christian,
>
> But I still couldn't manage to correctly clone my model. I either get an
> exception, or a model without sterotypes, or a new reference to the same
> model. How can I get everything into a single resource? How do I create a
> new resource from the Collection that EcoreUtil.copyAll(Collection)
> returns?
>
> If anyone could spare a few minutes, and help me write a method:
> public static Model copyModel(Model origModel) {...},
> I would really appreciate it.
>
> Thanks,Itai
>
> Christian W. Damus wrote:
>> Hi, Itai,
>>
>> Using the EcorUtil.copy(Collection) form of the copy API, you can copy
>> your
>> model and all of its applied stereotypes. Doing the copy in a single
>> operation in this way ensures that the stereotype copies applied to the
>> copies of your model elements, not the originals.
>>
>> It is particularly convenient if your model and its stereotype
>> applications
>> are contained in a single resource. Just do
>> EcoreUtil.copy(resource.getContents()) in that case.
>>
>> HTH,
>>
>> Christian
>>
>>
>> Itai Segall wrote:
>>
>>> Hi,
>>>
>>> I am trying to clone a UML2 model. As suggested in this newsgroup, I
>>> used newModel = (Model)EcoreUtil.copy(oldModel).
>>> Problem is stereotypes are not copied to the new model. The profiles
>>> seem to be applied to the model, but the stereotypes are not applied to
>>> the elements and their data is lost.
>>>
>>> Is there a way to fix this problem? Any way to completely clone a model,
>>> including its stereotypes?
>>>
>>> Thanks,
>>> Itai
>>
|
|
|
Re: EcoreUtil.copy() and stereotypes [message #470955 is a reply to message #470954] |
Sat, 17 February 2007 07:30 |
Eclipse User |
|
|
|
Originally posted by: itai.segall.weizmann.ac.il
Thanks Kenn,
Works like a charm :)
Itai
Kenn Hussey wrote:
> Itai,
>
> What exception did you get? Are you sure you copied all of the contents of
> the resource containing the model?
>
> I would expect something like this to work:
>
> Resource oldResource = model.eResource();
> Resource newResource =
> oldResource.getResourceSet().createResource(oldResource.getU RI().trimFileExtension().appendSegment( "copy").appendFileExtension("uml"));
> newResource.getContents().addAll(EcoreUtil.copyAll(oldResour ce.getContents()));
> newResource.save(null);
>
> Kenn
>
> "Itai Segall" <itai.segall@weizmann.ac.il> wrote in message
> news:er4jlt$m60$1@utils.eclipse.org...
>> Thanks Christian,
>>
>> But I still couldn't manage to correctly clone my model. I either get an
>> exception, or a model without sterotypes, or a new reference to the same
>> model. How can I get everything into a single resource? How do I create a
>> new resource from the Collection that EcoreUtil.copyAll(Collection)
>> returns?
>>
>> If anyone could spare a few minutes, and help me write a method:
>> public static Model copyModel(Model origModel) {...},
>> I would really appreciate it.
>>
>> Thanks,Itai
>>
>> Christian W. Damus wrote:
>>> Hi, Itai,
>>>
>>> Using the EcorUtil.copy(Collection) form of the copy API, you can copy
>>> your
>>> model and all of its applied stereotypes. Doing the copy in a single
>>> operation in this way ensures that the stereotype copies applied to the
>>> copies of your model elements, not the originals.
>>>
>>> It is particularly convenient if your model and its stereotype
>>> applications
>>> are contained in a single resource. Just do
>>> EcoreUtil.copy(resource.getContents()) in that case.
>>>
>>> HTH,
>>>
>>> Christian
>>>
>>>
>>> Itai Segall wrote:
>>>
>>>> Hi,
>>>>
>>>> I am trying to clone a UML2 model. As suggested in this newsgroup, I
>>>> used newModel = (Model)EcoreUtil.copy(oldModel).
>>>> Problem is stereotypes are not copied to the new model. The profiles
>>>> seem to be applied to the model, but the stereotypes are not applied to
>>>> the elements and their data is lost.
>>>>
>>>> Is there a way to fix this problem? Any way to completely clone a model,
>>>> including its stereotypes?
>>>>
>>>> Thanks,
>>>> Itai
>
>
|
|
|
Re: EcoreUtil.copy() and stereotypes [message #588834 is a reply to message #470936] |
Thu, 15 February 2007 14:42 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Itai,
Using the EcorUtil.copy(Collection) form of the copy API, you can copy your
model and all of its applied stereotypes. Doing the copy in a single
operation in this way ensures that the stereotype copies applied to the
copies of your model elements, not the originals.
It is particularly convenient if your model and its stereotype applications
are contained in a single resource. Just do
EcoreUtil.copy(resource.getContents()) in that case.
HTH,
Christian
Itai Segall wrote:
> Hi,
>
> I am trying to clone a UML2 model. As suggested in this newsgroup, I
> used newModel = (Model)EcoreUtil.copy(oldModel).
> Problem is stereotypes are not copied to the new model. The profiles
> seem to be applied to the model, but the stereotypes are not applied to
> the elements and their data is lost.
>
> Is there a way to fix this problem? Any way to completely clone a model,
> including its stereotypes?
>
> Thanks,
> Itai
|
|
|
Re: EcoreUtil.copy() and stereotypes [message #588898 is a reply to message #470944] |
Fri, 16 February 2007 15:47 |
Eclipse User |
|
|
|
Originally posted by: itai.segall.weizmann.ac.il
Thanks Christian,
But I still couldn't manage to correctly clone my model. I either get an
exception, or a model without sterotypes, or a new reference to the same
model. How can I get everything into a single resource? How do I create
a new resource from the Collection that EcoreUtil.copyAll(Collection)
returns?
If anyone could spare a few minutes, and help me write a method:
public static Model copyModel(Model origModel) {...},
I would really appreciate it.
Thanks,Itai
Christian W. Damus wrote:
> Hi, Itai,
>
> Using the EcorUtil.copy(Collection) form of the copy API, you can copy your
> model and all of its applied stereotypes. Doing the copy in a single
> operation in this way ensures that the stereotype copies applied to the
> copies of your model elements, not the originals.
>
> It is particularly convenient if your model and its stereotype applications
> are contained in a single resource. Just do
> EcoreUtil.copy(resource.getContents()) in that case.
>
> HTH,
>
> Christian
>
>
> Itai Segall wrote:
>
>> Hi,
>>
>> I am trying to clone a UML2 model. As suggested in this newsgroup, I
>> used newModel = (Model)EcoreUtil.copy(oldModel).
>> Problem is stereotypes are not copied to the new model. The profiles
>> seem to be applied to the model, but the stereotypes are not applied to
>> the elements and their data is lost.
>>
>> Is there a way to fix this problem? Any way to completely clone a model,
>> including its stereotypes?
>>
>> Thanks,
>> Itai
>
|
|
|
Re: EcoreUtil.copy() and stereotypes [message #588915 is a reply to message #470952] |
Sat, 17 February 2007 00:32 |
Kenn Hussey Messages: 1620 Registered: July 2009 |
Senior Member |
|
|
Itai,
What exception did you get? Are you sure you copied all of the contents of
the resource containing the model?
I would expect something like this to work:
Resource oldResource = model.eResource();
Resource newResource =
oldResource.getResourceSet().createResource(oldResource.getU RI().trimFileExtension().appendSegment( "copy").appendFileExtension("uml"));
newResource.getContents().addAll(EcoreUtil.copyAll(oldResour ce.getContents()));
newResource.save(null);
Kenn
"Itai Segall" <itai.segall@weizmann.ac.il> wrote in message
news:er4jlt$m60$1@utils.eclipse.org...
> Thanks Christian,
>
> But I still couldn't manage to correctly clone my model. I either get an
> exception, or a model without sterotypes, or a new reference to the same
> model. How can I get everything into a single resource? How do I create a
> new resource from the Collection that EcoreUtil.copyAll(Collection)
> returns?
>
> If anyone could spare a few minutes, and help me write a method:
> public static Model copyModel(Model origModel) {...},
> I would really appreciate it.
>
> Thanks,Itai
>
> Christian W. Damus wrote:
>> Hi, Itai,
>>
>> Using the EcorUtil.copy(Collection) form of the copy API, you can copy
>> your
>> model and all of its applied stereotypes. Doing the copy in a single
>> operation in this way ensures that the stereotype copies applied to the
>> copies of your model elements, not the originals.
>>
>> It is particularly convenient if your model and its stereotype
>> applications
>> are contained in a single resource. Just do
>> EcoreUtil.copy(resource.getContents()) in that case.
>>
>> HTH,
>>
>> Christian
>>
>>
>> Itai Segall wrote:
>>
>>> Hi,
>>>
>>> I am trying to clone a UML2 model. As suggested in this newsgroup, I
>>> used newModel = (Model)EcoreUtil.copy(oldModel).
>>> Problem is stereotypes are not copied to the new model. The profiles
>>> seem to be applied to the model, but the stereotypes are not applied to
>>> the elements and their data is lost.
>>>
>>> Is there a way to fix this problem? Any way to completely clone a model,
>>> including its stereotypes?
>>>
>>> Thanks,
>>> Itai
>>
|
|
|
Re: EcoreUtil.copy() and stereotypes [message #588926 is a reply to message #470954] |
Sat, 17 February 2007 07:30 |
Eclipse User |
|
|
|
Originally posted by: itai.segall.weizmann.ac.il
Thanks Kenn,
Works like a charm :)
Itai
Kenn Hussey wrote:
> Itai,
>
> What exception did you get? Are you sure you copied all of the contents of
> the resource containing the model?
>
> I would expect something like this to work:
>
> Resource oldResource = model.eResource();
> Resource newResource =
> oldResource.getResourceSet().createResource(oldResource.getU RI().trimFileExtension().appendSegment( "copy").appendFileExtension("uml"));
> newResource.getContents().addAll(EcoreUtil.copyAll(oldResour ce.getContents()));
> newResource.save(null);
>
> Kenn
>
> "Itai Segall" <itai.segall@weizmann.ac.il> wrote in message
> news:er4jlt$m60$1@utils.eclipse.org...
>> Thanks Christian,
>>
>> But I still couldn't manage to correctly clone my model. I either get an
>> exception, or a model without sterotypes, or a new reference to the same
>> model. How can I get everything into a single resource? How do I create a
>> new resource from the Collection that EcoreUtil.copyAll(Collection)
>> returns?
>>
>> If anyone could spare a few minutes, and help me write a method:
>> public static Model copyModel(Model origModel) {...},
>> I would really appreciate it.
>>
>> Thanks,Itai
>>
>> Christian W. Damus wrote:
>>> Hi, Itai,
>>>
>>> Using the EcorUtil.copy(Collection) form of the copy API, you can copy
>>> your
>>> model and all of its applied stereotypes. Doing the copy in a single
>>> operation in this way ensures that the stereotype copies applied to the
>>> copies of your model elements, not the originals.
>>>
>>> It is particularly convenient if your model and its stereotype
>>> applications
>>> are contained in a single resource. Just do
>>> EcoreUtil.copy(resource.getContents()) in that case.
>>>
>>> HTH,
>>>
>>> Christian
>>>
>>>
>>> Itai Segall wrote:
>>>
>>>> Hi,
>>>>
>>>> I am trying to clone a UML2 model. As suggested in this newsgroup, I
>>>> used newModel = (Model)EcoreUtil.copy(oldModel).
>>>> Problem is stereotypes are not copied to the new model. The profiles
>>>> seem to be applied to the model, but the stereotypes are not applied to
>>>> the elements and their data is lost.
>>>>
>>>> Is there a way to fix this problem? Any way to completely clone a model,
>>>> including its stereotypes?
>>>>
>>>> Thanks,
>>>> Itai
>
>
|
|
|
Goto Forum:
Current Time: Fri Mar 29 11:12:03 GMT 2024
Powered by FUDForum. Page generated in 0.02962 seconds
|