Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Retrieving custom attribute values of a work item

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?

0 votes



3 answers

Permanent link
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

0 votes


Permanent link
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

0 votes


Permanent link
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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,937

Question asked: Mar 24 '09, 9:37 a.m.

Question was seen: 7,866 times

Last updated: Mar 24 '09, 9:37 a.m.

Confirmation Cancel Confirm