It's all about the answers!

Ask a question

How do I get workitem details out of WorkItemHandleImpl ?


Yehiel Glass (25528786) | asked Jul 08 '12, 8:04 a.m.
edited Jul 08 '12, 8:57 a.m. by Geoffrey Clemm (30.0k23035)
Hi,
I need to get WorkItem details  on 'associate changeset to workitem' operation.
I have WorkItemHandleImpl from the SaveClosedChangeSetOperationData .
I need help to get IWorkItem out of WorkItemHandleImpl.
UUID is available but I don't know how to get workitem with UUID.
Thank in advance,
Yehiel

Accepted answer


permanent link
Ralph Schoon (60.5k33643) | answered Jul 11 '12, 5:59 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Yehil, I would suggest to search the Extensions Workshop.

It depends on what you do and where (Client extension, Plain Java client Libraries or Server extension)
An extension should extend AbstractService which provides important operations such as getAuthenticatedContributor() and getService() to get services that are listed in the prerequisites.

You use AbstractService.getService(Class<T> class) so

IAuditableCommon common = (IAuditableCommon) this.getService(IAuditableCommon.class)

Clients and client extensions you get Client Libraries using

IAuditableClient auditableClient = (IAuditableClient) iTeamrepository.getClientLibrary(IAuditableClient.class);


Ralph Schoon selected this answer as the correct answer

3 other answers



permanent link
Ralph Schoon (60.5k33643) | answered Jul 09 '12, 3:22 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jul 09 '12, 3:48 a.m.
The API often returns object handles instead of the full object
–To get the object from an IHandle use a resolve operation provided by the Services/Client Libraries. Objects might not be resolvable due to permissions. There are differences in the server and client API:

Server API uses services
        IAuditableCommon.resolveAuditable(handle, profile, monitor)
        IAuditableCommon.resolveAuditablesPermissionAware(handles, profile, monitor)
Example:
IWorkItem workItem = auditableCommon.resolveAuditable((IAuditableHandle) handle,IWorkItem.SMALL_PROFILE, monitor);     

Client API uses Client Libraries.
        IAuditableClient auditableClient = (IAuditableClient) repository.getClientLibrary(IAuditableClient.class);
        IWorkItem workItem = auditableClient.resolveAuditable((IAuditableHandle) handle,IWorkItem.FULL_PROFILE, monitor);       
 
On the client side the ItemManager provides the ability to resolve/fetch an item from a handle:
        ITeamrepository.itemManager().fetchCompleteItem(itemHandle, flags, monitor)

Profiles are used to determine how much data needs to be loaded when resolving a handle
–General profiles: ItemProfile.createFullProfile(IProjectArea.ITEM_TYPE)
–Special profiles: IWorkItem.SMALL_PROFILE, IQueryDescriptor.FULL_PROFILE
–On the client ItemManager flags are IItemManager.DEFAULT (cached), IItemManager.REFRESH (refresh cache)

Sometimes it is necessary to find the team repository containing an object; use getOrigin()
 ITeamRepository repository = (ITeamRepository) iItem.getOrigin();






Comments
Yehiel Glass commented Jul 11 '12, 5:36 a.m. | edited Jul 11 '12, 5:41 a.m.

Thanks Ralph, for your answer.

I don't know how to get IAuditableCommon on SaveClosedChangeSetOperationData .
I know hoe to get it on deliver operation or save work item operation but I don't know how to get the work-item from the data I get with SaveClosedChangeSetOperationData (This is the operation for associating Change-set to work-item).
I searched the forum but didn't find any clue.
Waiting for your help,
Yehiel


permanent link
Yehiel Glass (25528786) | answered Jul 13 '12, 8:07 a.m.
 Hi Ralph,
I'm now facing problem with the plugin prerequisites.
I saw one workshop example :  https://jazz.net/library/article/634/ 
Can you write some links to available extension workshops ?
Thanks.

permanent link
Ralph Schoon (60.5k33643) | answered Jul 13 '12, 8:22 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
That is what is there. I would suggest looking at the error in the log and to add that service to the prerequisites as described in the workshop. You add it in the plugin.xml.

Like:
.
.
.
         <extensionService
               componentId="net.jazz.rtcext.workitem.extensions"
               implementationClass="net.jazz.rtcext.workitem.extensions.service.BuildOnStateChangeParticipant">
            <prerequisites>
            <prerequisites>
               <requiredService
                  interface="com.ibm.team.workitem.service.IWorkItemServer"/>
               <requiredService
                  interface="com.ibm.team.build.internal.common.ITeamBuildService"/>
               <requiredService
                  interface="com.ibm.team.build.internal.common.ITeamBuildRequestService"/>
            </prerequisites>
        </extensionService>
.
.

Your answer


Register or to post your answer.