How to get value for State and Priority attributes.
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.
I am using plain java client for fetching all work items.
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();
}
Accepted answer
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).
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());
}
}
}