Plugin apllicable for a work item
Hi,
I have modified check summary advisor example to be applicable only to "task" work item type is this the right way to do it or I have missed something please have a look and let me know what should be done, import org.eclipse.core.runtime.IProgressMonitor; import com.ibm.team.process.common.IProcessConfigurationElement; import com.ibm.team.process.common.advice.AdvisableOperation; import com.ibm.team.process.common.advice.IAdvisorInfo; import com.ibm.team.process.common.advice.IAdvisorInfoCollector; import com.ibm.team.process.common.advice.runtime.IOperationAdvisor; import com.ibm.team.repository.common.IAuditable; import com.ibm.team.repository.common.TeamRepositoryException; import com.ibm.team.workitem.common.ISaveParameter; import com.ibm.team.workitem.common.model.IWorkItem; public class Newtry implements IOperationAdvisor { private final static String fWorkItemTypeId = "task"; public void run(AdvisableOperation operation, IProcessConfigurationElement advisorConfiguration, IAdvisorInfoCollector 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) { IWorkItem workItem= (IWorkItem) auditable; String newType = workItem.getWorkItemType(); if (newType.equals(Newtry.fWorkItemTypeId)) { String summary=workItem.getHTMLSummary().getPlainText(); if (summary.contains("fail")){ IAdvisorInfo info=collector.createProblemInfo("Exist fail", "workitem summary contains 'fail'", "error"); collector.addInfo(info); } } } } } } |
Accepted answer
Ralph Schoon (63.6k●3●36●46)
| answered Jul 02 '15, 3:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Jul 02 '15, 4:59 a.m.
Please look into the Rational Team Concert Extensions Workshop to understand how this is typically done.
The approach above is OK. A better approach is to return out of the extension as soon as you identify it should not be run. This also keeps the nesting level at bay. if (newType.equals(Newtry.fWorkItemTypeId)) return; You would probably also want to check for null values. Just a recommendation that helps us with avoiding repeatedly answering the the most basic questions: Just Starting With Extending RTC? If you just get started with extending Rational Team Concert, or create API based automation, start reading this and the linked posts to get some guidance on how to set up your environment. Then I would suggest to read the article Extending Rational Team Concert 3.x and perform the Rational Team Concert 4.0 Extensions Workshop. This provides you with a development environment and with a lot of example code and information that is essential to get started. If you have already done the Rational Team Concert 4.0 Extensions Workshop you can just perform Lab1 to setup your development environment for debugging. If you want to create code with the Plain Java Client Libraries or the RTC Client SDK please also work through Understanding and Using the RTC Java Client API, to understand the basics of the API and how you can use Eclipse to debug the code. Working with Work Item Attributes is also a useful resource to understand how work item attributes work. mohan kumar selected this answer as the correct answer
|
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.