2012-11-15 43 views
2

我現在用的拉力WSAPI 2.0p5與和JSON返回拉力賽:字段從多個表

我希望得到來自多個表中的字段在單個響應。這可能嗎?例如,我正在嘗試獲取用戶故事,並在相同的數據響應中獲取Iteration.State。我知道有可能做客戶端,如果這是唯一的方法。有人可以提供並舉例說明如何處理構建表(數組)的異步響應。

+1

您正在尋找的Iteration.State值來填充它的時候包含在故事中? –

+0

我不確定我是否理解這個問題。 當我查詢HierarchicalRequirement模型時,我想將Iteration.State作爲WSAPI響應中的字段。目前在返回中有一個Iteration對象,但該對象不包含狀態信息。它只是一個參考對象。而不是循環返回,併爲每個故事做第二次WSAPI調用Iteration,我只想讓Status成爲第一個回報的一部分。 – user1824727

回答

0

作爲我原來的問題的後續行動。我最近在Rally的WSAPI文檔中遇到了批量查詢WSAPI的alpha版本。我建議使用批量查詢在單個響應中檢索多個對象模型。

舉個例子,以獲取用戶故事,並獲得迭代狀態在一個單一的查詢。

{ 
    "stories" : "/HierarchicalRequirement?fetch=Name,Iteration,State&query=(Iteration.State = Accepted)" 
} 

結果是更有用的東西,並不需要多次查詢到服務器。即

"Results": [{ 
     "_rallyAPIMajor": "1", 
     "_rallyAPIMinor": "40", 
     "_ref": "https://rally1.rallydev.com/slm/webservice/x/hierarchicalrequirement/xxxxxxxx.js", 
     "_objectVersion": "17", 
     "_refObjectName": "<user role> I would like <feature> for <benifit>", 
     "Name": "As a <user role> I would like <feature> for <benifit>", 
     "Iteration":    { 
      "_rallyAPIMajor": "1", 
      "_rallyAPIMinor": "40", 
      "_ref": "https://rally1.rallydev.com/slm/webservice/x/iteration/xxxxxxxx.js", 
      "_objectVersion": "4", 
      "_refObjectName": "Sprint #", 
      "Name": "Sprint #", 
      "State": "Accepted", 
      "_type": "Iteration" 
     }, 
     "Project":    { 
      "_rallyAPIMajor": "1", 
      "_rallyAPIMinor": "40", 
      "_ref": "https://rally1.rallydev.com/slm/webservice/x/project/xxxxxxxx.js", 
      "_refObjectName": "Name", 
      "_type": "Project" 
     }, 
     "_type": "HierarchicalRequirement" 
    }, 
    .... 
    ] 

欲瞭解更多信息和一些資源:

1

只需將狀態添加到提取中包含的屬性列表中即可。即使被查詢的主類型沒有該字段,拉力賽的WSAPI也會填充子對象的值。

launch: function() { 
    var userStories = Ext.create('Rally.data.WsapiDataStore', { 
     model: 'HierarchicalRequirement', 
     fetch: ['Iteration', 'State'], 
     autoLoad: true, 
     filters: [ 
      { 
       property: 'Iteration.State', 
       value: 'Accepted' 
      } 
     ], 
     limit: 10000, 
     listeners: { load: this._onDataLoaded, scope: this } 
    }); 
} 
+0

我相信我做錯了什麼。這是我正在做的一個代碼片段。當我嘗試記錄它時,迭代名稱和狀態會返回undefined。 – user1824727

+0

<! - 語言:朗-JS - > 發射:函數(){ VAR userStories = Ext.create( 'Rally.data.WsapiDataStore',{ 模型: 'HierarchicalRequirement', 取:['迭代.NAME」, 'Iteration.State'], 自動加載:真, 濾波器:[{ 屬性: 'Iteration.Name', 運算符: '!=', 值: '' },{ 屬性: 'Iteration.State', 運算符: '=', 值: '接受' }], 極限:10000, 聽衆:{ 負載:this._onDataLoaded, SC ope:這個 } }); } – user1824727

+0

我用你的代碼更新了我的答案。請注意提取屬性。 –