It's all about the answers!

Ask a question

how get Full path of the File from changeset Using API?


praveen patidar (8623544) | asked Nov 08 '12, 8:34 p.m.
I m able to get the name of the file attached with the change set. But not able to get the API to get the Folder path of the file system.

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



permanent link
Ralph Schoon (63.7k33648) | answered Nov 09 '12, 6:17 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
There are several similar recent questions with answers in the forum. Does any of them help?

Comments
Andrew Niefer commented Nov 09 '12, 9:32 a.m.
JAZZ DEVELOPER

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


Fatla 777 commented Feb 20 '13, 2:14 p.m.

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


1
Tim Mok commented Feb 20 '13, 3:44 p.m.
JAZZ DEVELOPER

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.


Fatla 777 commented Feb 20 '13, 5:26 p.m.

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 ?


Fatla 777 commented Feb 20 '13, 5:39 p.m.

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


permanent link
Martin Dam Pedersen (1352814) | answered Mar 12 '13, 7:28 a.m.
edited Mar 12 '13, 7:29 a.m.
This is how you find the path:
Notice that versionableHandles is a List of versionableHandle, which mean that it will return a List of IAncestorReport corresponding to the versionableHandles.

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

That's it.  

permanent link
Ayse Bener (115) | answered Mar 20 '17, 6:22 p.m.
edited Mar 20 '17, 6:25 p.m.

 Cool. This works. But for fetching the paths of a lot of change set files belonging to a list of work items, this approach is very slow. It takes about 30 mins to retrieve paths of all the change sets for a single work item.

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.