Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Use Instance Type of EDataType
Use Instance Type of EDataType [message #689757] Tue, 28 June 2011 09:45 Go to next message
Yulia B is currently offline Yulia BFriend
Messages: 16
Registered: June 2011
Junior Member
Hi all,

I've created some Java class (let it be MyClass). Then I've created an ecore metamodel (MM1) and EDataType with Instance Type Name equals MyClass within the metamodel. If then i create an EClass (Class1) with an attribute (attribute1) of this EDataType, how can work out this attribute during the ATL transformation?

E.g. I have an attribute name of MyClass, and I want to map Class1 of MM1 into Class2 of some metamodel MM2 with the ATL transformation. Let the name (java field) of attribute1 to be mapped into the name (ecore attribute) of Class2.
Can I write something like:

rule MatchClasses {
from
i : MM1!Class1
to
o : MM2!Class2 (
name <- i.attribute1.name
)
}

So the problem is that the "name" is java field of java class MyClass, not ecore attribute of some EClass. Is there any possibility to extract data from Instance Type of EDataType during ATL transformation?

I'll really appreciate any thoughts. Thank you in advance!
Re: Use Instance Type of EDataType [message #692322 is a reply to message #689757] Mon, 04 July 2011 08:25 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
This should work. Try the getter if it doesn't
Re: Use Instance Type of EDataType [message #694389 is a reply to message #692322] Fri, 08 July 2011 13:27 Go to previous messageGo to next message
Yulia B is currently offline Yulia BFriend
Messages: 16
Registered: June 2011
Junior Member
This doesn't work. At the sample above i.attribute1.oclIsUndefined() returns true, so it doesn't recognize my EDataType at all. Maybe I should somehow "register" my EDataType? There aren't problems if I use standart EDataType like EString[java.lang.String], I can call some usual Java methods of Java String class (like trim(), endsWith(), etc.). But the methods are presented as EOperations, aren't they?
Maybe I should somehow import my Java class (or package containing this class) to the MM1.ecore? How can I do this?
Re: Use Instance Type of EDataType [message #694399 is a reply to message #689757] Fri, 08 July 2011 13:45 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Yulia

I can't answer for ATL, but from an OCL and QVT perspective I wouldn't
expect this to work.

A DataType has no Property elements (and an EDataType has no
EStructuralFeature elements) so why should model navigation be expected
to find something that isn't modeled?

You can define the instance class name for an EClass that is just an
interface, so I recommend using modeling approaches that align with your
requirement.

Regards

Ed Willink
>
> So the problem is that the "name" is java field of java class MyClass,
> not ecore attribute of some EClass. Is there any possibility to
> extract data from Instance Type of EDataType during ATL transformation?
>
> I'll really appreciate any thoughts. Thank you in advance!
Re: Use Instance Type of EDataType [message #694442 is a reply to message #694399] Fri, 08 July 2011 15:43 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
If you use getters of the EDataType to access the properties, this should work.
Re: Use Instance Type of EDataType [message #695764 is a reply to message #694442] Tue, 12 July 2011 13:59 Go to previous message
Yulia B is currently offline Yulia BFriend
Messages: 16
Registered: June 2011
Junior Member
Hi Sylvain,

Could you please clarify what a getter is? Should I create an EOperation, let it be getName(), in MM1!Class1?
How can I implement that getName() should return MM1!Class1.attribute.name?
Should I generate .genmodel and then Java code from the .genmodel, and then implement the method getName() in Class1Impl.java?
How can I "tell" ATL to process the MM1.ecore with Java packages generated from .genmodel if the previous answer is yes?

And why if Class1 contains attribute "attribute1" of some EDataType (with its Instance Type Name equals MyClass), the MM1!Class1.attribute1.oclType() returns OclAny instead of MyClass?

If you have any good tutorials on these features, please, send me some links..

Thank you very much in advance!
Previous Topic:(no subject)
Next Topic:[QVTo] Reuse Strategies (inherits, merges, disjuncts)
Goto Forum:
  


Current Time: Thu Mar 28 19:19:32 GMT 2024

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

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

Back to the top