How to get FileItem from a FileHandle?
Hi Jazz Team,
I want to retrieve all file changes from a work item including the authors and the filenames. I have reached the stage where I can get the File IDs. How can I get the FileItem from the FileHandle to get the contributor and file names?
My code:
Thanks
Nac
I want to retrieve all file changes from a work item including the authors and the filenames. I have reached the stage where I can get the File IDs. How can I get the FileItem from the FileHandle to get the contributor and file names?
My code:
IWorkItemWorkingCopyManager workingCopyManager= this.wi_client.getWorkItemWorkingCopyManager();
IWorkItemHandle handle = (IWorkItemHandle)workitem.getItemHandle();
workingCopyManager.connectCurrent(handle, com.ibm.team.workitem.common.model.IWorkItem.FULL_PROFILE, null);
WorkItemWorkingCopy workingCopy= workingCopyManager.getWorkingCopy(handle);
IWorkItemReferences references = workingCopy.getReferences();
ILinkType linkType = ILinkTypeRegistry.INSTANCE.getLinkType(ILinkConstants.CHANGESET_WORKITEM_LINKTYPE_ID);
IEndPointDescriptor descriptor = linkType.getSourceEndPointDescriptor();
//References for each work item
List<IReference> iRefs = references.getReferences(descriptor);
for(IReference iRef : iRefs)
{
if(iRef.isItemReference())
{
//Getting a change set for each reference
IItemHandle changeSetHandle = ((IItemReference) iRef).getReferencedItem();
IChangeSet changeSet = (IChangeSet) this.itemManager.getItem(changeSetHandle);
//Get changes from change set
List<IChange> changes = changeSet.changes();
for(IChange change : changes)
{
//for each change, get the file (id, name and the contributor)
/*change.
IVersionable file = this.scmManager.getFileFromHandle(change.item());
String name = file.getName();
//String id = change.item().getItemId().getUuidValue();// file.getItemId().getUuidValue();*/
}
}
Thanks
Nac
One answer
You can get the full state from:
(IFileItem)SCMPlatform.getWorkspaceManager(repo).versionableManager().fetchCompleteState(remoteHandle,
progressMonitor)
Note that the versionable handle should be the beforeState or afterState
of your IChange. Sometimes those fields are null (in the cases of a
change that shares a file, or a change that deletes a file).
On Mon, 03 Aug 2009 13:37:59 -0400, Nac
<naziakc> wrote:
--
(IFileItem)SCMPlatform.getWorkspaceManager(repo).versionableManager().fetchCompleteState(remoteHandle,
progressMonitor)
Note that the versionable handle should be the beforeState or afterState
of your IChange. Sometimes those fields are null (in the cases of a
change that shares a file, or a change that deletes a file).
On Mon, 03 Aug 2009 13:37:59 -0400, Nac
<naziakc> wrote:
Hi Jazz Team,
I want to retrieve all file changes from a work item including the
authors and the filenames. I have reached the stage where I can get
the File IDs. How can I get the FileItem from the FileHandle to get
the contributor and file names?
My code:
IWorkItemWorkingCopyManager workingCopyManager=
this.wi_client.getWorkItemWorkingCopyManager();
IWorkItemHandle handle =
(IWorkItemHandle)workitem.getItemHandle();
workingCopyManager.connectCurrent(handle,
com.ibm.team.workitem.common.model.IWorkItem.FULL_PROFILE, null);
WorkItemWorkingCopy workingCopy=
workingCopyManager.getWorkingCopy(handle);
IWorkItemReferences references =
workingCopy.getReferences();
ILinkType linkType =
ILinkTypeRegistry.INSTANCE.getLinkType(ILinkConstants.CHANGESET_WORKITEM_LINKTYPE_ID);
IEndPointDescriptor descriptor =
linkType.getSourceEndPointDescriptor();
//References for each work item
List<IReference> iRefs =
references.getReferences(descriptor);
for(IReference iRef : iRefs)
{
if(iRef.isItemReference())
{
//Getting a change set for each reference
IItemHandle changeSetHandle = ((IItemReference)
iRef).getReferencedItem();
IChangeSet changeSet = (IChangeSet)
this.itemManager.getItem(changeSetHandle);
//Get changes from change set
List<IChange> changes = changeSet.changes();
for(IChange change : changes)
{
//for each change, get the file (id, name and the
contributor)
/*change.
IVersionable file =
this.scmManager.getFileFromHandle(change.item());
String name = file.getName();
//String id =
change.item().getItemId().getUuidValue();//
file.getItemId().getUuidValue();*/
}
}
Thanks
Nac
--