In Rally Webservices API, if I want to traverse a Story hierarchy, it's necessary to do a query for the parent story, then grab the Children collection(s) off of the returned Stories, and then recursively query on each Child until the process reaches the Leaf node results.
Question - is there a handy way to do this without iterating, by using a single query in the Lookback API?
This is one of the best features of the Lookback API.
Let's say you have this hierarchy:
The document for Task 12 would look like this:
{
ObjectID: 12,
_Type: "Task",
WorkProduct: 777,
_ItemHierarchy: [444, 555, 666, 777, 12],
...
}
So when you submit a query against a field with an array value (like _ItemHierarchy), it will match any member of the array.
To get everything that descend from 444 your find clause would include _ItemHierarchy: 444
. See how that matches the _ItemHierarchy
value for Task 12?
To get everything that descend from 333 your find clause would include _ItemHierarchy: 333
. This also matches on Task 12.
To get just the Stories that descend from 444 (all Stories) your find clause would include:
_ItemHierarchy: 444,
_Type: "HierarchicalRequirement"
To get just the leaf Stories just add the clause Children: null
.
The _ItemHierarchy also goes all the way up to PortfolioItems.
_ItemHierarchy
is indexed so these queries should be very efficient.