Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Generating UML model with Stereotypes
[QVTO] Generating UML model with Stereotypes [message #104316] Fri, 01 May 2009 16:48 Go to next message
Alexandre Torres is currently offline Alexandre TorresFriend
Messages: 139
Registered: July 2009
Senior Member
Is it possible, in the last QVTO build, to generate an UML model (out
model) with applied stereotypes (and tagged values) ?
Re: [QVTO] Generating UML model with Stereotypes [message #104366 is a reply to message #104316] Sat, 02 May 2009 15:15 Go to previous messageGo to next message
Alexandre Torres is currently offline Alexandre TorresFriend
Messages: 139
Registered: July 2009
Senior Member
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?
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
Sergey Boyko is currently offline Sergey BoykoFriend
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?
>
>
>
Previous Topic:[ATL] Manipulating collections
Next Topic:[ATL] containment problem, output model incomplete
Goto Forum:
  


Current Time: Tue Nov 12 19:50:33 GMT 2024

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

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

Back to the top