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

find (back) a woirk item by its ID

Hi

I've created a small jazz UI plugin that allow the user to create
some work items based on some info from a Database.

I'd like to allow the user to find back a work item when he connects
later to another TeamConcert session. I can store the ID of the work
item when I create it, but how can I retreive a work item given its ID?

Could you show me some code snippets?

thanks for your help

--
cd

0 votes



3 answers

Permanent link
Hi,

You could use a query to find your Work Items but I think that's overkill if you just want one and you know the ID. I've written a small function for this once that might help you:


public IWorkItem getWorkItemByID(int id) {
IWorkItem workItem = null;
IWorkItemClient workItemClient = (IWorkItemClient) repository.getClientLibrary(IWorkItemClient.class);

try {
workItem = workItemClient.findWorkItemById(id, IWorkItem.FULL_PROFILE, monitor);
} catch (TeamRepositoryException e) {
log.severe(e.getMessage());
}

return workItem;
}







I hope that will help you

Kai



Hi

I've created a small jazz UI plugin that allow the user to create
some work items based on some info from a Database.

I'd like to allow the user to find back a work item when he connects
later to another TeamConcert session. I can store the ID of the work
item when I create it, but how can I retreive a work item given its ID?

Could you show me some code snippets?

thanks for your help

--
cd

0 votes


Permanent link
If you're just trying to store the same work item so you can recover it later, you might want to try saving its UUID instead of its ID. This is probably more efficient than searching by ID and will work with all auditable types - not just work items:


// How to save it:
UUID myId = workItem.getItemId();
String asString = myId.toString();

// How to restore it:
String someWorkItemUUID = ...
ITeamRepository repo = ...

UUID id = UUID.valueOf(someWorkItemUUID);
IWorkItemHandle handle = IWorkItem.ITEM_TYPE.createItemHandle(id, null);
IWorkItem workItem = repo.itemManager().fetchCompleteItem(handle, IItemManager.DEFAULT, progressMonitor);

// ...and now you've got your IWorkItem back...

0 votes


Permanent link
Hi

It just works fine.

Thanks!

--
cd
sxenos a crit :
If you're just trying to store the same work item so you can recover
it later, you might want to try saving its UUID instead of its ID.
This is probably more efficient than searching by ID and will work
with all auditable types - not just work items:


// How to save it:
UUID myId = workItem.getItemId();
String asString = myId.toString();

// How to restore it:
String someWorkItemUUID = ...
ITeamRepository repo = ...

UUID id = UUID.valueOf(someWorkItemUUID);
IWorkItemHandle handle = IWorkItem.ITEM_TYPE.createItemHandle(id,
null);
IWorkItem workItem = repo.itemManager().fetchCompleteItem(handle,
IItemManager.DEFAULT, progressMonitor);

// ...and now you've got your IWorkItem back...

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

Question asked: Jun 02 '08, 10:40 a.m.

Question was seen: 7,847 times

Last updated: Jun 02 '08, 10:40 a.m.

Confirmation Cancel Confirm