Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Changing the metaclass of an EObject
[ATL] Changing the metaclass of an EObject [message #75733] Tue, 04 March 2008 17:06 Go to next message
Eclipse UserFriend
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 #76126 is a reply to message #75733] Fri, 07 March 2008 10:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: quentin.glineur.obeo.fr

This is a multi-part message in MIME format.
--------------030109010301060009070204
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

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 #76143 is a reply to message #76126] Fri, 07 March 2008 10:37 Go to previous messageGo to next message
Eclipse UserFriend
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 11:25 Go to previous message
Eclipse UserFriend
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
>>
>
Previous Topic:[ATL] NPE at org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel.loadASMEMFModel(ASMEMFModel.java:320)
Next Topic:[ATL]Transform UML Activity Diagram using ATL
Goto Forum:
  


Current Time: Thu Apr 25 01:39:59 GMT 2024

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

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

Back to the top