IWorkSpaceHandle on a server side plugin
Accepted answer
IReference workItemReference = linkServiceLibrary.referenceFactory().createReferenceToItem(workItemHandle); ILinkQueryPage page = linkService.findLinksByTarget(ILinkConstants.CHANGESET_WORKITEM_LINKTYPE_ID, workItemReference); for (ILink link : page.getLinks()) {
IReference reference = link.getSourceRef();
String extraInfo = reference.getExtraInfo();
if (extraInfo != null) {
int index = extraInfo.indexOf('=');
if (index != -1) {
IWorkspaceHandle workspace = (IWorkspaceHandle) IWorkspace.ITEM_TYPE.createItemHandle(UUID.valueOf(extraInfo.substring(index + 1)), null);
// do work...
}
}
}
Comments
Thanks Remy for your answer.
Just few question to understand better. Is linkService on line 2 an instance of ILinkServiceLibrary? The same object the you use above to find workitemreference?
Yes, it is an ILinkServiceLibrary.
Thanks Remy, it seems to work well, I got
extrainfo: Workspace=_ir5fIDUIEeSD1IdFVDHgIw
One other answer
(ITeamArea) teamRepository.itemManager() .fetchCompleteItem(handle, IItemManager.REFRESH, monitor);
Another way to resolve Items -if they are IAuditables.
workItemCommon.getAuditableCommon().resolveAuditable(processAreaHandle,
ItemProfile.PROCESS_AREA_DEFAULT,monitor);
Comments
for who is interested in I got the workItemCommon as service of the abstractService
AbstractService.getService(IWorkItemCommon.class)
@ralph: Why ItemProfile.PROCESS_AREA_DEFAULT and not ItemProfile.PROJECT_AREA_DEFAULT?
Please read the blog(s) they explain these things.I did them to not have to answer everything over and over.
Use the Item profiles you think need. The profiles select more or less data.
Thanks Ralph. If you have suggestions also on how to reach the workspace handle would be great.
Comments
Remy Suen
Sep 09 '14, 1:02 p.m.I don't understand your question. What does an IWorkspaceHandle have anything to do with a work item? Please provide some sample code.
Marco Gianfico
Sep 10 '14, 4:12 a.m.Pheraps my question was not crystal clear.
I'm doing a Server Side Operation Participant on a work item save.
So in the beginning I just have a SaveParameter that refers to the work item and the service that I can reach with AbstracScmService.getService().
The work item is linked with a change set so I can have the changeset component.
From this point going on, how I can have the workspacehandle of where this changeset is lying.
Thanks any suggestions.
Remy Suen
Sep 10 '14, 8:09 a.m.Please attach the code that you have so far.
Also note that change sets do not have to reside in a workspace. They may have been suspended or discarded in which case they are not part of any workspace.
Marco Gianfico
Sep 12 '14, 4:41 a.m.In this case i'm sure that the changeset reside in a workspace.
The code is really long so I just attach the way to retrieve the changeset
Marco Gianfico
Sep 12 '14, 4:41 a.m.If needed I also have the ProjectAreaHandle retrieved from the workItem connected to that changeset, but i don't know ho to resolve the ProjectAreaHandle to a ProjectArea
IWorkItem workItem = (IWorkItem) saveParameter.getNewState();
IProjectAreaHandle projectAreaHandle = workItem.getProjectArea();