It's all about the answers!

Ask a question

Get project area list based on Repository


Tom Schmidt (645) | asked May 07 '12, 4:21 p.m.
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

2 answers



permanent link
Jared Burns (4.5k29) | answered May 11 '12, 5:58 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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

permanent link
Tom Schmidt (645) | answered May 08 '12, 4:26 p.m.
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.

Your answer


Register or 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.