It's all about the answers!

Ask a question

How to create the RTC project using OperationAdvisor plugin


Dashrath Kale (1542623) | asked Oct 27 '10, 5:13 a.m.
Hi

I need to create the RTC project Area using Operation Advisor Plugin on saving the workitem and for that I am using the below script code but it does not give any after execution and also does not work as expected.

I am refering the below article for this:

http://jazz.net/library/article/495

If anyone knows where I am missing , please let me know.


package helloworldadvisor;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;

import com.ibm.team.process.client.IProcessItemService;
import com.ibm.team.process.common.IProcessConfigurationElement;
import com.ibm.team.process.common.IProcessDefinition;
import com.ibm.team.process.common.IProjectArea;
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.repository.service.AbstractService;
import com.ibm.team.workitem.common.ISaveParameter;
import com.ibm.team.workitem.common.model.IWorkItem;

@SuppressWarnings("unchecked")
public class HelloWorldProhibitSave extends AbstractService implements IOperationAdvisor {
public static final String PROBLEM_TYPE = " HelloWorldAdvisor.prohibitSave";

public void run(AdvisableOperation operation,
IProcessConfigurationElement advisorConfiguration,
IAdvisorInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {

Object data = operation.getOperationData();

if (data instanceof ISaveParameter) {
ISaveParameter param = (ISaveParameter) data;
IAuditable auditable = param.getNewState();
if (auditable instanceof IWorkItem) {
IAdvisorInfo info = collector.createProblemInfo("ON-BOARDING",
"project created successfully", "error");
collector.addInfo(info);

IProcessItemService service = getService(IProcessItemService.class);
IProcessDefinition[] definitions = service
.deployPredefinedProcessDefinitions(
new String[] { "scrum.process.hsbc.com" },
new NullProgressMonitor());

IProjectArea projectArea = service.createProjectArea();
projectArea.setProcessDefinition(definitions[0]);
projectArea.setName("PluginTestProject");
projectArea = (IProjectArea) service.save(projectArea, monitor);
System.out.println("project created successfully");

}
}
}
}

6 answers



permanent link
Dashrath Kale (1542623) | answered Oct 27 '10, 5:15 a.m.
Sorry , below is the code having problem:

package helloworldadvisor;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;

import com.ibm.team.process.client.IProcessItemService;
import com.ibm.team.process.common.IProcessConfigurationElement;
import com.ibm.team.process.common.IProcessDefinition;
import com.ibm.team.process.common.IProjectArea;
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.repository.service.AbstractService;
import com.ibm.team.workitem.common.ISaveParameter;
import com.ibm.team.workitem.common.model.IWorkItem;

@SuppressWarnings("unchecked")
public class HelloWorldProhibitSave extends AbstractService implements IOperationAdvisor {
public static final String PROBLEM_TYPE = " HelloWorldAdvisor.prohibitSave";

public void run(AdvisableOperation operation,
IProcessConfigurationElement advisorConfiguration,
IAdvisorInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {

Object data = operation.getOperationData();

if (data instanceof ISaveParameter) {
ISaveParameter param = (ISaveParameter) data;
IAuditable auditable = param.getNewState();
if (auditable instanceof IWorkItem) {
IProcessItemService service = getService(IProcessItemService.class);
IProcessDefinition[] definitions = service
.deployPredefinedProcessDefinitions(
new String[] { "scrum.process.hsbc.com" },
new NullProgressMonitor());

IProjectArea projectArea = service.createProjectArea();
projectArea.setProcessDefinition(definitions);
projectArea.setName("PluginTestProject");
projectArea = (IProjectArea) service.save(projectArea, monitor);
System.out.println("project created successfully");
IAdvisorInfo info = collector.createProblemInfo("ON-BOARDING",
"project created successfully", "error");
collector.addInfo(info);
}
}
}
}



		                                        

permanent link
Qiong Feng Huang (76911610) | answered Oct 27 '10, 5:59 a.m.
JAZZ DEVELOPER
Let me try to understand your problem: You want to create project area automatically after you perform a specific operation (saving a work item). If so, I would say you should use Operation Participants instead of Operation Advisor. Operation Advisor means you want to do some pre-checking before you perform a specific operation. Please see the wiki doc about OperationAdviso(pre-condition) and OperationParticipants(follow-up action): https://jazz.net/wiki/bin/view/Main/PreconditionFollowupCreation

permanent link
Dashrath Kale (1542623) | answered Oct 28 '10, 1:48 a.m.
huang

Thank you very much for your reply.

Actually before my requirement is as below:

1) When I click on the save button of the workitem I need to change the value of on of custom attribute by retriving other attribute values of the same workitem.
2)Also these values needs to be validated before actually saving the workitem.
3)If the values are correct then I need to take those values and using those values ProjectArea needs to be created and if there is any problem while validating the attribute values or creating the RTC Project Area the workitem should not be saved and proper error should be mentioned on Team Advisor.

Let me know if you need to any more details.

permanent link
Qiong Feng Huang (76911610) | answered Oct 29 '10, 8:46 a.m.
JAZZ DEVELOPER
OK.
Then, what do you mean "it does not give any after execution and also does not work as expected" ? Do you see the precondition created by yourself in the project area editor after you install and provision your plugin in RTC server? Or, your precondition has already been installed in the server and you have already set this precondition in process configuration, but the precondition didn't work as expected?

permanent link
Dashrath Kale (1542623) | answered Nov 09 '10, 5:43 a.m.
Hi huang, I have installed the plugin on the server and also added as precondition in the process configuration but I am not getting the result as expected i.e. project area is not getting created and also not getting any error in the Team Advisor console in the RTC eclipse client.

It will be good for me if you have any sample code which I can refer for my work.

permanent link
Thomas Yu (45183) | answered Nov 09 '10, 8:50 p.m.
Hi huang, I have installed the plugin on the server and also added as precondition in the process configuration but I am not getting the result as expected i.e. project area is not getting created and also not getting any error in the Team Advisor console in the RTC eclipse client.

It will be good for me if you have any sample code which I can refer for my work.


Are you able to debug your code?If you are not, following article will be a good one for you to setup the debug environment.

http://jazz.net/library/article/477
Lab 1 of IBM Rational Team Concert Extensibility Workshop is about the debug environment setup.It would be helpful if you can debug what happens in your code.

Your answer


Register or to post your answer.