It's all about the answers!

Ask a question

How do I create a plan with the Java API?


0
1
Guido Schneider (3.4k1491115) | asked Jul 20 '12, 6:42 a.m.

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.)


Comments
Guido Schneider commented Jul 20 '12, 10:12 a.m.

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

Accepted answer


permanent link
Guido Schneider (3.4k1491115) | answered Jul 23 '12, 11:03 a.m.

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

Comments
Ralph Schoon commented Jul 23 '12, 11:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Thanks for sharing.


Dimitrios Dentsas commented Sep 23 '13, 3:29 a.m.

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


Ralph Schoon commented Sep 23 '13, 4:33 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Ralph Schoon commented Sep 23 '13, 4:44 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Ralph Schoon commented Sep 23 '13, 7:46 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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
Bruno Braga (48013621) | answered Jul 23 '12, 2:29 p.m.
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

permanent link
Guido Schneider (3.4k1491115) | answered Jul 20 '12, 10:14 a.m.
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

permanent link
Neha Malviya (623) | answered Dec 11 '14, 6:40 a.m.
 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...

Comments
Ralph Schoon commented Dec 11 '14, 6:45 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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 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.