[ATL] Changing the metaclass of an EObject [message #75733] |
Tue, 04 March 2008 12:06  |
Eclipse User |
|
|
|
Originally posted by: rivera.lcc.uma.es
Hi all,
sorry for asking again, but I forgot to precede with [ATL] the topic of
my previous e-mail,
¿Is it possible to change the metaclass of an object with ATL after
creating it?
I want to transform models from one platform to Ecore, independently of
its metamodel. I would like something like creating an EObject for each
object of my platform, and assigning its class (something like
setEClass, that does not exist, contrary to getEClass) depending of some
information and a metamodel as another input for example
Thank you in advance,
Edu
|
|
|
|
Re: [ATL] Changing the metaclass of an EObject [message #76143 is a reply to message #76126] |
Fri, 07 March 2008 05:37   |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------030807080900040607070702
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Quentin,
I'd previously explained that he needs to decide up front which type of
target object to create, not create a plain old EObject and they try to
morph the type. Certainly such type morphing is supported for dynamic
models. After all, EFactoryImpl.basicCreate looks like this:
| *protected *EObject basicCreate(EClass eClass)
{
*return*
eClass.getInstanceClassName() == "java.util.Map$Entry" ?
*new *DynamicEObjectImpl.BasicEMapEntry<String, String>(eClass) :
*new *DynamicEObjectImpl(eClass);
}|
Where the constructor just does
| /**
* Creates a dynamic EObject.
*/
*public *DynamicEObjectImpl(EClass eClass)
{
*super*();
eSetClass(eClass);
}|
But indeed generally you have to assume that an object has a fixed type
and that trying to change it after its been created by a factory is just
bad news.
Quentin Glineur wrote:
> Hi Jose,
>
> I don't think there's a way to do what you want to. Model
> transformation deals with fixed metamodels: In its spririt, ATL does
> not deal with EObject handling but with the concept of model elements
> (i.e. typed element whose type is described in a metamodel).
>
> In you case dealing with an Ecore metamodel means you can only create
> elements such as EClass, EReferences etc. And an EObject as only
> operations (no structural feature) so nothing to set! Moreover, its
> eSetClass() method call would raise an exception (as far as I know,
> this is just for internal use).
>
> Regards,
>
> Quentin
>
> Jose E. Rivera a
|
|
|
Re: [ATL] Changing the metaclass of an EObject [message #76159 is a reply to message #76143] |
Fri, 07 March 2008 06:25  |
Eclipse User |
|
|
|
Originally posted by: rivera.lcc.uma.es
Thank you both for your help :)
I can know the EClass of the object before creting it, but it will
depend on the souce model, and in an ATL Rule the classes of the target
elements to be created are fixed, that's why I asked.
Sorry Quentin for asking again the same question, but I wanted to know
if there was a "special" way to do it with ATL...
Ed Merks escribió:
> Quentin,
>
> I'd previously explained that he needs to decide up front which type of
> target object to create, not create a plain old EObject and they try to
> morph the type. Certainly such type morphing is supported for dynamic
> models. After all, EFactoryImpl.basicCreate looks like this:
>
> | *protected *EObject basicCreate(EClass eClass)
> {
> *return*
> eClass.getInstanceClassName() == "java.util.Map$Entry" ?
> *new *DynamicEObjectImpl.BasicEMapEntry<String, String>(eClass) :
> *new *DynamicEObjectImpl(eClass);
> }|
>
> Where the constructor just does
>
> | /**
> * Creates a dynamic EObject.
> */
> *public *DynamicEObjectImpl(EClass eClass)
> {
> *super*();
> eSetClass(eClass);
> }|
>
> But indeed generally you have to assume that an object has a fixed type
> and that trying to change it after its been created by a factory is just
> bad news.
>
>
> Quentin Glineur wrote:
>> Hi Jose,
>>
>> I don't think there's a way to do what you want to. Model
>> transformation deals with fixed metamodels: In its spririt, ATL does
>> not deal with EObject handling but with the concept of model elements
>> (i.e. typed element whose type is described in a metamodel).
>>
>> In you case dealing with an Ecore metamodel means you can only create
>> elements such as EClass, EReferences etc. And an EObject as only
>> operations (no structural feature) so nothing to set! Moreover, its
>> eSetClass() method call would raise an exception (as far as I know,
>> this is just for internal use).
>>
>> Regards,
>>
>> Quentin
>>
>> Jose E. Rivera a écrit :
>>> Hi all,
>>>
>>> sorry for asking again, but I forgot to precede with [ATL] the topic
>>> of my previous e-mail,
>>>
>>> ¿Is it possible to change the metaclass of an object with ATL after
>>> creating it?
>>>
>>> I want to transform models from one platform to Ecore, independently
>>> of its metamodel. I would like something like creating an EObject for
>>> each object of my platform, and assigning its class (something like
>>> setEClass, that does not exist, contrary to getEClass) depending of
>>> some information and a metamodel as another input for example
>>>
>>> Thank you in advance,
>>> Edu
>>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04058 seconds