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

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

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.

0 votes



3 answers

Permanent link
There are several similar recent questions with answers in the forum. Does any of them help?

1 vote

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


Permanent link
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.  

1 vote


Permanent link

 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.

0 votes

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

Question asked: Nov 08 '12, 8:34 p.m.

Question was seen: 10,730 times

Last updated: Mar 20 '17, 6:25 p.m.

Confirmation Cancel Confirm