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

creating child team area using plain Java API

 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; 
}

0 votes


Accepted answer

Permanent link
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

1 vote

Comments

Thanks alot Ralph. Great help! 


3 other answers

Permanent link
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.

0 votes

Comments

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


0 votes

Comments

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.


Permanent link

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.

0 votes

Comments
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: https://ibb.co/CsBfQGf

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 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
× 11,065

Question asked: Jul 30 '13, 5:50 a.m.

Question was seen: 8,270 times

Last updated: Aug 24 '21, 5:33 a.m.

Confirmation Cancel Confirm