It's all about the answers!

Ask a question

REST | OSLC : How to get workitem types, its workflow and then the actions possible in that workflow?


0
1
Sunil Kumar R (1.1k12643) | asked Sep 24 '14, 9:37 a.m.
JAZZ DEVELOPER
I am looking for some pointers to connect the workitem type --> workitem Workflow.

1. I use the workitem services URL to get the workitem types in a project area..
eg : https://clm.admin.ws/ccm/oslc/contexts/_u4qKYqUSEeOZfPTW9a4EhA/workitems/services.xml

2.1 I am interested in looking at the states / actions available in a particular workitem type.
eg: https://clm.admin.ws/ccm/oslc/types/_u4qKYqUSEeOZfPTW9a4EhA/defect
2.2. The URL to which will be :
https://clm.admin.ws/ccm/oslc/workflows/_u4qKYqUSEeOZfPTW9a4EhA/actions/com.ibm.team.workitem.defectWorkflow

I am looking for pointers on how to get from 2.1 to 2.2 using REST/ OSLC. I tried various ways but somehow the workitem type and links to their workflows dont seem to have a continuum.

Is there a sequential step to get from workitem type to its workflow link?
-or- 1 place where we can look at both workitem types, and the links to their workflows?

Thanks in advance...



Accepted answer


permanent link
Donald Nong (14.4k314) | answered Sep 24 '14, 11:58 p.m.
Hi Sunil,
At your step 2.1, check the work item "shape" rather than the type itself, namely
https://clm:9443/ccm/oslc/context/_pz7gsD7rEeSp1IF8DHJaNQ/shapes/workitems/defect
In the output, look for the "state" attribute and it should contain all the allowed state values
<oslc:AllowedValues rdf:about="https://clm:9443/ccm/oslc/context/_pz7gsD7rEeSp1IF8DHJaNQ/shapes/workitems/defect/property/internalState/allowedValues">
<oslc:allowedValue rdf:resource="https://clm:9443/ccm/oslc/workflows/_pz7gsD7rEeSp1IF8DHJaNQ/states/com.ibm.team.workitem.defectWorkflow/4"/>
<oslc:allowedValue rdf:resource="https://clm:9443/ccm/oslc/workflows/_pz7gsD7rEeSp1IF8DHJaNQ/states/com.ibm.team.workitem.defectWorkflow/3"/>
<oslc:allowedValue rdf:resource="https://clm:9443/ccm/oslc/workflows/_pz7gsD7rEeSp1IF8DHJaNQ/states/com.ibm.team.workitem.defectWorkflow/6"/>
<oslc:allowedValue rdf:resource="https://clm:9443/ccm/oslc/workflows/_pz7gsD7rEeSp1IF8DHJaNQ/states/com.ibm.team.workitem.defectWorkflow/1"/>
<oslc:allowedValue rdf:resource="https://clm:9443/ccm/oslc/workflows/_pz7gsD7rEeSp1IF8DHJaNQ/states/com.ibm.team.workitem.defectWorkflow/2"/>
</oslc:AllowedValues>
You also get the workflow id at the same time. Replace the "states" with "actions" in the URL and you will get all the actions in the workflow.
https://clm:9443/ccm/oslc/workflows/_pz7gsD7rEeSp1IF8DHJaNQ/actions/com.ibm.team.workitem.defectWorkflow
The challenge is to determine the allowed action(s) for a particular state, which does not seem possible with OSLC at this stage.
https://jazz.net/forum/questions/152920/how-find-available-actions-to-change-states-in-rtc-with-oslc
It is doable using Java API though.
http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/

Sunil Kumar R selected this answer as the correct answer

Comments
Sunil Kumar R commented Sep 29 '14, 8:36 a.m. | edited Sep 29 '14, 8:37 a.m.
JAZZ DEVELOPER

Donald, thank you. But using the 'shapes' URL gives me a 'HTTP 406 Not Acceptable' message with data..
eg: https://clm.admin.ws/ccm/oslc/context/_u4qKYqUSEeOZfPTW9a4EhA/shapes/workitems/defect
<oslc_cm:error>

<oslc_cm:status>406</oslc_cm:status>
<oslc_cm:message>OSLC Version '1.0' is not supported.</oslc_cm:message>
</oslc_cm:error>

Could this be occuring due to missing header..?

Thanks in advance..


1
Donald Nong commented Sep 29 '14, 7:55 p.m.

Yes it looks like an HTTP header is missing. Here are the two HTTP headers that I use most of the time for OSLC requests.

Accept: application/rdf+xml
OSLC-Core-Version: 2.0
If you omit the "OSLC-Core-Version" header, the default "OSLC-Core-Version: 1.0" will be assumed.


Sunil Kumar R commented Sep 30 '14, 6:27 a.m.
JAZZ DEVELOPER

Thanks a lot Donald! Yes, I am able to get the data as expected using the header, steps above.

One other answer



permanent link
Sunil Kumar R (1.1k12643) | answered Sep 30 '14, 6:42 a.m.
JAZZ DEVELOPER
In summary I used the steps as below....
To get from a project area to its workitem type(s) and then from the workitem type to its possible actions.


Using RESTClient on FireFox; with headers 'Accept: application/rdf+xml' and 'OSLC-Version: 2.0'
1. Obtain list of RTC project area ids using URL below.
https://clm.admin.ws/ccm/process/project-areas

2. Query for workitem type(s) available in this project area using the workitem services URL.
Append '/workitems/services.xml' to the URL from Step 1 and perform a GET.
https://clm.admin.ws/ccm/oslc/contexts/_u4qKYqUSEeOZfPTW9a4EhA/workitems/services.xml

2.1. Look for the workitem calm:id of which the workitem actions are to be known and note down its
<oslc:cm:url>
https://clm.admin.ws/ccm/oslc/contexts/_u4qKYqUSEeOZfPTW9a4EhA/workitems/defect

3. Query for the 'shape' of the workitem obtained in 2.1 to get to its possible actions.
To do this, append '/shapes' and chance '/contexts' to '/context' in the URL from step 2.1 as shown in example below and perform a GET.
https://clm.admin.ws/ccm/oslc/context/_u4qKYqUSEeOZfPTW9a4EhA/shapes/workitems/defect

3.1. Look for a sample "oslc:allowedValue" under rdf:description rdf:about ending with “/property/internalState/allowedValues” to get to the workflow link for defect.
https://clm.admin.ws/ccm/oslc/workflows/_u4qKYqUSEeOZfPTW9a4EhA/states/com.ibm.team.workitem.defectWorkflow/4

4. Query for possible actions in the defect workitem. Replace '/states' with '/actions' and remove the workflow index '/4' for example and perform GET on the URL obtained.
https://clm.admin.ws/ccm/oslc/workflows/_u4qKYqUSEeOZfPTW9a4EhA/actions/com.ibm.team.workitem.defectWorkflow

Comments
Jonas Studer commented Jul 27 '16, 6:50 a.m.

Hello Mister Kumar,

Thanks to share this with the community.
But how do I get the connection between actions and states?

On Actions I only see, which states we are getting in and not from which state we're comming...
Maybe you've got an Idea?


Donald Nong commented Aug 14 '16, 9:28 p.m.

If you are looking for the actions that have been done already, it is the "history". You need to use the REST API  and look into "itemHistory".

Your answer


Register or to post your answer.