It's all about the answers!

Ask a question

Java API extending - create a new work item and associate with a change set


Peter Moraza (331824) | asked Aug 21 '13, 4:44 p.m.
Hi,

I have code based on Snippet2.java which delivers files to a stream and creates a new change set. I want to create a new work item and associate that work item with the new change set. Snippet5.java provides an example of creating a new work item, but I need to understand how to link the work item with the change set. A brief example would help greatly

There are many related questions in the Forum, I apologize in advance if I've overlooked an earlier answer or example. Thanks!

Peter Moraza

Accepted answer


permanent link
Ralph Schoon (55.5k23642) | answered Aug 22 '13, 4:53 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You can find some examples on https://rsjazz.wordpress.com/ for example
  • https://rsjazz.wordpress.com/2012/09/20/the-rtc-workitem-server-link-api-linking-to-work-items-and-other-elements/
  • https://rsjazz.wordpress.com/2012/09/19/the-rtc-workitem-link-api-linking-workitems-to-other-elements/

You might also want to look at https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ , https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ , https://rsjazz.wordpress.com/2013/03/14/what-apis-are-available-for-rtc-and-what-can-you-extend/ and some other posts that talk about creating and modifying work items.

Peter Moraza selected this answer as the correct answer

Comments
Peter Moraza commented Aug 27 '13, 6:38 p.m.

Thanks Ralph for the excellent examples. I am able to create a Change Set and Work Item, and I have the following code (based on your examples) which tries to link Work Item to  Change Set. But when I open the Work Item in the Jazz GUI, the Links tab does not contain any reference to the Change Set (or anything else).


WorkItemWorkingCopy workingCopy = createWorkItem(repo, prjareahndl, monitor);
IItemType iit = cs1.getItemType();
IItemHandle iih = iit.createItemHandle(cs1.getItemId(), cs1.getStateId());
IItemReference reference = IReferenceFactory.INSTANCE.createReferenceToItem(iih);
IEndPointDescriptor endpoint = LinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.CHANGE_SET).getTargetEndPointDescriptor();
workingCopy.getReferences().add(endpoint, reference);

If I pass IItemHandle to createWorkItem method I get "InternalRepositoryException: Links of this type may only be modified by the defining component." when trying to save the IWorkItem.


1
Peter Moraza commented Aug 27 '13, 8:40 p.m.

I had not saved the WorkItemWorkingCopy after linking the Change Set and Work Item. After doing that and also changing WorkItemLinkType to  RELATED_CHANGE_MANAGEMENT the Link tab now contains a nice link to the Change Set. Thanks Ralph Schoon for pointing me in the right direction, and also for the instructions on configuring RTC for API development. Your articles are great!


Your answer


Register or to post your answer.