2014-06-19 81 views
2

如何使用java中的rally rest api檢索/獲取特定用戶故事形式拉力賽的缺陷?來自拉力賽的特定用戶故事的缺陷

以下代碼我試過了。

QueryRequest projectRequest = new QueryRequest("Defect"); 
projectRequest.setProject(
    "https://rally1.rallydev.com/slm/webservice/v2.0/project/"+prjid); 
projectRequest.setQueryFilter(new QueryFilter("Requirement", "=", UserR)); 
//projectRequest.setScopedDown(true); 
QueryResponse projectQueryResponse = this.restApi.query(projectRequest); 

回答

0

假設

String projectRef = "/project/12345"; 
String storyRef = "/hierarchicalrequirement/67890"; 

這裏是返回用戶故事的缺陷的例子:

try { 
       restApi = new RallyRestApi(
         new URI(host), 
         username, 
         password); 
       restApi.setApplicationName(applicationName); 

       QueryRequest defectRequest = new QueryRequest("Defect"); 
       defectRequest.setProject(projectRef); 
       defectRequest.setFetch(new Fetch(new String[] {"Name", "FormattedID","State", "Priority", "Severity", "Requirement"})); 
       defectRequest.setLimit(1000); 
       defectRequest.setScopedDown(false); 
       defectRequest.setScopedUp(false); 
       defectRequest.setQueryFilter(new QueryFilter("Requirement", "=", storyRef)); 

       QueryResponse defectQueryResponse = restApi.query(defectRequest); 

       for (int i=0; i<defectQueryResponse.getResults().size();i++){ 
        JsonObject defectJsonObject = defectQueryResponse.getResults().get(i).getAsJsonObject(); 
        System.out.println("Name: " + defectJsonObject.get("Name") + " State: " + defectJsonObject.get("State") + " Priority: " + defectJsonObject.get("Priority") + " FormattedID: " + defectJsonObject.get("Requirement")); 
       } 


      } finally { 
       if (restApi != null) { 
        restApi.close(); 
       } 
      } 
+0

它將檢索爲特定用戶故事中的缺陷,請澄清我嗎? –

+0

是的,它會循環代碼中的結果 – nickm

相關問題