[ATL] Problem when transforming a model stored in a .uml file into another model [message #548350] |
Wed, 21 July 2010 14:39 |
|
I've just written a toy transformation between UML models that use profiles. Using the UML Editor I developed two profiles (profileA and profileB), each one extending the UML2 Class meta-class with the corresponding stereotype (AClass and BClass, respectively) defining two new tagged values (payload and tag). Then, I used UML Editor to create a source model that instantiated the stereotyped defined by profileA.
I wrote this simple .atl file:
module AClass2BClass;
create OUT: profileB from IN: profileA;
helper context profileA!AClass def: translate() : String =
if self.payload > 0 then
'Greater than zero'
else
'Equal to zero'
endif;
rule main {
from
s: profileA!AClass
to
-- payload is an Integer in AClass
-- payload is a String in BClass
t: profileB!BClass (
payload <- s.translate()
)
}
The inputs to run this code I indicated to ATL Configuration were the two profiles (profileA.profile.uml and profileB.profile.uml), the source model (aclass_model.uml) and I indicated that ATL should generate the output model bclass_model.uml.
When I opened the generated output (bclass_model.uml) using the UML Editor I realized that the information about the profile was in the file, whereas the information about the transformed model element (the instance of the BClass meta-class) was not. When I open the bclass_model.uml file using a text editor I see XMI code that sets the payload tagged value as indicated by the transformation.
My questions are: is ATL able to transform .uml files properly? Do you see anything wrong in my procedure that prevents ATL from generating a proper .uml file?
Thanks a lot for your help.
/TB
[Updated on: Wed, 21 July 2010 14:47] Report message to a moderator
|
|
|
|
Re: [ATL] Problem when transforming a model stored in a .uml file into another model [message #548381 is a reply to message #548353] |
Wed, 21 July 2010 15:52 |
|
Thanks a lot Sylvain. You have provided me with very useful hints.
I agree with the creation of the instances of the meta-class Class. However, I am not sure that
base_Class <- s.base_Class
works.
I included this code in the main rule. The result was that the instance of Class was created, but I still do not see the instance of BClass in the bclass_model.uml file. In addition, there is a <Model> element at the top on the containment hierarchy in aclass_model.uml that is missing in bclass_model.uml too.
I will work now in two directions:
1. Determine how to link the instance of Class and the instance of BClass (i.e. the extension relationship) to generate the correct bclass_model.uml file.
2. Determine the structure of a .uml file so I can instantiate every single component correctly.
I will appreciate any advice on how to do these thinks.
Kindest regards.
/TB
[Updated on: Wed, 21 July 2010 15:52] Report message to a moderator
|
|
|
|
Re: [ATL] Problem when transforming a model stored in a .uml file into another model [message #548469 is a reply to message #548383] |
Thu, 22 July 2010 00:02 |
|
Understood.
I think I have written the correct transformation that does everything it was intended to do. I can share the code in case it is useful to any user:
module AClass2BClass;
create OUT: profileB from IN: profileA;
helper context profileA!AClass def: translate() : String =
if self.payload > 0 then
'Greater than zero'
else
'Equal to zero'
endif;
rule models {
from
source: profileA!Model
to
target: profileB!Model (
name <- 'bclass_model'
)
}
rule classes {
from
source: profileA!Class
to
target: profileB!Class (
name <- 'Target',
package <- source.package
)
}
rule stereotypes {
from
source: profileA!AClass
to
-- payload is an Integer in AClass
-- payload is a String in BClass
target: profileB!BClass (
payload <- source.translate(),
base_Class <- source.base_Class
)
}
All you need to do is create the profileA and profileB using the UML Editor and use any of them to build a source model with UML Editor as well.
Now I will check whether these .uml files can be created and rendered using a UML edition tool.
Thanks a lot for your help Sylvain, I appreciate it a lot.
/TB
|
|
|
Re: [ATL] Problem when transforming a model stored in a .uml file into another model [message #642525 is a reply to message #548469] |
Wed, 01 December 2010 16:36 |
Pejman Messages: 18 Registered: June 2010 |
Junior Member |
|
|
Hi,
I have tried to create the same example. you want to transform an instance of AClass in profileA to an instance of BClass in profileB.
when I ran this example the output model created but I could not open it (It was empty). Then I replaced your first rule with
rule models {
from
source: profileA!Package
to
target: profileB!Package (
name <- 'bclass_model'
)
}
It worked but in the out put model I ended up having UML classes without the stereotype.
I wonder if we need to use applyProfile() and applyStereotype() APIs
Am I missing something?
Thanks in advance
[Updated on: Wed, 01 December 2010 16:38] Report message to a moderator
|
|
|
|
|
Re: [ATL] Problem when transforming a model stored in a .uml file into another model [message #642629 is a reply to message #642525] |
Thu, 02 December 2010 04:49 |
|
I developed the excercise by using UML Editor to create the model (instance of the meta-class Model) that contained the class Source (instance of the meta-class Class); then, I applied the profile profileA using a command in UML Editor. All of these elements were stored in the .uml file, I then ran the ATL rules.
Did you use UML Editor to build the two profiles and the source model?
Did you use UML Editor to apply the profile to the model previous the execution of the rules?
/TB
[Updated on: Thu, 02 December 2010 04:50] Report message to a moderator
|
|
|
Re: [ATL] Problem when transforming a model stored in a .uml file into another model [message #642780 is a reply to message #642629] |
Thu, 02 December 2010 16:43 |
Pejman Messages: 18 Registered: June 2010 |
Junior Member |
|
|
Thanks a lot Balderas for your hint,
Actually I have defined my profiles in RSA(Rational Software Architect) and then import(with the *.profile.uml extension) them to eclipse. Apparently the problem was due to the import. So I have defined them in eclipse from scratch and now it works!
So do you have any similar experience with RSA or any other tools?(Since I have already defined 3 huge profiles in RSA I need to find a solution to use them directly in Eclipse)
The other part which is still not clear for me is what is the difference between the method that you used in your example and using applyProfile and applyStereotype functions.
Something like this :
module A2B;
create OUT : MM1 from IN : MM;
rule test{
from s: MM! Class(s.getAppliedStereotypes()->collect(st | st.name) ->at(1) ='A')
to t: MM1! Class(
name<- 'Target'
)
do {
t.applyStereotype('PB::B')
}
}
It would be insightful for me to have your opinion.
Thanks again
[Updated on: Thu, 02 December 2010 17:04] Report message to a moderator
|
|
|
Re: [ATL] Problem when transforming a model stored in a .uml file into another model [message #642800 is a reply to message #642780] |
Thu, 02 December 2010 18:08 |
|
These are my two cents:
1. I replicated this excercise using the eclipse plugin for Papyrus. I managed to create the .uml files using this tool, but the problem I had was that the .atl file in this poject was not compiled into the internal representation (.asm file) used by ATL's VM. I had to run the ATL rules from a similar file in another project. Weird stuff, do not know what happened here yet.
On the other hand, I tried to use Enterprise Architect as my first option, but had problems with importing. My little experience indicates that this inter-tool importing/exporting mechanisms for UML/XMI do not really work for most of the cases.
2. My understanding is that the developer wants to transform a model that has been extended as a result of the application of a profile; that is, the developer wants to build a complete model, that includes profile applications, before performing the transformation process. That is why I applied the profile to a model before running the transformation rules, instead of the transformation rules to apply the profile. My guess is that this is the correct procedure.
3. The target model produced by the transformation rules does not contain an instance of the ProfileApplication meta-meta-class; thus, it can not be seen as a model that has a profile (profileB) applied to it. Is this what you intended to do? In this case, we could not "de-apply" profileB from the target model produced by the rules I wrote because there is no such appication (instance of ProfileApplication), that is for sure. I would like to know the opinion of an expert on this, the specific question is:
If we have a source model to which we have applied a profile (profileA), and thus contains an instance of ProfileApplication, does our transformation have to generate a target model that also contains an instance of ProfileApplication?
Sylvian, what is your opinion on that?
Kindest regards.
/TB
|
|
|
|
|
Re: [ATL] Problem when transforming a model stored in a .uml file into another model [message #643061 is a reply to message #642887] |
Fri, 03 December 2010 19:37 |
Pejman Messages: 18 Registered: June 2010 |
Junior Member |
|
|
Thanks to both of you for the helpful information.
So if I understood correctly your suggestion is to go with the method that I had read in previous posts (which called is as static profile). And using this method we do not need to use the APIs.
And that was exactly happened in this example.
If so, what is the difference in the design process of the profiles?
I had fined a link that gives the tutorial for defining the static profile titled "Defining static profiles with Eclipse UML2 " but for this example I did not use these guidelines.
I have also tried to create two different Stereotypes as an output but I could not do so :
module A2B;
create OUT : MM1 from IN : MM;
rule models {
from
source: MM!Package
to
target: MM1!Package (
name <- 'bclass_model'
)
}
rule classes {
from
source: MM!Class
to
target: MM1!Class (
name <- 'Target',
package <- source.package
)
}
rule stereotypes {
from
source: MM!A
to
target: MM1!B (
base_Class <- source.base_Class
),
target2: MM1!C (
base_Class <- source.base_Class
)
}
Thanks in advance for your time. It is great opportunity for me to learn from you guys since I'm pretty new with the topic.
Regards,
[Updated on: Sun, 05 December 2010 23:47] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03212 seconds