Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » How to access stereotypes of uml elements?
How to access stereotypes of uml elements? [message #789913] Fri, 03 February 2012 15:13 Go to next message
Andreas Burger is currently offline Andreas Burger
Messages: 14
Registered: June 2011
Junior Member
Hello,

how can i access stereotypes of uml elements? I load the uml model with the following java code:

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createURI("org.eclipse.uml2.uml.source_3.2.0.v201105231350.jar!/");

uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP),
uri.appendSegment("profiles").appendSegment(""));

URI modeluri = URI.createURI("mymodel.uml");
Resource resource = resourceSet.getResource(modeluri,true);

Now i can access all elements of the uml model. But it is not possible to get the stereotypes of some elements in the uml model. Does anybody know how i can access stereotypes which are defined by an uml profile which is linked with the loaded uml model?

Regards,

Andreas

[Updated on: Fri, 03 February 2012 15:35]

Report message to a moderator

Re: How to access stereotypes of uml elements? [message #789950 is a reply to message #789913] Fri, 03 February 2012 16:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi

I think there are some helper functions called something like
getAppliedStereotypes().

Regards

Ed Willink


On 03/02/2012 15:13, Andreas Burger wrote:
> Hello,
>
> how can i access stereotypes of uml elements? I load the uml model
> with the following java code:
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
> URI uri =
> URI.createURI("org.eclipse.uml2.uml.source_3.2.0.v201105231350.jar!/");
>
> uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
> uri.appendSegment("libraries").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
> uri.appendSegment("metamodels").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP),
> uri.appendSegment("profiles").appendSegment(""));
>
> URI modeluri = URI.createURI("mymodel.uml");
> Resource resource = resourceSet.getResource(modeluri,true);
>
> Know i can access all elements of the uml model. But it is not
> possible to get the stereotypes of some elements in the uml model.
> Does anybody know how i can access stereotypes which are defined by an
> uml profile which is linked with the loaded uml model?
>
> Regards,
>
> Andreas
Re: How to access stereotypes of uml elements? [message #791821 is a reply to message #789950] Mon, 06 February 2012 09:50 Go to previous messageGo to next message
Andreas Burger is currently offline Andreas Burger
Messages: 14
Registered: June 2011
Junior Member
Hi,

thanks for fast respond. I tried these functions but they always return an empty list.
The stereotypes are present when viewing the uml model in the uml model editor. If the uml model is
traversed with the emf java possibilities the stereotypes cannot be accessed.
Does anybody know why the stereotypes are not present when using java emf uml parser?

Regards,

Andreas
Re: How to access stereotypes of uml elements? [message #791841 is a reply to message #791821] Mon, 06 February 2012 10:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi

If they exist in the model, and you can verify the XMI with a text
editor, then it is very very unlikely that they are not present in the
loaded Java. You just need to do some possibly hard work with the Java
debugger.

Regards

Ed Willink


On 06/02/2012 09:50, Andreas Burger wrote:
> Hi,
>
> thanks for fast respond. I tried these functions but they always
> return an empty list. The stereotypes are present when viewing the uml
> model in the uml model editor. If the uml model is traversed with the
> emf java possibilities the stereotypes cannot be accessed. Does
> anybody know why the stereotypes are not present when using java emf
> uml parser?
>
> Regards,
>
> Andreas
Re: How to access stereotypes of uml elements? [message #791848 is a reply to message #791821] Mon, 06 February 2012 10:17 Go to previous messageGo to next message
Peter  is currently offline Peter
Messages: 85
Registered: July 2009
Member
Hi Andreas,
just Debug the function...
I suppose that you hava a profile URI with pathmap and did not put that
in the URI_MAP. A Pathmap is only a placeholder for the real URI.
When you use a plugin like the UML Editor you must not care about these
things but when you use "standalone" Java you must consider it.
Greeting
Peter

Am 06.02.2012 10:50, schrieb Andreas Burger:
> Hi,
>
> thanks for fast respond. I tried these functions but they always return
> an empty list. The stereotypes are present when viewing the uml model in
> the uml model editor. If the uml model is traversed with the emf java
> possibilities the stereotypes cannot be accessed. Does anybody know why
> the stereotypes are not present when using java emf uml parser?
>
> Regards,
>
> Andreas
Re: How to access stereotypes of uml elements? [message #793633 is a reply to message #791848] Wed, 08 February 2012 11:22 Go to previous message
Tatiana Fesenko is currently offline Tatiana Fesenko
Messages: 61
Registered: July 2009
Member
I agree with Peter.

It seems profile were not loaded correctly. Probably the profiles are
referenced using the "platform:/plugin/" or "platform:/resource" URI. In
this case one has to add "platform:/plugin/" or "platform:/resource" to
the URI map.

The easiest way to check if the profile was loaded correctly is to see
if model.getAppliedProfiles() list contains your profile.

Regards,
--
Tatiana Fesenko
ModelSolv, Inc.
Model-Oriented Solutions for Service Integration
Previous Topic:XMI UML Profile to Ecore
Next Topic:3rd Biannual Eclipse/OMG Workshop on March 25
Goto Forum:
  


Current Time: Mon Sep 22 20:21:41 GMT 2014

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

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