Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Re: Changing States of workitems programatically

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.

0 votes



10 answers

Permanent link
the IWorkflowInfo object has methods to get all the IDs and their text names.

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);

0 votes


Permanent link
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.

0 votes


Permanent link
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.

0 votes


Permanent link
you don't SAVE WITH the workingCopy class.. you GET a workingCopy (read/write) of the workitem (read only)..

then you save THAT with the saveWorkItem2() method

0 votes


Permanent link
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.

0 votes


Permanent link
see my response in your other post.

net you can't use '.client' classes on the 'server'. '.client' is for Eclipse or standalone application side.

0 votes


Permanent link
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.

0 votes


Permanent link
you cannot save the read only copy of the workitem..
you must get & modify and save the workingcopy

// reference the right object type (cast)
IWorkItem workItem = (IWorkItem) auditable;
IWorkItem rr = (IWorkItem)workItem.getWorkingCopy();

0 votes


Permanent link
Thanks Sam. I figured it out and it works now.

0 votes


Permanent link
Thanks Sam. I figured it out and it works now.


Wonderful!

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: May 24 '12, 3:59 a.m.

Question was seen: 6,527 times

Last updated: May 24 '12, 3:59 a.m.

Confirmation Cancel Confirm