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:

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;
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.

Previous Topic:uml metamodel diagrams
Next Topic:Getting applied profile names programmatically?
Goto Forum:

Current Time: Mon Aug 08 22:00:36 GMT 2022

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

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

Back to the top