Errors getting Category value from linked Work Item
I am developing an Advisor (Pre-Condition) in a project with two work items. I am using the RTC-Server-sdk version 6.0.3.
One work Item type is parent to the other.
The parent has a multi-pick enumeration custom attribute that contains team names that match the built in team names of the Category (Filed Against) attribute of the child attribute.
The advisor is designed to get the names of the boxes that are checked on the parent work item and follow the link to all work items linked as children. If the box is checked on the parent, and a corresponding child work item is not filed against all teams checked, an error is thrown and the save action is prevented.
The problem is that I can't seem to be able to retrieve the Category value of the child work item.
I have tried two methods #1, use built-in the getCategory() method; #2 treat the category attribute like a custom attribute and retrieve the value based on the literal. Both result in errors that indicate there was no Category value set on the child work item even though a category value has been set on the child work item.
the following code excerpts iterate through all IEndPointDescriptor values linked to the Parent work item. Resolving the source reference link types to find the endpointLinkID that matches the parentWILinkID tells me the IReference returned by the getReferences method is a child link type.
I use the IReference.resolve() method to get the workItemHandle object, then use the resolveAuditable method to get a local copy of the IWorkItem object of the child.
Code for Method #1:
try{
ICategoryHandle filedAgainst = childWI.getCategory();
// this is where I save off this handle for later processing but it doesn't get here
}
catch (IllegalStateException ise)
{
// add error
}
Code for Method #2
IAttribute childFiledAgainst = workItemService.findAttribte(childWI.getProjectArea(), "com.ibm.team.workitem.attribute.category", monitor);
if (childFiledAgainst == null)
{
// add error
}
else
{
// this is where I save off this handle for later processing but it doesn't get here
}
If the child work item doesn't have the category value set, I expect to get the error conditions in both approaches listed above. However I have confirmed in the debugger that I am referencing the correct child and looking at the child work item the Category has been set.
Any specific ideas on how to proceed?
I have reviewed the following link extensively and worked through the Lab Exercises for Learn To Fly so please
don't point me to the generic answers. That will not be helpful.
If I don't "Accept" any answers, it means I don't have the rank on this forum to give it a thumbs down yet.
|
One answer
I found the problem...
The way that I was resolving the child work item from the WorkItemHandle using the resolveAuditable method was the issue.
One of the arguments of this method takes a constant value defined in the IWorkItem class to specify which values to resolve to the local copy of the work item returned.
I was specifying the IWorkItem.DEFAULT_PROFILE value for this argument which doesn't include data for the built-in Category parameter. The debugger showed that the Category value of the resolved work item was always null so both method 1 and 2 outlined above were always hitting the error conditions.
Once I switched to the argument value of IWorkItem.FULL_PROFILE for the resolveAuditable method the value for Category was included in the resolved work item. The built-in method to retrieve the Category value for this work item was then able successfully return a value when data in the child work item had a value set for the Planned For attribute.
Method 2 was never successful, but presumably it is always better to make use of built-in accessors for data.
|
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.