Enumeration literals for custom fields with RTC API on server side
Hello!
To get custom fields values, I use such code in my own Rational Team Concert follow-up action:
But all my experiments failed when I was trying to extract enumeration displayed values (or literals) for these fields. Here I can get the enumeration identifiers only but not literals. Does somebody knows how I could get them on the server side of my RTC custom extension?
Thank you very much in advance!
To get custom fields values, I use such code in my own Rational Team Concert follow-up action:
// Get custom attributes List<IAttributeHandle> wi_customs = wi.getCustomAttributes();
// Go through all work item fields
for (int i = 0; i < wi_customs.size(); i++) {
IAttribute attribute = (IAttribute) itemService.fetchItem(
wi_customs.get(i), IRepositoryItemService.COMPLETE);
String value = "";
// To avoid any problems with non-synchronized attributes
if (wi.hasAttribute(attribute)) {
Object objval = wi.getValue(attribute);
if (objval != null)
value = objval.toString();
}
attributes.add(new Attribute(attribute.getIdentifier(), value));
}
But all my experiments failed when I was trying to extract enumeration displayed values (or literals) for these fields. Here I can get the enumeration identifiers only but not literals. Does somebody knows how I could get them on the server side of my RTC custom extension?
Thank you very much in advance!
Accepted answer
You can access the data like this using IWorkItemCommn:
Also see https://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/
fWorkItemCommon = getService(IWorkItemCommon.class);
// Iterate the enumeration literals and create
IEnumeration targetEnumeration = fWorkItemCommon
.resolveEnumeration(enumerationAttribute, monitor);
List literals = targetEnumeration
.getEnumerationLiterals();
for (ILiteral targetLiteral : literals) {
.......
}
Also see https://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/