It's all about the answers!

Ask a question

How to filter RTC Reportable REST API output based on multiple criteria


Michael Taylor (8865764) | asked Jun 23 '13, 8:13 p.m.

I have been using the following references.

               REFERENCES:

a)      https://jazz.net/wiki/bin/view/Main/ReportsRESTAPI#Field_selection_and_filtering

b)      http://open-services.net/pub/Main/ReportingHome/Reportable_Rest_Services_Interfaces-OSLC_Submission.pdf (RRSI)

Page 17 of reference “b” (RRSI) right before section 4.3.2 seems to indicate that [Support for multiple comparisons using “and”and “or”] has been implemented.  I mention this in case it is a solution to my question.

               QUESTION:

My question is how can I limit the output of entire work items based on multiple criteria (such as the State of a parent and the Work Item Type of a child)?

(Approach 1): In other words, if a Parent Work Item is in a certain State, I want to list a number of child elements.  But I only want to list the child elements for child Work Items of a certain type (as well as two custom attributes - string and decimal - of the child).  If a parent work item has no children work items of the child work item type I’m looking for, I don’t want to list the parent work item at all.

(Aproach 2): If it helps, I may be able to attack the problem by starting with the child work item.  In that case, if a child work item is of a certain Work Item type, I want to list a number of parent elements of that child along with two custom attributes - string and decimal - of the child.  But I only want to list a work item in the output if the parent is in a particular State.

               EXPERIMENTATION:

I did a number of experiments such as the following.  The filtering seems to work to some degree.  But in many/most cases, the filtering simply limited the output of the particular element being filtered.  It still output the other elements for all work items.  The only exception to this seemed to be the filter by ID.  The filter by ID worked as I wanted it to (it output one and only one work item if the ID matched and nothing else).  But I need to filter based on parent Work Item State and child Work Item Type.  Is there a way to combine the criteria somehow to limit whether a work item is even represented in the output?

1)      URL: https://<server>:<port>/ccm/rpt/repository/workitem?fields=workitem/workItem[id=25]/(id|state/*|type/*)

a.      Worked as expected

2)      URL: https://<server>:<port>/ccm/rpt/repository/workitem?fields=workitem/workItem/(id|state[name='New']/*|type/*)

a.      Only displayed state elements where the name was ‘New” but still listed other work items that didn’t’ match on the state criteria.  In the latter cases, no state information was displayed for those work items.

3)      URL: https://<server>:<port>/ccm/rpt/repository/workitem?fields=workitem/workItem/(type[ @ id='source_code_ci_-_micses']/*|id|state/*) (space added before and after the "@" so the question would post correctly)

a.      Only displayed type elements where the id matched but still listed other work items that didn’t’ match on the type criteria.  In the latter cases, no type information was displayed for those work items.

4)      URL: https://<server>:<port>/ccm/rpt/repository/workitem?fields=workitem/workItem/((type[ @ id='source_code_ci_-_micses'])and(state[name='Accepted/Updated'])/*|id|state/*) (space added before and after the "@" so the question would post correctly)

a.      I tried to add “and” here but I couldn’t get any kind of “and” condition working (received syntax errors).

b.      What is valid syntax for adding “and” / “or”?

5)      URL: https://<server>:<port>/ccm/rpt/repository/workitem?fields=workitem/workItem/(children/(parent/(target/name|id|state/name))|children/stringExtensions[key='MICSES_Source_File_CI_Name']/value|children/bigDecimalExtensions[key='MICSES_Source_file_CI_Version_dec']/value)

a.      This is exactly what I want for output in terms of fields listed following “Approach 1” as described above.  All the information I want is listed under the child nodes for each parent work item.

b.      The challenge is I haven’t been able to add the filtering criteria successfully.  In other words, I haven’t been able to filter out children of a parent when a parent has children of the work item type I want as well as children of the work item type I do not want.

c.      I also have not been able to filter out parent work items that don’t match on any of my criteria.

d.      Once I get this closer to finalized, I will ultimately also need to filter on work items for a specific project so that I don’t interfere with other projects’ data.

 


Comments
Michael Taylor commented Jun 24 '13, 11:35 a.m.

Are there any suggestions for these questions?

One answer



permanent link
Alanna Zito (1.3k3) | answered Jun 24 '13, 12:14 p.m.
JAZZ DEVELOPER
For your examples 2) and 3), you're putting the filter at the wrong level.  The filter should go on the element that you want to include/exclude, not the attribute you want to filter by.  For example, if I wanted to filter work items by the project "Scrum Project", I would write a filter like this

fields=workitem/workItem[projectArea/name="Scrum Project"]/(id|summary|projectArea/name)

not

fields=workitem/workItem/(id|summary|projectArea[name="Scrum Project"]/name)

For 4, I think you need to combine your conditions within the same set of square brackets.  For example,

fields=workitem/workItem[projectArea/name="Scrum Project" and id=5]/(id|summary|projectArea/name)

worked for me to filter on both the project area name and the work item ID.

Comments
Michael Taylor commented Jun 24 '13, 1:34 p.m.

Yes.  What you suggested worked for me.  Thanks.  I wasn't sure if a space could be added before and after the and conditions.  Apparently that works.

 

For #2 though, when I move comparing the State name up to the level I think it needs to be at, I get an error message.  Please see this question:  It's wierd that it worked when I had the State name at a lower level...

    https://jazz.net/forum/questions/117472/how-to-filter-work-item-by-state-name-using-reportable-rest-api

Your answer


Register or 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.