Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » QVTo apply stereotype
QVTo apply stereotype [message #1838830] Fri, 05 March 2021 20:53 Go to next message
Gabriele Cavallaro is currently offline Gabriele CavallaroFriend
Messages: 5
Registered: March 2021
Junior Member
Hi all.
I'm trying to use this plugin:
https://projects.eclipse.org/projects/modeling.mmt.qvt-oml
For create some transformations from one UML model to another UML model,
where I have as input a generic model and a profile model that contains some additional stereotypes, in my case this stereotypes are roles of pattern, like an Observer or a Composite, that I want apply on some Classes. Assuming to have a mapping that reconize the Class where apply a stereotype, I can't find online any good example of how apply a stereotypes on a Classes, or what calls and instructionsare involved in this process.
Somone here have some example of this topic?
Thanks in advance for the future answers
Re: QVTo apply stereotype [message #1838841 is a reply to message #1838830] Sat, 06 March 2021 05:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The documentation on stereotypes is very thin. Searching the QVTo spec leaves little more than a tease and a suggestion that there is a useful "*" shortform.

A Bugzilla search for:

https://bugs.eclipse.org/bugs/buglist.cgi?classification=Modeling&list_id=20435524&longdesc=stereotype&longdesc_type=allwordssubstr&product=QVTo&query_format=advanced

perhaps finds the best examples with

https://bugs.eclipse.org/bugs/show_bug.cgi?id=266675 starting from a bug on a similar case to yours establishes a fix and an example to demonstrate. The example below uses the UML2 Java API rather than QVTo facilties. It does not appear to contribute to regression testing so bug reopened.

Regards

Ed Willink

modeltype Uml uses "http://www.eclipse.org/uml2/2.1.0/UML";
modeltype UmlInColor uses "http://myProfile";

transformation Profiles(in uml : Uml, out umlOut : Uml);

main() {
var umlProfile := uml.rootObjects()![Model].getAppliedProfile('UmlInColor');

var model := object Model {};
model.applyProfile(umlProfile);

uml.objectsOfType(Class)->collect(map toClass(model));
}

mapping Class::toClass(inout model : Package) : Class {

name := self.name;

end {
model.ownedType += result;

var thingStereotype := self.getAppliedStereotype('UmlInColor::thing');

-- apply stereotype (it may be not applied yet in case not required)
if (not self.isStereotypeApplied(thingStereotype)) then {
result.applyStereotype(thingStereotype);
}
endif;

var oldStreotypeApp := self.getStereotypeApplications()![UmlInColor::thing];
var newStreotypeApp := result.getStereotypeApplications()![UmlInColor::thing];

-- copy stereotype property
newStreotypeApp.Address := oldStreotypeApp.Address;
-- alternative way
result.setValue(thingStereotype, 'SerialNumber', oldStreotypeApp.SerialNumber);
}
}

Re: QVTo apply stereotype [message #1838845 is a reply to message #1838841] Sat, 06 March 2021 10:49 Go to previous messageGo to next message
Gabriele Cavallaro is currently offline Gabriele CavallaroFriend
Messages: 5
Registered: March 2021
Junior Member
Thank you a lot for the answer.
Is possible define something like:
transformation Profiles(in uml : Uml, in profile : Uml, out umlOut : Uml);
or profiles must be defined with a local reference as metamodels?
Re: QVTo apply stereotype [message #1838847 is a reply to message #1838845] Sat, 06 March 2021 12:49 Go to previous messageGo to next message
Gabriele Cavallaro is currently offline Gabriele CavallaroFriend
Messages: 5
Registered: March 2021
Junior Member
Also I trying to import the profile as metamodel like:
modeltype UmlInColor uses "http://myProfile";

Seems that the profile will not be loaded:
https://i.imgur.com/Bz1yMP6.png
https://i.imgur.com/XZDeJnI.png
I have define this profile using Papyrus:
https://pastebin.com/6wf3gcHw
https://i.imgur.com/sbMd6YV.png

Fails because the profile is not well defined or because the declaration is wrong?

Thanks again for the support
Re: QVTo apply stereotype [message #1838849 is a reply to message #1838847] Sat, 06 March 2021 13:32 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You can certainly define "transformation Profiles(in uml : Uml, in profile : Uml, out umlOut : Uml);" whether it will do what you want I cannot tell since I don't know what you want.

I don;'t know what you mean by "profiles must be defined with a local reference as metamodels".

Programs nearly always show interesting modes of failure until the user learns the eccentricities of the tool. Without a repro I cannot tell what you mean by "Fails because the profile is not well defined or because the declaration is wrong?" let alone reproduce it.

You may find https://wiki.eclipse.org/OCL/ForumNetiquette helpful in providing a repro that enables someone to help with your problems.

Regards

Ed Willink
Previous Topic:allSubobjectsOfType works with some types.
Next Topic:QVTo correct map references
Goto Forum:
  


Current Time: Tue Apr 23 17:07:24 GMT 2024

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

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

Back to the top