Stereoytpes are not applied after serialization! [message #628418] |
Thu, 29 April 2010 10:44 |
Timothy Marc Messages: 547 Registered: July 2009 |
Senior Member |
|
|
Hi all,
i've a problem in applying stereotypes programmatically. At first, i
must say that stereotypes being applied via the "UML Editor" (Element ->
Apply Stereotype) works as expected. That's why i'm pretty sure that the
profile itself is implemented correctly. The profile is realized as a
static profile.
What is the problem:
I try to apply a profile and its stereotype programmatically during a
transformation (handwritten in plain java). Although i'm able to load
and apply the profile as well as the stereotypes, only the applied
profile remains after saving the model. Even the XMI doesn't contain
these additional stereotype entries. But only after serialization! If i
ask (at the end of the transformation) for the profile and the specific
stereotypes, everything is accessbile and present. After serialization,
only the applied profile remains.
Here is the snippet, how the profile is applied by me (don't care for
the prefixes and the uri's. They are correct).
ResourceSet set = new ResourceSetImpl();
final Model model = UMLFactory.eINSTANCE.createModel();
model.setName("Test");
final Profile prof =
(Profile)set.getResource(URI.createURI("platform:plugin/staticProfile/model/my.profile.uml "),
true).getContents().get(0);
model.applyProfile(prof);
org.eclipse.uml2.uml.Class clazz = model.createOwnedClass("TestClass",
false);
final Stereotype s = clazz.getApplicableStereotype("my::Extension");
clazz.applyStereotype(s);
final Resource r = UMLResource.Factory.INSTANCE.createResource(uri);
r.getContents().add(model);
try {
r.save(null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I really didn't understand the problem... what am i doing wrong?
Thanks in advance
Timothy
|
|
|
Powered by
FUDForum. Page generated in 0.01767 seconds