It's all about the answers!

Ask a question

How to get value for State and Priority attributes.


pugazhenthi samidurai (26423942) | asked May 04 '12, 1:02 a.m.
Hi,

I am using plain java client for fetching all work items.

i am Using the below function for retrieve contributors.

public static String getContributorsValue(IContributorHandle contributorval)
{

ITeamRepository repository = RepositoryManager.getInstance().getCurrentRepository();

IItemManager itm = repository.itemManager();
IContributor contributor = null;

try {
contributor = (IContributor) itm.fetchCompleteItem(contributorval, IItemManager.DEFAULT, null);
} catch (TeamRepositoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return contributor.getName();

}

Let me know How to get the Values of State and Priority instead of literal.

Accepted answer


permanent link
sam detweiler (12.5k6195201) | answered May 04 '12, 9:22 a.m.
here is my code used on the server for finding all the values of all the attributes of a workitem..
you need to change IWorkItemCommon to IWorkItemClient. (and use the getclient for IWorkItemClient).

				// reference the right object type (cast)

IWorkItem workItem = (IWorkItem) auditable;
IWorkItemCommon workItemCommon = iac.getPeer(IWorkItemCommon.class);
// get all the attributes in this project area
for(IAttribute ia:workItemCommon.findAttributes(p.getOldProcessArea().getProjectArea(), monitor) )
{
// check to see if the attribute is used in this workitem
if(workItem.hasAttribute(ia))
{
System.out.println("processing for variable="+ia.getDisplayName()+" attrib type="+ia.getAttributeType());
try
{
// attempt to get the eumeration for this attribute
// will fail if not an enum
IEnumeration<ILiteral> enumeration = (IEnumeration<ILiteral>)workItemCommon.resolveEnumeration(ia, monitor);
if(enumeration!=null)
{
String[] iaval = ia.getValue(iac, workItem, monitor).toString().split(":");

if(iaval.length>1 && iaval[1]!=null)
{
List<ILiteral> enumerationLiterals = enumeration.getEnumerationLiterals();
for (ILiteral literal : enumerationLiterals)
{
if(literal.getIdentifier2().getStringIdentifier().equalsIgnoreCase(iaval[1]))
{
System.out.println("attribute name="+ia.getIdentifier() +", type"+"="+ia.getAttributeType()+" literal="+literal.getIdentifier2().getStringIdentifier()+" literal name="+literal.getName());
break;
}
}
}
}
}
catch (Exception e)
{
//System.out.println("Exception="+e.toString());
}
}
}
pugazhenthi samidurai selected this answer as the correct answer

One other answer



permanent link
pugazhenthi samidurai (26423942) | answered May 07 '12, 6:03 a.m.
Hi sam,

Thank you for your response.

Now i can able to retrieve priority attribute value and literal.

But it not fetching the value of Status attribute.

Is there any solution.

Comments
Gustavo Leyva commented Aug 05 '12, 5:20 p.m.

Hi,

Here is my code to obtain the value of Status attribute

returnAttribute.status = ((IWorkItemClient)repo.getClientLibrary(IWorkItemClient.class)).findWorkflowInfo(workItem, null).getStateName(workItem.getState2());

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.