Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » How to get "tagged values" from an attribute of class in UML2.0
icon5.gif  How to get "tagged values" from an attribute of class in UML2.0 [message #1063642] Thu, 13 June 2013 14:56 Go to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 96
Registered: April 2013
Member
Hello

I have an UML class with attributes. I would like to know how I can get all Taggues values of each attribute.

Thank you for your help.


Re: How to get "tagged values" from an attribute of class in UML2.0 [message #1063705 is a reply to message #1063642] Thu, 13 June 2013 19:37 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael Chaves
Messages: 161
Registered: July 2009
Senior Member
Use one of the #getAppliedStereotypes() variations in the Element metaclass (everything in UML is an element).

Re: How to get "tagged values" from an attribute of class in UML2.0 [message #1064213 is a reply to message #1063705] Tue, 18 June 2013 09:48 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 96
Registered: April 2013
Member
When i use class.getAppliedStereotypes().getKeyword() it return nothing but my class is stereotype <<singleton>>. I know that and it is possible the method class.getkeyword() is working. Everything I get using getAppliedStereotypes().
Is empty and I don't know how to proceed.
Nevertheless, I think that a taggues value is a stereotype in UML2, isn't it?
Thank you for your advice.
Re: How to get "tagged values" from an attribute of class in UML2.0 [message #1064307 is a reply to message #1064213] Tue, 18 June 2013 15:26 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael Chaves
Messages: 161
Registered: July 2009
Senior Member
A stereotype application connects a stereotype to an element (and instance of the stereotype) and describes the values of the stereotype attributes in that instance. Tagged values are no longer supported in UML, and were replaced by stereotype attributes.

You query the values of the stereotype attributes in a particular stereotype application using Element#getValue(Stereotype, String attributeName). You determine whih stereotypes apply to an element using Element#getAppliedStereotypes(). You find out what attributes are available on the Stereotype using Stereotype#getOwnedAttributes(). You can also use UMLUtil.getTaggedValue(String stereotypeName, String attributeName) to get one particular value. There is a wealth of stereotype-related API in Element, Stereotype and UMLUtil, get familiar with them.

If #getAppliedStereotypes() returns an empty list and you are positive there are stereotypes applied to the element in question, you may be suffering of an unresolved profile reference in the model. Does yourPackage.getAppliedProfiles() return an empty list as well? Can you paste your model here?

[Updated on: Tue, 18 June 2013 15:29]

Report message to a moderator

Re: How to get "tagged values" from an attribute of class in UML2.0 [message #1065294 is a reply to message #1064307] Tue, 25 June 2013 09:23 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 96
Registered: April 2013
Member
Hello,

Thank you for your advice.

I cannot paste my model here because I'm working on a confidential project. However, myPackage.getAppliedProfiles() return and emty list but getKeyword() return a specific stereotyped when it exists.
Re: How to get "tagged values" from an attribute of class in UML2.0 [message #1065424 is a reply to message #1065294] Tue, 25 June 2013 16:18 Go to previous message
Rafael Chaves is currently offline Rafael Chaves
Messages: 161
Registered: July 2009
Senior Member
Keywords and stereotypes are unrelated features.

Try to reproduce the problem using a simpler model then, and post that one here. Or omit the guts of the model file and provide only the top elements. For instance, the root xmi:XMI element and all the profileApplication elements, like this:

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:kirra="models/kirra" xmlns:mdd_extensions="profiles/mdd_extensions" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML" xsi:schemaLocation="models/kirra platform:/plugin/com.abstratt.kirra.mdd.core/models/kirra.uml#_http2F2Fwww.eclipse.org2Fuml22F2.0.02FUML-kirra profiles/mdd_extensions pathmap://MDD_PROFILES/mdd_extensions.uml#_http2F2Fwww.eclipse.org2Fuml22F2.0.02FUML-mdd_extensions">
  <uml:Package xmi:id="_0" name="shipit" URI="demo-cloudfier-examples-shipit/shipit">

<!-- ... model elements ... -->

<!-- profile applications -->

    <profileApplication xmi:id="_profileApplication.0">
      <eAnnotations xmi:id="_profileApplication.0-_http2F2Fwww.eclipse.org2Fuml22F2.0.02FUML" source="http://www.eclipse.org/uml2/2.0.0/UML">
        <references xmi:type="ecore:EPackage" href="pathmap://MDD_PROFILES/mdd_extensions.uml#_http2F2Fwww.eclipse.org2Fuml22F2.0.02FUML-mdd_extensions"/>
      </eAnnotations>
      <appliedProfile href="pathmap://MDD_PROFILES/mdd_extensions.uml#_0"/>
    </profileApplication>
    <profileApplication xmi:id="_profileApplication.1">
      <eAnnotations xmi:id="_profileApplication.1-_http2F2Fwww.eclipse.org2Fuml22F2.0.02FUML" source="http://www.eclipse.org/uml2/2.0.0/UML">
        <references xmi:type="ecore:EPackage" href="platform:/plugin/com.abstratt.kirra.mdd.core/models/kirra.uml#_http2F2Fwww.eclipse.org2Fuml22F2.0.02FUML-kirra"/>
      </eAnnotations>
      <appliedProfile href="platform:/plugin/com.abstratt.kirra.mdd.core/models/kirra.uml#_0"/>
    </profileApplication>
  </uml:Package>

<!-- ... stereotype applications ... -->

</xmi:XMI>


I suspect getAppliedProfiles() is returning an empty list because of a model reference (URI) not being resolved, the #1 issue people struggle with in this forum.
Previous Topic:UML profile with OCL constraints on stereotypes
Next Topic:what is the root for all UML models?
Goto Forum:
  


Current Time: Thu Oct 23 12:29:55 GMT 2014

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

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