It's all about the answers!

Ask a question

[closed] How can I create child team area using Java API


Kaushambi Singh (371310379) | asked Jun 30 '13, 1:42 a.m.
closed Aug 01 '13, 6:52 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;
}

The question has been closed for the following reason: "Duplicate Question" by kushsingh Aug 01 '13, 6:52 a.m.

2 answers



permanent link
sam detweiler (12.5k6189201) | answered Jun 30 '13, 9:58 a.m.
here is how to create a team area
<code>
// create Team Area
ITeamArea teamArea = (ITeamArea) ITeamArea.ITEM_TYPE.createItem();
String actualTeamName = teamName + System.currentTimeMillis();
teamArea.setName(actualTeamName);
teamArea.addMember(getContributor());

area = (IProjectArea) area.getWorkingCopy();
teamArea.setProjectArea(area.getProjectArea());
</code>

in the api you meantioned, the 1st parm(arg1) is the parent team area, and the second parm (arg2)is the new child.

see the javadoc

Comments
Kaushambi Singh commented Jul 01 '13, 3:42 a.m.

 Thanks for the reply. I already have created the team area.I would like to know the syntax for the second parameter (arg2) for child team areas. please reply.


Kaushambi Singh commented Jul 01 '13, 7:00 a.m.

To make my comment more clear on what I am looking for :

 ITeamArea teamArea = service.createTeamArea();
 projectarea.getTeamAreaHierarchy().addChild(teamArea,  TAHandle arg2) ;
Please help me how to get the arg2 value ? What should be the syntax for arg2 where we are passing the child teamarea name. 


permanent link
sam detweiler (12.5k6189201) | answered Jul 01 '13, 8:29 a.m.
edited Jul 01 '13, 8:29 a.m.
you need to pass the team area HANDLE

once again, please see the javadoc which is available in the product download section for each release since 3.0.1.1
void addChild(ITeamAreaHandle parent,
              ITeamAreaHandle child)
Adds a given team area as a child to another given team area.

Parameters:
parent - the parent team area
child - the child team area
Throws:
TeamAreaHierarchyException - if the parent is not part of this hierarchy or the child already has a parent


Comments
Kaushambi Singh commented Jul 02 '13, 6:47 a.m.

 I understood this addChild method from the doc but my question still remains, can you help me with an example syntax of argument (ITeamAreaHandle child) .Probably I am not getting how to pass this argument so an example syntax would be very helpful.


Kaushambi Singh commented Jul 03 '13, 1:52 a.m.

Please reply. 


sam detweiler commented Jul 03 '13, 8:24 a.m.

once again please see the javadoc, you should have noticed

public interface ITeamArea extends ITeamAreaHandle
        
which means you should be able to pass the teamArea object created with

 ITeamArea teamArea = service.createTeamArea();

to the addChild() method