Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » apply stereotype on element Problem!(I use applySereotype(),but there's no corresponding element.)
icon5.gif  apply stereotype on element Problem! [message #1115515] Tue, 24 September 2013 03:48 Go to next message
BaiChuan Nie is currently offline BaiChuan Nie
Messages: 5
Registered: September 2013
Junior Member
I wrote QVTo like this:

transformation CIM_To_PIM(in cim : UML,in profile : UML, out pim : UML);
property web_prof = profile.objectsOfType(UML::Profile)->asOrderedSet()->first();
property web_stereo = profile.objectsOfType(UML::Stereotype);
property web_model:UML::Model = null;
main() {
cim.rootObjects()[UML::Model]->map model2WebModel();
}
mapping UML::Model::model2WebModel() : UML::Model {
... ...
this.web_model := result;
packagedElement += self.nestedPackage->select(p|p.getAppliedStereotypes()->exists(name='CIM'))->asOrderedSet()->first().nestedPackage->map function2package();
}

mapping UML::Package::function2package() : UML::Package
when{self.getAppliedStereotypes()->exists(s|s.name='functionSet')}
{
... ...
packagedElement += self.map endFunction2Controller();
}
mapping UML::Package::endFunction2Controller() : UML::Class
when{
not self.nestedPackage->collect(p|p.getAppliedStereotypes())->exists(s|s.name='functionSet') and
not self.ownedElement[UML::Class]->isEmpty()
}
{
... ...
this.web_model.ownedType += result;
result.getApplicableStereotypes()-> forEach(stereotype){
log("applicable stereotype:", stereotype.name);
};
result.applyStereotype(web_stereo->any(name='controller'));
result.getAppliedStereotypes()-> forEach(stereotype){
log("applied stereotype:", stereotype.name);
};
}

Strange, the log output like below:
applicable stereotype:, data: validator
applicable stereotype:, data: controller
applicable stereotype:, data: logger
applicable stereotype:, data: exception
applied stereotype:, data: controller

but,in XMI,there is no element such as <controller:controller ... base_Class=""/>。
why the stereotype applied isn't sierialized into XMI???
Re: apply stereotype on element Problem! [message #1116692 is a reply to message #1115515] Wed, 25 September 2013 14:56 Go to previous messageGo to next message
Sergey Boyko is currently offline Sergey Boyko
Messages: 162
Registered: July 2009
Senior Member
Hi BaiChuan,

You have to apply profile to model first. For example you can place a call to "result.applyProfile(profile)" in 'model2WebModel()' mapping.

Regards,
Sergey.

Re: apply stereotype on element Problem! [message #1116705 is a reply to message #1116692] Wed, 25 September 2013 15:09 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi Sergey

Any change we can add this to a Wiki FAQ and/or a simple how to use UML
stereotypes example?

Regards

Ed Willink

On 25/09/2013 14:56, Sergey Boyko wrote:
> Hi BaiChuan,
>
> You have to apply profile to model first. For example you can place a
> call to "result.applyProfile(profile)" in 'model2WebModel()' mapping.
>
> Regards,
> Sergey.
>
>
Re: apply stereotype on element Problem! [message #1118075 is a reply to message #1116692] Thu, 26 September 2013 23:37 Go to previous messageGo to next message
BaiChuan Nie is currently offline BaiChuan Nie
Messages: 5
Registered: September 2013
Junior Member
I have apply the profile on the model, It is in the mapping model2WebModel,I forgot to paste:
mapping UML::Model::model2WebModel() : UML::Model {
name := self.name+'_Web_PIM';
result.applyProfile(web_prof);
this.web_model := result;
packagedElement += self.nestedPackage->any(p|p.isAppliedStereotype('CIM')).nestedPackage->map function2package();
}

But It is no use!


Now I want to use EAnnotation to replace Stereotype!
But there is still a little problem.

By the way,can I get your MSN or Email?Expecting for you help...
Re: apply stereotype on element Problem! [message #1226838 is a reply to message #1118075] Thu, 02 January 2014 16:39 Go to previous messageGo to next message
Ed Seidewitz is currently offline Ed Seidewitz
Messages: 5
Registered: July 2011
Junior Member
I just came across this, because I was having some similar problems. In case no one has addressed your issue since September, I believe the problem is that you are trying to apply the stereotypes during the mapping process, which is before the result of the mapping gets added to the package to which the profile is applied.

When you try to apply a stereotype to an element, Eclipse UML2 checks to see if there is a profile with that stereotype applied to any package in which the element is contained (directly or indirectly). If there is not, then the stereotype is not applied. Since you are trying to apply the stereotype before the element is put in the package with the applied profile, the stereotype does not get applied.

In order to get it to work, you have to do the function2package mapping without applying the stereotypes, add the results to the top-level Web Model, and then go back through and apply the stereotypes where appropriate.

[Updated on: Fri, 03 January 2014 18:27]

Report message to a moderator

Re: apply stereotype on element Problem! [message #1238302 is a reply to message #1226838] Fri, 31 January 2014 19:00 Go to previous message
Naif Mokhayesh is currently offline Naif Mokhayesh
Messages: 29
Registered: November 2011
Junior Member
Hi Ed Seidewitz,

could you please elaborate more on your suggested solution with simple example. In fact, I tried to follow it, but getAppliedStereotypes() shows the correct results during transformation execution verification and nothing added to output xmi file.

More detailes in http://www.eclipse.org/forums/index.php/t/642760/

thanks
Previous Topic:Setting a configuration property from Java
Next Topic:Stereotype not applied to the xmi output file !
Goto Forum:
  


Current Time: Fri Jul 25 21:21:12 EDT 2014

Powered by FUDForum. Page generated in 0.01994 seconds