It's all about the answers!

Ask a question

How does RTC determine literal id for a custom enumeration attribute?


Don Yang (7.6k2195131) | asked May 23 '14, 8:35 a.m.
RTC 4.0.5 used.

The user add enumeration attribute with some values and the configuration source will show

<enumeration attributeTypeId="ErrorCategoryEnum" name="Item">
   <literal default="true" id="ErrorCategoryEnum.literal.l2" name="item1"/>
   <literal id="ErrorCategoryEnum.literal.l4" name="item2"/>
   <literal id="ErrorCategoryEnum.literal.l6" name="item3"/>
   <literal id="ErrorCategoryEnum.literal.l8" name="item4"/>

In another project, when adding similar Item enumeration attribute, it will show
<enumeration attributeTypeId="ErrorCategoryEnum" name="Item">
   <literal default="true" id="ErrorCategoryEnum.literal.l1" name="item1"/>
   <literal id="ErrorCategoryEnum.literal.l2" name="item2"/>
   <literal id="ErrorCategoryEnum.literal.l3" name="item3"/>
   <literal id="ErrorCategoryEnum.literal.l4" name="item4"/>

Since there is an external program to check with literal id, they want to make them consistent. There are manual way to change literal id in the configuration source etc. The question here is:

How does RTC determine the literal id for the custom enumeration attribute as it does not make sense it assign
sequential id in one PA but even id in another one? Thanks


Accepted answer


permanent link
Donald Nong (14.4k314) | answered May 26 '14, 3:07 a.m.
For what it is worth, I did a quick test and found that enumerations added in the web GUI had the sequential literals, while in the Eclipse client even-numbered. Can't really say why the two clients behave differently. I'm using RTC 4.0.6.
So if it is designed this way and you want sequential literals, add the enumerations in the web GUI, not the Eclipse GUI.
Don Yang selected this answer as the correct answer

Comments
Don Yang commented May 26 '14, 3:44 a.m.

Thanks Donald for this info. I now know we need to find out why Eclipse and Web client have different behavior(as usual).

2 other answers



permanent link
Kevin Ramer (4.5k6172190) | answered May 23 '14, 9:32 a.m.
The ID value can be changed, but any work items that are using that literal value will actually show the ID in the associated attribute, not the name.    If you really want to go that route I suggest the following

  1. Change the name on the enumeration literals whose ID you are going to "retire" to a value with an eye-catching  string (e.g. DoNotUse+original name)
  2. In RTC Eclipse: Add new literals with the name you want using the UI, then before saving the configuration switch to the Configuration source and change the ID value to the one you want to end up with, save the project configuration.
  3. Change existing work items with the old enumeration values to the corresponding new value
  4. Remove the old enumeration literals.



Comments
sam detweiler commented May 23 '14, 9:35 a.m.

step 3 is the hard part.. and note that reports will be messed up for a while. 


Don Yang commented May 23 '14, 6:55 p.m.

Thanks Kevin for the details.
I did see the even id in my test here and manually modify the id to the expected ones. For the existing workitems, I have to use query to find and fix all of them and then delete the old ones in the source. These are basically similar approach as what you and Sam suggested.

I do notice that some enumeration attributes such as severity etc have sequential ids by default. So post this one and try to find out how RTC does to allocate the literal id for custom enum attributes as I have users who see the sequential ids in one place but even id in another one and wants to know why.


sam detweiler commented May 23 '14, 7:47 p.m.

I think the built in enums are sequential.  all new are even numbered


Don Yang commented May 28 '14, 9:12 p.m.

one interesting info to share here is that if using [Duplicate] instead of [Add] to create a new enum, then literal ids will be sequential, not even numbered.


sam detweiler commented May 28 '14, 9:41 p.m.

Interesting indeed. Thanks for that info. 


permanent link
sam detweiler (12.5k6189201) | answered May 23 '14, 8:57 a.m.
I have only ever seen the 2 step assignment
I2, I4, I6 ...

if you want specific IDs, I edit the source after creation but BEFORE saving to set the values as I want them.

I always recommend to use a class notation for the ID string

id=com.company.enum.value.name  name=name


Your answer


Register or to post your answer.