How to programme the prerequisites in plugin.xml?
Problem
The service 'helloworldadvisor.WorkItemSave@332a332a' failed to find the required service 'interface com.ibm.team.workitem.common.IAuditableCommon'. Check <prerequisites> in plugin.xml.
plugin.xml
The service 'helloworldadvisor.WorkItemSave@332a332a' failed to find the required service 'interface com.ibm.team.workitem.common.IAuditableCommon'. Check <prerequisites> in plugin.xml.
plugin.xml
<?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.4"?> <plugin> <extension point="com.ibm.team.process.service.operationAdvisors"> <operationAdvisor class="helloworldadvisor.WorkItemSave"
id="HelloWorldAdvisor.prohibitSave"
name="Prohibit Save (Hello World Advisor)"
operationId="com.ibm.team.workitem.operation.workItemSave">
</operationAdvisor>
</extension>
</plugin>
WorkItemSave.java
package helloworldadvisor; import java.sql.Timestamp;
import org.eclipse.core.runtime.IProgressMonitor;
import com.ibm.team.repository.service.AbstractService;
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.repository.common.UUID;
import com.ibm.team.workitem.common.IAuditableCommon;
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.common.model.IWorkItemType;
import com.ibm.team.workitem.common.model.Identifier;
public class WorkItemSave 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 {
System.out.println("--->AbstractService");
Object data = operation.getOperationData();
if (!(data instanceof ISaveParameter))
return;
ISaveParameter saveParameter = (ISaveParameter) data;
IAuditableCommon auditableCommon= (IAuditableCommon) getService(IAuditableCommon.class);
if (!(saveParameter.getNewState() instanceof IWorkItem))
return;
IWorkItem newState= (IWorkItem) saveParameter.getNewState();
String strWorkItemType = newState.getWorkItemType();
System.out.println("strWorkItemType--->" + strWorkItemType + "---");
if (!"task".equals(strWorkItemType.trim())) {
System.out.println("--->return");
return;
}
System.out.println("--->next step001");
Identifier newStateId = newState.getState2();
String state = newStateId.getStringIdentifier();
if (null != state) {
System.out.println("uuidStateId--->" + state);
}
System.out.println("--->next step002");
//set currentUser to owner
newState.setOwner(auditableCommon.getUser());
IWorkItemCommon workItemCommon= this.getService(IWorkItemCommon.class);
//set currentUser to approveaaa
IAttribute target= workItemCommon.findAttribute(newState.getProjectArea(), "approveaaa", monitor);
newState.setValue(target, auditableCommon.getUser());
System.out.println("--->next step003");
//set now to date
long now= System.currentTimeMillis();
IAttribute targetdate= workItemCommon.findAttribute(newState.getProjectArea(), "updatedate", monitor);
newState.setValue(targetdate, new Timestamp(now));
System.out.println("--->next step004");
IAuditable auditable = saveParameter.getNewState();
}
}
Accepted answer
Carefully read https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/
You also might want to search this forum. I am pretty sure the question has been asked and answered before.
I think I also sent you a bunch of copies of my blog posts and they also have links to download the code, so you can check e.g. the differences in the plugin XML.
The prerequisites are set this way:
You also might want to search this forum. I am pretty sure the question has been asked and answered before.
I think I also sent you a bunch of copies of my blog posts and they also have links to download the code, so you can check e.g. the differences in the plugin XML.
The prerequisites are set this way: