version-controljazzrational-team-concert

Equivalent method to fetchCompleteState in RTC java plain api


Is there any equivalent method for fetchCompleteState on versionableManager to fetch data of historic files? I'm having troubles with retrieving file name of file added in previous changelists. Here is example:

Changelist 1:     
add file: src/newFile.java

Changelist 2:     
modify file: src/newFile.java

Changelist 3:     
rename file: src/newFile.java -> src/newFile_rename.java

And now when I'm trying to get file name or file path of file in changelist 1 using following code:

// change is IChange, versionableManager is IVersionableManager     
// method getFilePath retrieve file path using ancestors     
file = versionableManager.fetchCompleteState(change.afterState(), monitor);     
if (file instanceof IFolder) {         
    IFolder folder = (IFolder) file;         
    relativePath = getFilePath(file, workspaceConnection.configuration(changeSet.getComponent()), monitor);
    fileName = folder.getName();      
} else {
    relativePath = getFilePath(file, workspaceConnection.configuration(changeSet.getComponent()), monitor);    
    fileName = ((FileItem) file).getName();     
}

I'm getting name and path of renamed file. How to get it's old name and path?


Solution

  • Ok found the solution:

    IFileItemHandle fileItemHandle = (IFileItemHandle) IFileItem.ITEM_TYPE.createItemHandle(change.afterState().getItemId(), change.afterState().getStateId());
    file = versionableManager.fetchCompleteState(fileItemHandle, monitor);
    
    if (file instanceof IFolder) {         
        IFolder folder = (IFolder) file;         
        relativePath = getFilePath(file, workspaceConnection.configuration(changeSet.getComponent()), monitor);
        fileName = folder.getName();      
    } else {
        relativePath = getFilePath(file, workspaceConnection.configuration(changeSet.getComponent()), monitor);    
        fileName = ((FileItem) file).getName();     
    }
    

    But still having isses with resolving file path. Anyways this is a big step.