The API was not designed to search for project areas. Fortunately, there is the IProcessClientService.findProcessArea(URI areaURI, Collection properties, IProgressMonitor monitor)
method:
- Call
ITeamRepository.getClientLibrary(IProcessClientService)
to get a IProcessClientService
instance.
- Call
IProcessClientService.findProcessArea(URI areaURI, Collection properties, IProgressMonitor monitor)
.
areaURI
is the project area name, 'encoded as URI' (can't explain why, it is internally converted back to string). I had to URL encode de name, but assuring that white-space is encoded as %20
instead of +
which would be the encoding standard.
- I found no documentation for the
properties
collection. Works with null.
- Progress monitor, may be null.
- The method already returns a
IProcessArea
instance and not IProcessAreaInstance
as I first expected by comparing with similar API methods. Therefore, no 'fetch' is needed.
IProjectArea findProjectAreaByName(String name) {
def processClient = repositoty.getClientLibrary(IProcessClientService) as IProcessClientService
def uri = URI.create(URLEncoder.encode(name, "UTF-8").replace('+','%20'))
return processClient.findProcessArea(uri, null, null) as IProjectArea
}