How to set value of custom attribute type Enumeration?
Can anybody tell me how can we set value for custom attribute of type Enumeration?
When trying to set a string value getting exception as:
"java.lang.String incompatible with com.ibm.team.workitem.common.model.Identifier"
Any suggestion or piece of code would be a great help.
Thanks.
Accepted answer
4 other answers
Any help?
I have seen one article stating how to set value for Filed against.
but how to deal with custom enumeration attributes?
Any body?
The key for me was discovering that enum values all have an underlying ID. So if you have an enum named "version" with values "1.0.0.0" and "1.1.0.0", each of those two values will have an ID and that ID is what gets stored with the work item.
I do something like this to get at enum attributes:
String enumAttributeName = "version";String value = "1.0.0.0";
String id = null;
IWorkItemClient client = (IWorkItemClient)repo.getClientLibrary(IWorkItemClient.class);
IAttribute attribute = workItemClient.findAttribute(areaHandle, enumAttributeName, null);
IEnumeration<ILiteral> enumeration = (IEnumeration<ILiteral>) workItemClient.resolveEnumeration(attribute, null);
List<ILiteral> enumerationLiterals = enumeration.getEnumerationLiterals();
for (ILiteral literal : enumerationLiterals)
if (literal.getName().equalsIgnoreCase(value))
id = literal.getIdentifier2().getStringIdentifier();
Any help?
I have seen one article stating how to set value for Filed against.
but how to deal with custom enumeration attributes?
Any body?
well you have to create the value object(Identifier) first, then setValue(attribute, object) should work. This is an OO system
how do you create an Identifier? I would look up its constructors
in Eclipse, this is click on the classname, and select 'Open Declaration' from the popup menu (or hit f3 if u can remember the keystroke mnemonics)
Sam
Basically, what I have is an attribute on a work item that should be a multi select attribute. To set this up I created an attribute of type string, and added a presentation editor that attaches an enumeration to the custom attribute.
When multiple values of the enumeration are selected, the string value of the custom work item is something like "test.multiselect.enumeration.l1,test.multiselect.enumeration.l2" and I need a way of first knowing that this custom attribute of type string is actually a multi select, and second translating the values of the enumeration literals to the display names.
Thanks for any help,
-ryan