Getting custom attributes names via Java API
I am trying to retrieve the list of custom attributes via Java API.
I've been able to retrieve a list of IAttributeHandle; can I get IAttribute from IAttributeHandle (in order to retrieve the name)?
|
Accepted answer
Based on Luca's comment, on the server side you can use the IRepositoryItemService class to achieve this.
IAttributeHandle handle = ...
Note that if you want to fetch a number of attribute handles you can use the IRepositoryItemService#fetchItems() method instead.
Luca Martinucci selected this answer as the correct answer
|
3 other answers
Hi Luca,
The following code snippet should get you started: com.ibm.team.workitem.common.model.IAttributeHandle handle = workItem.getCustomAttributes().get(0); com.ibm.team.workitem.common.model.IAttribute attribute = (IAttribute) teamRepository.itemManager().fetchCompleteItem(handle, IItemManager.DEFAULT, new NullProgressMonitor()); Comments
Luca Martinucci
commented Sep 12 '12, 6:07 a.m.
Hi Lauren, your code is fine, but in order to get a teamRepository, I need to import the com.ibm.team.repository.client package. Instead, I am writing a server-side extension, so I can use only "common" and "service" packages. Any suggestion? |
Jared, it works!
Thanks for your answer! |
That worked for me too. Thank you very much. I have one question: I have a custom datefield which is a timestamp. When I try to set its value by using Plain Java libraries and java.sql.Timestamp object, there's no problem. But when I try to do the same operation in server side I get the error below.
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.