Set and get method for Attribute Type for "ItemList and Item"
![]() Hi ,
I need to set and get the values of custome attribute in RTC . Those attribute identiifers are itemList and item. Could you please lte me know which RTC Java API can be used for the same.
Thanks Monali |
2 answers
![]()
Lauren Hayward Schaefer (3.3k●1●14●27)
| answered Sep 14 '12, 7:55 a.m.
JAZZ DEVELOPER edited Sep 14 '12, 7:56 a.m.
Hi Monali,
The type of the value you use will need to match whatever the type of your attribute is. For example, I created a custom attribute of type Item and then set the item type to Work Item. So instead of calling workItem.setValue with a String "my value", I called workItem.setValue with an IWorkItem: com.ibm.team.workitem.common.model.IAttributeHandle handle2 = workItem.getCustomAttributes().get(1); com.ibm.team.workitem.common.model.IAttribute attribute2 = (com.ibm.team.workitem.common.model.IAttribute) teamRepository.itemManager().fetchCompleteItem(handle2, IItemManager.DEFAULT, new NullProgressMonitor()) System.out.println("The attribute id: " + attribute2.getIdentifier()); System.out.println("The attribute name: " + attribute2.getDisplayName()); System.out.println("The value of the custom attribute: " + workItem.getValue(attribute2)); //Getting the handle for work item 15 IWorkItem handleOfWorkItemToSet = getWorkItemHandle(15, teamRepository); manager.connect(handleOfWorkItemToSet, IWorkItem.SMALL_PROFILE, progress.newChild(20)); IWorkItem workItemToSet = manager.getWorkingCopy(handleOfWorkItemToSet).getWorkItem(); workItem.setValue(attribute2, workItemToSet); I have the following getWorkItemHandle method defined: /** * Get the work item handle associated with the given work item id number * @param workItemId The id number of the work item * @param repo The team repository * @return The work item handle associated with the given work item * @throws TeamRepositoryException */ private IWorkItem getWorkItemHandle (int workItemId, ITeamRepository repo) throws TeamRepositoryException{ IWorkItemClient workItemClient= (IWorkItemClient)repo.getClientLibrary(IWorkItemClient.class); IWorkItem handle= workItemClient.findWorkItemById(workItemId, IWorkItem.SMALL_PROFILE, monitor); if (handle == null) { throw new TeamRepositoryException(NLS.bind(Messages.WorkItemCommenter_UNABLE_TO_FIND_WORK_ITEM, workItemId)); } return handle; } Comments Hi Lauren, We are also following the similar process for all other attribute types but we are not able to do it for only item and itemList attribute type. Thanks Hi Monali, The sample code I provided set the value for a custom attribute (attribute2), which was of type Item. Can you explain what problem you are hitting? |