How to find deleted parent item in operation participant?
Since i'm new to RTC, I have one question and any help would be appreciated.
I've created IOperationParticipant that is updating some data in workitem.
I've need to find out what workitem was parent to saved workitem before save.
The code I have is:
Object data = operation.getOperationData();
if (!(data instanceof ISaveParameter))
return;
//this returns reference to new parent if added
//saveParameter.getNewReferences().getReferences(WorkItemEndPoints.PARENT_WORK_ITEM)
//this returns empty array
//saveParameter.getNewReferences().getCreatedReferences(WorkItemEndPoints.PARENT_WORK_ITEM)
//this returns empty array
//saveParameter.getNewReferences().getDeletedReferences(WorkItemEndPoints.PARENT_WORK_ITEM)
I've tried using something like:
IAuditable oldStateAuditable = saveParameter.getOldState();
if(oldState!=null)
{
IAuditableCommon common = (IAuditableCommon)getService(IAuditableCommon.class);
IWorkItem oldItem = (IWorkItem)common.resolveAuditable(oldStateAuditable, IWorkItem.FULL_PROFILE, monitor);
oldReferences = workItemServer.resolveWorkItemReferences(oldItem, monitor);
}
but without success(it is also returning empty strings).
Based on this link: https://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=72536
my approach should work.
Please,
what am I missing?
2 answers
Hi,
you can use the following to know the deleted parent.
List<IReference> references = saveParameter.getNewReferences().getDeletedReferences(WorkItemEndPoints.PARENT_WORK_ITEM);
and then use the
for (IReference reference : references)
if (reference.isItemReference() && ((IItemReference)reference).getReferencedItem() instanceof IWorkItemHandle)
return (IWorkItemHandle)((IItemReference)reference).getReferencedItem();