Getting applied profile names programmatically? [message #625789] |
Mon, 31 December 2007 15:45 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02217 seconds