[Java]Change Programatically state of Work Item
Hello,
I need to change the state of a work item.
I have done the following:
public void changeWorkItemsState(IWorkItem workItem,
ITeamRepository repository, IProjectArea projectArea)throws TeamRepositoryException {
IAttribute internalState = findAttribute(repository, projectArea,"internalState");
Object value = workItem.getValue(internalState);
Object newWorkItemState = "TEST.project.WorkFlow.state.s3";
workItem.setValue(internalState, newWorkItemState);
}
However,I get the following IPE exception:
Thanks in advance.
I need to change the state of a work item.
I have done the following:
public void changeWorkItemsState(IWorkItem workItem,
ITeamRepository repository, IProjectArea projectArea)throws TeamRepositoryException {
IAttribute internalState = findAttribute(repository, projectArea,"internalState");
Object value = workItem.getValue(internalState);
Object newWorkItemState = "TEST.project.WorkFlow.state.s3";
workItem.setValue(internalState, newWorkItemState);
}
However,I get the following IPE exception:
Exception in thread "main" com.ibm.team.repository.common.internal.ImmutablePropertyException at com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2051) at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380) at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.setInternalState(WorkItemImpl.java:1045) at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.eSet(WorkItemImpl.java:2430) at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1081) at com.ibm.team.workitem.common.internal.PropertyUtil.set(PropertyUtil.java:120) at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.setValue(WorkItemImpl.java:2949) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:600)
Thanks in advance.
Accepted answer
Hi Fatla,
first you need a workingcopy and then you have to use another operation that sets the workflow action. You would use a workItemSave operation.
Currently you could use setState, but that is deprecated. I have written something up around this here: http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/
first you need a workingcopy and then you have to use another operation that sets the workflow action. You would use a workItemSave operation.
Currently you could use setState, but that is deprecated. I have written something up around this here: http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/
Comments
showing 5 of 13
show 8 more comments