如何使用lookback API获取计划估计更改的功能记录

时间:2015-02-26 02:19:35

标签: java rally lookbackapi

我正在使用java的反弹回望api。我正在尝试获取历史数据功能,我正在使用的示例代码如下所示。

LookbackApi lookbackApi = new LookbackApi();

lookbackApi.setCredentials("username", "password");
lookbackApi.setWorkspace(47903209423);
lookbackApi.setServer("https://rally1.rallydev.com");
//lookbackApi.setWorkspace("90432948"); 

LookbackQuery query = lookbackApi.newSnapshotQuery();
query.addFindClause("_TypeHierarchy", "PortfolioItem/Feature");
query.setPagesize(200)                      // set pagesize to 200 instead of the default 20k
.setStart(200)                      // ask for the second page of data        
.requireFields("ScheduleState",     // A useful set of fields for defects, add any others you may want
               "ObjectID",
               "State",
               "Project",
               "PlanEstimate",
               "_ValidFrom",
               "_ValidTo")
.sortBy("_UnformattedID")        
.hydrateFields("ScheduleState","State", "PlanEstimate","Project");    // ScheduleState will come back as an OID if it doesn't get hydrated      

LookbackResult resultSet = query.execute();


int resultCount = resultSet.Results.size();
Map<String,Object> firstSnapshot = resultSet.Results.get(0);

Iterator<Map<String,Object>> iterator = resultSet.getResultsIterator();
while (iterator.hasNext()) {
    Map<String, Object> snapshot = iterator.next();
}

我需要一种方法来设置条件,以便它将从历史记录中获取所有记录,这些记录将更改计划估计值,但会忽略任何功能和基础用户故事的其他历史记录。我这样需要它,以便我们可以跟踪计划估计变化,但是,能够避免获取不必要的数据并减少执行此操作的时间。

2 个答案:

答案 0 :(得分:1)

我不熟悉java工具包,但是使用原始的Lookback API,您可以使用像{"_PreviousValues.PlanEstimate": {"$exists": true}}这样的过滤器子句来实现这一点。

答案 1 :(得分:0)

    Map ifExist = new HashMap();
    ifExist.put("$exists",  true); 
    // Note:- true is java boolean, be careful with this as string "true" will not work.
    query.addFindClause("_PreviousValues.PlanEstimate",ifExist);

另外需要考虑添加&#34; _PreviousValues.PlanEstimate&#34;成 .requireFields()仅限于案例&#34; PlanEstimate&#34;需要补水