来自集会的特定用户故事的缺陷

时间:2014-06-19 11:39:30

标签: java rally

如何使用java中的拉力赛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);

1 个答案:

答案 0 :(得分: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();
                }
            }