copy plans in project to a different project, help
(maybe called Plan Modes).
anyone played with accessing these thru a plainjava application? I don't want to 'present' them, just copy their data to
another plan.
I 'think' based on looking at the plan editor code, I need access to the IterationPlanData object, which can be retrieved thru the IIterationPlan. but attemping this on a Release Backlog plan
IterationPlanData prodpd= ((IterationPlanClient)prodplanClient).fetchIterationPlanData((IIterationPlanRecordHandle) prodipr.getItemHandle(), new mylog());
gets me a fatal exception error
Reference problem: Unable to find IPlanCheckDescription with id com.ibm.team.apt.plancheck.requiredAttribute.
3 answers
did you resolve your Exception Error? I can't tell you about the Plain Java API but with the RTC SDK the following can be used (may also work with the Plain API).
// The iteration plan record of the target plan you created IIterationPlanRecord iterationPlanRecord = ...;
List<ISharedPlanMode> sharedPlanModes = new ArrayList<ISharedPlanMode>();
// IterationPlanData of the target plan record
IterationPlanData data = fPlanClient.fetchIterationPlanData((IIterationPlanRecordHandle)iterationPlanRecord.getItemHandle(), monitor);
// Get the XML structure of the sharedPlanMode object from source plan you want to copy
XMLMemento mementoOutput= XMLMemento.createWriteRoot(IStore.ROOT);
ConfigurationElementFactory.serializeIntoConfigData(sourceSharedPlanMode.getDescription(), mementoOutput);
// Create the target sharedPlanMode from the XML memento
ISharedPlanMode targetSharedPlanMode = createSharedPlanMode(data, mementoOutput);
// add it to the list of plan modes
sharedPlanModes.add(targetSharedPlanMode );
// Create the plan modes in the target plan
fPlanClient.saveSharedPlanModeDescription(sharedPlanModes, monitor).get(0);
and the createSharedPlanMode method could looks like this:
private ISharedPlanMode createSharedPlanMode(IterationPlanData data, XMLMemento memento) { ResolvedPlanMode planMode = data.getPlanModes().get(data.getPlanModes().size()-1);
ISharedPlanMode sharedPlanModeCopy= (ISharedPlanMode) planMode.getSharedPlanMode().getWorkingCopy();
ISharedPlanMode sharedPlanMode = (ISharedPlanMode) ISharedPlanMode.ITEM_TYPE.createItem(planMode.getSharedPlanMode());
try {
sharedPlanMode.setDescription(((XMLMemento)memento).asXMLString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
sharedPlanMode.setOwner(data.getOwner());
sharedPlanMode.setPlan(sharedPlanModeCopy.getPlan());
return sharedPlanMode;
}
Comments
I have not solved my problem, but thank you SO much.. I will report back as soon as I can..
I have started integrating you code into my app.. I have some questions/comments
Hi Sam,
1. My code from above is modified a little bit for simplicity. What I am really doing is exporting/importing plans and their planmodes to/from XML files that can be imported to remote systems, that's why you don't see the connection in code.
2. As in 1. I left the loop out for simplicity :). It loops around the referenced planmodes from the XML structure I'm reading in and creates multiple targetSharedPlanModes.
3. That's a tricky one. As far as I can tell, the data.getPlanModes list is not merely a collection of the different planmodes but also of their different versions in time of which all entries except the last one are marked as "dirty" because they are not the latest. When I am not fetching the last entry it throws an exception warning me of stale data.
I am getting this last entry in order to instantiate a new ISharedPlanMode from it. Maybe there is a better way, but this is how I got it working quickly.
yes, indeed 3 depends on info I wouldn't have guessed
Did you try this out only with newly created plans, or with existing ones (for which you already tampered with the views).
I think for new plans it just shows the first iteration and for views that already have a modified version of planmodes it shows more than one.
the source project has a number of custom views, which may have multiple iterations, no way of knowing
It would be interesting to see how the IIterationPlanRecord you are trying to save using the planService looks like. Is it fetched from some origin or newly created? Judging from your original answer there seems to be some plancheck reference that cannot be found. Does this plan come with customized plan views?
my code posted below. this is an arbitrary plan or arbitrary age, in an arbitrary RTC system (first was 3.01, second is 4.0.1, others to come) end system is 4.0.4
Comments
Your createPlan method code is almost identical to mine. What I don't have and what throws an exception for me as well when I try to fetch the IterationPlanData is the plan.setAuxiliaryData part. What does it do?
I get null pointer exception loading the plan data after commenting that out
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Mar 05 '14, 5:59 a.m.Unfortunately I never tried that. You are in an area that is mostly internal API today.