It's all about the answers!

Ask a question

Rename Baseline in Plain Java API


Stephen Long (14311013) | asked May 12 '14, 9:09 a.m.

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 commented 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 commented 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);

Accepted answer


permanent link
Tim Mok (6.6k38) | answered May 12 '14, 1:21 p.m.
JAZZ DEVELOPER
You should go through IWorkspaceManager#getBaselineConnection(IBaselineHandle, IProgressMonitor) to get the baseline connection.

Then call IBaselineConnection#setName(String) to set the new name.
Stephen Long selected this answer as the correct answer

Comments
Stephen Long commented May 13 '14, 3:37 a.m. | edited May 13 '14, 3:38 a.m.

Thanks Tim. I figured this out last night by analysing the JavaDocs. 

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.