Getting all workItems childs of a given workItem
I am working with EWM 7.0.2, with java, on server side
I Need to get all workItems childs of a given workitem.
I found an example; "com.ibm.js.team.workitem.extension.updateparent.participant"
but all functions there received an "AdvisableOperation operation" as parameter.
The example code is:
....
}
...
}
The question is, how I get the AdvisableOperation operation from a workItemType.
The example code is:
public class UpdateParentState extends AbstractService implements
IOperationParticipant {
private IWorkItemServer fWorkItemServer;
@Override
public void run(AdvisableOperation operation,
IProcessConfigurationElement participantConfig,
IParticipantInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {
/
* First check that the operation data is work item save data.
/
Object data = operation.getOperationData();
ISaveParameter saveParameter = null;
if (data instanceof ISaveParameter) {
saveParameter = (ISaveParameter) data;
....
}
...
}
The question is, how I get the AdvisableOperation operation from a workItemType.
Or how can I get the childs related to a given workItemType.
Accepted answer
You don't have to get the AdvisableOperation operation, it is provided by the Java runtime that runs the extension.
At least, for plugins that extend the com.ibm.team.workitem.operation.workItemSave operation.
Actually, every argument of the run method in the example you found is provided by the runtime, so you don't have to get it.
With the operation, you can then retrieve:
Object data = operation.getOperationData();
ISaveParameter saveParameter = (ISaveParameter) data;
IAuditable auditable = saveParameter.getNewState();
IWorkItem workItem = (IWorkItem) currentAuditable;
One other answer
Thanks.
But I am not using an extension of operation. Just a command line programm.
But I am not using an extension of operation. Just a command line programm.
I resolve it with this function, that i put here in case someone needs it,
public List<IWorkItem> getChildren(IWorkItem wi) throws TeamRepositoryException {
IProgressMonitor monitor = new NullProgressMonitor();
IAuditableCommon auditableCommon = (IAuditableCommon) teamRepository.getClientLibrary(IAuditableCommon.class);
IWorkItemCommon wic = teamRepository.getClientLibrary(IWorkItemCommon.class)
IWorkItemReferences references = wic.resolveWorkItemReferences(wi, monitor);
List<IWorkItem> children = new ArrayList<>();
List<IReference> childrenLinks = references.getReferences(WorkItemEndPoints.CHILD_WORK_ITEMS);
for(IReference childLink:childrenLinks) {
Object childObj = childLink.resolve();
if(childObj instanceof IWorkItemHandle) {
IWorkItemHandle childHandle = (IWorkItemHandle) childObj;
IWorkItem child = auditableCommon.resolveAuditable(childHandle, IWorkItem.FULL_PROFILE, monitor);
children.add(child);
}
}
return children;
}