Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Getting applied profile names programmatically?
Getting applied profile names programmatically? [message #625789] Mon, 31 December 2007 15:45
Eclipse UserFriend
Originally posted by: matt.mcgill.gmail.com

Hello all,

I've looked through many profile-related posts on the newsgroup here,
and haven't been able to put my finger on the source of my troubles.
I'm loading a UML2 model programmatically with the following code:

public static Model loadFromFile(String path) {
ResourceSet rs = new ResourceSetImpl();
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().p ut(
"uml", new XMIResourceFactoryImpl());
URI uri = URI.createFileURI(path);
EClass eClass = UMLPackage.eINSTANCE.getModel();
Model m = (Model) EcoreUtil.getObjectByType(
rs.getResource(uri, true).getContents(), eClass);
return m;
}

I'm writing a UML simulator that will rely on information supplied in a profile,
and as a first step, I want to check that the profile is applied. I wrote the
following code to do so:

boolean foundProfile = false;
for (Profile p : m.getAllAppliedProfiles()) {
if ("hydra-uml".equals(p.getName())) {
foundProfile = true;
break;
}
}
if (!foundProfile)
throw new HydraException(...);

Running this code on a simple test model with some applied profiles fails, however.
getAppliedProfiles() returns Profile instances representing the applied profiles,
but getName() returns null, and using the debugger I can see that only the eProxyURI
attribute on the ProfileImpl instances is initialized.

What do I need to do to get access to the names of these profiles? This code is all
stand-alone, not running within an Eclipse workbench.

Thanks,
-Matt
Previous Topic:uml metamodel diagrams
Next Topic:Getting applied profile names programmatically?
Goto Forum:
  


Current Time: Fri Apr 19 09:51:51 GMT 2024

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

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

Back to the top