It's all about the answers!

Ask a question

In Plain Java API, how to List and create WorkItem Links and to get Owner, Project Area and Status of a WorkItem


Tiago Fernandez (5331619) | asked Aug 12 '13, 2:42 p.m.
edited Aug 12 '13, 3:20 p.m.

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



permanent link
Rosa Naranjo (2.8k11420) | answered Aug 12 '13, 4:12 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited Aug 12 '13, 4:12 p.m.
Hello
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.

Comments
Michael Plautz commented Feb 18 '15, 3:22 p.m. | edited Feb 18 '15, 3:23 p.m.

 For printing the work item owner details, this can specifically be done from the second post link, in the Printing the Administrators and Team Members of a Process Area section. If you have a your IWorkItem object and your ITeamRepository object, these lines of codes do it:


IContributor contributor = (IContributor) teamRepository.itemManager()
        .fetchCompleteItem(item.getOwner(), IItemManager.DEFAULT, null);
System.out.print(": " + contributor.getUserId() + "\t"
        + contributor.getName() + "\t" + contributor.getEmailAddress() + "\t");

</pre>

Your answer


Register or to post your answer.