It's all about the answers!

Ask a question

Retrieving custom attribute values of a work item


vinay reddy (1711205) | asked Mar 24 '09, 9:37 a.m.
Can some one let me know how to get the custom attribute values?


I'm doing this

List<IAttributeHandle> attrHandles= workItem.getCustomAttributes();
int size = attrHandles.size();
for(int i=0; i<size;i++)
{
IAttributeHandle handle= attrHandles.get(i);
IItem attrItem = repositoryItemService.fetchItem(handle, null);
IAttribute attribute = (IAttribute) attrItem;

System.out.println(attribute.getAttributeType());
System.out.println(attribute.getIdentifier());
Object value= workItem.getValue(attribute);

System.out.println("value"+ value);
}


Output is

size is2
Category
skill
valuecom.ibm.team.workitem.common.model.ILiteral:Category.literal.l1
Role
Role
valuecom.ibm.team.workitem.common.model.ILiteral:Role.literal.l1

As you see from the output. workItem.getValue(attr) does not return the actual value stored for that attribute.Custom attributes here are enumerations. Any thing specific to be done to get the attr values in this context?

3 answers



permanent link
Marcel Bihr, Jazz Work Item team (1.4k) | answered Mar 24 '09, 11:20 a.m.
JAZZ DEVELOPER
Hi

workItem.getValue returns the value that is stored on the work item (the id of a literal). To get a nice presentation of that (icon, display name), you have to resolve the according enumeration.
Have a look at
IWorkItemCommon#resolveEnumeration
where you pass in the the attribute handle and get an IEnueration from where you can get the Literal by using findEnumerationLiteral and on the Literal, you have getName and getIconURL.

Regards

Marcel
Jazz Work Item team

permanent link
Ken Lin (2143) | answered Nov 18 '09, 4:08 a.m.
Hi..
I have similar problem about the custom attribue. But my environment is in java client. I found I have no repositoryItemService. My codes like follows:

IWorkItem workItem= workItemClient.findWorkItemById(9,IWorkItem.FULL_PROFILE, new NullProgressMonitor());
List<IAttributeHandle> lst = workItem.getCustomAttributes();
for(IAttributeHandle ih:lst){
..how can I get IAttribute from IAttributeHandle?
}
please kinldy give me a help. Thanks in advance.


Best Regards

permanent link
Patrick Streule (4.9k21) | answered Nov 18 '09, 6:23 a.m.
JAZZ DEVELOPER
IWorkItem workItem=
workItemClient.findWorkItemById(9,IWorkItem.FULL_PROFILE, new
NullProgressMonitor());
List<IAttributeHandle> lst = workItem.getCustomAttributes();
for(IAttributeHandle ih:lst){
..how can I get IAttribute from IAttributeHandle?
}
please kinldy give me a help. Thanks in advance.

You can use

IAttribute attribute=
workItemClient.getAuditableCommon().resolveAuditable(ih,
IAttribute.FULL_PROFILE, monitor);

--
Regards,
Patrick
Jazz Work Item Team

Your answer


Register or to post 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.