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

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:

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

0 votes



One answer

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

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



--

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

Question asked: Aug 03 '09, 1:30 p.m.

Question was seen: 5,379 times

Last updated: Aug 03 '09, 1:30 p.m.

Confirmation Cancel Confirm