Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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:

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.


0 votes


Accepted answer

Permanent link

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;

Marcelo Bilezker selected this answer as the correct answer

1 vote


One other answer

Permanent link

  

Thanks.
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;
}

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Nov 08 '21, 6:06 p.m.

Question was seen: 780 times

Last updated: Nov 09 '21, 8:41 a.m.

Confirmation Cancel Confirm