How do I get workitem details out of WorkItemHandleImpl ?
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
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
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);
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);
3 other answers
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();
–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
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
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.
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>
.
.
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>
.
.