how get Full path of the File from changeset Using API?
for (IChangeSet changeset : changesets) {
System.out.println("Change Set ITEM_ID_PROPERTY "
+ changeset.getItemId());
List changes = changeset.changes();
for(Object change : changes)
{
Change aChange = (Change)change;
if(aChange.item() instanceof IFileItemHandle)
{
IFileItemHandle fileItemHandle = (IFileItemHandle)aChange.afterState();
IFileItem fileItem = (IFileItem)SCMPlatform.getWorkspaceManager(clientUtil.getTeamRepository()).versionableManager().fetchCompleteState(fileItemHandle,null);
System.out.println("File Name :"+fileItem.getName());
}
}
What my approach is to create an text file that can be used for Load rule file for the SCM CLI. I wan to create this file using the API so that I can access the remote workspace.
3 answers
Comments
https://jazz.net/forum/questions/8704/is-it-possible-to-get-the-full-path-name-of-a-ifileitem
IComponentHandle component = changeSet.getComponent();
IConfiguration configuration = workspaceConnection.configuration(component);
configuration.determineAncestorsInHistory(List, ProgressMonitor);
I tried to use the same technique.However, I couldn't find a method
I tried:
IComponentHandle component = changeSet.getComponent();
IWorkspaceConnection workspaceConnection=(IWorkspaceConnection) SCMPlatform.getWorkspaceManager(repository);
workspaceConnection.configuration(). // Here couldn't allocate the mentioned method
I have posted question over:
https://jazz.net/forum/questions/103355/java-get-the-full-path-of-a-file-at-change-set
IWorkspaceConnection isn't the same type returned by your call to get the workspace manager. You can use the workspace manager to get the IWorkspaceConnection though.
1 vote
Sorry for this naive mistake.
I have updated my code.
However, I still have an issue at IWorkSpaceHandle as I'm searching on how to initialize it with my file.
I'd appreciate If you can assist me into the following points:
-How to initialize the IWorkSpaceHandle to see my file I need to get the full path of it.
-I have been reading the API documentation of RTC and I think that "determineAncestorsInHistory" won't get the directory of the file ... can u confirm that or not ?
My updated code:
IComponentHandle component = changeSet.getComponent();
IWorkspaceManager workspaceManager= SCMPlatform.getWorkspaceManager(repository);
WorkspaceSearchCriteria wsc = (WorkspaceSearchCriteria) IWorkspaceSearchCriteria.FACTORY.newInstance();
IWorkspaceConnection workspaceConnection= workspaceManager.getWorkspaceConnection(null, Application.getMonitor()); //I NEED TO INIT. THE WORKSPACE HANDLE
IConfiguration configuration = workspaceConnection.configuration(component);
List lst=new ArrayList<string>();
lst.add(fileItem.getName());
configuration.determineAncestorsInHistory(lst,getMon);
List<IVersionableHandle> versionableHandles = getVersionableHandlesFromSomewhere(); List<IAncestorReport> ancestorReports = configuration.locateAncestors(versionableHandles, monitor);
//Lets get the path of the first one, corresponding to the first versionable
IAncestorReport iAncestorReport = ancestorReports.get(0);
List<INameItemPair> reportList = iAncestorReport.getNameItemPairs();
String filePath = "" ;
for (INameItemPair iNameItemPair : reportList){
String temp = iNameItemPair.getName();
if (temp != null) {
filePath += "/" + temp ;
}
}
System.out.println(filePath);