假設
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();
}
}
它將檢索爲特定用戶故事中的缺陷,請澄清我嗎? –
是的,它會循環代碼中的結果 – nickm