Book a Demo

Author Topic: How to add taggedValue of specific type?  (Read 4552 times)

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
How to add taggedValue of specific type?
« on: October 26, 2010, 08:55:42 pm »
Hello,

how can I assign a specific TaggedValueType to a element?

This seams not to work...
myElement.TaggedValues.AddNew("<TaggedValueType>", "");

Thanks for help.

Regards
Rainer
« Last Edit: October 26, 2010, 09:39:53 pm by RQ »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to add taggedValue of specific type?
« Reply #1 on: October 27, 2010, 04:21:34 pm »
Rainer,

My code to add a tagged values to an element:
Code: [Select]
       /// <summary>
        /// adds a tagged value to this element
        /// </summary>
        /// <param name="name">the name of the tagged value</param>
        /// <returns>the added tagged value</returns>
        public override UMLTaggedValue addTaggedValue(string name)
        {
            return (UMLTaggedValue)EAWrapperFactory.createEAWrapper((EAModel)this.getModel(), this.wrappedElement.TaggedValues.AddNew(name, "TaggedValue"));
        }
So I guess your code you work if you do:
Code: [Select]
myElement.TaggedValues.AddNew("<TaggedValueType>", "TaggedValue");
Just be careful with the name of the tagged value. If you have defined your tagged value as part of a profile you'll have to use the FQN as in "ProfileName:TaggedValueName" (or "ProfileName::TaggedValueName", i don't remember exactly)


There should be some posts about that in this forum.

Geert
« Last Edit: October 27, 2010, 04:22:33 pm by Geert.Bellekens »

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: How to add taggedValue of specific type?
« Reply #2 on: October 27, 2010, 10:42:20 pm »
Hi Geert,

thanks for your replay. Actually my code did works (partially).

Here is what I do:
- create new PropertyValueTypes
- create a new element (Requiremnt)
- assign a set of taggedValues.

My problem now is, that when I select the new created requirement, it shows the assigned tagged values, but not the default values.

If I shut down EA and restart it, the default values are shown. Also if I then create more Requirements through my addin all default values of the TaggedValues are shown correctly from now on.

My conclution is, that I am missing some Update or Refresh after creating the TaggedValueTypes...

Regards
Rainer
« Last Edit: October 27, 2010, 10:43:31 pm by RQ »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to add taggedValue of specific type?
« Reply #3 on: October 27, 2010, 10:47:04 pm »
Can you post the code that creates the taggedValues?

Geert

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: How to add taggedValue of specific type?
« Reply #4 on: October 27, 2010, 11:02:47 pm »
Hi Geert,

here the code.

// creating the TaggedValueTypes
//=====================
repository.PropertyTypes.Refresh();
string property = "StoryPoints";
string description = "Estimated complexity of the user story";
string notes = "Type=enum;" + Environment.NewLine +
                "Values=0,1,2,3,5,8,13;" + Environment.NewLine +
                "Default=2;";
PropertyType tagType = repository.PropertyTypes.AddNew(property, "");
tagType.Description = description;
tagType.Detail = notes;
tagType.Update();            
repository.PropertyTypes.Refresh();

Regards
Rainer

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to add taggedValue of specific type?
« Reply #5 on: October 27, 2010, 11:12:06 pm »
Seems perfectly ok to me.
If it's really necesarry you could to a reload of your model, but I would leave it as is. After all, after a restart of EA you see the default values so...

(PS. IIRC The default value isn't actually filled in in the database. Its left null and the EA GUI will pretend it has the default value, but my memory could be failing me.)

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: How to add taggedValue of specific type?
« Reply #6 on: October 27, 2010, 11:18:11 pm »
Hi Geert,

thanks for your help. I guess I will the leave it as it is. Maybe some when later I will stumble over a solution to this minor issue.

Regards
Rainer