Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How do I create a plan with the Java API?

I tried to write a commandline tool, which creates plans with help of the Java-API. I like to have a csv file which contains a list of plans to create. Each row has Owner, IterationID, Plantype, IncludeAllItems.

There is a Wiki article with an example how to copy plans. So I tried to follow this:
https://jazz.net/wiki/bin/view/Main/InformalProjectCopy  (Section Agile Planning)

Now I'm stuck, because I get an exception on the save methode:

IterationPlanSaveResult saveResult= target.save(plan, monitor);

Error:  !ContentStorage.attributeDoesNotMatch!
(I was not able to find out which attribute doesn't match.)

Has anybody an idea what is wrong? Or has anybody a code-snippet which is working to create plans?

I'm running v.3.0.1.3 and 4.0. If it works only for 4.0 it's ok for me.

(I know there are already some very old enhancement requests for supporting this in the API. But all are pre-2.0 and on state triaged, so I thought have a try.)

1

0 votes

Comments

because this field is to short I post an answer below as addendum:


Accepted answer

Permanent link

With help of IBM, we found the issue. In the wiki page and in my code we didn't created the wiki pages for the plan.

My working code looks now like this:

public static void createPlan (String planName, IIteration planIteration, String planType, IProcessArea planTeam, IContributor creator) {
 // get classes for plan creation
 IAuditableCommon audit = (IAuditableCommon) this.teamRepository.getClientLibrary(IAuditableCommon.class);
 IIterationPlanService planService = (IIterationPlanService)((IClientLibraryContext) teamRepository).getServiceInterface(IIterationPlanService.class);

 // create necessary plan items
 IIterationPlanRecord plan = (IIterationPlanRecord) IIterationPlanRecord.ITEM_TYPE.createItem();
 IWikiPage wiki = (IWikiPage) IWikiPage.ITEM_TYPE.createItem();

 // setup plan values
 plan.setName(planName);
 plan.setIteration(planIteration);
 plan.setPlanType(planType);
 plan.setOwner(planTeam);
      
 // setup wiki page
 wiki.setName("");
 wiki.setWikiID(IIterationPlanRecord.OVERVIEW_PAGE_ID);
 wiki.setCreator(creator);
 wiki.setOwner(plan);
      
 String encoding = "UTF8";
 String xmlText = "";
 byte[] bytes = xmlText.getBytes(encoding);
 InputStream inputStream = new ByteArrayInputStream(bytes);
      
 wiki.setContent(audit.storeContent(IContent.CONTENT_TYPE_TEXT, encoding, inputStream, bytes.length, null));
      
 // save plan
 DTO_IterationPlanSaveResult saveResult = planService.save(project, plan, wiki);

 if (saveResult.isSetIterationPlanRecord() == false) {
  System.out.println("Saving failed!");
 }
}    
  

Note: this is not a public API. If you like to have a supported API for this, please vote here and write comments on: https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=65697

Ralph Schoon selected this answer as the correct answer

1 vote

Comments

Thanks for sharing.

Is this interal API not part of the Plain Java Client Libraries (4.0.3, 4.0.4)? Somehow I can't find the needed classes (e.g. IIterationPlanRecord, IIterationPlanService).

Could you point me in the right direction?

Thanks

This is internal API as mentioned by Bruno. However, dependent on your setup, try to import com.ibm.team.apt.* with * client or common.

I was able to find the classes in an environment where I have setup the SDK as well as the plain Java Client Libraries. I tried this with 4.0.1and 4.0.5 so I would assume the ones in between have the internal API as well.

I checked the Plain Java Client Libraries. They don't contain the com.ibm.team.apt packages. These are only contained in the SDK. So I would assume it would be necessary to run this kinds of code in a client based on the SDK, e.g. from an Eclipse RTC client.


3 other answers

Permanent link
I think the wiki is outdated.

BTW, I helped Guido in that WI:

https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=65697

That solution is using an internal API (it's not officially supported because it could change and broke your code).

So if you would like an open API to work with Plans, subscribe and comment at WorkItem 65697.

Thanks

1 vote


Permanent link
The plan is created, but if I try to open it I get an error on the WebUI:

Error - [object Object]
TypeError: _89 is undefined
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?exclude=A&include=com.ibm.team.apt.web.ui.internal.page.PlanningPageMain.js~com.ibm.team.apt.web.ui.internal.page.PlanningSearchProvider.js~com.ibm.team.dashboard.web.ui.internal.SearchProvider.js~com.ibm.team.scm.web.ui.internal.view.search.ScmSearchProvider.js~com.ibm.team.workitem.web.ui.internal.page.SearchProvider.js&_proxyURL=%2Fccm&locale=en-us:51322
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?exclude=A&include=com.ibm.team.apt.web.ui.internal.page.PlanningPageMain.js~com.ibm.team.apt.web.ui.internal.page.PlanningSearchProvider.js~com.ibm.team.dashboard.web.ui.internal.SearchProvider.js~com.ibm.team.scm.web.ui.internal.view.search.ScmSearchProvider.js~com.ibm.team.workitem.web.ui.internal.page.SearchProvider.js&_proxyURL=%2Fccm&locale=en-us:50970
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?exclude=A&include=com.ibm.team.apt.web.ui.internal.page.PlanningPageMain.js~com.ibm.team.apt.web.ui.internal.page.PlanningSearchProvider.js~com.ibm.team.dashboard.web.ui.internal.SearchProvider.js~com.ibm.team.scm.web.ui.internal.view.search.ScmSearchProvider.js~com.ibm.team.workitem.web.ui.internal.page.SearchProvider.js&_proxyURL=%2Fccm&locale=en-us:53759
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?exclude=A&include=com.ibm.team.apt.web.ui.internal.page.PlanningPageMain.js~com.ibm.team.apt.web.ui.internal.page.PlanningSearchProvider.js~com.ibm.team.dashboard.web.ui.internal.SearchProvider.js~com.ibm.team.scm.web.ui.internal.view.search.ScmSearchProvider.js~com.ibm.team.workitem.web.ui.internal.page.SearchProvider.js&_proxyURL=%2Fccm&locale=en-us:53769
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?exclude=A&include=com.ibm.team.apt.web.ui.internal.page.PlanningPageMain.js~com.ibm.team.apt.web.ui.internal.page.PlanningSearchProvider.js~com.ibm.team.dashboard.web.ui.internal.SearchProvider.js~com.ibm.team.scm.web.ui.internal.view.search.ScmSearchProvider.js~com.ibm.team.workitem.web.ui.internal.page.SearchProvider.js&_proxyURL=%2Fccm&locale=en-us:505
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?exclude=A&include=com.ibm.team.apt.web.ui.internal.page.PlanningPageMain.js~com.ibm.team.apt.web.ui.internal.page.PlanningSearchProvider.js~com.ibm.team.dashboard.web.ui.internal.SearchProvider.js~com.ibm.team.scm.web.ui.internal.view.search.ScmSearchProvider.js~com.ibm.team.workitem.web.ui.internal.page.SearchProvider.js&_proxyURL=%2Fccm&locale=en-us:29153
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?exclude=A&include=com.ibm.team.apt.web.ui.internal.page.PlanningPageMain.js~com.ibm.team.apt.web.ui.internal.page.PlanningSearchProvider.js~com.ibm.team.dashboard.web.ui.internal.SearchProvider.js~com.ibm.team.scm.web.ui.internal.view.search.ScmSearchProvider.js~com.ibm.team.workitem.web.ui.internal.page.SearchProvider.js&_proxyURL=%2Fccm&locale=en-us:53772
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?exclude=A&include=com.ibm.team.apt.web.ui.internal.page.PlanningPageMain.js~com.ibm.team.apt.web.ui.internal.page.PlanningSearchProvider.js~com.ibm.team.dashboard.web.ui.internal.SearchProvider.js~com.ibm.team.scm.web.ui.internal.view.search.ScmSearchProvider.js~com.ibm.team.workitem.web.ui.internal.page.SearchProvider.js&_proxyURL=%2Fccm&locale=en-us:53607
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:16725
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?exclude=A&include=com.ibm.team.apt.web.ui.internal.page.PlanningPageMain.js~com.ibm.team.apt.web.ui.internal.page.PlanningSearchProvider.js~com.ibm.team.dashboard.web.ui.internal.SearchProvider.js~com.ibm.team.scm.web.ui.internal.view.search.ScmSearchProvider.js~com.ibm.team.workitem.web.ui.internal.page.SearchProvider.js&_proxyURL=%2Fccm&locale=en-us:27216
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:16725
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:16451
_2@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:10944
_c@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:16450
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:16437
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:6283
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17
@https://bt-clmtestserver01.hqs.sbt.siemens.com/ccm/web/_js/?include=A~&etag=CdLJsqFIb_en_US:17

0 votes


Permanent link
 I am trying to create PLAN using java code . Can someone helps me out with any working code for the same and also supported API for the same.Please help me on this...

0 votes

Comments

There is a lot of code in the answers, did you try that?

In addition this is 2 years old and accepted/completed. I would suggest you create a new question. You can comment here and provide a link to the question if you want.

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 411

Question asked: Jul 20 '12, 6:42 a.m.

Question was seen: 7,196 times

Last updated: Dec 11 '14, 6:45 a.m.

Confirmation Cancel Confirm