It's all about the answers!

Ask a question

Programmatic get of all TeamAreas in a project


Susan Hanson (1.6k2201194) | asked Jan 16 '11, 3:16 p.m.
I'm sorry if this is very elementary, but I'm new at the java libs.

I am attempting to list out all of the Team Areas in a project.

I can get the projectArea just fine, and can print out. T

IProjectArea projectArea = SESSION.getProjectArea();
if (projectArea != null) {
System.out.println ("Project area: " + projectArea.getName ());
List teamAreas = projectArea.getTeamAreas();
for (int i=0;i<teamAreas.size();i++) {
ITeamAreaHandle teamArea = (ITeamAreaHandle)teamAreas.get(i);
}
}

It looks like I can do getTeamAreas() and get a list of the team areas. However, I have been very unsuccessful at printing out the names of the Team Areas. I have tried going through the list, and while I can get the ITeamAreaHandle, I don't find a way to actually get the name. If I try to use ITeamArea instead of ITeamAreaHandle, I get a ClassCastException:

ITeamArea teamArea = (ITeamArea)teamAreas.get(i);
System.out.println(teamArea.getName());

Thanks in Advance
Susan

11 answers



permanent link
Qiong Feng Huang (76911610) | answered Jan 17 '11, 12:13 a.m.
JAZZ DEVELOPER
The team area handle you get is just a reference to the real team area. If
your code is running in server side, you can use
IRepositoryItemService.fetchItems() to retrieve the real team areas. If
your code is running in client side, you can use
IItemManager.fetchCompleteItem().

permanent link
pere irazusta (2062120) | answered Sep 08 '11, 6:31 a.m.
Hi Susan,

Did you finally achieved what you were looking for? I'm experiencing the same problem but can't find any option. I'm trying to find a way to access TeamArea through IItemManager.fetchCompleteItem() but I've been unsuccesfull.

If you finaly found a solution could you share it? Or post an example?

Thanks!

permanent link
Susan Hanson (1.6k2201194) | answered Sep 08 '11, 8:06 a.m.
The team area handle you get is just a reference to the real team area. If
your code is running in server side, you can use
IRepositoryItemService.fetchItems() to retrieve the real team areas. If
your code is running in client side, you can use
IItemManager.fetchCompleteItem().


I am still unable to get the actual name.
if (projectArea != null) {
System.out.println ("Project area: " + projectArea.getName ());
List<ITeamAreaHandle> teamAreas = projectArea.getTeamAreas();
for (int i=0;i<teamAreas.size();i++) {
ITeamAreaHandle teamArea = (ITeamAreaHandle)teamAreas.get(i);
IItem item = im.fetchCompleteItem(teamArea,
IItemManager.DEFAULT,
_monitor);
System.out.println(item.getItemType());
// System.out.println(item.getName());
}
}

I can get the itemType, although it comes out quite ugly
com.ibm.team.repository.common.model.impl.ItemTypeImpl@43be43be (namespaceURI: com.ibm.team.process, name: TeamArea, abstract: false)

But the getName() doesn't work and I haven't found the right method on the item to actually get the actual name. If I do a toString, I do see the right name in there under the name:
Proxy of com.ibm.team.process.internal.common.impl.TeamAreaImpl@61586158 (stateId: , itemId: , origin: com.ibm.team.repository.client.internal.TeamRepository@52be52be, immutable: true) (contextId: , modified: 2011-04-26 09:34:40.03, workingCopy: <unset>) (mergePredecessor: null, workingCopyPredecessor: <unset>, workingCopyMergePredecessor: <unset>, predecessor: ) (descSummary: NGI - Common Installer, archived: false, name: NGI - Common Installer, uniqueName: _TeTgsGGvEd6-Y-pxdzN8BA)

(the name I want is NGI - Common Installer)

Any more help?

Susan

permanent link
Ralph Schoon (63.2k33646) | answered Sep 08 '11, 8:25 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I'm sorry if this is very elementary, but I'm new at the java libs.

I am attempting to list out all of the Team Areas in a project.

I can get the projectArea just fine, and can print out. T

IProjectArea projectArea = SESSION.getProjectArea();
if (projectArea != null) {
System.out.println ("Project area: " + projectArea.getName ());
List teamAreas = projectArea.getTeamAreas();
for (int i=0;i<teamAreas.size();i++) {
ITeamAreaHandle teamArea = (ITeamAreaHandle)teamAreas.get(i);
}
}

It looks like I can do getTeamAreas() and get a list of the team areas. However, I have been very unsuccessful at printing out the names of the Team Areas. I have tried going through the list, and while I can get the ITeamAreaHandle, I don't find a way to actually get the name. If I try to use ITeamArea instead of ITeamAreaHandle, I get a ClassCastException:

