|
|
Re: [QVTO] Generating UML model with Stereotypes [message #104417 is a reply to message #104366] |
Mon, 04 May 2009 03:45 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Sergey Boyko![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=serg.boyko2011%40gmail.com) Messages: 171 Registered: July 2009 |
Senior Member |
|
|
Hi Alexandre,
For the 'out' UML model you can pass profile instance as an additional
transformation parameter.
So transformation signature might look like follows:
modeltype UmlInColor uses "http://myProfile";
modeltype Uml uses "http://www.eclipse.org/uml2/2.1.0/UML";
transformation Profiles(in profile : UmlInColor, out umlOut : Uml);
Input URI for the profile (in Operational QVT launch configuration)
should be the same as used for static profile registration
(org.eclipse.uml2.uml.generated_package extension point, URI with the
object id of the profile, see
http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2/msg00819.html).
For example in my test case it's
" platform:/plugin/emf.sample/model/UmlInColor.profile.uml#_rT qRYAokEd2pfIRA2tuSLQ ".
Once passed to the transformation profile instance can be obtained like:
var inColorProfile := profile.rootObjects()![Profile];
and later applied:
var model := object Model {};
model.applyProfile(inColorProfile);
The same with stereotype instance:
var thingStereotype := inColorProfile.ownedStereotype->select(name =
"thing")->any(true);
var cls := object uml::Class { name := 'foo' };
model.ownedType += cls;
-- apply stereotype (it may be not applied yet in case not required)
if (not cls.isStereotypeApplied(thingStereotype)) then {
cls.applyStereotype(thingStereotype);
}
endif;
var newStreotypeApp :=
cls.getStereotypeApplications()![UmlInColor::thing];
-- copy stereotype property
newStreotypeApp.Address := 'foo';
-- alternative way
cls.setValue(thingStereotype, 'SerialNumber', 'foo');
Hope this helps.
Regards,
Sergey
Alexandre Torres wrote:
> I succeded in applying stereotypes on M6, but I can't figure out how to
> apply a profile in a QVTO transformation. I'm using a static profile
> (generated as emf plugin).
>
> If I get an "inout uml model" with a profile already applied, I can find
> the stereotype and pass it to applyStereotype operation. It works, and I
> can use oclAsType :
>
> --to get the profile:
> <myRootPackage>.getAppliedProfiles()![Profile]
>
> --to get mystereotype
> <profile>.allInstances(Stereotype)->any(name='MyStereotype');
>
> --to apply stereotype and set its properties
> var extension =
> cl.applyStereotype(<myStereotype>).oclAsType(MyProfile::MyStereotype);
> extension.<my attribute> := <value>; -- cool ! autocomplete works :)
>
> and them, voilá, it saves the UML with the new stereotype applications
> and values. I *guess* that it's possible to apply this profile to other
> packages.
> The only problem is if the UML model is "out" only. I don't know how to
> get a valid Profile instance to start with. Any sugestions?
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04151 seconds