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

How do you assign an owner to children WIs automatically when saving a parent WI?

How do you assign an owner to children WIs automatically when saving a parent WI?

0 votes


Accepted answer

Permanent link
Hi Take-san,

If you are talking about a custom followup action, I am doing like below. It doesn't work for a child WI which is created by a parent and you will need to add more exception handlings, but I think you can use this sample as a start point.

public void run(AdvisableOperation operation,
            IProcessConfigurationElement participantConfig,
            IParticipantInfoCollector collector, IProgressMonitor monitor)
            throws TeamRepositoryException {
       
        Object data= operation.getOperationData();
        ISaveParameter saveParameter = null;
        if (!(data instanceof ISaveParameter)){
            return;
        }
        saveParameter = (ISaveParameter) data;
         if (          (saveParameter.getAdditionalSaveParameters() == null)
                 ||
                 ((saveParameter.getAdditionalSaveParameters() != null)
           && (!saveParameter.getAdditionalSaveParameters().contains(Recursion)))
        ) {
            IWorkItem parent = (IWorkItem) saveParameter.getNewState();
            IContributorHandle owner = parent.getOwner();
            List<IWorkItemHandle> workItemHandleList = findChildHandle(saveParameter, monitor);
            if(workItemHandleList.isEmpty()){
                return;
            }
            IWorkItemServer workItemServer = getService(IWorkItemServer.class);
           
            Iterator<IWorkItemHandle> iter = workItemHandleList.iterator();
            while (iter.hasNext()){
                IWorkItemHandle workItemHandle = (IWorkItemHandle)iter.next();
                IWorkItem workItem = (IWorkItem) workItemServer.getAuditableCommon().resolveAuditable(workItemHandle, IWorkItem.FULL_PROFILE,
                                monitor).getWorkingCopy();
                workItem.setOwner(owner);
                workItemServer.saveWorkItem3(workItem, null, null, bypass);
            }
         }
    }
    private List<IWorkItemHandle> findChildHandle(ISaveParameter saveParameter,
            IProgressMonitor monitor) throws TeamRepositoryException {
       
        List<IWorkItemHandle> workItemHandleList = new ArrayList<IWorkItemHandle>();
        List<IReference> references = saveParameter.getNewReferences()
                .getReferences(WorkItemEndPoints.CHILD_WORK_ITEMS);
        if (references.isEmpty())
            return workItemHandleList;

        for (IReference reference : references){
            if (reference.isItemReference() && ((IItemReference) reference).getReferencedItem() instanceof IWorkItemHandle) {
                workItemHandleList.add((IWorkItemHandle)((IItemReference) reference).getReferencedItem());
            }
        }
        return workItemHandleList;
    }
Taki Nakajo selected this answer as the correct answer

3 votes


One other answer

Permanent link
Hi,

Below link shows updating parent, thought this may interest you... :
https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/

Regards,
Dinesh

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
× 6,117

Question asked: Feb 12 '16, 2:32 a.m.

Question was seen: 2,169 times

Last updated: Feb 12 '16, 3:46 a.m.

Confirmation Cancel Confirm