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 |
3 answers
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 |
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... |
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 |
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.