Java Code for creating PLAN in RTC?
2 answers
here is a routine in one of my programs. note that you must use the *.apt.* jar files from the sdk plugins
this is derived from Guido's code in https://jazz.net/forum/questions/82381/how-do-i-create-a-plan-with-the-java-api
private static void createPlan(IAuditableClient destauditableClient,
IProjectArea project, String planName,
IIterationHandle planIteration, String planType,
IItemHandle planTeam, String planinfo, IContributor creator)
{
// get classes for plan creation
IAuditableCommon audit = (IAuditableCommon) destauditableClient.getTeamRepository().getClientLibrary(IAuditableCommon.class);
IIterationPlanService planService = (IIterationPlanService) ((IClientLibraryContext) destauditableClient.getTeamRepository()).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((IProcessAreaHandle) planTeam);
// setup wiki page
wiki.setName("entry " + planName);
wiki.setWikiID(IIterationPlanRecord.OVERVIEW_PAGE_ID);
wiki.setCreator(creator);
wiki.setOwner(plan);
String encoding = "UTF8";
String xmlText = "<p>test</p>";
byte[] bytes;
try
{
InputStream inputStream = null;
if (planinfo != null)
{
bytes = planinfo.getBytes(encoding);
inputStream = new ByteArrayInputStream(bytes);
plan.setAuxiliaryData(audit.storeContent(IContent.CONTENT_TYPE_TEXT, encoding, inputStream, bytes.length, null));
}
bytes = xmlText.getBytes(encoding);
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!");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
this is derived from Guido's code in https://jazz.net/forum/questions/82381/how-do-i-create-a-plan-with-the-java-api
private static void createPlan(IAuditableClient destauditableClient,
IProjectArea project, String planName,
IIterationHandle planIteration, String planType,
IItemHandle planTeam, String planinfo, IContributor creator)
{
// get classes for plan creation
IAuditableCommon audit = (IAuditableCommon) destauditableClient.getTeamRepository().getClientLibrary(IAuditableCommon.class);
IIterationPlanService planService = (IIterationPlanService) ((IClientLibraryContext) destauditableClient.getTeamRepository()).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((IProcessAreaHandle) planTeam);
// setup wiki page
wiki.setName("entry " + planName);
wiki.setWikiID(IIterationPlanRecord.OVERVIEW_PAGE_ID);
wiki.setCreator(creator);
wiki.setOwner(plan);
String encoding = "UTF8";
String xmlText = "<p>test</p>";
byte[] bytes;
try
{
InputStream inputStream = null;
if (planinfo != null)
{
bytes = planinfo.getBytes(encoding);
inputStream = new ByteArrayInputStream(bytes);
plan.setAuxiliaryData(audit.storeContent(IContent.CONTENT_TYPE_TEXT, encoding, inputStream, bytes.length, null));
}
bytes = xmlText.getBytes(encoding);
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!");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
The code is not working for me . Idont have the supported APIs for IWikiPage , IIterationPlanRecord ,IIterationPlanService .
Can someone else provide me some other working code?