Re: Changing States of workitems programatically
10 answers
the IWorkflowInfo object has methods to get all the IDs and their text names.
the IWorkflowInfo can be located off the operation data
the IWorkflowInfo can be located off the operation data
Object data= operation.getOperationData();
ISaveParameter p = (ISaveParameter)data;
IAuditableCommon iac = p.getSaveOperationParameter().getAuditableCommon();
WorkflowManager wfm = new WorkflowManager(iac);
// get the workflow this workitem is in, so we can get the labels of the states
IWorkItem workItem = (IWorkItem) auditable;
IWorkflowInfo x =wfm.getWorkflowInfo(workItem, monitor);
Hi All,
I am implementing a custom participant plugin. Based on certain conditions, i need to change the state of the workitem. I am using the setstate2() function, but not sure how to get the value of the Identifier <IState> for all the available states in the workflow.
Thanks.
setState2 will not work. You have to use IWorkItemServer.saveWorkItem2 method.
Best regards,
Michele.
Hello.
My code looks like this:
IWorkItem sourceworkItem = (IWorkItem) auditable;
IProjectAreaHandle projectArea = sourceworkItem.getProjectArea();
IItemHandle item = sourceworkItem.getItemHandle();
IAuditableCommon iac = ((ISaveParameter) data).getSaveOperationParameter().getAuditableCommon();
Integer Id = sourceworkItem.getId();
String parentWItype = sourceworkItem.getWorkItemType();
IWorkItemServer workItemServer = this.getService(IWorkItemServer.class);
IStatus a1 = workItemServer.saveWorkItem(sourceworkItem, "Close");
I am getting a stale state error. I tried using the workingcopy, but unable to find the save method.
My code looks like this:
IWorkItem sourceworkItem = (IWorkItem) auditable;
IProjectAreaHandle projectArea = sourceworkItem.getProjectArea();
IItemHandle item = sourceworkItem.getItemHandle();
IAuditableCommon iac = ((ISaveParameter) data).getSaveOperationParameter().getAuditableCommon();
Integer Id = sourceworkItem.getId();
String parentWItype = sourceworkItem.getWorkItemType();
IWorkItemServer workItemServer = this.getService(IWorkItemServer.class);
IStatus a1 = workItemServer.saveWorkItem(sourceworkItem, "Close");
I am getting a stale state error. I tried using the workingcopy, but unable to find the save method.
Hi Sam,
I get the below errors after including "com.ibm.team.workitem.client" dependency in manifest file:
2012-05-28 15:38:58,168 ERROR eam.repository.provision.internal.ProvisionService - CRJAZ0291I Failed to start the bundle "advisor.example 1.0.0.201205281530".
org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Require-Bundle: com.ibm.team.workitem.client; bundle-version="3.0.2"
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1313)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1297)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:309)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:272)
at com.ibm.team.repository.provision.internal.ProvisionService.startFeatureBundles(ProvisionService.java:1341)
at com.ibm.team.repository.provision.internal.ProvisionService.installFromProfiles(ProvisionService.java:1049)
at com.ibm.team.repository.provision.internal.ProvisionService.installFromProfileNoWait(ProvisionService.java:1146)
at com.ibm.team.repository.provision.internal.ProvisionService.installFromProfile(ProvisionService.java:1084)
at com.ibm.team.repository.provision.internal.ProvisionService.installFromContextConfigurationUrl(ProvisionService.java:1163)
at com.ibm.team.repository.web.internal.Activator$1.run(Activator.java:125)
at java.lang.Thread.run(Thread.java:811)
* The component is available in the target platform path though (SDK).
Thanks.
I get the below errors after including "com.ibm.team.workitem.client" dependency in manifest file:
2012-05-28 15:38:58,168 ERROR eam.repository.provision.internal.ProvisionService - CRJAZ0291I Failed to start the bundle "advisor.example 1.0.0.201205281530".
org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Require-Bundle: com.ibm.team.workitem.client; bundle-version="3.0.2"
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1313)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1297)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:309)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:280)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:272)
at com.ibm.team.repository.provision.internal.ProvisionService.startFeatureBundles(ProvisionService.java:1341)
at com.ibm.team.repository.provision.internal.ProvisionService.installFromProfiles(ProvisionService.java:1049)
at com.ibm.team.repository.provision.internal.ProvisionService.installFromProfileNoWait(ProvisionService.java:1146)
at com.ibm.team.repository.provision.internal.ProvisionService.installFromProfile(ProvisionService.java:1084)
at com.ibm.team.repository.provision.internal.ProvisionService.installFromContextConfigurationUrl(ProvisionService.java:1163)
at com.ibm.team.repository.web.internal.Activator$1.run(Activator.java:125)
at java.lang.Thread.run(Thread.java:811)
* The component is available in the target platform path though (SDK).
Thanks.
Thanks Sam. This is the brief of my code:
IWorkItemServer service = getService(IWorkItemServer.class);
IWorkItem a = service.findWorkItemById(145, IWorkItem.FULL_PROFILE, monitor);
for (IAttributeHandle ia:a.getCustomAttributes())
{
IAttribute attribute= iac.resolveAuditable(ia,IAttribute.FULL_PROFILE, monitor);
a.setValue(attribute, finalexp);
IStatus st1 = service.saveWorkItem2(a, null, null);
I am getting assertion failed error at the setvalue method of the attribute. I read that we need to get a working copy of the item. My plugin is a server-side plugin and i couldnt find any options to setvalue or save work item using a working copy. How can this be done?
Thanks.
IWorkItemServer service = getService(IWorkItemServer.class);
IWorkItem a = service.findWorkItemById(145, IWorkItem.FULL_PROFILE, monitor);
for (IAttributeHandle ia:a.getCustomAttributes())
{
IAttribute attribute= iac.resolveAuditable(ia,IAttribute.FULL_PROFILE, monitor);
a.setValue(attribute, finalexp);
IStatus st1 = service.saveWorkItem2(a, null, null);
I am getting assertion failed error at the setvalue method of the attribute. I read that we need to get a working copy of the item. My plugin is a server-side plugin and i couldnt find any options to setvalue or save work item using a working copy. How can this be done?
Thanks.