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

Action result states do not match workflow states

I am trying to programmatically determine which workflow action to execute in order to transition workflow state for a defect. I use the following methods to accomplish this task:

IWorkItem.getState2() - to get the id of the current state
IWorkflowInfo.getAllStateIds() - to find the id of target state
IWorkflowInfo.getActionIds(Identifier<IState>) - to get valid actions in the current state
getActionResultState(Identifier<IWorkflowAction>) - to get the result state id for each action.

The problem is, the state id from getActionResultState does not match any of the state ids from getAllStateIds, so I am unable to determine the required action.

In fact, none of the action result state ids match any of the state ids from the getAllStateIds method.

Is this a bug, or is there another way to accomplish this task?

0 votes



5 answers

Permanent link
I am trying to programmatically determine which workflow action to
execute in order to transition workflow state for a defect. I use
the following methods to accomplish this task:

IWorkItem.getState2() - to get the id of the current state
IWorkflowInfo.getAllStateIds() - to find the id of target state
IWorkflowInfo.getActionIds(Identifier<IState>) - to get valid
actions in the current state
getActionResultState(Identifier<IWorkflowAction>) - to get the
result state id for each action.

The problem is, the state id from
getActionResultState does not match any
of the state ids from getAllStateIds, so
I am unable to determine the required action.

In fact, none of the action result state ids match any of the state
ids from the getAllStateIds method.

Is this a bug, or is there another way to accomplish this task?

Could you paste a snippet of code that illustrates the calls in context?
What you describe sounds basically ok, and maybe we can spot the problem.

--
Regards,
Patrick
Jazz Work Item Team

0 votes


Permanent link
I am trying to programmatically determine which workflow action to
execute in order to transition workflow state for a defect. I use
the following methods to accomplish this task:

IWorkItem.getState2() - to get the id of the current state
IWorkflowInfo.getAllStateIds() - to find the id of target state
IWorkflowInfo.getActionIds(Identifier<IState>) - to get valid
actions in the current state
getActionResultState(Identifier<IWorkflowAction>) - to get the
result state id for each action.

The problem is, the state id from
getActionResultState does not match any
of the state ids from getAllStateIds, so
I am unable to determine the required action.

In fact, none of the action result state ids match any of the state
ids from the getAllStateIds method.

Is this a bug, or is there another way to accomplish this task?

Could you paste a snippet of code that illustrates the calls in context?
What you describe sounds basically ok, and maybe we can spot the problem.

--
Regards,
Patrick
Jazz Work Item Team

The silly method below illustrates the problem, it will ALWAYS return null:

public Identifier<IWorkflowAction> getAction( IWorkItem workItem,

IWorkflowInfo workflowInfo )
{
Identifier<IWorkflowAction> findActionId = null;
Identifier<IState>[] allStates = workflowInfo.getAllStateIds();
Identifier<IState> curState = workItem.getState2();

for (Identifier<IState> stateId : allStates)
{
Identifier<IWorkflowAction>[] allActions = workflowInfo
.getActionIds( curState );

for (Identifier<IWorkflowAction> actionId : allActions)
{
Identifier<IState> resultState = workflowInfo
.getActionResultState( actionId );

if (resultState.equals( stateId ))
{
findActionId = actionId;
}
}
}

return findActionId;
}

0 votes


Permanent link
The silly method below illustrates the problem, it will
ALWAYS return null:
public Identifier<IWorkflowAction
getAction( IWorkItem workItem,
IWorkflowInfo workflowInfo )
{

I can't see anything obvious in the code. When you print out the states,
is there a pattern why they don't match? Originally, states were integers
and later changed to strings. There is come compatibility code that
transforms identifier like 's2' back to '2'. So If some of the states that
are compared have the identifiers 's1, s2, s3' and others '1, 2, 3', this
would explain why they never match.

--
Regards,
Patrick
Jazz Work Item Team

0 votes


Permanent link
I can't see anything obvious in the code. When you print out the states, is there a pattern why they don't match? Originally, states were integers and later changed to strings. There is come compatibility code that transforms identifier like 's2' back to '2'. So If some of the states that are compared have the identifiers 's1, s2, s3' and others '1, 2, 3', this would explain why they never match.

--
Regards,
Patrick
Jazz Work Item Team

0 votes


Permanent link
I can't see anything obvious in the code. When you print out the states, is there a pattern why they don't match? Originally, states were integers and later changed to strings. There is come compatibility code that transforms identifier like 's2' back to '2'. So If some of the states that are compared have the identifiers 's1, s2, s3' and others '1, 2, 3', this would explain why they never match.

--
Regards,
Patrick
Jazz Work Item Team


That is exactly what appears to be happening, the action result states have identifiers that begin with the 's' character. What is this compatibility code of which you speak?

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,927

Question asked: May 18 '09, 12:35 p.m.

Question was seen: 6,163 times

Last updated: May 18 '09, 12:35 p.m.

Confirmation Cancel Confirm