In Plain Java API, how to List and create WorkItem Links and to get Owner, Project Area and Status of a WorkItem
Hello I am doing some basic tries with Plain API, and I have some questions, that might seems fool questions since I am a beginner, anyway, here they go:
1) How should I do to (given a workItem) list all its links (any type of link specifying the type of link it is).
2) Similar to the prior question, How should I do to create a link to a given WorkItem, the link I want to create is the type "Related Artifacts"
3) And the last question is how do I get the name of the Owner, the Project Area, and the current state of a WorkItem. For this I had tried workItem.getOwner(), but it returns "com.ibm.team.repository.common.model.impl.ContributorHandleImpl@fef26a (stateId: <unset>, itemId: [UUID _9UUxMCLiEd-NDrRiecOlSQ], origin: com.ibm....."
4) Then which are all possible states a WorkItem can have, so then depending of its state, I will do some specific actions, in other words, how should I do a case/if statement with the WorkItem state?
Thank you very much for the help.
PS: Just to mention that part of my code that I have, is ony until I check if a WorkItem Number exists or not:
....
def workItemClient = (IWorkItemClient)repo.getClientLibrary(IWorkItemClient.class)
int workItemNumber = -1
try {
workItemNumber = Integer.parseInt(wi);
println("WorkItem Number after Integer parser:" + wi)
} catch (NumberFormatException e) {
println("Invalid work item nubmer:" + wi)
System.exit(1)
}
try {
workItem = workItemClient.findWorkItemById(workItemNumber, IWorkItem.FULL_PROFILE, new SysoutProgressMonitor())
println("["+workItem.getId()+"] "+workItem.getHTMLSummary().getPlainText())
println("Owner is: " + workItem.getOwner())
} catch (NullPointerException e) {
println("The specified WorkItem Number doesn't exist:" + wi)
System.exit(1)
}
....
One answer
My colleague has written several blog posts about the Plain Java Client API. Check out this post and others which may contain the answers to your questions.
http://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/
http://rsjazz.wordpress.com/2012/12/09/analyzing-a-aroject-areas-members-and-roles-using-the-plain-java-client-libraries/
If this helps, please mark the answer as accepted.