Rename Baseline in Plain Java API
I want to rename a baseline (something that you can do via the client), but the IBaseline object does not seem to have a method that allows the name to be changed.
Is this correct? Is there another way of doing it?
IWorkspaceManager workspaceManager = (IWorkspaceManager)repo.getClientLibrary(IWorkspaceManager.class);
IComponentSearchCriteria compCrit = IComponentSearchCriteria.FACTORY.newInstance();
compCrit.setExactName("LATF");
List<IComponentHandle> components = workspaceManager.findComponents(compCrit,100,new SysoutProgressMonitor());
IComponentHandle componentHandle = null;
for (Iterator<IComponentHandle> ci = components.iterator(); ci.hasNext();) {
componentHandle = (IComponentHandle)ci.next();
IComponent component_comp = (IComponent)repo.itemManager().fetchCompleteItem(componentHandle, IItemManager.DEFAULT, new SysoutProgressMonitor());
System.out.println(component_comp.getName());
}
IBaselineSearchCriteria crit1 = IBaselineSearchCriteria.FACTORY.newInstance();
crit1.setExactName(oldBaseline);
crit1.setComponentRequired(componentHandle);
List<IBaselineHandle> baselines = workspaceManager.findBaselines(crit1,100,new SysoutProgressMonitor());
for (Iterator<IBaselineHandle> bi = baselines.iterator(); bi.hasNext();) {
IBaselineHandle baselineHandle = (IBaselineHandle)bi.next();
IBaseline baseline_comp = (IBaseline)repo.itemManager().fetchCompleteItem(baselineHandle, IItemManager.DEFAULT, new SysoutProgressMonitor());
if (baseline_comp.getName().equals(oldBaseline)) {
System.out.println("found");
}
}
Comments
sam detweiler
May 12 '14, 9:21 a.m.usually the I* interfaces has concrete classes behind them which hav the set....() methods.. usually the concrete classes are usually in 'internal' jar files.
so IBaseLine = Baseline.
Stephen Long
May 12 '14, 11:19 a.m.Sam,
Thanks. Seems I need to get a working copy of the object. I can now call setName ok, but cannot see how to save the object back to the repository...
Baseline theBaseline = (Baseline)baseline_comp.getWorkingCopy();
theBaseline.setName(newBaseline);