It's all about the answers!

Ask a question

how to retrieve the name of a baseline set


Neerav Salaria (3132) | asked Apr 14 '10, 1:24 a.m.
how can i get the names of all baseline sets available in repository using a JAVA API ...I have with me baseline set handles which give me the UUID of the baseline sets ..is there any way to get name from the UUID using any JAVA API


i am using these APIs to find the baselines from a stream ..
1)List <IBaselineSetHandle> blset = workspaceConnection.getBaselineSets(null);

2)BaselineSetSearchCriteria bssearch = (BaselineSetSearchCriteria) IBaselineSetSearchCriteria.FACTORY.newInstance();
bssearch.setOwnerWorkspaceOptional(handle);
List <IBaselineSet> blsets2 = SCMPlatform.getWorkspaceManager(teamRepository).findBaselineSets(bssearch, Integer.MAX_VALUE, null);

from the above code , i get the list having the baselinesets

i used this method to lift an element of the list :-
while(IBaselineSetHandle bsh : blset2){}


now from bsh i get the UUID of each set ...but not hte name of the baselineset .. is there any way to find the name of the baselinesets

5 answers



permanent link
K M (38325051) | answered Apr 21 '10, 3:35 p.m.
String list = "";

// Create search Criteria and get Baselines
IBaselineSearchCriteria crit1 = IBaselineSearchCriteria.FACTORY.newInstance();
crit1.setComponentRequired(component);
List baselines = wm.findBaselines(crit1,Integer.MAX_VALUE,MONITOR);

for (Iterator b = baselines.iterator(); b.hasNext();) {
IBaselineHandle baseline = (IBaselineHandle) b.next();
IBaseline baseline_comp = (IBaseline)repo.itemManager().fetchCompleteItem(baseline, IItemManager.DEFAULT, MONITOR);

if (baseline_comp.getName().equals("")) {
list += "No Baseline name\n";
} else {
list += baseline_comp.getName() + "\n";
}
}

permanent link
Neerav Salaria (3132) | answered Apr 26 '10, 1:35 a.m.
String list = "";

// Create search Criteria and get Baselines
IBaselineSearchCriteria crit1 = IBaselineSearchCriteria.FACTORY.newInstance();
crit1.setComponentRequired(component);
List baselines = wm.findBaselines(crit1,Integer.MAX_VALUE,MONITOR);

for (Iterator b = baselines.iterator(); b.hasNext();) {
IBaselineHandle baseline = (IBaselineHandle) b.next();
IBaseline baseline_comp = (IBaseline)repo.itemManager().fetchCompleteItem(baseline, IItemManager.DEFAULT, MONITOR);

if (baseline_comp.getName().equals("")) {
list += "No Baseline name\n";
} else {
list += baseline_comp.getName() + "\n";
}
}


Your code give me the name of the baselines of a particular component ..but what i want is the name of a baseline set or a snapshot in a particular stream ........ i am able to get the handle but not the name of the baseline set/snapshot

permanent link
K M (38325051) | answered Apr 26 '10, 8:53 a.m.
// Get snapshot stream
crit1.setExactName(tmp);
crit1.setExactOwnerName(tmp);
crit1.setKind(IWorkspaceSearchCriteria.STREAMS);

List tmp_list = wm.findWorkspaces(crit1, 1, MONITOR);
if (tmp_list.size() == 0) {
throw new TeamRepositoryException("Snapshot Stream " + tmp + " does not exists");
}
// Get snapshot stream connection
Iterator it = tmp_list.iterator();
IWorkspaceHandle snapshot_hd = (IWorkspaceHandle) it.next();
IWorkspaceConnection wc = wm.getWorkspaceConnection(snapshot_hd, null);

// Get snap shot
IBaselineSetSearchCriteria crit2 = IBaselineSetSearchCriteria.FACTORY.newInstance();
crit2.setOwnerWorkspaceOptional(snapshot_hd);
crit2.setExactName(tmp);
tmp_list = wm.findBaselineSets(crit2,1,MONITOR);

