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

Bug 357912

Summary: Sterotype which contained a stereotype applied to Class type are not retrieved as Class
Product: [Modeling] MDT.UML2 Reporter: bkhamphousone
Component: CoreAssignee: UML2 Inbox <mdt-uml2-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: critical    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description bkhamphousone CLA 2011-09-16 04:20:40 EDT
Hi,

I've encountered a problem with Stereotype.

Actually, I'm trying to find a way to workaround this issue.

I'm using Acceleo so we've got a UML2 Model as source of the generation. Everything works fine until I've to generate something awkward but very useful in my opinion.

There's a Stereotype (IHMMethod) which contains a property name bean. This property has to be a type of another Stereotype which name is DTO.

The stereotype DTO is applied to some classes and the stereotype IHMMethod is applied to Operation type. So we've got this :

Operation <<IHMMethod>> <-- bean <<DTO>> <-- every class stereotyped with DTO

When I access to an Operation type and when this last one got the stereotype IHMMethod, I retrieve the bean property. Unfortunately, it is a DynamicEObjectImpl and not an Element. So I'm not able to get the class contains in the bean property.

This seems to works fine with uml2 1.0.6 and not with uml2 1.1.2.

Here is the code to retrieve the object.

public class testServices {
public String getBeanIHMMethodService(Operation anOperation) {
String result = null;
if (anOperation != null) {
try {
Stereotype st = anOperation
.getAppliedStereotype("myprofile::IHM Method");
if (st == null) {
result = "st null";
} else {
DynamicEObjectImpl obj = (DynamicEObjectImpl) anOperation.getValue(st, "bean");
if(obj != null){
result = obj.toString();

}else{
result = "nulllqsdaaa";
}
}
} catch (Exception e) {
result = e.toString();
}
} else {
result = "nullaaa";
}
return result;
}
}

Thank you very much.
Comment 1 Kenn Hussey CLA 2011-09-24 10:39:00 EDT
Note that it's generally not a good idea to cast to an implementation class...

Once you retrieve the stereotype application object, it should be possible to get its base element, e.g., using the eGet(...) method, and then retrieve the value of that object's stereotype...
Comment 2 Kenn Hussey CLA 2012-06-20 21:54:10 EDT
Alternatively, the UMLUtil#getBaseElement(EObject) should be able to return the UML element to which a given stereotype application (dynamic Ecore object) is applied, and from there it should be possible to obtain the value of a stereotype property. Does this help?
Comment 3 Kenn Hussey CLA 2012-11-01 13:14:57 EDT
Given the lack of response, I'll assume this is no longer an issue.