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

Plugin Participant fails when saveWorkItem2

Hi,

I want to create a plugin (IOperationParticipant) thats auto create Approvers (with the creator)

public class WIAprovalsParticipand extends AbstractService implements IOperationParticipant {   

private static final String APPROVAL_NAME = "Aprobacion DA";  
private IWorkItemServer fWorkItemServer = null;
private IProcessServerService fProcessServerService = null; 
private IAuditableCommon fAuditableCommon = null;      

 public void run(AdvisableOperation operation,IProcessConfigurationElement participantConfig,IParticipantInfoCollector collector, IProgressMonitor monitor)            throws TeamRepositoryException {    

Object data= operation.getOperationData();                     
fWorkItemServer = getService(IWorkItemServer.class);    
fAuditableCommon = getService(IAuditableCommon.class); 

  if (data instanceof ISaveParameter) {    
       IAuditable auditable = ((ISaveParameter)data).getNewState(); 
                if (auditable instanceof IWorkItem) { 
                        IWorkItem workItem = (IWorkItem) auditable;
    IWorkItem workingCopy = (IWorkItem) fWorkItemServer   .getAuditableCommon()                        .resolveAuditable(workItem, IWorkItem.FULL_PROFILE, monitor)                        .getWorkingCopy();

Approvals approvals = workingCopy.getApprovals();
 IApprovalDescriptor descriptor= approvals.createDescriptor(WorkItemApprovals.REVIEW_TYPE.getIdentifier(), APPROVAL_NAME);          
IContributorHandle reviewer = workingCopy.getCreator();   
IApproval approval= approvals.createApproval(descriptor, reviewer);         approvals.add(approval);
IStatus saveStatus = fWorkItemServer.saveWorkItem2(workingCopy, null, null );    ...


I Can add the follow action to Save WI, but doesnt work,  the server is "Saving" loop and dont stop, the ccm log is full with:

2013-04-30 15:08:57,021 [              WebContainer : 6] ERROR com.ibm.team.workitem.common                        - Error invoking value provider 'com.ibm.team.workitem.valueproviders.VALUE_PROVIDER._QNifQGC9EeKTg8I24BTQkg'java.lang.NullPointerException



I Can add the follow action to Save WI, but doesnt work,  the server is "Saving" loop and dont stop, the ccm log is full.

 think  my error is in the SaveWorkitem? because I  prove and  I access to the attributes of the WorkItem.

Anybody can help me?

Thanks.


0 votes


Accepted answer

Permanent link
Marcos,

here a description how such a participant can be developed: https://rsjazz.wordpress.com/2012/11/30/a-create-approval-work-item-save-participant/ - with code - and here a deeper reasoning on how to avoid recursions https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ look at the end of the post if you are in a hurry.

Hope that helps.

Marcos Sánchez selected this answer as the correct answer

0 votes

Comments

Thanks Ralph for your time.

I dont understand why I have a recursion problem  (like parents,child) if I want to create Approvers only and not affect to "Links Parents/Childs),  no?

Thanks.

if you change some workitem and SAVE it, then the participant chain will run again.. BEFORE the current chain finishes..


IStatus saveStatus = fWorkItemServer.saveWorkItem2(workingCopy, null, null );  


1 vote

Exactly, you save a work item. So all advisors and postconditions will run again. If you don't filter the save out, especially your participant will run again, which might add an approval, which will.....


2 other answers

Permanent link
usually you use saveWorkitem3(workitem, null, null, parm) so you can pass yourself a parameter to be able to detect recursion

saveWorkItem3(sourceWorkItem, null, null, additionalParams);


0 votes


Permanent link
Thank you very much Ralph and Sam.

I understand / resolve my doubts and solved the problem.

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
× 10,937
× 70

Question asked: Apr 30 '13, 10:18 a.m.

Question was seen: 5,927 times

Last updated: May 02 '13, 8:24 a.m.

Confirmation Cancel Confirm