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 } } } } } |
2 answers
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. Comments
Sudeshna Mitra
commented Aug 14 '12, 3:15 a.m.
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. |
Ralph Schoon (63.6k●3●36●46)
| answered Aug 15 '12, 11:06 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.
|
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.