It's all about the answers!

Ask a question

Ho to fetch workitem type attribute value?


pugazhenthi samidurai (26423742) | asked May 08 '12, 5:01 a.m.
Hi,

i am using plain java for fetching all work items from project area.

i have one doubt how to fetch value for work item type attribute.

6 answers



permanent link
Ralph Schoon (61.4k33643) | answered May 08 '12, 6:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please see:

https://jazz.net/forums/viewtopic.php?t=3680
https://jazz.net/forums/viewtopic.php?t=4957
https://jazz.net/forums/viewtopic.php?t=14318
https://jazz.net/forums/viewtopic.php?t=17467
https://jazz.net/forums/viewtopic.php?t=24184
https://jazz.net/forums/viewtopic.php?t=1588

In a nutshell

Find the attribute

IAttribute customString = workItemClient.findAttribute(fProjectArea,
fCustomStringAttributeID, null);


Or iterate the exiting ones:


// List Custom Attributes
List<IAttributeHandle> custAttribs = workItem.getCustomAttributes();
for (Iterator<IAttributeHandle> iterator = custAttribs.iterator(); iterator.hasNext();) {
IAttributeHandle iAttributeHandle = (IAttributeHandle) iterator
.next();
IAttribute iAttribute = (IAttribute)fTeamRepository.itemManager().fetchCompleteItem(iAttributeHandle, 0, null);
System.out.print("Custom: " +iAttribute.getIdentifier()+" \t" +iAttribute.getDisplayName()+" \t"+iAttribute.getAttributeType());
Object value = workItem.getValue(iAttribute);
if(value!=null && value instanceof String) {
String sValue = (String) value;
System.out.print("\tValue: " + sValue);
}
System.out.println();
}


You get the value as an object and need to cast it. Enumerations return ILiteral or something like that. I have no code snippet lying around for that case.

permanent link
sam detweiler (12.5k6189201) | answered May 08 '12, 8:31 a.m.
My code for finding the values of ALL attributes in a workitem (including enumerations) is here

https://jazz.net/forums/viewtopic.php?t=24762

but if you are asking how to find the workitem TYPES in a project..

the call is

workItemClient.findWorkItemTypes(fProjectArea, monitor)


Sam

permanent link
pugazhenthi samidurai (26423742) | answered May 08 '12, 10:19 a.m.
Hi Sam,

Thank you very much.

Based on your post (
https://jazz.net/forums/viewtopic.php?t=24762) .

i have found the solution for retrieving priority and other values like enumeration , string type values.

But i am unable to retrieve Status (interanalState) attribute and work item type attributes values.

permanent link
pugazhenthi samidurai (26423742) | answered May 08 '12, 10:36 a.m.
Hi Ralph Schoon,

Thank you for your response.

i have followed your post.

check my output below for this line,

System.out.print("Custom: " +customString.getIdentifier()+" \t" +customString.getDisplayName()+" \t"+customString.getAttributeType());

output:

Custom: customerid Customer ID workItem


And it doesn't return any value for work item type of attribute.

permanent link
Ralph Schoon (61.4k33643) | answered May 08 '12, 11:02 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,

If I read your output correctly it says that the attribute Type identifier returned by IAttribute.getAttributeType() is "workItem".

So I would assume that it was configured to contain work items. Is that not correct?

If you are talking about the state of a work item, the work item has getters and setters for the built in attributes that you can use too.

permanent link
pugazhenthi samidurai (26423742) | answered May 09 '12, 12:22 a.m.
Hi Ralph Schoon,

its correct one of my attribute type is work item.

Please suggest me how to get the value of that attribute(work item type).

And also i am unable to fetch the value of State attribute.

Sorry for my inappropriate post.

I want to read the values of two attributes.

1. work item type attribute
2. State type attribute.

Your answer


Register or to post your answer.