It's all about the answers!

Ask a question

IReference to IWorkItem


Abhishek Minde (7121912) | asked Jul 14 '09, 6:27 a.m.
Hi,

I have a reference of type IReference, from which I need to get the workitem (IWorkItem). Please provide you suggestion on this.


Thank you
Abhishek

3 answers



permanent link
Michele Pegoraro (1.8k14119103) | answered Jul 14 '09, 8:21 a.m.
You have to use IItemReference class

IReference source = ...

if(target.isItemReference()){
IItemReference itemRef = (IItemReference)target;
IItemHandle handle = itemRef.getReferencedItem();
if (handle instanceof IWorkItemHandle){
IWorkItemHandle wiHandle = (IWorkItemHandle)handle;
IWorkItem wi = (IWorkItem)items.fetchItem(wiHandle, monitor);
}
}


where items is an ItemProvider instance.

permanent link
Michele Pegoraro (1.8k14119103) | answered Jul 14 '09, 10:16 a.m.
Hi Abhishek,
yes, I was wrong with "source". It was "target".

For ItemProvider it depends on which side you are. On Client side you can use

ProviderFactory provider = (ProviderFactory)repo.getClientLibrary(ProviderFactory.class);
ItemProvider items = provider.getItemProvider();

On Server side use

ProviderFactory provider = getService(ProviderFactory.class)
ItemProvider items = provider.getItemProvider();

permanent link
Abhishek Minde (7121912) | answered Jul 14 '09, 9:42 a.m.
Hi Michele,

Thanks for the quick reply. I have a couple of questions.

1) Is 'target' same as the source IReference ?
2) How can we get ItemProvider instance?

I appreciate your help on this.

You have to use IItemReference class

IReference source = ...

if(target.isItemReference()){
IItemReference itemRef = (IItemReference)target;
IItemHandle handle = itemRef.getReferencedItem();
if (handle instanceof IWorkItemHandle){
IWorkItemHandle wiHandle = (IWorkItemHandle)handle;
IWorkItem wi = (IWorkItem)items.fetchItem(wiHandle, monitor);
}
}


where items is an ItemProvider instance.

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.