How can I get a STATE Name of workitem in RTCClientplainJava
Accepted answer
It's very old question but I hope it will help someone.
private String getStateName(IWorkItem workItem, IProgressMonitor monitor) throws TeamRepositoryException {
if (workItem != null) {
Identifier<IState> state = workItem.getState2();
IWorkflowInfo workflowInfo = workItemClient.findWorkflowInfo(workItem, monitor);
return workflowInfo.getStateName(state);
}
return null;
if (workItem != null) {
Identifier<IState> state = workItem.getState2();
IWorkflowInfo workflowInfo = workItemClient.findWorkflowInfo(workItem, monitor);
return workflowInfo.getStateName(state);
}
return null;
}
2 other answers
I don't know how to get the first data item in a client
but here is a snippet of code I use in an Advisor.
you need the IWorkflowInfo object for this workitem.
but here is a snippet of code I use in an Advisor.
you need the IWorkflowInfo object for this workitem.
IAuditableCommon iac = ((ISaveParameter) data).getSaveOperationParameter().getAuditableCommon();
WorkflowManager wfm = new WorkflowManager(iac);
// reference the right object type (cast)
IWorkItem workItem = (IWorkItem) auditable;
// get the workflow this workitem is in, so we can get the labels of the states
IWorkflowInfo x =wfm.getWorkflowInfo(workItem, monitor);
if(Debug) System.out.println("the workitem state is "+ workItem.getState2().getStringIdentifier()+ "=" +x.getStateName(workItem.getState2()) );
// if this workitem is going into resolved state (we accessed 'proposed new' state above
if(x.getStateName(workItem.getState2()).equalsIgnoreCase(ResolvedState))
I want to get the STATE name of a work item, i tried with the below code it returns the State not the Name.
workItem.getState2().getStringIdentifier()
We found a solution in this post: https://jazz.net/forums/viewtopic.php?p=74030#74030
But that method
com.ibm.team.workitem.client.WorkflowUtilities.findWorkflowInfo(IWorkItem, IProgressMonitor).getStateName(Identifier<IState>)is not very perfomant... :?