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

Problem in Operation Participant code.

Hi,
This is  operation Participant code , It works fine only when I was create a new RCN it adds some description, but when I did some modifications in RCN page and again save, it didn't update the RCN description.
I want to update description whenever I click on save button.
what is the problem in the code I don't understand .....any help??

Code :

package test;

import org.eclipse.core.runtime.IProgressMonitor;
import com.ibm.team.foundation.common.text.XMLString;
import com.ibm.team.process.common.IProcessConfigurationElement;
import com.ibm.team.process.common.advice.AdvisableOperation;
import com.ibm.team.process.common.advice.runtime.IOperationParticipant;
import com.ibm.team.process.common.advice.runtime.IParticipantInfoCollector;
import com.ibm.team.repository.common.IAuditable;
import com.ibm.team.repository.common.TeamRepositoryException;
import com.ibm.team.repository.service.AbstractService;
import com.ibm.team.workitem.common.ISaveParameter;
import com.ibm.team.workitem.common.IWorkItemCommon;
import com.ibm.team.workitem.common.model.IAttribute;
import com.ibm.team.workitem.common.model.IWorkItem;
import com.ibm.team.workitem.service.IWorkItemServer;

public class TestClass extends AbstractService implements IOperationParticipant {

    private static final String SAVE_DESCRIPTION="description";
    private IWorkItemServer workItemServer;
    private IWorkItemCommon wiCommon;
   
    public void run(AdvisableOperation operation,
            IProcessConfigurationElement participantConfig,
            IParticipantInfoCollector collector, IProgressMonitor monitor)
            throws TeamRepositoryException
    {
       
        Object data = operation.getOperationData();
        if (data instanceof ISaveParameter)
        {
            ISaveParameter saveParameter = (ISaveParameter) data;
            IAuditable auditable = saveParameter.getNewState();
       
            if (auditable instanceof IWorkItem)
            {
                workItemServer = getService(IWorkItemServer.class);
                wiCommon = getService(IWorkItemCommon.class);
               
                IWorkItem workItem = (IWorkItem) auditable;
                IWorkItem workItemWC = (IWorkItem)workItem.getWorkingCopy();
                       
               
               
                            if (workItemWC == null) {
                   
                                System.out.println("Work Item not found.");
                   
                                return;
                   
                            }
                            try
                            {
                                IAttribute summaryAttribute = wiCommon.findAttribute(workItemWC.getProjectArea(),SAVE_DESCRIPTION, monitor);
                               
                                String str=workItemWC.getHTMLSummary()+"update new ";
                                                           
                                workItemWC.setValue(summaryAttribute, str);
                               
                                workItemServer.saveWorkItem2(workItemWC, null, null);
                               
                           
                            }
                            catch (Exception e)
                            {
                                    // TODO: handle exception
                               
                            }
               
            }
        }
    }

}

0 votes



2 answers

Permanent link
Hi,

Replace the Code

String str=workItemWC.getHTMLSummary()+"update new ";

With

String str=workItemWC.getHTMLSummary().getPlainText()+"update new ";

Because, getHTMLSummary method will return XMLString and not the String.


0 votes

Comments

Actually , the code is working fine and it add desciption when I was creates a new RCN and save it.My problem is It doesnt update the desciption when I do some changes to old RCN and again save it , it do nothing.


Permanent link
You might want to look into https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ what it does is getting a working copy of the work item to update. You also might want to look into getting a fresh version to avoid stale data issues.

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
× 1,700
× 383

Question asked: Aug 14 '12, 1:48 a.m.

Question was seen: 4,728 times

Last updated: Aug 15 '12, 11:06 a.m.

Confirmation Cancel Confirm