It's all about the answers!

Ask a question

creating child team area using plain Java API


Kaushambi Singh (37139979) | 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); 
   area.getTeamAreaHierarchy().addChild(teamArea,childTAHandle);

 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 (57.5k23642) | answered Jul 30 '13, 11:32 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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());
        area.setProcessDefinition(definitions[0]);
        IDescription description = area.getDescription();
        description.setSummary(projectName + " example project based on the Scrum project template");
        area = (IProjectArea) service.save(area, monitor);
        area = (IProjectArea) service.getMutableCopy(area);
        // Create team 1
        ITeamArea teamArea = service.createTeamArea();
        teamArea.setName(projectName);
        teamArea.addMember(repo.loggedInContributor());
        teamArea.setProjectArea(area);

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

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

Thanks alot Ralph. Great help! 

2 other answers



permanent link
Ralph Schoon (57.5k23642) | answered Jul 30 '13, 7:22 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I think this was already answered in https://jazz.net/forum/questions/118159/how-can-i-create-child-team-area-using-java-api I would assume you need a working copy to do a save.

Comments
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.

service.save(new IProcessItem[] {area, teamArea},null);


permanent link
Kaushambi Singh (37139979) | 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.



Comments
Ralph Schoon commented Jul 31 '13, 9:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I would suggest to use the techniques described here: https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ 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.

Your answer


Register or to post your answer.