Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » GMT (Generative Modeling Technologies) » [Epsilon]cloning a model element in EOL
[Epsilon]cloning a model element in EOL [message #385326] Fri, 05 September 2008 01:18 Go to next message
Kimon Polychroniadis is currently offline Kimon PolychroniadisFriend
Messages: 30
Registered: July 2009
Member
Hi,

I am trying to copy an element of my model in another container in the
model. For example I got element A in container C1 and I want to make a
copy of A (e.g. B) in another container (e.g. C2). So the goal is to
have A in C1 and B in C2, wiht A and B being identical.

However, I noticed that the ':= ' operator moves the object rather
copying it. I also thought of using the clone() command, manipulating
the element as a Collection, no result. Is there a more rational way of
doing this?

Thank you in advance,
Kimon
Re: [Epsilon]cloning a model element in EOL [message #385347 is a reply to message #385326] Fri, 05 September 2008 07:16 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Kimon,

There is currently no built-in operation for copying model elements in
EOL; however this seems to be a useful addition. Could you please open a
feature request in the bugzilla?

As a temporary workaround you can use the (static)
EcoreUtil.copy(EObject eObject) method which does exactly that. You'll
need to create a new Epsilon tool and add a copy(EObject) operation that
delegates to the respective operation of the EcoreUtil class.

Cheers,
Dimitris

Kimon Polychroniadis wrote:
> Hi,
>
> I am trying to copy an element of my model in another container in the
> model. For example I got element A in container C1 and I want to make a
> copy of A (e.g. B) in another container (e.g. C2). So the goal is to
> have A in C1 and B in C2, wiht A and B being identical.
>
> However, I noticed that the ':= ' operator moves the object rather
> copying it. I also thought of using the clone() command, manipulating
> the element as a Collection, no result. Is there a more rational way of
> doing this?
>
> Thank you in advance,
> Kimon
Re: [Epsilon]cloning a model element in EOL [message #385349 is a reply to message #385347] Fri, 05 September 2008 12:26 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Kimon,

Thanks for submitting https://bugs.eclipse.org/bugs/show_bug.cgi?id=246352

I'll look into it shortly.

Cheers,
Dimitris

Dimitrios Kolovos wrote:
> Hi Kimon,
>
> There is currently no built-in operation for copying model elements in
> EOL; however this seems to be a useful addition. Could you please open a
> feature request in the bugzilla?
>
> As a temporary workaround you can use the (static)
> EcoreUtil.copy(EObject eObject) method which does exactly that. You'll
> need to create a new Epsilon tool and add a copy(EObject) operation that
> delegates to the respective operation of the EcoreUtil class.
>
> Cheers,
> Dimitris
>
> Kimon Polychroniadis wrote:
>> Hi,
>>
>> I am trying to copy an element of my model in another container in the
>> model. For example I got element A in container C1 and I want to make a
>> copy of A (e.g. B) in another container (e.g. C2). So the goal is to
>> have A in C1 and B in C2, wiht A and B being identical.
>>
>> However, I noticed that the ':= ' operator moves the object rather
>> copying it. I also thought of using the clone() command, manipulating
>> the element as a Collection, no result. Is there a more rational way
>> of doing this?
>>
>> Thank you in advance,
>> Kimon
Re: [Epsilon]cloning a model element in EOL [message #385351 is a reply to message #385349] Fri, 05 September 2008 13:55 Go to previous messageGo to next message
Kimon Polychroniadis is currently offline Kimon PolychroniadisFriend
Messages: 30
Registered: July 2009
Member
So, let's suppose there is model element A of type TypeOfA , and I wish
to create a copy.
Isn't it possible to create a copy in a more 'manual' manner, with the
following the steps below:

1. create a new element e.g. B := new TypeOfA;

2. copy A's attributes and feature values one by one (looping through
the attributes and features of A, B(.

3. move B in the container of choice.

However, I am not sure as to how I should reference the atttributes and
features of A (and their values).

I realise the solution (if feasible) is a bit 'brute force' but it's a
relatively small model I 've got, so I don't think performance would be
an issue.

Thanks,
Kimon

O/H Dimitrios Kolovos έγραψε:
> Hi Kimon,
>
> Thanks for submitting https://bugs.eclipse.org/bugs/show_bug.cgi?id=246352
>
> I'll look into it shortly.
>
> Cheers,
> Dimitris
>
> Dimitrios Kolovos wrote:
>> Hi Kimon,
>>
>> There is currently no built-in operation for copying model elements in
>> EOL; however this seems to be a useful addition. Could you please open
>> a feature request in the bugzilla?
>>
>> As a temporary workaround you can use the (static)
>> EcoreUtil.copy(EObject eObject) method which does exactly that. You'll
>> need to create a new Epsilon tool and add a copy(EObject) operation
>> that delegates to the respective operation of the EcoreUtil class.
>>
>> Cheers,
>> Dimitris
>>
>> Kimon Polychroniadis wrote:
>>> Hi,
>>>
>>> I am trying to copy an element of my model in another container in the
>>> model. For example I got element A in container C1 and I want to make a
>>> copy of A (e.g. B) in another container (e.g. C2). So the goal is to
>>> have A in C1 and B in C2, wiht A and B being identical.
>>>
>>> However, I noticed that the ':= ' operator moves the object rather
>>> copying it. I also thought of using the clone() command, manipulating
>>> the element as a Collection, no result. Is there a more rational way
>>> of doing this?
>>>
>>> Thank you in advance,
>>> Kimon
Re: [Epsilon]cloning a model element in EOL [message #385352 is a reply to message #385351] Fri, 05 September 2008 14:36 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Kimon,

Say you have

class A {
attr String a1;
ref A[*] referenced;
val A[*] contained[*];
}

To create a copy you should define an operation like this:

operation A createCopy() {
var n : new A;
n.a1 := self.a1;
n.referenced := self.referenced;
for (contained in self.contained) {
n.contained.add(contained.createCopy());
}
return n;
}

Now if you need to have a generic operation that creates a copy of any
element, you should use EMF reflection - but in this case it is simpler
(and safer) to just use the EcoreUtil.copy method mentioned previously.

Cheers,
Dimitris

Kimon Polychroniadis wrote:
> So, let's suppose there is model element A of type TypeOfA , and I wish
> to create a copy.
> Isn't it possible to create a copy in a more 'manual' manner, with the
> following the steps below:
>
> 1. create a new element e.g. B := new TypeOfA;
>
> 2. copy A's attributes and feature values one by one (looping through
> the attributes and features of A, B(.
>
> 3. move B in the container of choice.
>
> However, I am not sure as to how I should reference the atttributes and
> features of A (and their values).
>
> I realise the solution (if feasible) is a bit 'brute force' but it's a
> relatively small model I 've got, so I don't think performance would be
> an issue.
>
> Thanks,
> Kimon
>
> O/H Dimitrios Kolovos έγραψε:
>> Hi Kimon,
>>
>> Thanks for submitting
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=246352
>>
>> I'll look into it shortly.
>>
>> Cheers,
>> Dimitris
>>
>> Dimitrios Kolovos wrote:
>>> Hi Kimon,
>>>
>>> There is currently no built-in operation for copying model elements
>>> in EOL; however this seems to be a useful addition. Could you please
>>> open a feature request in the bugzilla?
>>>
>>> As a temporary workaround you can use the (static)
>>> EcoreUtil.copy(EObject eObject) method which does exactly that.
>>> You'll need to create a new Epsilon tool and add a copy(EObject)
>>> operation that delegates to the respective operation of the EcoreUtil
>>> class.
>>>
>>> Cheers,
>>> Dimitris
>>>
>>> Kimon Polychroniadis wrote:
>>>> Hi,
>>>>
>>>> I am trying to copy an element of my model in another container in the
>>>> model. For example I got element A in container C1 and I want to make a
>>>> copy of A (e.g. B) in another container (e.g. C2). So the goal is to
>>>> have A in C1 and B in C2, wiht A and B being identical.
>>>>
>>>> However, I noticed that the ':= ' operator moves the object rather
>>>> copying it. I also thought of using the clone() command,
>>>> manipulating the element as a Collection, no result. Is there a more
>>>> rational way of doing this?
>>>>
>>>> Thank you in advance,
>>>> Kimon
Re: [Epsilon]cloning a model element in EOL [message #385353 is a reply to message #385352] Fri, 05 September 2008 14:48 Go to previous message
Kimon Polychroniadis is currently offline Kimon PolychroniadisFriend
Messages: 30
Registered: July 2009
Member
This is the approach I have adopted, yet I was wondering if there is any
way of copying the references and attributes without having to do that
one-by-one, in a more generic manner. But I suppose that is far more
practical for immediate use.

Thank you very much,
Kimon

O/H Dimitrios Kolovos έγραψε:
> Hi Kimon,
>
> Say you have
>
> class A {
> attr String a1;
> ref A[*] referenced;
> val A[*] contained[*];
> }
>
> To create a copy you should define an operation like this:
>
> operation A createCopy() {
> var n : new A;
> n.a1 := self.a1;
> n.referenced := self.referenced;
> for (contained in self.contained) {
> n.contained.add(contained.createCopy());
> }
> return n;
> }
>
> Now if you need to have a generic operation that creates a copy of any
> element, you should use EMF reflection - but in this case it is simpler
> (and safer) to just use the EcoreUtil.copy method mentioned previously.
>
> Cheers,
> Dimitris
>
> Kimon Polychroniadis wrote:
>> So, let's suppose there is model element A of type TypeOfA , and I
>> wish to create a copy.
>> Isn't it possible to create a copy in a more 'manual' manner, with the
>> following the steps below:
>>
>> 1. create a new element e.g. B := new TypeOfA;
>>
>> 2. copy A's attributes and feature values one by one (looping through
>> the attributes and features of A, B(.
>>
>> 3. move B in the container of choice.
>>
>> However, I am not sure as to how I should reference the atttributes
>> and features of A (and their values).
>>
>> I realise the solution (if feasible) is a bit 'brute force' but it's a
>> relatively small model I 've got, so I don't think performance would
>> be an issue.
>>
>> Thanks,
>> Kimon
>>
>> O/H Dimitrios Kolovos έγραψε:
>>> Hi Kimon,
>>>
>>> Thanks for submitting
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=246352
>>>
>>> I'll look into it shortly.
>>>
>>> Cheers,
>>> Dimitris
>>>
>>> Dimitrios Kolovos wrote:
>>>> Hi Kimon,
>>>>
>>>> There is currently no built-in operation for copying model elements
>>>> in EOL; however this seems to be a useful addition. Could you please
>>>> open a feature request in the bugzilla?
>>>>
>>>> As a temporary workaround you can use the (static)
>>>> EcoreUtil.copy(EObject eObject) method which does exactly that.
>>>> You'll need to create a new Epsilon tool and add a copy(EObject)
>>>> operation that delegates to the respective operation of the
>>>> EcoreUtil class.
>>>>
>>>> Cheers,
>>>> Dimitris
>>>>
>>>> Kimon Polychroniadis wrote:
>>>>> Hi,
>>>>>
>>>>> I am trying to copy an element of my model in another container in the
>>>>> model. For example I got element A in container C1 and I want to
>>>>> make a
>>>>> copy of A (e.g. B) in another container (e.g. C2). So the goal is to
>>>>> have A in C1 and B in C2, wiht A and B being identical.
>>>>>
>>>>> However, I noticed that the ':= ' operator moves the object rather
>>>>> copying it. I also thought of using the clone() command,
>>>>> manipulating the element as a Collection, no result. Is there a
>>>>> more rational way of doing this?
>>>>>
>>>>> Thank you in advance,
>>>>> Kimon
Re: [Epsilon]cloning a model element in EOL [message #621757 is a reply to message #385326] Fri, 05 September 2008 07:16 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Kimon,

There is currently no built-in operation for copying model elements in
EOL; however this seems to be a useful addition. Could you please open a
feature request in the bugzilla?

As a temporary workaround you can use the (static)
EcoreUtil.copy(EObject eObject) method which does exactly that. You'll
need to create a new Epsilon tool and add a copy(EObject) operation that
delegates to the respective operation of the EcoreUtil class.

Cheers,
Dimitris

Kimon Polychroniadis wrote:
> Hi,
>
> I am trying to copy an element of my model in another container in the
> model. For example I got element A in container C1 and I want to make a
> copy of A (e.g. B) in another container (e.g. C2). So the goal is to
> have A in C1 and B in C2, wiht A and B being identical.
>
> However, I noticed that the ':= ' operator moves the object rather
> copying it. I also thought of using the clone() command, manipulating
> the element as a Collection, no result. Is there a more rational way of
> doing this?
>
> Thank you in advance,
> Kimon
Re: [Epsilon]cloning a model element in EOL [message #621759 is a reply to message #385347] Fri, 05 September 2008 12:26 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Kimon,

Thanks for submitting https://bugs.eclipse.org/bugs/show_bug.cgi?id=246352

I'll look into it shortly.

Cheers,
Dimitris

Dimitrios Kolovos wrote:
> Hi Kimon,
>
> There is currently no built-in operation for copying model elements in
> EOL; however this seems to be a useful addition. Could you please open a
> feature request in the bugzilla?
>
> As a temporary workaround you can use the (static)
> EcoreUtil.copy(EObject eObject) method which does exactly that. You'll
> need to create a new Epsilon tool and add a copy(EObject) operation that
> delegates to the respective operation of the EcoreUtil class.
>
> Cheers,
> Dimitris
>
> Kimon Polychroniadis wrote:
>> Hi,
>>
>> I am trying to copy an element of my model in another container in the
>> model. For example I got element A in container C1 and I want to make a
>> copy of A (e.g. B) in another container (e.g. C2). So the goal is to
>> have A in C1 and B in C2, wiht A and B being identical.
>>
>> However, I noticed that the ':= ' operator moves the object rather
>> copying it. I also thought of using the clone() command, manipulating
>> the element as a Collection, no result. Is there a more rational way
>> of doing this?
>>
>> Thank you in advance,
>> Kimon
Re: [Epsilon]cloning a model element in EOL [message #621761 is a reply to message #385349] Fri, 05 September 2008 13:55 Go to previous message
Kimon Polychroniadis is currently offline Kimon PolychroniadisFriend
Messages: 30
Registered: July 2009
Member
So, let's suppose there is model element A of type TypeOfA , and I wish
to create a copy.
Isn't it possible to create a copy in a more 'manual' manner, with the
following the steps below:

1. create a new element e.g. B := new TypeOfA;

2. copy A's attributes and feature values one by one (looping through
the attributes and features of A, B(.

3. move B in the container of choice.

However, I am not sure as to how I should reference the atttributes and
features of A (and their values).

I realise the solution (if feasible) is a bit 'brute force' but it's a
relatively small model I 've got, so I don't think performance would be
an issue.

Thanks,
Kimon

O/H Dimitrios Kolovos έγραψε:
> Hi Kimon,
>
> Thanks for submitting https://bugs.eclipse.org/bugs/show_bug.cgi?id=246352
>
> I'll look into it shortly.
>
> Cheers,
> Dimitris
>
> Dimitrios Kolovos wrote:
>> Hi Kimon,
>>
>> There is currently no built-in operation for copying model elements in
>> EOL; however this seems to be a useful addition. Could you please open
>> a feature request in the bugzilla?
>>
>> As a temporary workaround you can use the (static)
>> EcoreUtil.copy(EObject eObject) method which does exactly that. You'll
>> need to create a new Epsilon tool and add a copy(EObject) operation
>> that delegates to the respective operation of the EcoreUtil class.
>>
>> Cheers,
>> Dimitris
>>
>> Kimon Polychroniadis wrote:
>>> Hi,
>>>
>>> I am trying to copy an element of my model in another container in the
>>> model. For example I got element A in container C1 and I want to make a
>>> copy of A (e.g. B) in another container (e.g. C2). So the goal is to
>>> have A in C1 and B in C2, wiht A and B being identical.
>>>
>>> However, I noticed that the ':= ' operator moves the object rather
>>> copying it. I also thought of using the clone() command, manipulating
>>> the element as a Collection, no result. Is there a more rational way
>>> of doing this?
>>>
>>> Thank you in advance,
>>> Kimon
Re: [Epsilon]cloning a model element in EOL [message #621762 is a reply to message #385351] Fri, 05 September 2008 14:36 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Kimon,

Say you have

class A {
attr String a1;
ref A[*] referenced;
val A[*] contained[*];
}

To create a copy you should define an operation like this:

operation A createCopy() {
var n : new A;
n.a1 := self.a1;
n.referenced := self.referenced;
for (contained in self.contained) {
n.contained.add(contained.createCopy());
}
return n;
}

Now if you need to have a generic operation that creates a copy of any
element, you should use EMF reflection - but in this case it is simpler
(and safer) to just use the EcoreUtil.copy method mentioned previously.

Cheers,
Dimitris

Kimon Polychroniadis wrote:
> So, let's suppose there is model element A of type TypeOfA , and I wish
> to create a copy.
> Isn't it possible to create a copy in a more 'manual' manner, with the
> following the steps below:
>
> 1. create a new element e.g. B := new TypeOfA;
>
> 2. copy A's attributes and feature values one by one (looping through
> the attributes and features of A, B(.
>
> 3. move B in the container of choice.
>
> However, I am not sure as to how I should reference the atttributes and
> features of A (and their values).
>
> I realise the solution (if feasible) is a bit 'brute force' but it's a
> relatively small model I 've got, so I don't think performance would be
> an issue.
>
> Thanks,
> Kimon
>
> O/H Dimitrios Kolovos έγραψε:
>> Hi Kimon,
>>
>> Thanks for submitting
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=246352
>>
>> I'll look into it shortly.
>>
>> Cheers,
>> Dimitris
>>
>> Dimitrios Kolovos wrote:
>>> Hi Kimon,
>>>
>>> There is currently no built-in operation for copying model elements
>>> in EOL; however this seems to be a useful addition. Could you please
>>> open a feature request in the bugzilla?
>>>
>>> As a temporary workaround you can use the (static)
>>> EcoreUtil.copy(EObject eObject) method which does exactly that.
>>> You'll need to create a new Epsilon tool and add a copy(EObject)
>>> operation that delegates to the respective operation of the EcoreUtil
>>> class.
>>>
>>> Cheers,
>>> Dimitris
>>>
>>> Kimon Polychroniadis wrote:
>>>> Hi,
>>>>
>>>> I am trying to copy an element of my model in another container in the
>>>> model. For example I got element A in container C1 and I want to make a
>>>> copy of A (e.g. B) in another container (e.g. C2). So the goal is to
>>>> have A in C1 and B in C2, wiht A and B being identical.
>>>>
>>>> However, I noticed that the ':= ' operator moves the object rather
>>>> copying it. I also thought of using the clone() command,
>>>> manipulating the element as a Collection, no result. Is there a more
>>>> rational way of doing this?
>>>>
>>>> Thank you in advance,
>>>> Kimon
Re: [Epsilon]cloning a model element in EOL [message #621763 is a reply to message #385352] Fri, 05 September 2008 14:48 Go to previous message
Kimon Polychroniadis is currently offline Kimon PolychroniadisFriend
Messages: 30
Registered: July 2009
Member
This is the approach I have adopted, yet I was wondering if there is any
way of copying the references and attributes without having to do that
one-by-one, in a more generic manner. But I suppose that is far more
practical for immediate use.

Thank you very much,
Kimon

O/H Dimitrios Kolovos έγραψε:
> Hi Kimon,
>
> Say you have
>
> class A {
> attr String a1;
> ref A[*] referenced;
> val A[*] contained[*];
> }
>
> To create a copy you should define an operation like this:
>
> operation A createCopy() {
> var n : new A;
> n.a1 := self.a1;
> n.referenced := self.referenced;
> for (contained in self.contained) {
> n.contained.add(contained.createCopy());
> }
> return n;
> }
>
> Now if you need to have a generic operation that creates a copy of any
> element, you should use EMF reflection - but in this case it is simpler
> (and safer) to just use the EcoreUtil.copy method mentioned previously.
>
> Cheers,
> Dimitris
>
> Kimon Polychroniadis wrote:
>> So, let's suppose there is model element A of type TypeOfA , and I
>> wish to create a copy.
>> Isn't it possible to create a copy in a more 'manual' manner, with the
>> following the steps below:
>>
>> 1. create a new element e.g. B := new TypeOfA;
>>
>> 2. copy A's attributes and feature values one by one (looping through
>> the attributes and features of A, B(.
>>
>> 3. move B in the container of choice.
>>
>> However, I am not sure as to how I should reference the atttributes
>> and features of A (and their values).
>>
>> I realise the solution (if feasible) is a bit 'brute force' but it's a
>> relatively small model I 've got, so I don't think performance would
>> be an issue.
>>
>> Thanks,
>> Kimon
>>
>> O/H Dimitrios Kolovos έγραψε:
>>> Hi Kimon,
>>>
>>> Thanks for submitting
>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=246352
>>>
>>> I'll look into it shortly.
>>>
>>> Cheers,
>>> Dimitris
>>>
>>> Dimitrios Kolovos wrote:
>>>> Hi Kimon,
>>>>
>>>> There is currently no built-in operation for copying model elements
>>>> in EOL; however this seems to be a useful addition. Could you please
>>>> open a feature request in the bugzilla?
>>>>
>>>> As a temporary workaround you can use the (static)
>>>> EcoreUtil.copy(EObject eObject) method which does exactly that.
>>>> You'll need to create a new Epsilon tool and add a copy(EObject)
>>>> operation that delegates to the respective operation of the
>>>> EcoreUtil class.
>>>>
>>>> Cheers,
>>>> Dimitris
>>>>
>>>> Kimon Polychroniadis wrote:
>>>>> Hi,
>>>>>
>>>>> I am trying to copy an element of my model in another container in the
>>>>> model. For example I got element A in container C1 and I want to
>>>>> make a
>>>>> copy of A (e.g. B) in another container (e.g. C2). So the goal is to
>>>>> have A in C1 and B in C2, wiht A and B being identical.
>>>>>
>>>>> However, I noticed that the ':= ' operator moves the object rather
>>>>> copying it. I also thought of using the clone() command,
>>>>> manipulating the element as a Collection, no result. Is there a
>>>>> more rational way of doing this?
>>>>>
>>>>> Thank you in advance,
>>>>> Kimon
Previous Topic:[MOFScript]
Next Topic:[Epsilon] top-level container in EOL
Goto Forum:
  


Current Time: Fri Apr 19 01:16:21 GMT 2024

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

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

Back to the top