forked from nmusaelian-rally/rally-java-rest-apps
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPiTypes.java
More file actions
51 lines (41 loc) · 1.87 KB
/
PiTypes.java
File metadata and controls
51 lines (41 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.util.Fetch;
import com.rallydev.rest.request.QueryRequest;
import com.rallydev.rest.request.UpdateRequest;
import com.rallydev.rest.response.UpdateResponse;
import com.rallydev.rest.response.QueryResponse;
import com.rallydev.rest.util.QueryFilter;
import java.util.Date;
public class PiTypes{
public static void main(String[] args) throws URISyntaxException, IOException {
String host = "https://rally1.rallydev.com";
String apiKey = "_abc123"; //use your ApiKey
String applicationName = "Nick:PiTypes";
RallyRestApi restApi = new RallyRestApi(new URI(host),apiKey);
restApi.setApplicationName(applicationName);
String workspaceRef = "/workspace/12345";
try {
QueryRequest typedefRequest = new QueryRequest("TypeDefinition");
typedefRequest.setFetch(new Fetch("ElementName","Ordinal"));
typedefRequest.setOrder("Ordinal DESC");
typedefRequest.setQueryFilter(new QueryFilter("Parent.Name", "=", "Portfolio Item"));
typedefRequest.setWorkspace(workspaceRef);
QueryResponse typedefResponse = restApi.query(typedefRequest);
for (int i=0; i<typedefResponse.getTotalResultCount();i++){
JsonObject typedefObj = typedefResponse.getResults().get(i).getAsJsonObject();
if(typedefObj.get("Ordinal").getAsInt() > -1){
System.out.println("ElementName: " + typedefObj.get("ElementName") + ", " +
"Ordinal: " + typedefObj.get("Ordinal"));
}
}
} finally {
restApi.close();
}
}
}