It's all about the answers!

Ask a question

creating child team area using plain Java API

Kaushambi Singh (371310379) | asked Jul 30 '13, 5:50 a.m.
closed Aug 01 '13, 7:01 a.m.
 How can I create child team areas while creating teamarea. Pasting the below piece of code which I feel should create the child team area but it doesn't. I think my mistake is I am not able to get the child team area name in a handle. Looking at the code below, if someone can help, will be great.

   List <teamareahandle> teamlist = area.getTeamAreas();
 childTAHandle = findChildTeamArea(teamlist,childteamAreaName,monitor); 

 the method: findChildTeamArea is:

public ITeamAreaHandle findChildTeamArea (List<teamareahandle> teamlist, String ChildTeamID, IProgressMonitor monitor) throws TeamRepositoryException {
for (ITeamAreaHandle teamAreaHandle : teamlist) { 
ITeamArea teamArea = (ITeamArea)teamRepository.itemManager().fetchCompleteItem(teamAreaHandle,ItemManager.DEFAULT,monitor); 
if (ChildTeamID.equals(teamArea.getName())) { 
return teamAreaHandle; 

return null; 

Accepted answer

permanent link
Ralph Schoon (63.1k33646) | answered Jul 30 '13, 11:32 a.m.
edited Jul 30 '13, 11:33 a.m.
The Code of Snippet 3 of the Plain Java Client Libraries can be changed this way to create a child team area:
        IProjectArea area = service.createProjectArea();
        area.setName(projectName + " - " + System.currentTimeMillis());
        IDescription description = area.getDescription();
        description.setSummary(projectName + " example project based on the Scrum project template");
        area = (IProjectArea), monitor);
        area = (IProjectArea) service.getMutableCopy(area);
        // Create team 1
        ITeamArea teamArea = service.createTeamArea();

        // Set Root
        area.getTeamAreaHierarchy().addRoot(teamArea, area.getDevelopmentLines()[0]);
        // Create team 2
        ITeamArea teamArea2 = service.createTeamArea();
        teamArea2.setName(projectName+" 1");
        // add child to Team 1
        area.getTeamAreaHierarchy().addChild(teamArea, teamArea2);
        // Save all new items
        IProcessItem[] items = IProcessItem[] {area, teamArea, teamArea2}, monitor);
Kaushambi Singh selected this answer as the correct answer

Kaushambi Singh commented Jul 31 '13, 5:19 a.m.

Thanks alot Ralph. Great help! 

3 other answers

permanent link
Ralph Schoon (63.1k33646) | answered Jul 30 '13, 7:22 a.m.
I think this was already answered in I would assume you need a working copy to do a save.

Kaushambi Singh commented Jul 30 '13, 10:15 a.m.

 Hi Ralph, I did save at end but its still not creating the child team area. IProcessItem[] {area, teamArea},null);

permanent link
Kaushambi Singh (371310379) | answered Jul 31 '13, 8:12 a.m.
 Hi Ralph,

I also want to know how can I add child team areas in an already existing team area. I think we need to have process area working copy for this but then  I am not getting the method getTeamAreaHierarchy() with that in the method list.

teamArea2 = (ITeamArea)ta.teamRepository.itemManager().fetchCompleteItem(TAHandle,IItemManager.DEFAULT,monitor);
IProcessAreaWorkingCopy areaWc = (IProcessAreaWorkingCopy)service.getWorkingCopyManager().createPrivateWorkingCopy(teamArea2);

But I don't find getTeamAreaHierarchy() method when  I do areaWC.

Ralph Schoon commented Jul 31 '13, 9:16 a.m.

I would suggest to use the techniques described here: to look for code. Eventually you have to master that techniques, if you want to use the API. We can't support an real-time online tutorial and code example service in the forum. For the answer above I had to spend half an hour myself to figure it out and this is obviously not sustainable.

The way the snippet3 works indicates, to do what you want, you likely have to get the team area you want to add a child, get the project area, its workingCopy from that. Then add the new team area as child as in the example code above.

permanent link
Emiliano Iannetti (389) | answered Aug 17 '21, 9:38 a.m.

Hello everyone, thank you very much Ralph for everything, in a few days I will also reply to the other post with the closure of my attempts.

But I wanted to ask you something, to me the line: area.getTeamAreaHierarchy (). AddRoot (teamArea, area.getDevelopmentLines () [0]); An indexOutOfBound exception returns, as it is empty, but I can't find any set, as if you expected it to be always full, why? Then I also wanted to add but is it possible that the addChild method necessarily needs two parameters? What if one only wanted to create a teamArea child? And then can you tell me why it turns out to me that you ask for two ITeamAreaHandles and not two ITeamArea? Thank you.

Emiliano Iannetti commented Aug 24 '21, 5:33 a.m.
Update this answer:
From your source failing to understand what I should pass it I tried to pass it null and it worked correctly, here is the screen to the result:

It is our intention to make this batch a rest service if I succeed I would like to share the source with you, what should I do? Sorry for the OT but I think it can be useful for other users too.

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.