gpt4 book ai didi

java - 获取特定迭代下的所有任务(符合条件)?

转载 作者:行者123 更新时间:2023-12-01 12:49:22 25 4
gpt4 key购买 nike

我想使用 Rally Rest Toolkit java 获取 2014-06-01 到 2014-06-08 之间的所有迭代,然后获取这些迭代下的所有任务。我该怎么做?

任何帮助都会很棒!非常感谢!

最佳答案

要获取特定日期内的迭代任务,请使用以下语法:

taskRequest.setQueryFilter(new QueryFilter("Iteration.StartDate", ">=", "2014-06-01").and(new QueryFilter("Iteration.EndDate", "<=", "2014-06-08")));

并设置请求的工作空间:

taskRequest.setWorkspace("123456); //use your ObjectID

以便具有相同开始和结束日期的子迭代(来自工作区中的所有项目)包含在结果中。

public static void main(String[] args) throws URISyntaxException, IOException {

String host = "https://rally1.rallydev.com";
String username = "user@co.com";
String password = "psw";
String workspaceRef = "/workspace/12352608129";
String applicationName = "ExampleFindTasks";

RallyRestApi restApi = null;

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

QueryRequest taskRequest = new QueryRequest("Task");
taskRequest.setFetch(new Fetch("Name","FormattedID","Iteration","Project"));
taskRequest.setLimit(1000);
taskRequest.setScopedDown(true);
taskRequest.setScopedUp(false);
taskRequest.setWorkspace(workspaceRef);
taskRequest.setQueryFilter(
new QueryFilter("Iteration.StartDate", ">=", "2014-06-01").and(
new QueryFilter("Iteration.EndDate", "<=", "2014-06-08")));

QueryResponse taskQueryResponse = restApi.query(taskRequest);
int numberOfResults = taskQueryResponse.getTotalResultCount();
System.out.println(numberOfResults);

if(numberOfResults > 0){
for (int i=0;i<numberOfResults;i++){
JsonObject taskJsonObject = taskQueryResponse.getResults().get(i).getAsJsonObject();
System.out.println("Name: " + taskJsonObject.get("Name") + " " + "FormattedID: " +
taskJsonObject.get("FormattedID"));
JsonElement iteration = taskJsonObject.get("Iteration");
JsonElement project = taskJsonObject.get("Project");
try{
JsonObject iterationObject = iteration.getAsJsonObject().getAsJsonObject();
JsonObject projectObject = project.getAsJsonObject().getAsJsonObject();
System.out.println(iterationObject.get("Name"));
System.out.println(projectObject.get("Name"));
}
catch (java.lang.IllegalStateException ise) {
System.out.println("ise");
}
}
}
}
finally{
if (restApi != null) {
restApi.close();
}
}
}

关于java - 获取特定迭代下的所有任务(符合条件)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24360459/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com