ITeamArea teamArea = (ITeamArea)teamAreas.get(i);
System.out.println(teamArea.getName());

Thanks in Advance
Susan


Susan, handles need to get resolved to get at the actual object. Please try TeamRepository.itemManager().fetchCompleteItem(handle,0,null);

Or use auditableClient.resolveAuditable(). You need to get the client library first.

permanent link
Susan Hanson (1.6k2201194) | answered Sep 08 '11, 8:29 a.m.
I'm sorry if this is very elementary, but I'm new at the java libs.

I am attempting to list out all of the Team Areas in a project.

I can get the projectArea just fine, and can print out. T

IProjectArea projectArea = SESSION.getProjectArea();
if (projectArea != null) {
System.out.println ("Project area: " + projectArea.getName ());
List teamAreas = projectArea.getTeamAreas();
for (int i=0;i<teamAreas.size();i++) {
ITeamAreaHandle teamArea = (ITeamAreaHandle)teamAreas.get(i);
}
}

It looks like I can do getTeamAreas() and get a list of the team areas. However, I have been very unsuccessful at printing out the names of the Team Areas. I have tried going through the list, and while I can get the ITeamAreaHandle, I don't find a way to actually get the name. If I try to use ITeamArea instead of ITeamAreaHandle, I get a ClassCastException:

ITeamArea teamArea = (ITeamArea)teamAreas.get(i);
System.out.println(teamArea.getName());

Thanks in Advance
Susan


Susan, handles need to get resolved to get at the actual object. Please try TeamRepository.itemManager().fetchCompleteItem(handle,0,null);

Or use auditableClient.resolveAuditable(). You need to get the client library first.


Thanks .. I had gotten a little further today, and had used the fetchCompleteItem but still can't find a method call to get the Name.

IItem item = im.fetchCompleteItem(teamArea,
IItemManager.DEFAULT,
_monitor);
System.out.println(item.getItemType());
// System.out.println(item.getName());

permanent link
Ralph Schoon (63.2k33646) | answered Sep 08 '11, 8:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I would try to fetch not to IItem, but to ITeamArea if possible.

permanent link
Ralph Schoon (63.2k33646) | answered Sep 08 '11, 8:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
One more thing: Set the SDK up as described in the Extensions workshop in the library. Then add the Plain Java API as a user library. Then you can search the SDK.

Try to find places where the ITemaAreaHandle or ITeamArea is used. That is how I find out how to get to data.

permanent link
Qiong Feng Huang (76911610) | answered Sep 09 '11, 5:24 a.m.
JAZZ DEVELOPER
You should use ITeamArea to get the name. For example:

ITeamArea item = (ITeamArea )im.fetchCompleteItem(teamArea,
IItemManager.DEFAULT,
_monitor);
String name = item.getName();

permanent link
Ralph Schoon (63.2k33646) | answered Sep 26 '11, 2:51 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Susan, were you able to resolve the issue?

permanent link
Susan Hanson (1.6k2201194) | answered Sep 30 '11, 1:33 a.m.
Susan, were you able to resolve the issue?


For the most part ... I am able to the the bottom Team Area name but it doesn't give me the full path or hierarchy.

I see that I can get:
Name
Description
Members and their roles on the team

What I need in the end is:
Full Path Name (like Feature Teams/Security Feature Team vs Test Teams/Persona Test Team
Description (this is good I think)
Members (I can get the IContributor[], so I think I'm good here)
Roles ... I'm not sure how to get what Role "Joe" has in this TeamArea.

Susan

Comments
Susan Hanson commented Sep 28 '12, 3:09 a.m.

I am close but not quite there.  What I still haven't been able to get are:
1) I can get the team area name, but not the path with the parent hierarchy
2) I cannot seem to get the description, getDescription.getSummary() seems blank and getDescription.getDetails I can get content type but not content.
3) I can get Members (name, email, ID) but I cannot get what Role(s) they have on that individual team.

I run out of characters iwth the code, will add another comment with code.

Susan


Susan Hanson commented Sep 28 '12, 3:13 a.m.

ITeamAreaHandle teamAreaHandle = (ITeamAreaHandle)teamAreas.get(i);
ITeamArea teamArea = (ITeamArea)rtcm.getRepository().itemManager().fetchCompleteItem(teamAreaHandle,0,null);
name = teamArea.getName();
summary = teamArea.getDescription().getSummary();
IContent content = teamArea.getDescription().getDetails();
details = content.getContentType();
IContributorHandle[] ic = teamArea.getMembers();
for (int j=0;j<ic.length;j++) {
   IContributor fullPerson = (IContributor)rtcm.getRepository().itemManager().fetchCompleteItem(ic[j],0,null);      }


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.