Pages

Saturday, March 15, 2014

How to get list of Rally Projects

public Map<String, List<String>> getProjectReferenceMap()
throws IOException {
// Get the workspace references
List<String> workspaceReferenceList = getWorkSpaceReferences();
String workSpaceName = "";
String projectRef = "";
GetRequest workspaceRequest;
GetResponse workspaceResponse;
Map<String, List<String>> projectWorkSpaceMap = new HashMap<String, List<String>>();
List<String> projectList = new ArrayList<String>();
// Iterate through each workspace and get all the project associated
// with each workspace
for (String workspaceRef : workspaceReferenceList) {
// Get the workspaces
if (workspaceRef.equalsIgnoreCase("workSpace")) {
workspaceRequest = new GetRequest(workspaceRef);
workspaceRequest.setFetch(new Fetch("Name", "Projects"));
workspaceResponse = restApi.get(workspaceRequest);
JsonObject workspaceObj = workspaceResponse.getObject();
JsonArray workspaceArray = workspaceObj.get("Results")
.getAsJsonArray();
JsonObject jo;
JsonElement projRef;
// For each workspace get the list of projects
for (int i = 0; i < workspaceArray.size(); i++) {
jo = workspaceArray.get(i).getAsJsonObject();
workSpaceName = jo.get("Name").getAsString();
projRef = jo.get("Projects");
JsonObject jobject = projRef.getAsJsonObject();
JsonElement je = jobject.get("_ref");
projectRef = je.toString();
projectList.add(projectRef);
}
projectWorkSpaceMap.put(workSpaceName, projectList);
}

}

return projectWorkSpaceMap;
}

1 comment:

  1. Hi Kiran,
    I need to delete all results (execution result s) of a test case. Could you please give an approach. Explored but don't get any results.

    Thanks in advance.

    ReplyDelete