It's all about the answers!

Ask a question

RTC Plain JAVA API To open an existing defect and update a field


kishan adhi (44279) | asked May 01 '13, 3:02 p.m.
Hi
 I am trying to update an existing defect.
What I want to do is search for a defect open it and update a field like summary.
To search a defect I have the following code what I cant do is update the defect.


public static IWorkItem getWorkItem()
    throws TeamRepositoryException, FileNotFoundException,
    ParseException {

        // Set the connection
        String repositoryURI = getHost(env);
       
        // Start the platform.
        TeamPlatform.startup();
       
        ITeamRepository teamRepository = TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
        teamRepository.registerLoginHandler(new LoginHandler(userName, userPass));
        teamRepository.login(null);
        IWorkItemClient workItemClient = (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);
       
            IProgressMonitor progressMonitor = new NullProgressMonitor();
            ItemProfile<IWorkItem> arg1 = IWorkItem.FULL_PROFILE;
            IWorkItem foundId  = workItemClient.findWorkItemById(119049, arg1, progressMonitor);
       
              System.out.println("found me"+foundId.getId());
              System.out.println("found me"+foundId.getHTMLSummary().getPlainText());
              System.out.println("found me"+foundId.getHTMLDescription().getPlainText());

        teamRepository.logout();
        TeamPlatform.shutdown();
        return foundId;
}




Any suggestion are welcome
Thanks
MrCoolK


Accepted answer


permanent link
sam detweiler (12.5k6189201) | answered May 01 '13, 3:43 p.m.
edited May 01 '13, 5:30 p.m.
RTC has two views of a workitem.. the readonly copy (given out be default) and the read/write version, called the workingcopy.

so, once you find the handle, you get the workitem (read only), IWorkItem foundId above
then get the read/write version (getworkingcopy) IWorkItem foundid_rw = foundid.getworkingcopy();

you update the fields in the workingcopy, then Save the working copy.


kishan adhi selected this answer as the correct answer

Comments
kishan adhi commented May 02 '13, 3:54 p.m.

Thank you very much for the answer.It worked

Your answer


Register or to post your answer.