public IWorkItemHandle findParent(AdvisableOperation operation) throws TeamRepositoryException
{
Object data = operation.getOperationData();
if (data instanceof ISaveParameter) // from Workitem -> save operation
{
ISaveParameter saveParameter = (ISaveParameter) data;
IWorkItemReferences ref = saveParameter.getNewReferences();
List<IEndPointDescriptor> types = ref.getTypes();
for (IEndPointDescriptor desc : types)
{
if (desc.getId().equalsIgnoreCase("parent")) // "parent" is an RTC/Jazz string ID
{
List<IReference> refList = ref.getReferences(desc);
if (refList.size() > 0)
{
IReference iRef = refList.get(0); // Only one parent
Object obj = iRef.resolve();
if (obj instanceof IWorkItemHandle) // Only looking for Workitems.
{
return (IWorkItemHandle) obj;
}
else
return null;
}
else
return null;
}
}
}
return null;
}
Object data = operation.getOperationData();
if (data instanceof ISaveParameter) // from Workitem -> save operation
{
ISaveParameter saveParameter = (ISaveParameter) data;
IWorkItemReferences ref = saveParameter.getNewReferences();
List<IEndPointDescriptor> types = ref.getTypes();
for (IEndPointDescriptor desc : types)
{
if (desc.getId().equalsIgnoreCase("parent")) // "parent" is an RTC/Jazz string ID
{
List<IReference> refList = ref.getReferences(desc);
if (refList.size() > 0)
{
IReference iRef = refList.get(0); // Only one parent
Object obj = iRef.resolve();
if (obj instanceof IWorkItemHandle) // Only looking for Workitems.
{
return (IWorkItemHandle) obj;
}
else
return null;
}
else
return null;
}
}
}
return null;
}
The WorkItemEndPoints are only a subset.
Example for requirements: Use the WorkItemLinkTypes and the ILinkRegistry.
ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.IMPLEMENTS_REQUIREMENT).getTargetEndPointDescriptor()
No comments:
Post a Comment