RTC Plain Java API: Having IWorkspace and IComponent, need IBaseline of IComponent as it is in IWorkspace
Hello all,
I use the RTC Plain Java API 4.0.4. I have an IWorkspace and an IComponent (which is a direct child of the IWorkspace). How to get the IBaseline of the IComponent as it is contained in the IWorkspace?
I don't want all IBaselines of the IComponent as I then do not know which of the IBaselines is the one in IWorkspace.
Any hint is highly appreaciated.
Kind regards and thanks
Martin Muellenberg
I use the RTC Plain Java API 4.0.4. I have an IWorkspace and an IComponent (which is a direct child of the IWorkspace). How to get the IBaseline of the IComponent as it is contained in the IWorkspace?
I don't want all IBaselines of the IComponent as I then do not know which of the IBaselines is the one in IWorkspace.
Any hint is highly appreaciated.
Kind regards and thanks
Martin Muellenberg
Accepted answer
Hi Martin, try importing:
com.ibm.team.scm.client.SCMPlatform
com.ibm.team.scm.client.IWorkspaceConnection
and using:
ITeamRepository repo = ...
IWorkspace workspace = ... // or just IWorkspaceHandle
IComponent component = ... // or just IComponentHandle
IProgressMonitor pm = null; // should really use a proper one
IWorkspaceConnection conn = SCMPlatform.getWorkspaceManager(repo).getWorkspaceConnection(workspace, pm);
int max = 10;
IHistoricBaselineIterator iter = conn.getBaselinesInHistory(component, max, pm)
where IHistoricBaselineIterator is kind of a page iterator, with methods getBaselines() (their handles), hasPrevious(), and getPrevious(...).
One other answer
Just to point out that com.ibm.team.scm.client.IFlowNodeConnection.getBaselinesInHistory(IComponentHandle, int, IProgressMonitor) returns baselines that "... are considered to be part of this workspace's history if this workspace's change history is built explicitly on top of previous baselines. In the very least, this result should include the component's initial baseline...".
So if you're searching instead a list of the specific stream or workspace component baselines (like what you get from ui when you right click on the component of a workspace and then you select show > baselines) you've to follow a different path, for example this link just changing for example from
wsConn.getComponentAuditTrail(compHandle, numBasisInHistory - 1, 1, new NullProgressMonitor());
to
long numBasisInHistory = currentComponentInfo.numBasisInHistory();
wsConn.getComponentAuditTrail(compHandle, 0,
numBasisInHistory , new NullProgressMonitor());