It's all about the answers!

Ask a question

Programmatic Creation of Work Items guide for RTC 4.0.x


Lukas Steiger (3131628) | asked Oct 17 '13, 9:20 a.m.
 Hi community,

I just started using the RTC Java client API. I successfully searched for a work item and did some modification. But I stuck created a new work item.
I have used the following guide to try to create a new work item, but I think some code in there is outdated.

Is there a newer version of this guide or something similar?

Thanks in advance for your help :-)

Accepted answer


permanent link
Ralph Schoon (63.4k33646) | answered Oct 17 '13, 1:35 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please have a look at http://rsjazz.wordpress.com/ there should be several examples there. Follow http://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ . However  https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation has always worked for me.
Lukas Steiger selected this answer as the correct answer

Comments
Lukas Steiger commented Oct 18 '13, 2:25 a.m.

 Hi  Ralph


Thanks for your answer :-) 
I already came across you blog and have used your guide for setup and to find out how to search work items and modify them through the API. 

The code line from the ProgrammaticWorkItemCreation article which I have troubles with is the following:
WorkItemInitialization operation = new WorkItemInitialization(summary, category);
I get the following error: WorkItemInitialization cannot be resolved to a type

Unfortunately, I couldn't find out if the type WorkItemInitialization is still available in the 4.0.4 API. Do you know something about that?


Ralph Schoon commented Oct 18 '13, 2:45 a.m. | edited Oct 18 '13, 2:47 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

If you search, with the browser on ProgrammaticWorkItemCreation for WorkitemInitialization, you will find that this is an inner class you have to create so that it does what you want.

    private static class WorkItemInitialization extends WorkItemOperation {

    private String fSummary;

    public WorkItemInitialization(String summary) {
        super("Initializing Work Item", IWorkItem.FULL_PROFILE);
        fSummary= summary;
    }

    @Override
    protected void execute(WorkItemWorkingCopy workingCopy, IProgressMonitor monitor) throws TeamRepositoryException {
        IWorkItem workItem= workingCopy.getWorkItem();
        workItem.setHTMLSummary(XMLString.createFromPlainText(fSummary));
    }

    @Override
    protected void commit(WorkItemWorkingCopy[] workingCopies, IProgressMonitor monitor) throws TeamRepositoryException {
    }
}


You would code the class that needs to extend WorkItemOperation in a way you want it to behave. Update or create a work item.

If you grab an example from my blog or the Wiki, make sure to fully understand the example and make it work before you try our own enhancements.


Lukas Steiger commented Oct 18 '13, 2:47 a.m. | edited Oct 18 '13, 2:48 a.m.
EDIT: You were faster, thank you :-)

Nevermind, I just found out that this was a handmade class, Should have searched for that earlier.


Thanks for your help

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.