if (tmp_list.size() == 0) {
throw new TeamRepositoryException("Snapshot " + tmp + " does not exists");
}

// Get baselines
it = tmp_list.iterator();
IBaselineSetHandle baselineSetHandle = (IBaselineSetHandle) it.next();
IBaselineSet baselineSet = (IBaselineSet)repo.itemManager().fetchCompleteItem(baselineSetHandle, IItemManager.DEFAULT, MONITOR);

// Get Snap shot baselines
List baselineHandles = baselineSet.getBaselines();
List baseline_comp = repo.itemManager().fetchCompleteItems(baselineHandles, IItemManager.DEFAULT, MONITOR);
// Get baseline names
for (Iterator b = baseline_comp.iterator(); b.hasNext();) {
IBaselineHandle baseline = (IBaselineHandle) b.next();
IBaseline baseline_tmp = (IBaseline)repo.itemManager().fetchCompleteItem(baseline, IItemManager.DEFAULT, MONITOR);
IBaselineConnection baselineConnection = wm.getBaselineConnection(baseline,MONITOR);
IComponentHandle component = baseline_tmp.getComponent();
list += baseline_tmp.getName() + "\n";
}

permanent link
Neerav Salaria (3132) | answered Apr 28 '10, 12:37 a.m.
// Get snapshot stream
crit1.setExactName(tmp);
crit1.setExactOwnerName(tmp);
crit1.setKind(IWorkspaceSearchCriteria.STREAMS);

List tmp_list = wm.findWorkspaces(crit1, 1, MONITOR);
if (tmp_list.size() == 0) {
throw new TeamRepositoryException("Snapshot Stream " + tmp + " does not exists");
}
// Get snapshot stream connection
Iterator it = tmp_list.iterator();
IWorkspaceHandle snapshot_hd = (IWorkspaceHandle) it.next();
IWorkspaceConnection wc = wm.getWorkspaceConnection(snapshot_hd, null);

// Get snap shot
IBaselineSetSearchCriteria crit2 = IBaselineSetSearchCriteria.FACTORY.newInstance();
crit2.setOwnerWorkspaceOptional(snapshot_hd);
crit2.setExactName(tmp);
tmp_list = wm.findBaselineSets(crit2,1,MONITOR);

if (tmp_list.size() == 0) {
throw new TeamRepositoryException("Snapshot " + tmp + " does not exists");
}

// Get baselines
it = tmp_list.iterator();
IBaselineSetHandle baselineSetHandle = (IBaselineSetHandle) it.next();
IBaselineSet baselineSet = (IBaselineSet)repo.itemManager().fetchCompleteItem(baselineSetHandle, IItemManager.DEFAULT, MONITOR);

// Get Snap shot baselines
List baselineHandles = baselineSet.getBaselines();
List baseline_comp = repo.itemManager().fetchCompleteItems(baselineHandles, IItemManager.DEFAULT, MONITOR);
// Get baseline names
for (Iterator b = baseline_comp.iterator(); b.hasNext();) {
IBaselineHandle baseline = (IBaselineHandle) b.next();
IBaseline baseline_tmp = (IBaseline)repo.itemManager().fetchCompleteItem(baseline, IItemManager.DEFAULT, MONITOR);
IBaselineConnection baselineConnection = wm.getBaselineConnection(baseline,MONITOR);
IComponentHandle component = baseline_tmp.getComponent();
list += baseline_tmp.getName() + "\n";
}

hey thanks mcraek ..tht wrks perfect ...i have 1 more query can u just answer tht ..
i am creating a workspace from the snapshot ..with the same name ->
SCMPlatform.getWorkspaceManager(teamRepository).createWorkspace(con1,name,"space",blz,null);
..after creating the workspace ....i want to extract the contents of the workspace on to the local machine ..i hve been doing this using a scm command ->scm load name -r repo -d folder......is there any java api that can perform the very same function of loading the contents of the workspace on a local folder ..

permanent link
K M (38325051) | answered Apr 28 '10, 7:41 a.m.
I trying to figure out how to bring a single file down,
edit it and check it back in now..........

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.