Get the Attributes Value for a given WorkItem in Java Plain API
Hello, I have a simple question for you surely, but since I'm brand new I don't know how to do it.
How to get the value of any attribute of a WorkItem with Plain Java API?
I already have the workitem in my code with:
workItem = workItemClient.findWorkItemById(workItemNumber, IWorkItem.FULL_PROFILE, new SysoutProgressMonitor())
but now I want to show some of its attributes with its values and I don't know how to continue.
Thanks for the help.
Accepted answer
https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes
3 other answers
the routine that does the attribute work is
<code>
static void printAttributes(IWorkItem workItem,
IAuditableClient auditableClient, IProjectArea projectArea,
org.eclipse.core.runtime.IProgressMonitor monitor, ITeamRepository repository, String XML)
{
}
</code>
it loops thru all the attributes and handles each one on the fly.
but you will need to have the project area and the AuditableClient library handle.
I figured out myself, thanks.
Following some examples (they are in Groovy since I am working on that lengauge, similar to Java):
// Getting the workItem
workItem = workItemClient.findWorkItemById(workItemNumber, IWorkItem.FULL_PROFILE, new SysoutProgressMonitor())
println("WorkItem found: ["+workItem.getId()+"] "+workItem.getHTMLSummary().getPlainText())
//Getting the WorkItem Owner
owner = workItem.getOwner()
def iContributor = (IContributor) repo.itemManager().fetchCompleteItem(owner, IItemManager.DEFAULT, null);
def owner = iContributor.getName();
println("Owner is: " + owner)
//Getting the WorkItem Project Area
def projectArea = workItem.getProjectArea()
def iProjectArea = (IProjectArea) repo.itemManager().fetchCompleteItem(projectArea, IItemManager.DEFAULT, null);
projectArea = iProjectArea.getName();
println("Project Area is: " + projectArea)
//Geting the WorkItem State
IWorkflowInfo info= workItemClient.findWorkflowInfo(workItem, new SysoutProgressMonitor());
def status = info.getStateName(workItem.getState2());
println("Status: " + status)