Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Get All Stereotype of Element ( getAppliedStereotypes )
Get All Stereotype of Element ( getAppliedStereotypes ) [message #1007157] Mon, 04 February 2013 16:03 Go to next message
edipo federle is currently offline edipo federleFriend
Messages: 21
Registered: November 2012
Junior Member
Hi, I am trying use method getAppliedStereotypes but that return empty list.

I Have a model.uml and a profile.uml. In the model I have a class called Test, with a stereotype called Interface applied to this class.

But in java when I try to retrieve the stereotypes I get an empty list

I try Add this to my ResourceSet:

RESOURCE_SET.getURIConverter().getURIMap().put(URI.createURI("pathmap://Papyrus_PROFILES/smartyProfile.uml"), URI.createFileURI(new File("/Users/edipofederle/Documents/smartyProfile.uml").getAbsolutePath()));

But dont work.


Does anyone know how to solve this problem?

Thanks

[Updated on: Mon, 04 February 2013 20:45]

Report message to a moderator

Re: Get All Stereotype of Element ( getAppliedStereotypes ) [message #1007187 is a reply to message #1007157] Mon, 04 February 2013 21:14 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1618
Registered: July 2009
Senior Member
If you're running standalone (i.e., outside of Eclipse), try calling
UMLResourcesUtil.init(resourceSet) first.

Kenn

On 13-02-04 11:03 AM, edipo federle wrote:
> Hi, I am trying use method getAppliedStereotypes but that return empty
> list.
>
> I Have a model.uml and a profile.uml. In the model I have a class called
> Test, with a stereotype called Interface applied to this class.
>
> But in Java code, when I get this class and looking to stereotypes with
> the method getAppliedStereotypes return a empty list.
>
> I try Add this to my ResourceSet:
>
> RESOURCE_SET.getURIConverter().getURIMap().put(URI.createURI("pathmap://Papyrus_PROFILES/smartyProfile.uml"),
> URI.createFileURI(new
> File("/Users/edipofederle/Documents/smartyProfile.uml").getAbsolutePath()));
>
>
> But dont work.
>
>
> Does anyone know how to solve this problem?
>
> Thanks
Re: Get All Stereotype of Element ( getAppliedStereotypes ) [message #1007188 is a reply to message #1007187] Mon, 04 February 2013 21:23 Go to previous messageGo to next message
edipo federle is currently offline edipo federleFriend
Messages: 21
Registered: November 2012
Junior Member
Hi Kenn, No, i am not using standalone mode..... If I apply a stereotype to a element in " memory" the method getAppliedStereotypes works. But if I recover a model from disk The method dont work....
Re: Get All Stereotype of Element ( getAppliedStereotypes ) [message #1007636 is a reply to message #1007188] Wed, 06 February 2013 20:15 Go to previous message
edipo federle is currently offline edipo federleFriend
Messages: 21
Registered: November 2012
Junior Member
Hello, good news, It worked! I will show below how I get that done.

First of all. You can use this POM.XML file ( if you already using maven ).

The first thing than you need is register path maps, like this:

https://gist.github.com/edipofederle/4725342

And when you load the model, you should use a code than looks like this:

https://gist.github.com/edipofederle/4725346

Notice the parameter pathAbsolute, this is necessary. In short, you need the uri absolute to the resource ( i.e: your model ). The first parameter, uri, is the relative uri to your resource.

About model:

In my work, I am reading the uml files exported from Papyrus. To this works, you need all files. When I say all files, I want say that, for example. If you have a model called model ( created on papyrus), and a profile called myProfile, when you export this model the follow files should be present:



  • model.uml
  • mode.notation
  • model.di


The same to the profile:


  • myProfile.uml
  • myProfile.notation
  • myProfile.di


This is all. If someone have problems, fell free to asking.
Previous Topic:Any way to set the default value for a LiteralInteger explicitly?
Next Topic:Stereotype applicable to different elements
Goto Forum:
  


Current Time: Mon Nov 24 14:24:35 GMT 2014

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

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