Rally Java:使用ItemHierarchy获取功能

时间:2014-03-06 15:38:29

标签: rally lookbackapi

我正在使用lookback API,这是我的代码:

LookbackQuery query = this.lookback.newSnapshotQuery();
query.addFindClause("_TypeHierarchy", "PortfolioItem/Feature");
query.addFindClause("_ItemHierarchy", new BigInteger(workProductObjectID)); 
//here the workProductObjectID is the string representation of objectID of the user story.
//I am trying to look for the feature in that story's hierarchy.

query.requireFields("FormattedID","Name","ObjectID");
LookbackResult result = query.execute();

返回的totalResultCount是0,但我可以看到故事确实有一个指定的功能。当我删除'_ItemHierarchy'约束时,我得到了所有的功能。

1 个答案:

答案 0 :(得分:2)

在代码中,您将类型层次结构限制为PortfolioItem / Feature,同时希望获得从用户素材下降的项目层次结构,这是相互矛盾的。

对于此层次结构:

Feature 3333
-Top Story 4444
--Child Story 5555
---Task 6666

类似于代码中的查询的端点将返回0结果:

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1111/artifact/snapshot/query.js?find={"_ItemHierarchy":4444,"_TypeHierarchy": "PortfilioItem/Feature"}

要检索从功能3333下载的所有故事(包括故事4444,5555但不包括任务6666),请在查询中包含此子句:

{
    "_ItemHierarchy": 4444,
    "_TypeHierarchy": "HierarchicalRequirement"
}

返回与此相同的工件:

{
    "_ItemHierarchy": 3333,
    "_TypeHierarchy": "HierarchicalRequirement"
}

如果要获取功能,请确保在“字段”语句中包含Feature。这相当于端点:

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/1111/artifact/snapshot/query.js?find={"_ItemHierarchy":4444,"_TypeHierarchy": "HierarchicalRequirement"}&fields=["Name","Feature"]

它将返回:

Results: [
{
Feature: 3333,
Name: "A Top Story One"
},
{
Feature: 3333,
Name: "A Story One"
}

在编写代码之前,您可以直接在浏览器中测试,看看您的查询是否返回了您的期望。