Create a work item programatically
We want to configure our Java-based Springboot web application to be able to create work items on demand.
Exception in thread "main" com.ibm.team.repository. <wbr> common.transport. <wbr> ServiceMethodInvocationError: java.lang.NoSuchMethodError: com.ibm.team.repository. <wbr> common.internal.util.ItemUtil. <wbr> isProvisionalAndDisabled(Lorg/ <wbr> eclipse/emf/ecore/ <wbr> EModelElement;)Z
at com.ibm.team.repository. <wbr> transport.client. <wbr> RemoteTeamService. <wbr> getAppropriateException( <wbr> RemoteTeamService.java:737)
at com.ibm.team.repository. <wbr> transport.client. <wbr> RemoteTeamService. <wbr> executeMethod( <wbr> RemoteTeamService.java:573)
at com.ibm.team.repository. <wbr> transport.client. <wbr> RemoteTeamService.invoke( <wbr> RemoteTeamService.java:202)
at com.ibm.team.repository. <wbr> transport.client. <wbr> ServiceInvocationHandler. <wbr> invoke( <wbr> ServiceInvocationHandler.java: <wbr> 43)
at com.sun.proxy.$Proxy0. <wbr> describe(Unknown Source)
at sun.reflect. <wbr> NativeMethodAccessorImpl. <wbr> invoke0(Native Method)
at sun.reflect. <wbr> NativeMethodAccessorImpl. <wbr> invoke( <wbr> NativeMethodAccessorImpl.java: <wbr> 62)
at sun.reflect. <wbr> DelegatingMethodAccessorImpl. <wbr> invoke( <wbr> DelegatingMethodAccessorImpl. <wbr> java:43)
at java.lang.reflect.Method. <wbr> invoke(Method.java:498)
at com.ibm.team.repository. <wbr> client.internal. <wbr> ServiceInterfaceProxy. <wbr> invokeServiceCall( <wbr> ServiceInterfaceProxy.java: <wbr> 254)
at com.ibm.team.repository. <wbr> client.internal. <wbr> ServiceInterfaceProxy.invoke( <wbr> ServiceInterfaceProxy.java: <wbr> 110)
at com.sun.proxy.$Proxy0. <wbr> describe(Unknown Source)
at com.ibm.team.repository. <wbr> client.internal. <wbr> TeamRepository$4.run( <wbr> TeamRepository.java:1564)
at com.ibm.team.repository. <wbr> client.internal. <wbr> TeamRepository$4.run( <wbr> TeamRepository.java:1)
at com.ibm.team.repository. <wbr> client.internal. <wbr> TeamRepository$3.run( <wbr> TeamRepository.java:1327)
at com.ibm.team.repository. <wbr> common.transport. <wbr> CancelableCaller.call( <wbr> CancelableCaller.java:79)
at com.ibm.team.repository. <wbr> client.internal. <wbr> TeamRepository. <wbr> callCancelableService( <wbr> TeamRepository.java:1322)
at com.ibm.team.repository. <wbr> client.internal. <wbr> TeamRepository.internalLogin( <wbr> TeamRepository.java:1557)
at com.ibm.team.repository. <wbr> client.internal. <wbr> TeamRepository.login( <wbr> TeamRepository.java:653)
at com.ibm.team.repository. <wbr> client.internal. <wbr> TeamRepository.login( <wbr> TeamRepository.java:627)
at com.ibm.team.workitem.ide.ui. <wbr> example.CreateWorkItem.run( <wbr> CreateWorkItem.java:117)
at com.ibm.team.workitem.ide.ui. <wbr> example.CreateWorkItem.main( <wbr> CreateWorkItem.java:87)
Accepted answer
The simplest - and it does not get simpler from here - is to follow
https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation go to the section
Plain-Java Client
You should be able to cut and paste the code. You should only have to provide the Plain Java Client libraries.The other example you downloaded is an addition to the Eclipse UI.
I would also suggest https://rsjazz.wordpress.com/2015/09/30/learning-to-fly-getting-started-with-the-rtc-java-apis/
for some context. https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ as a minimum.
Comments
Thanks that worked. One issue I ran into is that the work item type had to be in all lower case ("task"), even though when I pulled the list of types using fetchAllWorkITemTypesNames it returned results with capitalization ("Task"). Now I need to figure out how to set attributes like Description, Severity, Impact, etc. before it will let me save.
fetchAllWorkITemTypesNames it returned results with capitalization ("Task")
You want the type ID and not the name.
Now I need to figure out how to set attributes like Description, Severity, Impact, etc. before it will let me save.
I gave you the links above for a reason. I provide example code, explanation and background on https://rsjazz.wordpress.com/
Believe me, I have spent many hours reading that blog. I do appreciate all of the time you've put into helping people. I think the best long-term solution would be for someone to write a wrapper around the plain Java API called the Simple Java API, and all valuese are entered as key value pairs. Imagine how fun it would be to code like this:
IWorkItem workItem = workItemClient.createWorkItem("Task");
workItem.setAttribute("Summary", "Test Summary");
workItem.setAttribute("Severity", "High");
workItem.setAttribute("Owner", "John Doe");
workItem.addLink("Parent", "110256");
workItem.save();
Would be nice. I have pretty much all you'd need in the WorkItem CommandLine for that.
Realistically what you ask for is for scripting, because in an API you don't necessarily get all that stuff as a string. More often than not you also need some mapping.
But I agree you would like to have an API that might sacrifice performance and is a bit easier to understand. Mind you the work item API is just a small part of the APIs.