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

How to fetch the all work flow states based on the every Work Item Type in IBM RTC using Java API?

 Hi All,
 I want to display the All the Work flow states based on the selected Work Item Type. Please help me on this.

Regards,
Ramesh M

0 votes



2 answers

Permanent link
Ramesh,

starting from
IWorkItemHandle wiHandle;
you need to resolve this to a full work item:
IAuditableCommon auditableCommon = (IAuditableCommon) teamRepository.getClientLibrary(IAuditableCommon.class);
IWorkItem workItem = auditableCommon.resolveAuditable(wiHandle, IWorkItem.SMALL_PROFILE, null);
Then obtain a workItemClient and use it to get an IWorkflowInfo object then use its .getAllStateIds method:
IWorkItemClient workItemClient = (IWorkItemClient) teamRepository
                    .getClientLibrary(IWorkItemClient.class);
IWorkflowInfo workflowInfo = workItemClient.findWorkflowInfo(workItem, monitor);
List< IState> allStates = workflowInfo.getAllStateIds();
If you want the names of the states, loop over the list and use
workflowInfo.getStateName();

If this is helpful please mark the answer as accepted.
- Arne

0 votes

Comments

 HI Arne,

             Thanks for the clear explanation. bu i am getting null pointer exception on below.
Please assist on below.

        IAuditableCommon auditableCommon = (IAuditableCommon) repository.getClientLibrary(IAuditableCommon.class);

 how to initialize the IWorkItemHandle wiHandle;

Regards,
Ramesh

Ramesh,

please work through https://jazz.net/library/article/1000 to be up to par with terminology.
Then please describe where you are starting from. Are you using a client plugin, a server side extension or are you e.g. writing a java script against Plain Java API?

In either case at one point you need to query for a work item by name, by id or some other mechanism. Please cp. the excellent article from Ralph Schoon on work item querying: https://rsjazz.wordpress.com/2012/11/19/using-expressions-for-automation/

Using any such technique will leave you with either a valid IWorkItemHandle or possibly already a full IWorkItem.
Once you log in (basic exercise in workshop or the snippets shipped with Plain Java SDK) from the session you can obtain the necessary ITeamRepository object.

Then you should be all set.

gg,
Arne


Permanent link
 Hi All ,
I found the solutions to retrive the all the states based on the work item type. Please find code from below.

First Step1 :
 ITeamRepository iTeamRepository ; Login in to RTC

IWorkItemCommon workItemCommon = (IWorkItemCommon) iTeamRepository.getClientLibrary(IWorkItemCommon.class);

Step2 : use Work Item Common get the Work item types:
List<IWorkItemType> workItemTypes = null;
workItemTypes = workItemCommon.findWorkItemTypes(projectArea, monitor);

Step3:
IWorkItemClient workItemClient = (IWorkItemClient) iTeamRepository.getClientLibrary(IWorkItemClient.class);

Step4:
IWorkItemWorkingCopyManager workingManager = workItemClient.getWorkItemWorkingCopyManager();

Step5:
Iterate the work item types to get states:
List status = new ArrayList();
for (IWorkItemType iworkItemType : workItemTypes) {
wc = workingManager.getWorkingCopy(workingManager.connectNew(iworkItemType, monitor));
workFlowInfo = workItemCommon.findWorkflowInfo(wc.getWorkItem(), monitor);
states = workFlowInfo.getAllStateIds();
for (Identifier<IState> identifier : states) {
                                       sysout(workFlowInfo.getStateName(identifier))
status.add(workFlowInfo.getStateName(identifier));
}
}

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
× 12,014

Question asked: Sep 07 '15, 9:41 a.m.

Question was seen: 2,981 times

Last updated: Sep 09 '15, 9:52 a.m.

Confirmation Cancel Confirm