How to Set Attribute of a Work Item in an Asynchrounous Task?
Hi,
I'm implementing an asynchronous task and have gotten some work items as I expected.
My question is, how to set a specific attribute with my own value for a work item?
Is it possible to do that in an asynchronous task?
I've tried to get a workingCopy before I call the setValue method.
However, it returns an 'assertion exception' and I have no idea how to deal with it.
Please help on this issue, thanks!
I'm implementing an asynchronous task and have gotten some work items as I expected.
My question is, how to set a specific attribute with my own value for a work item?
Is it possible to do that in an asynchronous task?
I've tried to get a workingCopy before I call the setValue method.
However, it returns an 'assertion exception' and I have no idea how to deal with it.
Please help on this issue, thanks!
3 answers
Hello Kenery,
IWorkItem findWorkItem = workItemClient.findWorkItemById(currentWorkItemID, IWorkItem.FULL_PROFILE, monitor);
IWorkItemHandle wiHandle = (IWorkItemHandle) findworkItem.getItemHandle();
IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();
wcm.connect(handle, IWorkItem.FULL_PROFILE, null);
WorkItemWorkingCopy wc = wcm.getWorkingCopy(handle);
IWorkItem wcWorkItem = wc.getWorkItem(); /* do whatever you want */ wc.save(monitor);
Comments
I'm assuming that saying "asynchronous task" you mean an event handler (as advisor and follow-up are synchronous).
On server side you need to use this, where workItemService is an instance of IWorkItemServer:
On server side you need to use this, where workItemService is an instance of IWorkItemServer:
IWorkItem freshCopy = (IWorkItem)workItemService.findWorkItemById(wi.getId(), IWorkItem.FULL_PROFILE, null).getWorkingCopy(); freshCopy.setValue(automationAttribute, Boolean.valueOf(false)); workItemService.saveWorkItem2(freshCopy, null, null);
Comments
showing 5 of 11
show 6 more comments
16:43:40,026 [jazz: AsynchronousTaskRunner-2 @@ 16:41] ERROR com.ibm.team.repository - CRJAZ0852I An exception occurred while executing the task "Delay_Days_Monitor_taskID", contributed by component "com.ibm.team.repository". The task will be removed from the schedule.
org.eclipse.core.runtime.AssertionFailedException: assertion failed:
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.setValue(WorkItemImpl.java:2909)
at com.delta.workitem.asynchronousTask.DelayDaysMonitor.setAttribute(DelayDaysMonitor.java:207)
at com.delta.workitem.asynchronousTask.DelayDaysMonitor.findDelayWorkItem(DelayDaysMonitor.java:193)
at com.delta.workitem.asynchronousTask.DelayDaysMonitor.runTask(DelayDaysMonitor.java:103)
at com.ibm.team.repository.service.async.AbstractAutoScheduledTask.executeTask(AbstractAutoScheduledTask.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
at com.sun.proxy.$Proxy834.executeTask(Unknown Source)
at com.ibm.team.repository.service.internal.scheduler.AsynchronousTaskRunner.runTask(AsynchronousTaskRunner.java:185)
at com.ibm.team.repository.service.internal.scheduler.AsynchronousTaskRunner.run(AsynchronousTaskRunner.java:138)
at java.lang.Thread.run(Thread.java:761)