Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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");
    }
   }   

0 votes

Comments

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.

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

0 votes

Comments

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

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941
× 169

Question asked: May 12 '14, 9:09 a.m.

Question was seen: 4,139 times

Last updated: May 13 '14, 3:38 a.m.

Confirmation Cancel Confirm