It's all about the answers!

Ask a question

Creating Iterations using java api


Sudipto Sarkar (63334) | asked May 15 '15, 1:35 a.m.
edited May 15 '15, 3:25 a.m. by Krzysztof Kaźmierczyk (7.4k34897)
Hi,

 I want to create Iterations using java client library. I saw a post in jazz forum where is it explained.
https://jazz.net/forum/questions/65253/create-or-delete-iteration-and-timelines-programatically

But my question is do I need to set up a plugin development project for this? Can't I do the same as java project where I will import required jars and create iterations? If yes, Please show me an example.

Thanks!
Sud

Accepted answer


permanent link
Tiago Moura (8387) | answered May 15 '15, 12:13 p.m.
Yes, you can only setup a "standalone" enviroment to create iterations on the RTC. You need to download the RTC SDK and use the jars, like you said.

This post explain how to setup you enviroment using Maven:
https://www.ibm.com/developerworks/community/blogs/cbe857dd-5392-4111-b0ea-6827c54f2e66/entry/setting_up_rtc_java_plain_api_dev_enviroment_with_maven_and_eclipse?lang=en

Sudipto Sarkar selected this answer as the correct answer

Comments
Sudipto Sarkar commented May 16 '15, 5:33 a.m.

 It worked. Thanks.

One other answer



permanent link
Sudipto Sarkar (63334) | answered May 19 '15, 12:52 a.m.
If somebody is looking for an live example , here is :
public void createIteration(ITeamRepository repo,
 IProgressMonitor monitor,
            String iterationName, String id, String startDate, String endDate)
            throws TeamRepositoryException {
        IAuditableClient fAuditableClient;
        fAuditableClient = (IAuditableClient) repo
                .getClientLibrary(IAuditableClient.class);

        CreateWI wi = new CreateWI();
        Date start = almDateFormat(startDate);
        Date end = almDateFormat(endDate);
        IProcessItemService service = (IProcessItemService) repo
                .getClientLibrary(IProcessItemService.class);
        List<IProjectArea> activeProjectAreas = new ArrayList();
        List<IProjectArea> allProjectAreas;
        IProjectArea iProjectArea = null;
        allProjectAreas = service.findAllProjectAreas(service.ALL_PROPERTIES,
                monitor);
        Iterator<IProjectArea> iterator = allProjectAreas.iterator();
        while (iterator.hasNext()) {
            iProjectArea = iterator.next();
            if (CommonString.PROJECT_AREA_NAME.equals(iProjectArea.getName())) {
                break;
            }
        }
        System.out.println(iProjectArea.getName());

        IDevelopmentLineHandle developmentLineHandler = iProjectArea
                .getProjectDevelopmentLine();
        IDevelopmentLine developmentLine = fAuditableClient.resolveAuditable(
                developmentLineHandler, ItemProfile.DEVELOPMENT_LINE_DEFAULT,
                monitor);

        IIterationHandle[] iterationHandle = developmentLine.getIterations();
        for (int i = 0; i < iterationHandle.length; i++) {
            IIterationHandle iterationList = iterationHandle[i];
            List handle = new ArrayList();
            handle.add(iterationList);
            IFetchResult result = repo.itemManager()
                    .fetchCompleteItemsPermissionAware(handle,
                            IItemManager.REFRESH, monitor);
            IIteration iteration = (IIteration) result.getRetrievedItems().get(
                    0);
            if (iteration.getName().equals(iterationName)) {
                System.out.println("Iterations already exist. cannot create. Iteration name: "+iteration.getName());
            }
        }
        IIteration newIteration = (IIteration) IIteration.ITEM_TYPE
                .createItem();
        newIteration.setName(iterationName);
        newIteration.setId(id);
        newIteration.setStartDate(start);
        newIteration.setEndDate(end);

        IDevelopmentLine workingDevLine = (IDevelopmentLine) developmentLine
                .getWorkingCopy();
        workingDevLine.addIteration((IIterationHandle) newIteration
                .getItemHandle());

        newIteration.setDevelopmentLine(workingDevLine);

        service.save(new IProcessItem[] { workingDevLine, newIteration },
                monitor);

    }

}

Your answer


Register or to post your answer.