Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 331315

Summary: Moving a stereotyped Class remove the stereotype
Product: [Modeling] QVTo Reporter: Alexis Muller <Alexis.Muller>
Component: EngineAssignee: Sergey Boyko <serg.boyko2011>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: nicolas.f.rouquette, serg.boyko2011
Version: unspecifiedFlags: serg.boyko2011: indigo+
Target Milestone: 3.1   
Hardware: PC   
OS: All   
Whiteboard: Extensibility
Attachments:
Description Flags
A project example none

Description Alexis Muller CLA 2010-11-29 05:45:36 EST
Build Identifier: 20100917-0705

Moving a stereotyped Class into a QVTo transformation on an inout model remove the stereotype.

Reproducible: Always

Steps to Reproduce:
1. create an uml model with a stereotyped element
2. create a transformation with an uml inout model
3. add a mapping rule that move the element (for example : from a package to another)
4. run the transformation

result : the element has lost its stereotype
Comment 1 Alexis Muller CLA 2010-11-29 05:50:59 EST
Created attachment 184021 [details]
A project example

This is a project example with :
 - A uml model with a stereotyped element (Test.uml)
 - The profile used in Test.uml (Test.profile.uml)
 - A transformation example (movingStereotypedElement.qvto)

Look into Test.uml : MyStereotypedClass is stereotyped
Run movingStereotypedElement with Test.uml as parameter
Look into Test.uml : MyStereotypedClass is not stereotyped anymore
Comment 2 Nicolas Rouquette CLA 2010-12-03 13:25:29 EST
(In reply to comment #1)
> Created an attachment (id=184021) [details]
> ....
>  - A transformation example (movingStereotypedElement.qvto)

This transformation does not move a package, it duplicates its structure, copies its name and moves the owned types from the source package (self) to the target package (result).

This is not a QVTo bug.
Comment 3 Alexis Muller CLA 2010-12-03 17:11:13 EST
(In reply to comment #2)
> This transformation does not move a package, it duplicates its structure,
> copies its name and moves the owned types from the source package (self) to the
> target package (result).

Yes, this transformation does not move a package but its owned types. And if one of this owned type is stereotyped, it loses its stereotype (like the MyStereotypedClass Class in my example).

This is a QVTo bug.
Comment 4 Nicolas Rouquette CLA 2011-01-20 05:19:58 EST
I stand corrected; the behavior you've observed is definitely a defect.

However, it's hard to fix this defect in QVTo because the UML specification does not provide any generic way to find instances of stereotypes in a model.
The consequence of this is that there is a lot of implementation-level variability in the way UML tools manage instances of stereotypes
and their relationship with modeling elements. 

Perhaps, QVTo could provide a pluggable mechanism to inform the QVTo engine about the implementation-specific details for accessing & managing instances of stereotypes in a model.
This problem is closely related to an issue I've raised against the UML at the OMG: http://www.omg.org/issues/uml2-rtf.open.html#Issue15001
Comment 5 Sergey Boyko CLA 2013-07-14 13:47:11 EDT
Actually the problem is in script. Mapping simpleMove() creates new package thus necessary profiles need to applied to it in order to be able to contain types (UML classes) with applied stereotypes.

Modified mapping (which remediates the problem) is below:

mapping Uml::Package::simpleMove() : Uml::Package
{
	name := 'topackage';
	
	self.getAllAppliedProfiles()->forEach(p) {
		result.applyProfile(p);
	};
	
	ownedType := self.ownedType;
}


Checked with QVTO from Kepler release.