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

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.

0 votes


Accepted answer

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

0 votes


One other answer

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

0 votes

Comments

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 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,930

Question asked: May 04 '12, 1:02 a.m.

Question was seen: 5,888 times

Last updated: Aug 05 '12, 5:20 p.m.

Confirmation Cancel Confirm