Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Stereoytpes are not applied after serialization!
Stereoytpes are not applied after serialization! [message #628418] Thu, 29 April 2010 10:44
Timothy Marc is currently offline 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
Previous Topic:Attribute Types
Next Topic:create InterfaceRealization issue
Goto Forum:
  


Current Time: Mon Sep 22 02:26:58 GMT 2014

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

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