Getting the state of the child workitem
I have created two workitems, Project (parent) and ChangeRequest
(child).
I want to have precondition for saving state of parent workitem.
The precondition is "Parent workitem will be saved at "development completed" state only if all of its changerequests's(child) workitems state is "development completed"."
Progress :
1. Able to get current state of the parent workitem
2. Able to linked workitem
Obstacles
1. Not able to resolve if there are multiple number of child WI's
2. How to get simple reference to individual child WI
3. How to get state of child WI
|
Accepted answer
Hi Dnyanesh, It does work...you're probably missing the definitions in the plugin.xml (in this case, you definitely need the highlighted ones). You'll have to hand-code this in to the plugin.xml - page 59 of the extensions lab doc (v3.0.1) explains. (btw. see also Nick's comment in here https://jazz.net/forum/questions/70215/fetching-parent-workitem-using-plain-java-api?redirect=%2Fforum%2Fquestions%2F70215%2Ffetching-parent-workitem-using-plain-java-api for a better way to get the work item referenced) <prerequisites> <requiredService interface="com.ibm.team.workitem.service.IWorkItemServer"> </requiredService> <requiredService interface="com.ibm.team.build.internal.common.ITeamBuildService"> </requiredService> <requiredService interface="com.ibm.team.build.internal.common.ITeamBuildRequestService"> </requiredService> <requiredService interface="com.ibm.team.repository.service.IRepositoryItemService"> </requiredService> <requiredService interface="com.ibm.team.links.common.service.ILinkService"> </requiredService> </prerequisites>
Dnyanesh Markad selected this answer as the correct answer
|
3 other answers
Ralph Schoon (63.5k●3●36●46)
| answered Nov 16 '12, 5:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,
I would suggest with reading this post http://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ and then work through the rest of the posts for open questions. You can also search the forum for API, I think I remember having seen numerous questions and answers with example code around the topics you ask about. |
IWorkItemServer workItemService = getService(IWorkItemServer.class);
List<IWorkItem> children = new ArrayList<IWorkItem>();
List<IReference> references= saveParameter.getNewReferences().getReferences(WorkItemEndPoints.CHILD_WORK_ITEMS);
for (IReference reference: references){
String comment = reference.getComment();
String workItemID = comment.substring(0, comment.indexOf(":"));
IWorkItem workItem = workItemService.findWorkItemById(Integer.parseInt(workItemID), IWorkItem.FULL_PROFILE, monitor);
if (workItem.getWorkItemType().equals(requiredWorkitemType)){
children.add(workItem);
}
}
Comments
Dnyanesh Markad
commented Nov 19 '12, 1:39 a.m.
Hi Sola,
I have tried your code. i got an error like this
"Exception checking precondition. An unhandled exception occurred during "Get link State 1".
The service 'ncb_3.GetLink@3da83da8' failed to find the required service 'interface com.ibm.team.workitem.service.IWorkItemServer'. Check <prerequisites> in plugin.xml."
|
Ralph Schoon (63.5k●3●36●46)
| answered Nov 19 '12, 5:10 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Dnyanesh, please follow https://jazz.net/library/article/1000 carefully. You got that exception because you did not include com.ibm.team.workitem.service.IWorkItemServer in the prerequisites. You have to manually add them in the plugin.xml like below:
|
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.