About ATL transformations and classes in the target model [message #722119] |
Sun, 04 September 2011 14:22 |
fafanellu Messages: 37 Registered: July 2011 |
Member |
|
|
Hi,
I'm back with my types...!
I'd like to know how to improve a mapping by creating a rule which modifies the target metamodel without extracting information from the source metamodel.
For instance, I have two metamodels :
module _'meta1.ecore'
package Meta1 : Meta1 = 'Meta1'
{
class ClassA
{
attribute chaine : String[?] { ordered };
}
}
and
module _'meta2.ecore'
package Meta2 : Meta2 = 'Meta2'
{
package Global : Global = 'Global'
{
abstract class AbstractClass
{
property uses_type : Types::Type[1] { ordered };
}
class TargetClass extends AbstractClass
{
attribute parameter : String[?] { ordered };
}
}
package Types : Types = 'Types'
{
abstract class Type;
class TypeOne extends Type;
class TypeTwo extends Type;
}
}
The purpose of my ATL transformation is to make a mapping between the attribute "chaine" from Meta1 and the attribute parameter of Meta 2.
Here is the example I took, this is just an instance of the ClassA, with its field "chaine" set to "thisisatest". :
<?xml version="1.0" encoding="ASCII"?>
<Meta1:ClassA xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:Meta1="Meta1" xsi:schemaLocation="Meta1 meta1.ecore" chaine="thisisatest"/>
Here is the mapping I wrote :
-- @path Meta1=/ATL_Test/Meta1.ecore
-- @path Meta2=/ATL_Test/Meta2.ecore
module testATL;
create OUT: meta2 from IN: meta1;
rule M1toM2 {
from
m1:meta1!ClassA
to
m2:meta2!TargetClass(
parameter <- m1.chaine
)
}
And it works fine, I get a .xmi file as a result, with the correct value of the attribute "parameter"...(when open the .xmi in text mode).but now I'd like to handle the eReference "uses_type". I mean, I want the field uses_type of the TargetClass to be always set to TypeOne, for instance.
I tried to solve this with a called rule, called from a do in a "classic" match rule, but I didn't manage. I don't know how to call a called rule (thisModule is only used for the variables and the helpers...)
And I have another remaining question, when I open the .xmi result with the Sample Reflective Ecore Model Editor, I'm always sent a package error. I think it is because of a bad package registration, but if someone could tell me where (and how) they must be registered, it would be great =) I have many classes and it's more suitable to see them in a graphical format rather than a text format ...
Thanks !
[Updated on: Sun, 04 September 2011 16:32] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03110 seconds