Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Get project area list based on Repository

I'm working on an eclipse based application within which I'm developing a mechanism for users to open RTC work items. I would like the user to be able to select the project area he/she wants to open the work item against based on the repository they have logged into.

Can someone help me to point me in the right direction to get a list of project areas contained within a particular repository. Is this possible using the RTC API?

Currently working with packages within:
com.ibm.team
.repository
.workItem

0 votes



2 answers

Permanent link
I was able to figure this out today thanks to a post by "Marly" under a thread titled "Reading the list of project Area".

Here is the final code I will use for this function:

	@SuppressWarnings("unchecked")

public String [] getProjectAreaList() {
List<IProjectArea> projectAreas = null;
String [] toReturn;
IProcessItemService client = (IProcessItemService) teamRepository.getClientLibrary(IProcessItemService.class);
try {
projectAreas = (List<IProjectArea>) client.findAllProjectAreas(IProcessClientService.ALL_PROPERTIES, null);
} catch (TeamRepositoryException e) {
MyPlugin.println("Unable to obtain project areas list in getProjectAreasList:" + e + ":" + e.getMessage());
return null;
}

toReturn = new String[projectAreas.size()];
for (int i = 0; i < projectAreas.size(); i++)
toReturn[i] = projectAreas.get(i).getName();

return toReturn;
}


Unrelated... If anyone can advise how the list can be type checked to avoid the use of the suppressed warning, that would be appreciated.

0 votes


Permanent link
I was able to figure this out today thanks to a post by "Marly" under a thread titled "Reading the list of project Area".

Here is the final code I will use for this function:

	@SuppressWarnings("unchecked")

public String [] getProjectAreaList() {
List<IProjectArea> projectAreas = null;
String [] toReturn;
IProcessItemService client = (IProcessItemService) teamRepository.getClientLibrary(IProcessItemService.class);
try {
projectAreas = (List<IProjectArea>) client.findAllProjectAreas(IProcessClientService.ALL_PROPERTIES, null);
} catch (TeamRepositoryException e) {
MyPlugin.println("Unable to obtain project areas list in getProjectAreasList:" + e + ":" + e.getMessage());
return null;
}

toReturn = new String[projectAreas.size()];
for (int i = 0; i < projectAreas.size(); i++)
toReturn[i] = projectAreas.get(i).getName();

return toReturn;
}


Unrelated... If anyone can advise how the list can be type checked to avoid the use of the suppressed warning, that would be appreciated.


The code above is passing in a null progress monitor to the Process client library. This is strongly discouraged, because it will result in long-running network calls that can't be cancelled.

Since code like this in the Eclipse client can't be run in the UI thread, you should always be running it in some context that has a progress monitor. Either a Job or some background content provider functions which pass you a monitor.

- Jared

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,936

Question asked: May 07 '12, 4:21 p.m.

Question was seen: 5,008 times

Last updated: May 07 '12, 4:21 p.m.

Confirmation Cancel Confirm