문제

I would like to write a Java API to retrieve just the team members for each project in Rally and push to db. Is there any query which could help me with this request?

The project could be identified by naming convention, as our workspace has hierarchical based projects where only last tier of hierarchy holds the team members list.

Please do mail me if you need further details

Thanks

Sree

도움이 되었습니까?

해결책

Here is a code example that returns team members of a project:

public static void main(String[] args) throws URISyntaxException, IOException {
        String host = "https://rally1.rallydev.com";
        String username = "user@co.com";
        String password = "secret";
        String workspaceRef = "/workspace/12352608129"; 
        String applicationName = "RESTExample get team members";

        RallyRestApi restApi = new RallyRestApi(
                new URI(host),
                username,
                password);
        restApi.setApplicationName(applicationName); 
        System.out.println(restApi.getWsapiVersion()); 

        try{
             QueryRequest projectRequest = new QueryRequest("Project");
             projectRequest.setFetch(new Fetch("Name", "TeamMembers"));
             projectRequest.setWorkspace(workspaceRef);
             projectRequest.setQueryFilter(new QueryFilter("Name", "=", "Company X"));

             QueryResponse projectQueryResponse = restApi.query(projectRequest);
             int count = projectQueryResponse.getResults().size();
             System.out.println(count);
             if(count > 0){
                 JsonObject projectObject = projectQueryResponse.getResults().get(count-1).getAsJsonObject();
                 int numberOfTeamMembers = projectObject.getAsJsonObject("TeamMembers").get("Count").getAsInt();
                 if(numberOfTeamMembers > 0) {
                        QueryRequest teamRequest = new QueryRequest(projectObject.getAsJsonObject("TeamMembers"));
                        JsonArray teammates = restApi.query(teamRequest).getResults();
                        for (int j=0;j<numberOfTeamMembers;j++){
                            System.out.println(teammates.get(j).getAsJsonObject().get("_refObjectName").getAsString());
                        }
                    }
             }

        }catch(Exception e){
            e.printStackTrace();

        } finally{
            restApi.close();
        }
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top